如何从基色开始生成一般美学上令人愉悦的线图颜色范围(数量未知)?

时间:2022-11-25 20:10:57

I like the random color generation algorithm proposed here by David Crow, but I wonder if there's a way to focus its results around a single color and regulate the results.

我喜欢David Crow提出的随机颜色生成算法,但我想知道是否有办法将结果集中在一种颜色上并调整结果。

My program will be generating graphs that track a number of variables. Each variable belongs to one of 7 categories. I'd like to generate line-colors for these variables that are legible, unique and for which the hue, saturation and luminosity are within a proximate range of a root color which is associated with their category. For example, category Red's variables would be various legible and discernible variations on red.

我的程序将生成跟踪许多变量的图表。每个变量属于7个类别之一。我想为这些变量生成线色,这些变量清晰,独特,色调,饱和度和亮度都在与其类别相关的根颜色的近似范围内。例如,类别Red的变量将是红色的各种易读和可辨别的变体。

One solution might be to declare a root color, plus upper and lower boundaries for hue, saturation and luminosity. I could then randomly pull values from within those ranges, but is there a better way to hopscotch within those three dimensions so that the resulting colors have a decent amount of variation, but still leaving space to grow? For example, assume each pipe is a range value and each line is an iteration:

一种解决方案可能是声明根颜色,加上色调,饱和度和亮度的上下边界。然后,我可以从这些范围内随机拉出值,但是有更好的方法可以在这三个维度内进行跳房子游戏,以便产生的颜色具有相当大的变化量,但仍然留有空间增长吗?例如,假设每个管道都是一个范围值,每一行都是一个迭代:

01 > |---------------|---------------|
02 > |-------|-------|---------------|
03 > |-------|-------|-------|-------|
04 > |---|---|-------|-------|-------|
05 > |---|---|---|---|-------|-------|
06 > |---|---|---|---|---|---|-------|
07 > |---|---|---|---|---|---|---|---|
08 > |-|-|---|---|---|---|---|---|---|
09 > |-|-|-|-|---|---|---|---|---|---|
10 > |-|-|-|-|-|-|---|---|---|---|---|
11 > |-|-|-|-|-|-|-|-|---|---|---|---|
12 > |-|-|-|-|-|-|-|-|-|-|---|---|---|
13 > |-|-|-|-|-|-|-|-|-|-|-|-|---|---|
14 > |-|-|-|-|-|-|-|-|-|-|-|-|-|-|---|
15 > |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|

What's the best way to do this? Or is this even the best solution to my problem? A single graph may not plot more than 4 or 5 variables, but the number of variables which can be plotted could be in the hundreds.

最好的方法是什么?或者这甚至是我问题的最佳解决方案?单个图形可能不会绘制超过4或5个变量,但可以绘制的变量数量可能是数百个。

Thanks for your help.

谢谢你的帮助。

1 个解决方案

#1


3  

You can look at this as a sphere-packing problem in 3D: you want your colors a uniform distance from each other. The best arrangement for this depends on the number of variant colors you need, and finding an optimal solution is not simple. However, a simple mechanism might be to save a sequence of face-centered-cubic coordinates, starting at (0,0,0) and ordered by distance from this origin, and use them in sequence as offsets to your "base" color (scaled by a parameter which sets how different from each other they should look).

您可以将此视为3D中的球体包装问题:您希望颜色彼此之间的距离相等。最好的安排取决于您需要的变体颜色的数量,找到最佳解决方案并不简单。但是,一个简单的机制可能是保存一系列面心立方坐标,从(0,0,0)开始并按距离此原点排序,并按顺序使用它们作为“基本”颜色的偏移量(通过参数缩放,该参数设置它们应该看起来彼此之间的差异)。

If you want to pay maximal attention to detail, note that researchers in color theory and perception have measured the minimum discernible color difference, across the visible gamut. You can use this data adjust your color offset vector (using matrix multiplication, in lieu of the above-mentioned simple scaling), to ensure that your color differences look the same.

如果您想最大限度地关注细节,请注意色彩理论和感知方面的研究人员已经测量了可见色域中最小的可辨别色差。您可以使用此数据调整颜色偏移矢量(使用矩阵乘法,代替上述简单缩放),以确保您的颜色差异看起来相同。

#1


3  

You can look at this as a sphere-packing problem in 3D: you want your colors a uniform distance from each other. The best arrangement for this depends on the number of variant colors you need, and finding an optimal solution is not simple. However, a simple mechanism might be to save a sequence of face-centered-cubic coordinates, starting at (0,0,0) and ordered by distance from this origin, and use them in sequence as offsets to your "base" color (scaled by a parameter which sets how different from each other they should look).

您可以将此视为3D中的球体包装问题:您希望颜色彼此之间的距离相等。最好的安排取决于您需要的变体颜色的数量,找到最佳解决方案并不简单。但是,一个简单的机制可能是保存一系列面心立方坐标,从(0,0,0)开始并按距离此原点排序,并按顺序使用它们作为“基本”颜色的偏移量(通过参数缩放,该参数设置它们应该看起来彼此之间的差异)。

If you want to pay maximal attention to detail, note that researchers in color theory and perception have measured the minimum discernible color difference, across the visible gamut. You can use this data adjust your color offset vector (using matrix multiplication, in lieu of the above-mentioned simple scaling), to ensure that your color differences look the same.

如果您想最大限度地关注细节,请注意色彩理论和感知方面的研究人员已经测量了可见色域中最小的可辨别色差。您可以使用此数据调整颜色偏移矢量(使用矩阵乘法,代替上述简单缩放),以确保您的颜色差异看起来相同。