You are here

function _fivestar_color_pack in Fivestar 6.2

Same name and namespace in other branches
  1. 5 fivestar_color.inc \_fivestar_color_pack()
  2. 6 fivestar_color.inc \_fivestar_color_pack()

Convert an RGB triplet to a hex color.

1 call to _fivestar_color_pack()
_fivestar_color_blend in includes/fivestar.color.inc
Blend two hex colors and return the resulting hex color.

File

includes/fivestar.color.inc, line 422
File containing functions relating to the color widget.

Code

function _fivestar_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);
}