mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Add missing Color.js.
This commit is contained in:
parent
b944b82abe
commit
068c4dc1ca
1 changed files with 42 additions and 0 deletions
42
src/color/Color.js
Normal file
42
src/color/Color.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
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;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the color has an alpha value.
|
||||
*
|
||||
* @return {@true if the color has an alpha value}
|
||||
*/
|
||||
hasAlpha: function() {
|
||||
return this._alpha != -1;
|
||||
},
|
||||
|
||||
statics: {
|
||||
read: function(args, index) {
|
||||
var index = index || 0, length = args.length - index;
|
||||
if (length == 1 && args[index] instanceof Color) {
|
||||
return args[index];
|
||||
} else if (length != 0) {
|
||||
var rgbColor = new RGBColor();
|
||||
rgbColor.initialize.apply(rgbColor, index > 0
|
||||
? Array.prototype.slice.call(args, index) : args);
|
||||
return rgbColor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue