@@ 25-27 (lines=3) @@ | ||
22 | ||
23 | $h = (360 + ($hue % 360)) % 360; // hue values can be less than 0 and greater than 360. This normalises them into the range 0-360. |
|
24 | ||
25 | if ($h > 0 && $h <= 60) { |
|
26 | return [round(($c + $m) * 255), round(($x + $m) * 255), round($m * 255)]; |
|
27 | } |
|
28 | ||
29 | if ($h > 60 && $h <= 120) { |
|
30 | return [round(($x + $m) * 255), round(($c + $m) * 255), round($m * 255)]; |
|
@@ 29-31 (lines=3) @@ | ||
26 | return [round(($c + $m) * 255), round(($x + $m) * 255), round($m * 255)]; |
|
27 | } |
|
28 | ||
29 | if ($h > 60 && $h <= 120) { |
|
30 | return [round(($x + $m) * 255), round(($c + $m) * 255), round($m * 255)]; |
|
31 | } |
|
32 | ||
33 | if ($h > 120 && $h <= 180) { |
|
34 | return [round($m * 255), round(($c + $m) * 255), round(($x + $m) * 255)]; |
|
@@ 33-35 (lines=3) @@ | ||
30 | return [round(($x + $m) * 255), round(($c + $m) * 255), round($m * 255)]; |
|
31 | } |
|
32 | ||
33 | if ($h > 120 && $h <= 180) { |
|
34 | return [round($m * 255), round(($c + $m) * 255), round(($x + $m) * 255)]; |
|
35 | } |
|
36 | ||
37 | if ($h > 180 && $h <= 240) { |
|
38 | return [round($m * 255), round(($x + $m) * 255), round(($c + $m) * 255)]; |
|
@@ 37-39 (lines=3) @@ | ||
34 | return [round($m * 255), round(($c + $m) * 255), round(($x + $m) * 255)]; |
|
35 | } |
|
36 | ||
37 | if ($h > 180 && $h <= 240) { |
|
38 | return [round($m * 255), round(($x + $m) * 255), round(($c + $m) * 255)]; |
|
39 | } |
|
40 | ||
41 | if ($h > 240 && $h <= 300) { |
|
42 | return [round(($x + $m) * 255), round($m * 255), round(($c + $m) * 255)]; |
|
@@ 41-43 (lines=3) @@ | ||
38 | return [round($m * 255), round(($x + $m) * 255), round(($c + $m) * 255)]; |
|
39 | } |
|
40 | ||
41 | if ($h > 240 && $h <= 300) { |
|
42 | return [round(($x + $m) * 255), round($m * 255), round(($c + $m) * 255)]; |
|
43 | } |
|
44 | ||
45 | if ($h > 300 && $h <= 360) { |
|
46 | return [round(($c + $m) * 255), round($m * 255), round(($x + $m) * 255)]; |
|
@@ 45-47 (lines=3) @@ | ||
42 | return [round(($x + $m) * 255), round($m * 255), round(($c + $m) * 255)]; |
|
43 | } |
|
44 | ||
45 | if ($h > 300 && $h <= 360) { |
|
46 | return [round(($c + $m) * 255), round($m * 255), round(($x + $m) * 255)]; |
|
47 | } |
|
48 | } |
|
49 | ||
50 | public static function rgbValueToHsl($red, $green, $blue) |