| rdfs:comment
| - Snippets for working with colors A simple RGB object function RGB(r,g,b){ this.r = r; this.g = g; this.b = b; this.ease = function(newRGB,pct){ var newR = this.r + Math.round((newRGB.r - this.r)*pct); var newG = this.g + Math.round((newRGB.g - this.g)*pct); var newB = this.b + Math.round((newRGB.b - this.b)*pct); return new RGB(newR,newG,newB); } this.hex = function(){ var rhex, ghex, bhex; if ((rhex=this.r.toString(16)).length < 2) {rhex = "0"+rhex;} if ((ghex=this.g.toString(16)).length < 2) {ghex = "0"+ghex;} if ((bhex=this.b.toString(16)).length < 2) {bhex = "0"+bhex;} return "#"+rhex+ghex+bhex; } }
|
| abstract
| - Snippets for working with colors A simple RGB object function RGB(r,g,b){ this.r = r; this.g = g; this.b = b; this.ease = function(newRGB,pct){ var newR = this.r + Math.round((newRGB.r - this.r)*pct); var newG = this.g + Math.round((newRGB.g - this.g)*pct); var newB = this.b + Math.round((newRGB.b - this.b)*pct); return new RGB(newR,newG,newB); } this.hex = function(){ var rhex, ghex, bhex; if ((rhex=this.r.toString(16)).length < 2) {rhex = "0"+rhex;} if ((ghex=this.g.toString(16)).length < 2) {ghex = "0"+ghex;} if ((bhex=this.b.toString(16)).length < 2) {bhex = "0"+bhex;} return "#"+rhex+ghex+bhex; } } Example var pct = i / (rowsInList - 1); var fin = new RGB(128,128,128); var ini = new RGB(221,221,221); list[i].bgColor = ini.ease(fin,pct).hex(); See Also:
|