You are here

function color_field_rgb2hex in Color Field 7.2

Same name and namespace in other branches
  1. 8 color_field.module \color_field_rgb2hex()
  2. 7 color_field.module \color_field_rgb2hex()

Helper: Convert RGB to HEX6.

Parameters

array $rgb: The colors specified as an RGB triplet.

Return value

string $hex The colors specified as an hexadecimal format (a hex triplet) (#134E1A).

File

./color_field.module, line 96

Code

function color_field_rgb2hex($rgb = FALSE) {
  $hex = '';
  $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
  $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
  $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
  return $hex;
}