UIColor HSB/HSV 360 degree to 0.0 thru 1.0 decimal conversion and bc.

As we all know, UIColor's method colorWithHue:saturation:brightness:alpha: maps the hue argument to a value between 0.0 and 1.0. Out in the real world, this is a value from 0 to 360. So after I'm done color shopping, I use bc to convert the hue values to the proper range from the UIKit framework. Unfortunately, I left bc with my usual scale value of 3.

Yes, a 5th grader would quickly realize how bad my mistake was, but I'm no 5th grader. It took me a while.

An example:

(1/360) * 140
(1/360) * 140

Yikes! No wonder everything looked funny.

No comments:

Post a Comment