public static function fromHSV($h, $s, $v)
    {
        $h -= floor($h);

        $c = new self();
        if ($s == 0) {
            $c->r = $c->g = $c->b = $v * 255;
            return $c;
        }

        $chroma = $v * $s;

        // Divide $h by 60 degrees i.e by (60 / 360)
        $h_ = $h * 6;
        // intermediate
        $k = intval($h_);

        $h_mod2 = $k % 2 + $h_ - floor($h_);
        $x = $chroma * abs(1 - abs($h_mod2 - 1));

        $r = $g = $b = 0.0;

        switch ($k) {
        case 0: case 6:
            $r = $chroma;
            $g = $x;
            break;
        case 1:
            $r = $x;
            $g = $chroma;
            break;
        case 2:
            $g = $chroma;
            $b = $x;
            break;
        case 3:
            $g = $x;
            $b = $chroma;
            break;
        case 4:
            $r = $x;
            $b = $chroma;
            break;
        case 5:
            $r = $chroma;
            $b = $x;
            break;
        }

        $m = $v - $chroma;

        $c->r = (($r + $m) * 255);
        $c->g = (($g + $m) * 255);
        $c->b = (($b + $m) * 255);

        return $c;
    }