| 1 |
define(["dojo/_base/array", "dojo/_base/declare", "dojox/color"], |
| 2 |
function(arr, declare, color){ |
| 3 |
|
| 4 |
return declare("dojox.color.SimpleColorModel", null, { |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
_startColor: null, |
| 10 |
_endColor: null, |
| 11 |
|
| 12 |
constructor: function(startColor, endColor){ |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
if(endColor != undefined){ |
| 22 |
this._startColor = startColor; |
| 23 |
this._endColor = endColor; |
| 24 |
}else{ |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
var hsl = startColor.toHsl(); |
| 30 |
hsl.s = 100; |
| 31 |
hsl.l = 85; |
| 32 |
this._startColor = color.fromHsl(hsl.h, hsl.s, hsl.l); |
| 33 |
this._startColor.a = startColor.a; |
| 34 |
hsl.l = 15; |
| 35 |
this._endColor = color.fromHsl(hsl.h, hsl.s, hsl.l); |
| 36 |
this._endColor.a = startColor.a; |
| 37 |
} |
| 38 |
}, |
| 39 |
|
| 40 |
_getInterpoledValue: function(from, to, value){ |
| 41 |
return(from + (to - from) * value); |
| 42 |
}, |
| 43 |
|
| 44 |
getNormalizedValue: function(value){ |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
}, |
| 51 |
|
| 52 |
getColor: function(value){ |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
var completion = this.getNormalizedValue(value); |
| 58 |
var hslFrom = this._startColor.toHsl(); |
| 59 |
var hslTo = this._endColor.toHsl(); |
| 60 |
var h = this._getInterpoledValue(hslFrom.h, hslTo.h, completion); |
| 61 |
var s = this._getInterpoledValue(hslFrom.s, hslTo.s, completion); |
| 62 |
var l = this._getInterpoledValue(hslFrom.l, hslTo.l, completion); |
| 63 |
var a = this._getInterpoledValue(this._startColor.a, this._endColor.a, completion); |
| 64 |
var c = color.fromHsl(h, s, l); |
| 65 |
c.a = a; |
| 66 |
return c; |
| 67 |
} |
| 68 |
}); |
| 69 |
}); |