Question

I wrote the following and ran it on my simulator just for fun while sipping an evening cup of coffee; it simply just change from light gray color to dark gray color and back forever.

self.view.layer.backgroundColor = [UIColor lightGrayColor].CGColor;

[UIView animateWithDuration:3.0f delay:0.0f options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionRepeat animations:^
    {
        [UIView setAnimationRepeatAutoreverses:YES];
        [UIView setAnimationRepeatCount:HUGE_VAL];
        self.view.layer.backgroundColor = [UIColor darkGrayColor].CGColor;
    }
    completion:^(BOOL finished)
    {
    }];

Juvenile thing, I know, but as I said, I did it just for fun as to have something to stare at while resting and having coffee.

I would have never even thought of digging deeper into this had it not been my little cousin, who walked up and looked at my simulator and said: "light!", "no light!".

I said: "no, brighter, then darker".

Then the question hit me:

How do we describe color changes properly?

Using the example above, how could we:

1.) describe the changes of color from one to another (let's say from a "lighter to a "darker" one) and color in general in terms of its Hue, Luminosity, brightness, darkness, RGB, Intensity.

I might be wrong here, but perhaps when we say "this is darker" and in computer term, perhaps it should be described differently as (ex:) "the intensity of this color is stronger than the other, its R is greater, its G is (so and so) and B value is at (so and so)....." etc etc.

I hope you know what I mean.

And again using the example code above, how could we properly describe the difference between lightGrayColor and darkGrayColor in terms of:

1.) brightness (what is brightness actually in terms of computer image? does that mean it has more "white" pixels sporadically in between "darker" pixels so it looks "brighter"?)

2.) Luminosity (for this if it were a lightbulb, I would understand, but as far as computer image goes, since it is not a light source itself, what defines luminosity in terms of computer image? What defines Luminosity in terms of colors in an image?)

3.) Hue (some call it pure color while some call it shade / tint)

4.) Intensity (Ok, to an human eye, most would say "if it's darker, it is more intense." But is it really a proper way to describe in terms of computer imagery / color theory?)

5.) RGB

I would really appreciate it if you could describe to me the above with both textual explanation and some code in iOS to describe the difference between the above colors (light gray and dark gray) in terms of the terms mentioned above (hue, luminosity, intensity, brightness, rgb, etc) so that I could quickly grasp the meaning of these terms in general as far as colors are concerned. Thanks very much in advance.

Was it helpful?

Solution

The Quartz2D Programming Guide goes into great detail about the various color models supported by the core-graphics system.

The most important detail is that in theory any color you can represent with the RGB model can also be represented with CMYK or HSB. The various color models exist to make it easier to conceptualize colors in different scenarios, as well as work with the peculiarities of the given rendering device.

There are too many details to describe in the SO format (or at least I don't know how to). However, in summary and to get your started these color models are:

Red-green-blue additive (plus alpha channel)

Additive means starting with black, and the primary colors are accumulated to result in pure white. This is the typical color space for back-lit devices. There are 2n possible colors where n = the number of bits.

There can also be an alpha channel, and they way a color is calculated when one color is painted on top of another depends on the blending mode, of which there are many.

Cyan-magenta-yellow-kelvin subtractive (plus alpha channel)

Subtractive means starting with white, and removing the primary colors until reaching black. This is the typical color space for printing devices. Due to printing technology, in practice this results in a deep purple, hence the addition of 'kelvin' an additional black ink to correct this.

Like RGB, this color space also supports an an alpha-channel with numerous blending modes.

Hue-saturation-brightness

Yes another color model.

Grey-scale

Allows manipulation of brightness only, without hue or saturation properties.

iOS Color Spaces

The Quartz2D system allows you to specify any of the available color spaces for drawing, however on iOS you're limited to an array of supported Device Color Spaces. (AFAIK there is one for the screen, one for printing and a grey-scale).

For more details, please consult the full Quartz2D guide - it's certainly worth reading, and unlike some Apple documentation its not so dry (eg you could read it on the iPad while drinking coffee ;) ). For that there's a PDF version available here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top