public static function toLazarus($color)
{
$color = ltrim($color, '#');
if (!ctype_xdigit($color)) {
throw new \InvalidArgumentException('Color must be a hexdec string');
}
if (strlen($color) == 3) {
list($r, $g, $b) = str_split($color, 1);
$r = $r . $r;
$g = $g . $g;
$b = $b . $b;
} elseif (strlen($color) == 6) {
list($r, $g, $b) = str_split($color, 2);
} else {
throw new \InvalidArgumentException('Color must have a valid hexdec color format');
}
// Lazarus uses #bbggrr
return hexdec($b . $g . $r);
}