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

        // expand shorthand notation (#36A -> #3366AA)
        if (3 == strlen($hex)) {
            $hex = $hex{0}
            .$hex{0}
            .$hex{1}
            .$hex{1}
            .$hex{2}
            .$hex{2};
        }

        return array(
            hexdec(substr($hex, 0, 2)),
            hexdec(substr($hex, 2, 2)),
            hexdec(substr($hex, 4, 2)),
        );
    }