Trying to port this one: http://www.cs.rit.edu/~ncs/color/t_convert.html .. the other function will follow soon enough, first this one.
So uhm, maybe I'm blind orso, but I don't quite get the point of the result here below not working properly. Observe the H result of 'blue' in the debuglog..
So uhm, maybe I'm blind orso, but I don't quite get the point of the result here below not working properly. Observe the H result of 'blue' in the debuglog..
Function RGBtoHSV(r:Float,g:Float,b:Float,h:Float Var,s:Float Var,v:Float Var) Local maxc:Float=Max(r,Max(g,b)) Local minc:Float=Min(r,Min(g,b)) v=maxc Local delta:Float=maxc-minc If maxc<>0 s=delta/maxc Else s=0 h=-1 Return EndIf If r=maxc h=(g-b)/delta ElseIf g=maxc h=2+(b-r)/delta Else h=4=(r-g)/delta EndIf h:*60 If h<0 h:+360 DebugLog "--------------------------------" DebugLog h+" "+s+" "+v End Function Local h:Float Local s:Float Local v:Float RGBtoHSV 1, 0, 0,h,s,v RGBtoHSV 1, 1, 0,h,s,v RGBtoHSV 0, 1, 0,h,s,v RGBtoHSV 0, 1, 1,h,s,v RGBtoHSV 0, 0, 1,h,s,v ' <- blue RGBtoHSV 1, 0, 1,h,s,v DebugLog Chr(10) RGBtoHSV 1,.2,.1,h,s,v RGBtoHSV .5,.5, 0,h,s,v RGBtoHSV .1, 1,.2,h,s,v RGBtoHSV 0,.5,.5,h,s,v RGBtoHSV .2,.1, 1,h,s,v ' <- blue'ish RGBtoHSV .5, 0,.5,h,s,v End