得到两个颜色的十六进制裁判或RGB之间的颜色颜色、两个、RGB、十六进

由网友(我的肩膀好痒可能在长翅膀)分享简介:可能重复: 色彩插值3颜色之间在.NET 我一直在试图让使用C#颜色类别列表:I have been trying to get a categories list of colors using C#:Red:255, 69, 0255, 99, 71etc.. Green:0, 250, 154...

可能重复:   色彩插值3颜色之间在.NET

我一直在试图让使用C#颜色类别列表:

I have been trying to get a categories list of colors using C#:

Red:
255, 69, 0
255, 99, 71
etc.. 

Green:
0, 250, 154
143, 188, 139
etc...

到目前为止,我一直pretty的失败。回理想的情况下,我想是一种能够提供两个十六进制裁判或RGB裁判并得到一个清单说这两个之间的引用10种颜色。这是可能在C#?

So far I have been pretty unsuccessful. Ideally, what I'd like is a way to supply two HEX refs or RGB refs and get a list back of say 10 colors between those two references. Is this possible in C#?

修改

发现这个...... http://meyerweb.com/eric/tool​​s/color-混合/ 只是JS转换为C#现在。会后,当它完成。

Found this... http://meyerweb.com/eric/tools/color-blend/ just converting the js to c# now. Will post when its done.

推荐答案

我不知道内置的功能,会帮助你,但你可以自己做。

I am not aware of built-in function which would help you, but you can do it yourself.

只要颜色可以用3个数字来定义(R,G,B),可以采取两种颜色:

As long as color can be defined using 3 numbers (R,G,B), you can take two colors:

(R1,G1,B1)
(R2,G2,B2)

然后划分差异对​​之间以及间隔产生的数字。

Then divide diff between pairs and produce numbers by intervals.

int numberOfIntervals = 10; //or change to whatever you want.
var interval_R = (R2 - R1) / numberOfIntervals;
var interval_G = (G2 - G1) / numberOfIntervals;
var interval_B = (B2 - B1) / numberOfIntervals;

var current_R = R1;
var current_G = G1;
var current_B = B1;

for (var i = 0; i <= numberOfIntervals; i++)
{
    var color = Color.FromRGB(current_R, current_G, current_B);
    //do something with color.

    //increment.
    current_R += interval_R;
    current_G += interval_G;
    current_B += interval_B;
}

我还没有编制的code,但你的想法。

I haven't compiled the code, but you get the idea.

阅读全文

相关推荐

最新文章