Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why brightness of [UIColor whiteColor] and blackColor are equal

Let my show you some results of getting hue, saturation and brightness of three UIColors.

[[UIColor redColor] getHue:&hue
                saturation:&saturation
                 brightness:&brightness
                 alpha:&alpha];

hue = 1.0 saturatino = 1.0 brightness = 1.0 alpha = 0.0

[[UIColor whiteColor] getHue:&hue
                  saturation:&saturation
                  brightness:&brightness
                       alpha:&alpha];

hue = 0.0 saturatino = 0.0 brightness = 0.0 alpha = 0.0

[[UIColor blackColor] getHue:&hue
                  saturation:&saturation
                  brightness:&brightness
                       alpha:&alpha];

hue = 0.0 saturatino = 0.0 brightness = 0.0 alpha = 0.0

Can anyone explain why hue, saturation, brightness of white and black color are equal? Why alpha is equals zero?

What I wanted to do in my project is generate 'darker' color from a given color by changing it brightness:

brightness = brightness * 0.8;

It works fine for any color, but it produces black color from white color. (Although I would expect a grey color).

like image 717
msmialko Avatar asked Feb 28 '13 08:02

msmialko


People also ask

Why is the color white so bright?

White light contains all the wavelengths of the visible spectrum, so when the color white is being reflected, that means all wavelengths are being reflected and none of them absorbed, making white the most reflective color.

How are color and brightness related?

Brightness refers to intensity, distinguished by the amount of shading mixed with the hue. Any desired hue of light can be produced when various amounts of two of the primary colors of light—the primary colors being red, green, and blue—are combined mechanically, either by addition or by subtraction.

Is white contrast the highest with black?

But too high contrast between design elements might give an unsettled and messy impression. Black and white create the highest contrast possible.

Is black and white colour contrast?

DESIGNING WITH BLACK AND WHITE TO COMPLETE It's been said that “opposites attract.” To put it another way: contrast creates completion. The convergence of black and white (more so than any other color combination) is an example of how two divergent colors communicate more powerfully together than they do on their own.


1 Answers

The reason is because +whiteColor and +blackColor both return colors in the greyscale colorspace, which is not compatible with the HSB colorspace. As such, -getHue:saturation:brightness:alpha: is actually not modifying the parameters. I think you'll find you have them all set to 0.0 before calling that method. If you check the return value of -getHue:saturation:brightness:alpha: it will tell you if it successfully converted to HSB.

like image 169
Lily Ballard Avatar answered Nov 10 '22 00:11

Lily Ballard