mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-10 06:41:59 -05:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
|
/*
|
||
|
* 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://paperjs.org/
|
||
|
* http://scriptographer.org/
|
||
|
*
|
||
|
* Distributed under the MIT license. See LICENSE file for details.
|
||
|
*
|
||
|
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
|
||
|
* http://lehni.org/ & http://jonathanpuckey.com/
|
||
|
*
|
||
|
* All rights reserved.
|
||
|
*/
|
||
|
|
||
|
var HSBColor = this.HSBColor = Color.extend(new function() {
|
||
|
var components = ['hue', 'saturation', 'brightness', 'alpha'];
|
||
|
return Base.each(components, function(name) {
|
||
|
var internalName = '_' + name;
|
||
|
name = Base.capitalize(name);
|
||
|
if (name !== 'alpha') {
|
||
|
this['get' + name] = function() {
|
||
|
return this[internalName];
|
||
|
};
|
||
|
// Avoid overriding setHue:
|
||
|
if (!this['set' + name]) {
|
||
|
this['set' + name] = function(value) {
|
||
|
this._cssString = null;
|
||
|
this[internalName] = value;
|
||
|
return this;
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}, { beans: true,
|
||
|
_colorType: 'hsb',
|
||
|
_components: components,
|
||
|
|
||
|
setHue: function(hue) {
|
||
|
if (hue < 0)
|
||
|
hue = 360 + hue;
|
||
|
this._cssString = null;
|
||
|
this._hue = hue;
|
||
|
return this;
|
||
|
}
|
||
|
});
|
||
|
});
|