@@ 153-167 (lines=15) @@ | ||
150 | * @param float $delta The delta value ($max - $min) |
|
151 | * @return void |
|
152 | */ |
|
153 | protected static function _rgbhsl_hue(float &$h, float $r, float $g, float $b, float $max, float $delta) { |
|
154 | $delta_r = static::_rgbhsl_delta_rgb($r, $max, $delta); |
|
155 | $delta_g = static::_rgbhsl_delta_rgb($g, $max, $delta); |
|
156 | $delta_b = static::_rgbhsl_delta_rgb($b, $max, $delta); |
|
157 | ||
158 | $h = (2 / 3) + $delta_g - $delta_r; |
|
159 | if ($r == $max) { |
|
160 | $h = $delta_b - $delta_g; |
|
161 | } elseif ($g == $max) { |
|
162 | $h = (1 / 3) + $delta_r - $delta_b; |
|
163 | } |
|
164 | if ($h < 0) { |
|
165 | $h++; |
|
166 | } |
|
167 | } |
|
168 | ||
169 | /** |
|
170 | * Convert a HSL array to a RGB array |
@@ 104-118 (lines=15) @@ | ||
101 | * @param float $delta The delta value ($max - $min) |
|
102 | * @return void |
|
103 | */ |
|
104 | protected static function _rgbhsl_hue(float &$h, float $r, float $g, float $b, float $max, float $delta) { |
|
105 | $delta_r = static::_rgbhsl_delta_rgb($r, $max, $delta); |
|
106 | $delta_g = static::_rgbhsl_delta_rgb($g, $max, $delta); |
|
107 | $delta_b = static::_rgbhsl_delta_rgb($b, $max, $delta); |
|
108 | ||
109 | $h = (2 / 3) + $delta_g - $delta_r; |
|
110 | if ($r == $max) { |
|
111 | $h = $delta_b - $delta_g; |
|
112 | } elseif ($g == $max) { |
|
113 | $h = (1 / 3) + $delta_r - $delta_b; |
|
114 | } |
|
115 | if ($h < 0) { |
|
116 | $h++; |
|
117 | } |
|
118 | } |
|
119 | ||
120 | /** |
|
121 | * Handle low hue values |