Skip to content

Commit 8e6bc58

Browse files
committed
fix hsv2hex method, allow 0 hue
1 parent 95d3379 commit 8e6bc58

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

RandomColor.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static private function _getHueRange($options)
177177
{
178178
$hue = intval($options['hue']);
179179

180-
if ($hue < 360 && $hue > 0)
180+
if ($hue < 360 && $hue >= 0)
181181
{
182182
return array($hue, $hue);
183183
}
@@ -234,7 +234,7 @@ static public function hsv2hex($hsv)
234234

235235
foreach ($rgb as $c)
236236
{
237-
$hex.= str_pad(dechex($c), 2, '0');
237+
$hex.= str_pad(dechex($c), 2, '0', STR_PAD_LEFT);
238238
}
239239

240240
return $hex;
@@ -270,9 +270,9 @@ static public function hsv2rgb($hsv)
270270
$n = $v * (1 - $s * $f);
271271
$k = $v * (1 - $s * (1 - $f));
272272

273-
$r = 255;
274-
$g = 255;
275-
$b = 255;
273+
$r = 1;
274+
$g = 1;
275+
$b = 1;
276276

277277
switch ($i)
278278
{

0 commit comments

Comments
 (0)