2011-02-19 11:10:26 -05:00
|
|
|
Color = Base.extend({
|
|
|
|
beans: true,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A value between 0 and 1 that specifies the color's alpha value.
|
|
|
|
* All colors of the different subclasses support alpha values.
|
|
|
|
*/
|
|
|
|
getAlpha: function() {
|
|
|
|
return this._alpha;
|
|
|
|
},
|
|
|
|
|
|
|
|
setAlpha: function(alpha) {
|
|
|
|
if (this._alpha == null || alpha == -1) this._alpha = -1;
|
|
|
|
else if (this._alpha < 0) this._alpha = 0;
|
|
|
|
else if (alpha > 1) this._alpha = 1;
|
|
|
|
else this._alpha = alpha;
|
2011-02-19 12:01:08 -05:00
|
|
|
this._cssString = null;
|
2011-02-19 11:10:26 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the color has an alpha value.
|
|
|
|
*
|
|
|
|
* @return {@true if the color has an alpha value}
|
|
|
|
*/
|
|
|
|
hasAlpha: function() {
|
|
|
|
return this._alpha != -1;
|
|
|
|
},
|
|
|
|
|
2011-02-19 16:50:37 -05:00
|
|
|
getCanvasStyle: function() {
|
|
|
|
return this.cssString;
|
|
|
|
},
|
|
|
|
|
2011-02-19 11:10:26 -05:00
|
|
|
statics: {
|
|
|
|
read: function(args, index) {
|
|
|
|
var index = index || 0, length = args.length - index;
|
|
|
|
if (length == 1 && args[index] instanceof Color) {
|
|
|
|
return args[index];
|
2011-02-20 18:25:45 -05:00
|
|
|
} else if (length != 0 && args[0] !== null) {
|
2011-02-19 19:45:53 -05:00
|
|
|
var rgbColor = new RGBColor(RGBColor.dont);
|
2011-02-19 11:10:26 -05:00
|
|
|
rgbColor.initialize.apply(rgbColor, index > 0
|
|
|
|
? Array.prototype.slice.call(args, index) : args);
|
|
|
|
return rgbColor;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|