Generating hex colors

T

tascien

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.
 
R

Rik

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,
 
T

tascien

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.

T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top