| Days | |
| Hours | |
| Minutes | |
| Seconds |
I wrote this little function because I wanted a little background color shifter without having to deal with a big script animation library. Really simple, and it takes some time to run through itself. I’ll rewrite it to be faster, more flexible later.
Actually I probably won’t.
Anyway, here it is, and heres a demo. Multiple clicks will get you psycho function timeouts all over the place and some strange color changes. Rad.
1 2 3 4 5 6 7 8 | function colorShift(strTarget,sR,sG,sB,tR,tG,tB) { if(sR == tR && sG == tG && sB == tB) { return; } if(sR != tR) { (sR < tR) ? sR++ : sR--; } if(sG != tG) { (sG < tG) ? sG++ : sG--; } if(sB != tB) { (sB < tB) ? sB++ : sB--; } document.getElementById(strTarget).style.backgroundColor = "rgb("+sR+","+sG+","+sB+")"; setTimeout("colorShift('"+strTarget+"',"+sR+","+sG+","+sB+","+tR+","+tG+","+tB+")",1); } |
Now that I look, it’s sorta related to the Javascript Attention Grabber from earlier this month.
Posted November 22nd, 2006 - Permalink