颜色混合超过2种颜色

eej*_*i42 4 .net c# colors

I'm trying to find an algorithm that will mix colors, based on a % amount. I'm working on an election project, and want to be able to assign each candidate in a race a different color, and then create a "resulting" color based on how much of the vote that candidate has gotten.

This question:

Is there an algorithm for color mixing that works like mixing real colors?

is close the question I'm asking - but potentially I need to be able to mix 3 or 4 or 5 colors together. I understand that this ultimately an incredibly complicated question - but I'm curious what the suggested method is for doing this on more than 2 colors. So, I might have:

Red (40%), Green(10%), Blue (50%)

OR

Red (40%), Yellow (5%), Blue (10%), Orange (45%)

Once again, I know that the last example would probably produce some sort of Gray or Brown or Black - and that's fine. My problem is that I don't even have an algorithm that attempts to solve this problem.


Edit: So - after posting this message, I realized that what I was really trying to accomplish was basically PAINT color mixing. IN other words, I don't want LIGHT color mixing, I want to simulate what would happen with PAINT mixing - as that is the "predictable" result that I kept 'expecting' - and was having trouble getting.

I found this link: http://painting.about.com/library/blpaint/blcolormixingpalette1.htm

这与我正在努力完成的事情非常接近 - 并且在我最初的想法中暴露了一个小的"缺陷".所展示的是,即使我可以使用此算法混合多达6种颜色,实际的"数据"总是分解为3种基色.

即便如此 - 这非常接近.

感谢所有为此主题做出贡献的人 - 所有这些建议对于探索这个令人惊讶的复杂问题/领域非常有帮助.

小智 6

你试过加权加权吗?

d.R = a.R*0.25 + b.R*0.25 + c.R*0.5
d.G = a.G*0.25 + b.G*0.25 + c.G*0.5
...
where a, b, c are the colors you're mixing
Run Code Online (Sandbox Code Playgroud)

从我的研究来看,似乎没有任何一个正确的答案,但似乎产生最合适的效果.此外,我不认为简单地混合颜色会在infograph上显示任何内容.你最好尝试一些非常精细的抖动http://en.wikipedia.org/wiki/Dither#Digital_photography_and_image_processing