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

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 100

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;
}