2011-03-06 19:50:44 -05:00
|
|
|
/*
|
|
|
|
* Paper.js
|
|
|
|
*
|
|
|
|
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
|
|
|
|
* based on Scriptographer.org and designed to be largely API compatible.
|
|
|
|
* http://scriptographer.org/
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://lehni.org/ & http://jonathanpuckey.com/
|
|
|
|
*
|
|
|
|
* All rights reserved. See LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
2011-03-04 08:34:31 -05:00
|
|
|
var Color = this.Color = Base.extend({
|
2011-02-19 11:10:26 -05:00
|
|
|
beans: true,
|
|
|
|
|
2011-03-04 08:19:07 -05:00
|
|
|
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() {
|
2011-03-04 19:16:26 -05:00
|
|
|
return this._alpha != null ? this._alpha : 1;
|
2011-02-19 11:10:26 -05:00
|
|
|
},
|
2011-03-03 17:45:17 -05:00
|
|
|
|
2011-02-19 11:10:26 -05:00
|
|
|
setAlpha: function(alpha) {
|
2011-03-04 19:16:26 -05:00
|
|
|
if (alpha < 0) this._alpha = 0;
|
2011-02-19 11:10:26 -05:00
|
|
|
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
|
|
|
},
|
2011-03-03 17:45:17 -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() {
|
2011-03-04 19:16:26 -05:00
|
|
|
return this._alpha != null;
|
2011-02-19 11:10:26 -05:00
|
|
|
},
|
2011-03-03 17:45:17 -05:00
|
|
|
|
2011-02-19 16:50:37 -05:00
|
|
|
getCanvasStyle: function() {
|
2011-03-04 12:14:24 -05:00
|
|
|
return this.toCssString();
|
2011-02-19 11:10:26 -05:00
|
|
|
}
|
2011-03-03 11:32:55 -05:00
|
|
|
});
|