算法随机生成一个美观的调色板 [英] Algorithm to randomly generate an aesthetically-pleasing color palette

查看:700
本文介绍了算法随机生成一个美观的调色板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个简单的算法来生成大量的随机,美观的颜色。所以没有疯狂的霓虹色,颜色让人想起粪便等。

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.

我已经找到这个问题的解决方案,但他们依赖于替代调色板比RGB。
我宁愿只使用直接RGB比来回映射。这些其他解决方案最多也只能产生32个左右的令人满意的随机颜色。

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.

任何想法都很棒。

推荐答案

随机颜色的RGB值与常量颜色的RGB值:

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

(Java中的示例)

(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;
}



将随机颜色与白色255,255)通过在保持原始颜色的色调的同时增加亮度来创建中性色调。


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:



您还可以将随机颜色与常量的粉彩混合,这将产生一组有色的中性色。例如,使用浅蓝色会创建以下颜色:


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:



更进一步,您可以为发电机添加启发式算法,考虑补色或阴影等级,


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.

一些额外的资源:

  • http://en.wikipedia.org/wiki/Color_theory
  • http://en.wikipedia.org/wiki/Complementary_color

这篇关于算法随机生成一个美观的调色板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆