Fixed: CPColor colorWithHue:saturation:brightness: parameters not clamped.

Previously, the parameters to CPColor colorWithHue:saturation:brightness: could be specified below 0 or above 1.0.

Now the values are clamped so that values below 0 are taken as 0 and values above 1.0 and taken as 1.0.
This commit is contained in:
Alexander Ljungberg committed 2013-04-21 14:21:47 +01:00
1 parent 0c2abf3629
commit d00846aae7
1 file changed
+5
+5
View File
@@ -199,6 +199,11 @@ var cachedBlackColor,
*/
+ (CPColor)colorWithHue:(float)hue saturation:(float)saturation brightness:(float)brightness alpha:(float)alpha
{
// Clamp values.
hue = MAX(MIN(hue, 1.0), 0.0);
saturation = MAX(MIN(saturation, 1.0), 0.0);
brightness = MAX(MIN(brightness, 1.0), 0.0);
if (saturation === 0.0)
return [CPColor colorWithCalibratedWhite:brightness alpha:alpha];