private static function hex2rgb($hex, &$r, &$g, &$b)
    {
        // Remove hash if present
        $hex = preg_replace('/[^a-fA-F0-9]/', '', $hex);

        if (strlen($hex) == 6) {
            // 6-digit hex
            $r = substr($hex, 0, 2);
            $g = substr($hex, 2, 2);
            $b = substr($hex, 4, 2);
        } else {
            // 3-digit hex, pad to 6 total...
            $r = $hex[0] . $hex[0];
            $g = $hex[1] . $hex[1];
            $b = $hex[2] . $hex[2];
        }

        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);
    }