得到两个颜色的十六进制裁判或RGB之间的颜色 [英] Get colors between two color HEX refs or RGB

查看:230
本文介绍了得到两个颜色的十六进制裁判或RGB之间的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  色彩插值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.

这篇关于得到两个颜色的十六进制裁判或RGB之间的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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