Finally got a chance to work with your functions.
Basically the first thing I did was put a regex into the rgb_to_hsv(), so that I can just feed it a value like rgb(150,200,255) and it will extract the red, green and blue. For example:
$hsv = rgb_to_hsv("rgb(150,200,255)");
Verified the regex was working:
// print_r results:
// Array ( [0] => rgb(120,200,255) [1] => 120 [2] => 200 [3] => 255 )
I also changed hsv_to_rgb() to return the value back to a regular rgb value, for instance, rgb(56,94,120)
Here is the actual line that I changed in your function:
return "rgb(" . round($red * 255) . "," . round($green * 255) . "," . round($blue * 255) . ")";
OK, so here's my test page (abbreviated):
$color = "rgb(120,200,255)";
$hsv_array = rgb_to_hsv($color);
$processed_color = hsv_to_rgb($hsv_array);
print "
<body style='background-color: {$processed_color};'>
<p>Original Color: {$color}</p>
<p>HSV Array: " . print_r($hsv_array,true) . "</p>
<p>Processed Color: {$processed_color}</p>
</body>
";
I expected that the $processed_color would be the same as the original $color. However, here were my results:
Original Color: rgb(120,200,255)
HSV Array: Array ( [0] => 204.44444444444 [1] => 0.52941176470588 [2] => 0.47058823529412 )
Processed Color: rgb(56,94,120)
As you can see the processed color changed in value from the original. Any ideas?