[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::atarist

Title:Atari ST, TT, & Falcon
Notice:Please read note 1.0 and its replies before posting!
Moderator:FUNYET::ANDERSON
Created:Mon Apr 04 1988
Last Modified:Tue May 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1433
Total number of notes:10312

1024.0. "Step thru colour range ?" by SIEVAX::JAMIE (Use me, Use me... Ooops! Excuse me!) Mon Dec 03 1990 08:11

    I'm currently experimenting with graphics on the ST and have come up
    against a problem that I'm sure someone else here must have already
    figured out...
    
    I want to step through the entire range of possible colours from
    darkest to brightest.
    
    Given that R, G and B each take 3 bits to represent I'd have thought
    there'd have been a neat little sequence of boolean statement that I
    could perform on these 9 bits to step through this sequence.
    
    Try as I might, though, I've have no luck whatsoever. Any ideas ?
    
    I suppose the sequence starts (in hex)
    
    001, 010, 100, 011, 101, 110, 111, 002, 020, 200, 021, 201 etc...
    
    Though I'm not even sure about that!
    
    
    Any help would be gratefully received...
    
    Cheers,
    
    
    				Jamie.
T.RTitleUserPersonal
Name
DateLines
1024.1SIEVAX::JAMIEUse me, Use me... Ooops! Excuse me!Tue Dec 04 1990 11:4912
    I've since been informed that this is not as easy at it sounds!
    Apparently there are lots of horrible equation thingys needed to solve
    this!
    
    So I'm going to produce a look-up table instead!!!
    
    
    
    Cheers,
    
    
    				Jamie.
1024.2Is this the sequence you are looking for?YNOTME::WALLACEWed Dec 05 1990 13:3848
>    I want to step through the entire range of possible colours from
>    darkest to brightest.
    
>    Try as I might, though, I've have no luck whatsoever. Any ideas ?
    
At first glance it seemed liked a reasonably trivial problem. At second glance
it seemed not quite so trival but doable.  In any case the problem/chalenge
intriqued me so I went to work... And put together a 69 line C program which
generates the 1035 triplets of color combinations.

The program can be copied from OLDTMR::$1$DUA8:[WALLACE.PUBLIC]TEASE.C,.LST,.EXE
Where .C is the source, .EXE is the VMS executible, and .LST is the output of
the program.

Here is an excerpt from the output of the program (first # is just a count of
the triplets, the next three numbers are the color values, red, green, blue) -

 21 ->  2  2  2

 22 ->  3  0  0
 23 ->  0  3  0
 24 ->  0  0  3
 25 ->  3  1  0
 26 ->  3  0  1
 27 ->  3  1  1
 28 ->  0  3  1
 29 ->  1  3  0
 30 ->  1  3  1
 31 ->  1  0  3
 32 ->  0  1  3
 33 ->  1  1  3
 34 ->  3  2  1
 35 ->  3  1  2
 36 ->  3  2  2
 37 ->  1  3  2
 38 ->  2  3  1
 39 ->  2  3  2
 40 ->  2  1  3
 41 ->  1  2  3
 42 ->  2  2  3
 43 ->  3  3  2
 44 ->  3  2  3
 45 ->  3  3  3

 46 ->  4  0  0


	Ray
1024.3SIEVAX::JAMIEUse me, Use me... Ooops! Excuse me!Mon Dec 10 1990 06:0024
    Thanks! That looks like just the biscuit! Though aren't there just 512
    "triplets" ?
    
    I had a crack at something like this myself; I found a formula to rate
    a triplets brightness according to its RGB value :
    
    luminosity = .299 red + .587 green + .114 blue
    
    When I saw this I thought it would do the trick, so I wrote a program
    to produce a lookup table of colours sorted according to luminosity and
    displayed them on the screen...
    
    What a mess!!! The trouble with the formula is that it can rate a
    colour that's a shade of red as being the closest to a colour that's a
    shade of blue - and do they clash ???!!!!
    
    I think .-1 is more like it; a gradual move from one colour to the
    next, though it's still best used in a lookup table.
    
    Thanks, Ray.
    
    
    
    				Jamie.
1024.4A much improoved version of the programYNOTME::WALLACEMon Dec 10 1990 15:0122
>    Thanks! That looks like just the biscuit! Though aren't there just 512
>    "triplets" ?
Right, I wrote the code for 4 bits per color instead of 3. Also there was a
glitch in my calculations so that not all color combinations were being
output. Both of which have been fixed and there are new files available in the
same directory.
    
>    I had a crack at something like this myself; I found a formula to rate
>    a triplets brightness according to its RGB value :
>    luminosity = .299 red + .587 green + .114 blue
I didn't give any consideration to this.
    
>    I think .-1 is more like it; a gradual move from one colour to the
>    next, though it's still best used in a lookup table.
A small change to the output routine at the end of my code could easily
produce the lookup table file (.byte instructions or whatever).

This program does not produce the optimum sequence, but I think it's
close enough, depending on what your going to do with the output.


	Ray
1024.5Hue, Lightness and SaturationVISUAL::WEAVERDave, Image Systems GroupMon Dec 17 1990 17:4315
There are equations for hue, lightness and saturation, and others that produce
similar results.  To do what you want, you will need to compute at least
hue and lightness, but that will limit the values unless you also compute
saturation.

Hue = Color
Lightness = Brightness
Saturation = purity of the color.  0 saturation tends toward gray.

Foley and VanDamm's [sic] book on "Interactive Computer Graphics" (I believe
that is the title) goes into quite a bit of detail.  I would expect most
Digital Libraries would have a copy, possibly bigger local libraries might
as well.

							-Dave