paper.js/src/color/Color.js

39 lines
840 B
JavaScript
Raw Normal View History

var Color = this.Color = Base.extend({
2011-02-19 11:10:26 -05:00
beans: true,
initialize: function() {
var rgb = new RGBColor(RGBColor.dont);
rgb.initialize.apply(rgb, arguments);
return rgb;
},
2011-02-19 11:10:26 -05:00
/**
* 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;
},
2011-02-19 11:10:26 -05:00
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;
this._cssString = null;
2011-02-19 11:10:26 -05:00
},
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;
},
getCanvasStyle: function() {
return this.toCssString();
2011-02-19 11:10:26 -05:00
}
2011-03-03 11:32:55 -05:00
});