PHP HSV to RGB formula comprehension

vasquezmango

New Member
I can convert RGB values to HSV with the following code...\[code\] $r = $r/255; $g = $g/255; $b = $b/255; $h = 0; $s = 0; $v = 0; $min = min(min($r, $g),$b); $max = max(max($r, $g),$b); $r = $max-$min; $v = $max; if($r == 0){ $h = 0; $s = 0; } else { $s = $r / $max; $hr = ((($max - $r) / 6) + ($r / 2)) / $r; $hg = ((($max - $g) / 6) + ($r / 2)) / $r; $hb = ((($max - $b) / 6) + ($r / 2)) / $r; if ($r == $max) $h = $hb - $hg; else if($g == $max) $h = (1/3) + $hr - $hb; else if ($b == $max) $h = (2/3) + $hg - $hr; if ($h < 0)$h += 1; if ($h > 1)$h -= 1; }\[/code\]But how do you convert HSV to RGB in PHP???The following is on wikipedia but I don't understand it,I'm guessing it's pretty obvious
IzI73.png
 
Back
Top