_color_pack

Versions
5 – 6
_color_pack($rgb, $normalize = false)
7
_color_pack($rgb, $normalize = FALSE)

Convert an RGB triplet to a hex color.

▾ 1 function calls _color_pack()

_color_shift in modules/color/color.module
Shift a given color, using a reference pair and a target blend color.

Code

modules/color/color.module, line 614

<?php
function _color_pack($rgb, $normalize = false) {
  $out = 0;
  foreach ($rgb as $k => $v) {
    $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8));
  }
  return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.