View Single Post

  #2 (permalink)  
Old 06-29-2003
Geoff Berrow
 
Posts: n/a
Default Re: random text & background colors?

Message-ID: <bdm774$2jj$1@news-reader2.wanadoo.fr> from Bill Parker
contained the following:

>is what I have in mind.... but I really don't know how the hex codes for rgb
>realte to "darkness"



You have six hexadecimal values - two for red, two for green, two for blue.
The two values multiplied together give a range of 0-255 for each colour

A hex number is a number between 0 and 15 which is displayed as the numbers
0-9 and the letters A-F. Hence A = 10, B=11 and so on. Light colours have
higher values, and hence #000000 is black and #FFFFFF is white. So a mid
grey is between #777777 and #888888.

I assume that your definition of a dark colour would be any colour that was
darker than this mid point. (though this is clearly going to be subjective)

From the above you can see that any colour whose hex values are less than
or equal to 7 is guaranteed to be a dark colour and any colour where values
are greater than or equal to 8 is light. Also, any colour where the
/average/ of the hex values is less than 7 is dark also. So #000ccc has an
average of (0+0+0+12+12+12)/6 which equals 6 and so is 'dark'. Similarly,
#00FFFF has an average of 10 and is hence 'light'.
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote