Reply to Re: Generating hex colors

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация