HTML颜色代码:红色到黄色到绿色 [英] HTML Color Codes: Red to Yellow to Green

查看:671
本文介绍了HTML颜色代码:红色到黄色到绿色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够提供尽可能多的HEX HTML值,以使颜色渐变从红色变为绿色:

I would like to come up with as many HEX HTML values to have a smooth color gradient from red to green:

我希望它与以下内容:
http://www.utexas.edu/learn/html/colors .html

I would like this to be similar to the following: http://www.utexas.edu/learn/html/colors.html

我没有最好的颜色选择眼睛,所以我希望标准图表已经放在一起展示了如何从顺利地通过黄色到绿色。

I don't have the best eye for color choices, so I'm hoping a standard chart is already put together showing how to transition from red through yellow to green smoothly.

在该网站上,6之1与我所寻找的内容最为相似,但该示例仅限于11种颜色:

On that website "1 of 6" is most similar to what I'm looking for, but that example is limited to 11 colors:

(1) FF0000 Red, 
(2) FF3300 Red(Orange)
(3) ff6600 
(4) ff9900 
(5) FFCC00 Gold 
(6) FFFF00 Yellow
(7) ccff00
(8) 99ff00
(9) 66ff00
(10) 33ff00
(11) 00FF00 Lime 

能够将数字加倍的颜色,但仍然让他们平稳过渡。

It would be great to be able to double the number of colors, but yet make them transition smoothly.

感谢您的任何见解和帮助。

Thanks for any insights and help.

推荐答案

根据您想要结束的颜色数量,解决方案只是将绿色值增加一定金额,然后当绿色最大( FF ),将红色值重复减少相同的金额。

Depending on how many colors you want to end up with, the solution is just to keep incrementing the green value by a certain amount, and then when green is maxed (FF), decrement the red value repeatedly by the same amount.

伪码:

Pseudo-code:

int red = 255; //i.e. FF
int green = 0;
int stepSize = ?//how many colors do you want?
while(green < 255)
{
    green += stepSize;
    if(green > 255) { green = 255; }
    output(red, green, 0); //assume output is function that takes RGB
}
while(red > 0)
{
    red -= stepSize;
    if(red < 0) { red = 0; }
    output(red, green, 0); //assume output is function that takes RGB
}

的函数,可以通过手动生成增加16,如下所示:

Generating by hand, you can simply increment by 16, like so:

FF0000
FF1000
FF2000
FF3000
FF4000
FF5000
FF6000
FF7000
FF8000
FF9000
FFA000
FFB000
FFC000
FFD000
FFE000
FFF000
FFFF00 //max, step by 15
F0FF00 //cheat, start with a -15 to simplify the rest
E0FF00
D0FF00
C0FF00
B0FF00
A0FF00
90FF00
80FF00
70FF00
60FF00
50FF00
40FF00
30FF00
20FF00
10FF00

这篇关于HTML颜色代码:红色到黄色到绿色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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