mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Fix and improve Color documentation.
This commit is contained in:
parent
fb493959d0
commit
0797202b22
1 changed files with 20 additions and 6 deletions
|
@ -652,7 +652,7 @@ var Color = Base.extend(new function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Number[]} the converted components as an array.
|
* @return {Number[]} the converted components as an array
|
||||||
*/
|
*/
|
||||||
_convert: function(type) {
|
_convert: function(type) {
|
||||||
var converter;
|
var converter;
|
||||||
|
@ -666,6 +666,13 @@ var Color = Base.extend(new function() {
|
||||||
this._components));
|
this._components));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the color another type.
|
||||||
|
*
|
||||||
|
* @param {String('rgb', 'gray', 'hsb', 'hsl')} type the color type to
|
||||||
|
* convert to.
|
||||||
|
* @return {Color} the converted color as a new instance
|
||||||
|
*/
|
||||||
convert: function(type) {
|
convert: function(type) {
|
||||||
return new Color(type, this._convert(type), this._alpha);
|
return new Color(type, this._convert(type), this._alpha);
|
||||||
},
|
},
|
||||||
|
@ -673,7 +680,7 @@ var Color = Base.extend(new function() {
|
||||||
/**
|
/**
|
||||||
* The type of the color as a string.
|
* The type of the color as a string.
|
||||||
*
|
*
|
||||||
* @type String('rgb', 'hsb', 'gray')
|
* @type String('rgb', 'gray', 'hsb', 'hsl')
|
||||||
* @bean
|
* @bean
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
|
@ -690,6 +697,13 @@ var Color = Base.extend(new function() {
|
||||||
this._type = type;
|
this._type = type;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color components that define the color, including the alpha value
|
||||||
|
* if defined.
|
||||||
|
*
|
||||||
|
* @type Number[]
|
||||||
|
* @bean
|
||||||
|
*/
|
||||||
getComponents: function() {
|
getComponents: function() {
|
||||||
var components = this._components.slice();
|
var components = this._components.slice();
|
||||||
if (this._alpha != null)
|
if (this._alpha != null)
|
||||||
|
@ -786,9 +800,9 @@ var Color = Base.extend(new function() {
|
||||||
/**
|
/**
|
||||||
* Returns the color as a CSS string.
|
* Returns the color as a CSS string.
|
||||||
*
|
*
|
||||||
* @param {Boolean} hex wether to return the color in hex-representation
|
* @param {Boolean} hex wether to return the color in hexadecial
|
||||||
* or as a CSS rgb / rgba string.
|
* representation or as a CSS RGB / RGBA string.
|
||||||
* @return {String} a css string representation of the color.
|
* @return {String} a CSS string representation of the color.
|
||||||
*/
|
*/
|
||||||
toCSS: function(hex) {
|
toCSS: function(hex) {
|
||||||
// TODO: Support HSL / HSLA CSS3 colors directly, without conversion
|
// TODO: Support HSL / HSLA CSS3 colors directly, without conversion
|
||||||
|
@ -812,7 +826,7 @@ var Color = Base.extend(new function() {
|
||||||
toCanvasStyle: function(ctx) {
|
toCanvasStyle: function(ctx) {
|
||||||
if (this._canvasStyle)
|
if (this._canvasStyle)
|
||||||
return this._canvasStyle;
|
return this._canvasStyle;
|
||||||
// Normal colors are simply represented by their css string.
|
// Normal colors are simply represented by their CSS string.
|
||||||
if (this._type !== 'gradient')
|
if (this._type !== 'gradient')
|
||||||
return this._canvasStyle = this.toCSS();
|
return this._canvasStyle = this.toCSS();
|
||||||
// Gradient code form here onwards
|
// Gradient code form here onwards
|
||||||
|
|
Loading…
Reference in a new issue