Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could average the RGB values of random colors with those of a constant color:</p> <p><em>(example in Java)</em></p> <pre><code>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; } </code></pre> <p><br/> 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.</p> <p>Here are some pastel colors generated using the above method:</p> <p><img src="https://i.stack.imgur.com/8jKGx.jpg" alt="First"></p> <p><br/> 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:</p> <p><img src="https://i.stack.imgur.com/zI406.jpg" alt="Second"></p> <p><br/> 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.</p> <p>Some additional resources:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Color_theory" rel="noreferrer">http://en.wikipedia.org/wiki/Color_theory</a></li> <li><a href="http://en.wikipedia.org/wiki/Complementary_color" rel="noreferrer">http://en.wikipedia.org/wiki/Complementary_color</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload