mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Less cryptic code without Base.each() side-car makes more sense here.
This commit is contained in:
parent
2367cfa6f2
commit
d643ac7626
1 changed files with 7 additions and 5 deletions
|
@ -206,16 +206,16 @@ var Color = this.Color = Base.extend(new function() {
|
|||
// possible color types. Requesting any of these components on any color
|
||||
// internally converts the color to the required type and then returns its
|
||||
// component, using bean access.
|
||||
return Base.each({
|
||||
Base.each({
|
||||
rgb: ['red', 'green', 'blue'],
|
||||
hsb: ['hue', 'saturation', 'brightness'],
|
||||
gray: ['gray']
|
||||
}, function(components, colorType) {
|
||||
Base.each(components, function(component) {
|
||||
this['get' + Base.capitalize(component)] = function() {
|
||||
fields['get' + Base.capitalize(component)] = function() {
|
||||
return this.convert(colorType)[component];
|
||||
};
|
||||
this['set' + Base.capitalize(component)] = function(value) {
|
||||
fields['set' + Base.capitalize(component)] = function(value) {
|
||||
var color = this.convert(colorType);
|
||||
color[component] = value;
|
||||
color = color.convert(this._colorType);
|
||||
|
@ -223,8 +223,10 @@ var Color = this.Color = Base.extend(new function() {
|
|||
this[this._components[i]] = color[this._components[i]];
|
||||
}
|
||||
};
|
||||
}, this);
|
||||
}, fields);
|
||||
});
|
||||
});
|
||||
|
||||
return fields;
|
||||
}, {
|
||||
beans: true,
|
||||
|
||||
|
|
Loading…
Reference in a new issue