Random colour

Ken Norris pixelbird at interisland.net
Mon Jun 9 13:10:01 EDT 2003


***********
> Date: Mon, 9 Jun 2003 10:16:33 -0600
> From: David Squance <squance at elkvalley.net>
> Subject: Random colour
> 
> Is there a simple way to randomize color of text and background of a field
> without getting a combination which is unreadable?
----------
It seems like this was gone through a few months back, maybe you should
check the archives.

Well, other than ending up with the same color for both, it's matter of what
you beleive is unreadable. Complimentary and clashing colors have standards,
but then you add contrast and brightness which complicates the matter.
You're dealing with 65536 possible color combos in standard SuperCard CLUTs.

The matter can get very complicated because of how we see color. For example
a medium color of red shows up bright on a black background, but not on a
medium blue, so making lists of "dark" colors and 'light' colors won't
necessarily work. 

Perhaps you could develop a sliding 'spread gap', i.e. differences that
work. IOW, the gap between contrasting values remains the same, and one of
your random functions will need to mathematically slide it back and forth in
the list, making sure there are some colors left on either end, then two
more to randomly select colors from those at each end, i.e., one from the
darker end and one from the lighter end.

Then, finally, a simple one to decide which of the two derived from the
above will be text and which background.

HTH to get you started,
Ken N.




More information about the use-livecode mailing list