Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm to randomly generate an aesthetically-pleasing color palette [closed]

I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc.

I've found solutions to this problem but they rely on alternative color palettes than RGB. I would rather just use straight RGB than mapping back and forth. These other solutions also can at most generate only 32 or so pleasing random colors.

Any ideas would be great.

like image 706
Brian Gianforcaro Avatar asked Sep 04 '08 01:09

Brian Gianforcaro


People also ask

What is a color algorithm?

In computer science and graph theory, the term color-coding refers to an algorithmic technique which is useful in the discovery of network motifs. For example, it can be used to detect a simple path of length k in a given graph.

How do you create an appealing color palette?

One of the simplest ways to create a professional looking color scheme is to take a few tones, tints, and shades of a given color (avoiding the pure hue), and then add in another pure hue (or close to pure) that's at least three spaces away on the color wheel (part of a tetradic, triatic, or split-complementary color ...

What is a color palette generator?

Colormind is a color scheme generator that uses deep learning. It can learn color styles from photographs, movies, and popular art. Different datasets are loaded each day, check back tomorrow for even more color inspiration. Visit the blog for tech info or have a look at our API.


1 Answers

You could average the RGB values of random colors with those of a constant color:

(example in Java)

public Color generateRandomColor(Color mix) {     Random random = new Random();     int red = random.nextInt(256);     int green = random.nextInt(256);     int blue = random.nextInt(256);      // mix the color     if (mix != null) {         red = (red + mix.getRed()) / 2;         green = (green + mix.getGreen()) / 2;         blue = (blue + mix.getBlue()) / 2;     }      Color color = new Color(red, green, blue);     return color; } 


Mixing random colors with white (255, 255, 255) creates neutral pastels by increasing the lightness while keeping the hue of the original color. These randomly generated pastels usually go well together, especially in large numbers.

Here are some pastel colors generated using the above method:

First


You could also mix the random color with a constant pastel, which results in a tinted set of neutral colors. For example, using a light blue creates colors like these:

Second


Going further, you could add heuristics to your generator that take into account complementary colors or levels of shading, but it all depends on the impression you want to achieve with your random colors.

Some additional resources:

  • http://en.wikipedia.org/wiki/Color_theory
  • http://en.wikipedia.org/wiki/Complementary_color
like image 136
David Crow Avatar answered Sep 30 '22 11:09

David Crow