mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Compress code using Base.each side-car.
This commit is contained in:
parent
1bd0127ece
commit
f3663c04fe
1 changed files with 10 additions and 18 deletions
|
@ -67,25 +67,17 @@ var GrayColor = this.GrayColor = Color.extend({
|
||||||
return this._cssString;
|
return this._cssString;
|
||||||
}
|
}
|
||||||
}, new function() {
|
}, new function() {
|
||||||
var fields = { beans: true };
|
|
||||||
|
|
||||||
// Using the standard NTSC conversion formula that is used for
|
// Using the standard NTSC conversion formula that is used for
|
||||||
// calculating the effective luminance of an RGB color:
|
// calculating the effective luminance of an RGB color:
|
||||||
// http://www.mathworks.com/support/solutions/en/data/1-1ASCU/index.html?solution=1-1ASCU
|
// http://www.mathworks.com/support/solutions/en/data/1-1ASCU/index.html?solution=1-1ASCU
|
||||||
var componentWeights = {
|
return Base.each({ red: 0.2989, green: 0.5870, blue: 0.114 },
|
||||||
red: 0.2989,
|
function(weight, key) {
|
||||||
green: 0.5870,
|
this['get' + Base.capitalize(key)] = function() {
|
||||||
blue: 0.114
|
return 1 - this._gray;
|
||||||
};
|
};
|
||||||
|
this['set' + Base.capitalize(key)] = function(value) {
|
||||||
Base.each(componentWeights, function(weight, key) {
|
this._cssString = null;
|
||||||
fields['get' + Base.capitalize(key)] = function() {
|
this._gray = this._gray * (1 - weight) + weight * (1 - value);
|
||||||
return 1 - this._gray;
|
};
|
||||||
};
|
}, { beans: true });
|
||||||
fields['set' + Base.capitalize(key)] = function(value) {
|
|
||||||
this._cssString = null;
|
|
||||||
this._gray = this._gray * (1 - weight) + weight * (1 - value);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
return fields;
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue