16.}
17.
18.var Map = function(array, callback, thisObject){
19. if(array.map){
20. return array.map(callback, thisObject);
21. }else{
22. var res = [];
23. for (var i = 0, len = array.length; i < len; i++) { res
.push(callback.call(thisObject, array[i], i, array)); }
24. return res;
25. }
26.}
27.
28.
29.var ColorGrads = function(options){
30. this.SetOptions(options);
31. this.StartColor = this.options.StartColor;
32. this.EndColor = this.options.EndColor;
33. this.Step = Math.abs(this.options.Step);
34.};
35.ColorGrads.prototype = {
36. //设置默认属性
37. SetOptions: function(options) {
38. this.options = {//默认值
39. StartColor: "#fff",//开始颜色
40. EndColor: "#000",//结束颜色
41. Step: 20//渐变级数
42. };
43. Extend(this.options, options || {});
44. },
45. //获取渐变颜色集合
46. Create: function() {
47. var colors = [],
48. startColor = this.GetColor(this.StartColor),
49. endColor = this.GetColor(this.EndColor),
50. stepR = (endColor[0] - startColor[0]) / this.Step,
51. stepG = (endColor[1] - startColor[1]) / this.Step,
52. stepB = (endColor[2] - startColor[2]) / this.Step;
53. //生成颜色集合
54. for(var i = 0, n = this.Step, r = startColor[0], g = startC
olor[1], b = startColor[2]; i < n; i++){
55. colors.push([r, g, b]); r += stepR; g += stepG; b += st
epB;
56. }