You are here

function override_css_html2rgb in Override css 7

1 call to override_css_html2rgb()
override_css_generate_css in ./override_css.module
Generate css

File

./override_css.module, line 471

Code

function override_css_html2rgb($color) {
  if ($color[0] == '#') {
    $color = substr($color, 1);
  }
  if (strlen($color) == 6) {
    list($r, $g, $b) = array(
      $color[0] . $color[1],
      $color[2] . $color[3],
      $color[4] . $color[5],
    );
  }
  elseif (strlen($color) == 3) {
    list($r, $g, $b) = array(
      $color[0] . $color[0],
      $color[1] . $color[1],
      $color[2] . $color[2],
    );
  }
  else {
    return false;
  }
  $r = hexdec($r);
  $g = hexdec($g);
  $b = hexdec($b);
  return array(
    $r,
    $g,
    $b,
  );
}