protected function convertHexColor($color, $blnWriteToFile = false, $vars = array())
{
// Support global variables
if (strncmp($color, '$', 1) === 0) {
if (!$blnWriteToFile) {
return array($color);
} else {
$color = str_replace(array_keys($vars), array_values($vars), $color);
}
}
$rgb = array();
// Try to convert using bitwise operation
if (strlen($color) == 6) {
$dec = hexdec($color);
$rgb['red'] = 0xff & $dec >> 0x10;
$rgb['green'] = 0xff & $dec >> 0x8;
$rgb['blue'] = 0xff & $dec;
} elseif (strlen($color) == 3) {
$rgb['red'] = hexdec(str_repeat(substr($color, 0, 1), 2));
$rgb['green'] = hexdec(str_repeat(substr($color, 1, 1), 2));
$rgb['blue'] = hexdec(str_repeat(substr($color, 2, 1), 2));
}
return $rgb;
}