The function is as follows:
function gCL(i){
var f=parseInt((i )/5);
i=i %5;
switch(f){
case 0:return "#" cS2(255-i*51) cS2 (i*51) "00";
case 1:return "#00" cS2(255-i*51) cS2(i*51);
case 2:return "#" cS2(i*51 ) "00" cS2(255-i*51);
}
}
function cS2(i) {
var s=i.toString(16);
return ("00 " s).substr(s.length);
}
Using gCL, you can use increasing numbers to return the gradient color from red to green to blue. The gradient effect is as follows, a total of 15 colors, cyclic gradient:
For example, in the following application, use this function to gradient the background color of a hyperlink:
]
This function can be modified Produce more detailed color changes, interested friends can try it.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn