diff --git a/www/admin/class_test.colors.php b/www/admin/class_test.colors.php index b0a32410..9811798c 100644 --- a/www/admin/class_test.colors.php +++ b/www/admin/class_test.colors.php @@ -79,6 +79,15 @@ $hsb = [0, 0, 5]; print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: " . DgS::printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])) . "
"; +// Random text +$h = rand(0, 359); +$s = rand(15, 70); +$b = 100; +$l = 50; +print "RANDOM IN: H: " . $h . ", S: " . $s . ", B/L: " . $b . "/" . $l . "
"; +print "RANDOM hsb->rgb:
" . DgS::printAr(Colors::hsb2rgb($h, $s, $b)) . "

"; +print "RANDOM hsl->rgb:
" . DgS::printAr(Colors::hsl2rgb($h, $s, $l)) . "

"; + // TODO: run compare check input must match output // error message diff --git a/www/lib/CoreLibs/Convert/Colors.php b/www/lib/CoreLibs/Convert/Colors.php index f5f2d776..b593d2bc 100644 --- a/www/lib/CoreLibs/Convert/Colors.php +++ b/www/lib/CoreLibs/Convert/Colors.php @@ -66,7 +66,8 @@ class Colors } $rgbArray = []; if (strlen($hexStr) == 6) { - // If a proper hex code, convert using bitwise operation. No overhead... faster + // If a proper hex code, convert using bitwise operation. + // No overhead... faster $colorVal = hexdec($hexStr); $rgbArray['r'] = 0xFF & ($colorVal >> 0x10); $rgbArray['g'] = 0xFF & ($colorVal >> 0x8); @@ -289,7 +290,8 @@ class Colors if ($lum < 0 || $lum > 100) { return false; } - $hue = (1 / 360) * $hue; // calc to internal convert value for hue + // calc to internal convert value for hue + $hue = (1 / 360) * $hue; // convert to internal 0-1 format $sat /= 100; $lum /= 100;