Generating hex colors

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.

Re: Generating hex colors wrote:
Quoted text here. Click to load it

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));

Rik Wasmus

Re: Generating hex colors

thanks. I think i am going to take your advice and select 50 colors and
if the colors are done, I start from the beginning.

ps. I use C#. I don't know if there is an equivalent of that.


Site Timeline