function hex2rgb

5.x fp_pie_chart.php hex2rgb($hex)
1 call to hex2rgb()
fp_pie_chart.php in inc/pchart/fp_pie_chart.php
This script uses the pchart library (pchart.net) to display a pie chart in FlightPath.

File

inc/pchart/fp_pie_chart.php, line 87
This script uses the pchart library (pchart.net) to display a pie chart in FlightPath.

Code

function hex2rgb($hex) {
  $hex = str_replace("#", "", $hex);

  if (strlen($hex) == 3) {
    $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
    $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
    $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
  }
  else {
    $r = hexdec(substr($hex, 0, 2));
    $g = hexdec(substr($hex, 2, 2));
    $b = hexdec(substr($hex, 4, 2));
  }

  $rgb = array("r" => $r, "g" => $g, "b" => $b);
  return $rgb; // returns an array with the rgb values
}