函数用于创建色轮 [英] Function for creating color wheels

查看:126
本文介绍了函数用于创建色轮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我一直的伪解决了很多次,从来没有完全发现,卡住了我的解决方案。问题是想出一种方法来生成N种颜色,可有效用作区分尽可能其中N是一个参数

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.

推荐答案

我对这个问题首先想到的是如何产生的空间N中的载体,最大限度地提高彼此的距离。你可以看到,RGB(或使用形成在颜色空间的基础上的任何其它规模)只是载体。看看随机点采摘。希望这是一个良好的开端为您服务!一旦你有一组向量被最大化的一部分,你可以将它们保存在一个哈希表或东西后,只是对他们进行随机旋转,让你的愿望是最大限度地彼此分开所有的颜色!

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!

编辑:关于这个问题的思考更多,这将是最好的映射中的颜色线性庄园,可能是(0,0,0) - >(255,255,255)字典顺序,然后分发它们均匀。我真的不知道该怎么好这样的工作,但它应该,因为让说:

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 我们知道我们有16777216种颜色(256 ^ 3)。我们可以使用扣算法515 找到字典序索引颜色。你可能得修改算法,以避免溢出,并可能增加一些细微的速度提升。

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屋!

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