I would like to come up with as many HEX HTML values to have a smooth color gradient from red to green:
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.
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.
Here is a simple, yet dirty, way to generate these colors:
The color encoding is for Google maps: aabbggrr.
This will give you a list of 103 colors. I removed three and then indexed the list with using a percentage as an integer.
I used this in a php page:
Your RGB is then ($red, $green, $blue)
Note: The 5.1 factor dervies from 255/50
My reason for finding this question was that I was trying to make a colored uptime indicator for a table full of devices that "check-in" hourly. The idea being that it would be red at 0%, transition to yellow at 50%, and be green at 100%. This is of course pretty useless but it was an easy way to make a table look more impressive than it actually was. Given a min, max, and value it returns rgb 0-255 values for the correct color. Assumes valid input.
Nowadays all modern browsers support color gradients in CSS which allow totally smooth gradients over any width/height. However, still not all browsers support the official CSS
linear-gradient
, so in order to support all browsers, use the following CSS class:For further reference of the CSS gradient functions, see the following articles in the Mozilla Developer Network:
A very good web site to quickly generate completely customized color gradients for all browsers is the Ultimate CSS Gradient Generator.
Here is nice looking gradient from green to red
Works in Chrome & Safari only
From NiceWebType.com: