private static function hueToRgb($m1, $m2, $h)
    {
        if ($h < 0) {
            $h = $h + 6;
        } elseif ($h > 6) {
            $h = $h - 6;
        }
        
        if ($h < 1) {
            $r = $m1 + ($m2 - $m1) * $h;
        } elseif ($h < 3) {
            $r = $m2;
        } elseif ($h < 4) {
            $r = $m1 + ($m2 - $m1) * (4 - $h);
        } else {
            $r = $m1;
        }
        
        return (int)(255 * $r);
    }