erica / uicolor-utilities

Helpful utilities for UIColor for iPhone
262 stars 102 forks source link

colorWithHue: returns wrong result #5

Closed tewha closed 11 years ago

tewha commented 13 years ago

[UIColor colorWithHue: saturation: brightness: alpha:] is a system function. This code overrides it with a function that returns a different result.

Example:

id green = [UIColor colorWithHue:0.231 saturation:0.786 brightness:0.669 alpha:1.000];
self.navigationController.navigationBar.tintColor = green;

Try this without UIColor-utilities and you'll get green. Try it while using UIColor-utilities, and UIColor-utilities will replace colorWithHue with one that returns red instead.

There's two bugs here:

  1. Whatever logic UIColor-utilities uses to map HSB to RGB doesn't work. (I assume this affects code that serves a purpose, too.)
  2. UIColor-utilities should not be replacing perfectly good system functions without reason.
tewha commented 13 years ago

I suspect the problem here is that UIColor-utilities is treating hue as a degree angle, whereas UIKit treats it as a fraction from 0-1.

erica commented 13 years ago

It predates that stuff and I haven't had a moment to update it.

-- E

On Sep 2, 2011, at 3:26 PM, tewha wrote:

[UIColor colorWithHue: saturation: brightness: alpha:] is a system function. This code overrides it with a function that returns a different result.

Example:

id green = [UIColor colorWithHue:0.231 saturation:0.786 brightness:0.669 alpha:1.000]; self.navigationController.navigationBar.tintColor = green;

Try this without UIColor-utilities and you'll get green. Try it while using UIColor-utilities, and UIColor-utilities will replace colorWithHue with one that returns red instead.

There's two bugs here:

  1. Whatever logic UIColor-utilities uses to map HSB to RGB doesn't work. (I assume this affects code that serves a purpose, too.)
  2. UIColor-utilities should not be replacing perfectly good system functions without reason.

Reply to this email directly or view it on GitHub: https://github.com/erica/uicolor-utilities/issues/5

tewha commented 13 years ago

This code seems to have been added in 2009, and colorWithHue dates to iOS 2.0.

https://github.com/erica/uicolor-utilities/commit/9a28215bf8b3dea2b67f6a413574ef5ff3a2786b http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIColor_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006892-CH3-SW4

erica commented 13 years ago

Thanks for the heads up. I'll take a look when I get a chance and try to figure out what was going on.

-- E

On Sep 2, 2011, at 7:53 PM, tewha wrote:

This code seems to have been added in 2009, and colorWithHue dates to iOS 2.0.

https://github.com/erica/uicolor-utilities/commit/9a28215bf8b3dea2b67f6a413574ef5ff3a2786b http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIColor_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006892-CH3-SW4

Reply to this email directly or view it on GitHub: https://github.com/erica/uicolor-utilities/issues/5#issuecomment-1984894