You are here

function color_field_hex2rgb in Color Field 8

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

Helper: Convert HEX6 to RGB

Parameters

$hex.:

2 calls to color_field_hex2rgb()
ColorFieldSwatchFormatter::viewElements in src/Plugin/Field/FieldFormatter/ColorFieldSwatchFormatter.php
Builds a renderable array for a field value.
ColorFieldTextFormatter::viewElements in src/Plugin/Field/FieldFormatter/ColorFieldTextFormatter.php
Builds a renderable array for a field value.

File

./color_field.module, line 53
An color field with a custom color picker using the Field Types API.

Code

function color_field_hex2rgb($hex = FALSE) {
  $r = hexdec(substr($hex, 0, 2));
  $g = hexdec(substr($hex, 2, 2));
  $b = hexdec(substr($hex, -2));
  return compact('r', 'g', 'b');
}