算法有问题,自己查看hex值。- <body scroll="no">
- <div id="_hex_"></div>
- <div id='center'>
- <span id="curtime" /></span><span id="cursec" /></span>
- <br/>
- <center><span id="curdate" /></span><span id="curweek" /></span></center>
- </div>
- </body>
复制代码
- function changColor(obj, uuid, type, step) {
- if (!HueSign[uuid]) HueSign[uuid] = 1;
- var rgb = obj.style[type];
- var hex = (rgb2hex(rgb)).substring(1);
- var r = parseInt("0x" + hex.substr(0, 2));
- var g = parseInt("0x" + hex.substr(2, 2));
- var b = parseInt("0x" + hex.substr(4, 2));
- var hsl = rgbToHsl(r, g, b);
- var h = Math.round(hsl[0] * 2400) / 10;
- var s = Math.round(hsl[1] * 2400) / 10;
- var l = Math.round(hsl[2] * 2400) / 10;
- h = h + HueSign[uuid] * step * 1; //修改色调
- if (h <= 0 || h >= 240) HueSign[uuid] = -1 * HueSign[uuid];
- if (h <= 0) h = 0;
- if (h >= 240) h = 240;
- var rgb = hslToRgb(h / 240, s / 240, l / 240);
- hex = rgb2hex('rgb(' + rgb.join(', ') + ')');
- document.getElementById('_hex_').innerText = hex;
- obj.style[type] = hex;
- return (true);
- }
复制代码
|