![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
Re: Contrasting Coloursby TomDLux (Vicar) |
on May 29, 2003 at 16:04 UTC ( #261581=note: print w/replies, xml ) | Need Help?? |
Option 1 - maximum contrast for black and white, fading to no contrast for middle gray: For each component, R, G, & B, subtract the current value from 255. reassamble into a colour - there's your complementary colour. If you haven't defined the format for a tuple, yet, I suggest using anonymous arrays. In any case, you'll need routines to do format conversions.
Option 2 - less, but reasonable contrast for all values. Add half the range, 128, to each of R, G, B, rolling over values that go out of range. Black and white both go to middle grey, middle grey goes to white
Option 3 - Modify each of R, G, B by a varying amount, between 1/3 and 2/3 full range. As a consequence, looking for ten contrasting colours for black would generate ten different colours between dark grey and light grey, providing some degree of actual colour as well as monochrome. This provides fair contrast, but no repeatability.
In Section
Seekers of Perl Wisdom
|
|