You are here: Dynamically Generate Pleasing Colors « PHP « IT news, forums, messages
Dynamically Generate Pleasing Colors

Posted by Richard Lynch on 10/04/29 11:09

I'm drawing a GD map from selected points in a database.

I am using imagecreatetruecolor.

I'm outputting PNGs, but could change to JPEG if it would help. [I doubt it]

In experimentation so far, I've found that using the lighter shades is
more pleasing to the eye, in general, so want to stay above 0x66 in R, G,
and B values.

The background will be white, so I can't get too close to that color either.

I'd like the colors to be not TOO ugly with each other, and I absolutely
cannot have the borders of two regions the exact SAME color.

Now, I don't want to get into Fermat's Last Theorom and 2 billion lines of
code to do the 4-color thing, so that's out.

And I'm not a Designer, so I have NO IDEA if there's some magical listing
of "pretty colors number 1 through N" that go together. I'm still waiting
for "Geranimals for Men" to come out. :-)

I could just use $N colors, for however many colors I need, and not worry
about the borders at all. The occasional case of two shades of green
being too close is "livable" though not "ideal"

I've tried your basic 3-D loop:
for ($r ...)
for ($g ...)
for ($b ...)
$colors[] = imagecolorallocate($image, $r, $g, $b);
to generate the colors with acceptable ranges in values, skipping shades
of grey, or even any shades where $r == $g || $r == $b || $g == $b to try
to avoid same-looking colors.

I probably won't ever need more than 250 colors, really, so played around
with settings that seemed like they should work.

I used shuffle() sometimes to try and mix up the colors

I've had what you might call mixed results...

I've searched and read, and only vaguely understand the ideas behind
brightness and contrast in RGB number system, so can't figure out anything
useful from my findings of maximizing contrast of an existing image etc.

I'm not using php 5 yet, so imagefilter is "out"

I'm hoping somebody has gone through this already, and has an easy way to
generate a pleasing set of colors, with good contrast, for any given
number $N of colors.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this 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

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