|
Posted by Rik on 07/17/06 22:55
tascien@gmail.com wrote:
> I have an application that create charts. I don't know how many bars
> will be generated, the number will depend on the data fed to the
> chart.
>
>
> What I want is not be able to generate a hex color for each unique
> bar. What is the formula to generate hex colors?
>
> Anyhelp would be appreciated.
First of all, choosing about 30 colors beforehand is wiser. You can control
the contrast with it, and avoid that a random color accidentaly (closely)
matches an already existing color.
In what language is your application?
In PHP I'd do this:
$hex = dechex(mt_rand(0,255)).dechex(mt_rand(0,255)).dechex(mt_rand(0,255));
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|