创建色轮的功能 [英] Function for creating color wheels
问题描述
这是我已经伪解决了很多次,从来没有找到一个解决方案。这是卡住了我。问题是想出一种方法来生成 N
颜色,尽可能区分,其中 N
是一个参数。
我的第一个想法是如何在最大化彼此距离的空间中生成N个向量。你可以看到,RGB(或任何其他比例,你使用形成一个基础的颜色空间)只是向量。请查看随机点拣配。希望这是一个好的开始!一旦你有一个向量最大化一个零件,你可以将它们保存在一个哈希表或一些东西以后,只是执行随机旋转,以获得所有你想要的颜色,最大限度地彼此分离! p>
编辑:更多地考虑这个问题,最好在线性庄园中映射颜色,可能是(0,0,0) - >(255,255,255),然后均匀分布。我真的不知道这会有多好,但它应该,因为,让我们说:
n = 10
我们知道我们有16777216种颜色^ 3)。我们可以使用 buckles算法515 查找词典编码索引的颜色。。您可能必须编辑算法以避免溢出,并可能添加一些小的速度改进。
This is something I've pseudo-solved many times and never quite found a solution. That's stuck with me. The problem is to come up with a way to generate N
colors, that are as distinguishable as possible where N
is a parameter.
My first thought on this is "how generate N vectors in a space that maximize distance from each other." You can see that the RGB (or any other scale you use that forms a basis in color space) are just vectors. Take a look at Random Point Picking. Hope this is a good start for you! Once you have a set of vectors that are maximized a part, you can save them in a hash table or something for later, and just perform random rotations on them to get all the colors you desire that are maximally apart from each other!
Edit: Thinking about this problem more, it would be better to map the colors in a linear manor, possibly (0,0,0) --> (255,255,255) lexicographically, and then distribute them evenly. I really don't know how well this will work, but it should since, lets say:
n = 10 we know we have 16777216 colors (256^3). We can use buckles algorithm 515 to find the lexicographically indexed color.. You'll probably have to edit the algorithm to avoid overflow and probably add some minor speed improvements.
这篇关于创建色轮的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!