Color Generator

S

Simon Wigzell

My form allows the user to assign colors to different fields that are then
used in a java piechart/barchart applet as the colors of the different pie
sections/bars. It can be tedious assigning colors even with my color pic
tool especially as the number of different colors increases. The application
is data driven so it may end up requiring any number of colors up to about
100. Of course you want the colors to be as different as possible. It would
be nice to have an "Auto" button to click that will then fill out all the
color fields with a properly generated set of colors - that is colors that
are as different from each other as possible. Random colors won't do as you
might end up with very similar colors. Is such a program possible?
 
L

Lee

Simon Wigzell said:
My form allows the user to assign colors to different fields that are then
used in a java piechart/barchart applet as the colors of the different pie
sections/bars. It can be tedious assigning colors even with my color pic
tool especially as the number of different colors increases. The application
is data driven so it may end up requiring any number of colors up to about
100. Of course you want the colors to be as different as possible. It would
be nice to have an "Auto" button to click that will then fill out all the
color fields with a properly generated set of colors - that is colors that
are as different from each other as possible. Random colors won't do as you
might end up with very similar colors. Is such a program possible?

By far the simplest solution is to pre-select more colors than you
expect to ever be useful and have the application go down the list.


--
 
T

tim.n.hunt

Simon said:
My form allows the user to assign colors to different fields that are then
used in a java piechart/barchart applet as the colors of the different pie
sections/bars. It can be tedious assigning colors even with my color pic
tool especially as the number of different colors increases. The application
is data driven so it may end up requiring any number of colors up to about
100. Of course you want the colors to be as different as possible. It would
be nice to have an "Auto" button to click that will then fill out all the
color fields with a properly generated set of colors - that is colors that
are as different from each other as possible. Random colors won't do as you
might end up with very similar colors. Is such a program possible?

Possibly.

Here's some color conversion functions

http://www.cs.rit.edu/~ncs/color/t_convert.html

Choose a hue to create the first color and the full Saturation and
Value (S=1, V=1) , then create the rgb values using tHSVtoRGB functions
by changing the hue value by 15/30/45 degrees each time.

Once you reach 360 degrees repeat the previous steps but with less
Saturation and full Value ( S<1 , V=1) , then the next time round with
full saturation and less value (S=1, V<1), and so on till you have
enough colors

The colors will then be fairly distributed with a reasonably even
distribution,

One problem is the HSV algorithm is not really perfectly evenly
distributed to the human eye - so you may end up with more blue +
violets than reds and yellow ( or maybe the other way round? )

Another problem is that with a 100 colors some will look alike, with
that many colors some shades will be hard to tell apart no matter what
you do.

Hope this is of some help

Tim
 
T

tim.n.hunt

Possibly.
Here's some color conversion functions

The functions are written in C, its enough easy to convert them to
javascript but its even easier to have me email them to you. :)

I won't be online much longer tonight, so if you want them write back
soon

Tim
 
T

Thomas 'PointedEars' Lahn

Simon said:
[...] It would be nice to have an "Auto" button to click that will then
fill out all the color fields with a properly generated set of colors -
that is colors that are as different from each other as possible. Random
colors won't do as you might end up with very similar colors. Is such a
program possible?

I think it is, although I do not think the solution will be a trivial one.
The first step would be to define the distance function: What makes color
C more different from color A than color B? Is it its color temperature,
hue, luminance etc. or a combination of either one (whereas you have to
take into account that computer displays and printers cannot display all
colors perceptible by humans)? After you have done that, you can devise an
algorithm to calculate C as the point with the maximum distance from A and
B within a finite n-dimensional space, according to that relation. Of
course there can be more than one solution, given the same start point.

The most simple solution would be using the existing RGB three-dimensional
color space. Starting with Black (0, 0, 0), the next "most different"
color, defined as the most distant point in the color space, would be White
(255, 255, 255). The next most distant points not already visited (colors
already used) would be the corners of that cube, identifying Red (255, 0,
0), Green (0, 255, 0), Blue (0, 0, 255), and the other standard colors like
Magenta (255, 0, 255). That would provide you with 8 "very different"
colors already, that do not even need to be computed (with a given set of
already used colors, you would only need to compute what corner color point
would have the maximum distance from all already used color points). The
next "most different" color, i.e. a point in the color space with the
maximum distance from all other already used points would be the center of
the greatest subset created by adjacent visited points (where you would
define the shape of that subset truly linear [between adjacent visited
points on a straight line], truly triangular [the center of the triangle
created by visited points that are not on a straight line], cubic, and so
on; since the color space is cubic, I would use a cubic-shaped subset).

In practice, you want to align that algorithm on the points in the color
space identifying the 216 True Web-safe colors, and you want to avoid
reddish and greenish colors that have the same grey-value.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Simon said:
[Is there a program to generate colors that are as different from each
other as possible?]

[...]
Choose a hue to create the first color and the full Saturation and
Value (S=1, V=1) , then create the rgb values using tHSVtoRGB functions
by changing the hue value by 15/30/45 degrees each time.

Once you reach 360 degrees repeat the previous steps but with less
Saturation and full Value ( S<1 , V=1) , then the next time round with
full saturation and less value (S=1, V<1), and so on till you have
enough colors

The colors will then be fairly distributed with a reasonably even
distribution,

One problem is the HSV algorithm is not really perfectly evenly
distributed to the human eye - so you may end up with more blue +
violets than reds and yellow ( or maybe the other way round? )

Another problem is that with a 100 colors some will look alike, with
that many colors some shades will be hard to tell apart no matter what
you do.

Another catch of this approach is that for a reasonable decrement in
saturation, and later value, to create colors "most different" from
one another (taking the restrictions above into account), you would
need to know how many colors would be needed _before_ you apply the
algorithm. My "RGB color space coordinates-marking" approach does
not need that.


PointedEars
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top