mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Clean up code.
This commit is contained in:
parent
7de0859a85
commit
6558574980
1 changed files with 19 additions and 18 deletions
|
@ -63,39 +63,40 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var converters = {
|
var converters = {
|
||||||
'rgb-hsb': function(col) {
|
'rgb-hsb': function(color) {
|
||||||
var hsb = Color.RGBtoHSB(col._red, col._green, col._blue);
|
var hsb = Color.RGBtoHSB(color._red, color._green, color._blue);
|
||||||
return new HSBColor(hsb[0] * 360, hsb[1], hsb[2], col._alpha);
|
return new HSBColor(hsb[0] * 360, hsb[1], hsb[2], color._alpha);
|
||||||
},
|
},
|
||||||
|
|
||||||
'hsb-rgb': function(col) {
|
'hsb-rgb': function(color) {
|
||||||
var rgb = Color.HSBtoRGB(col._hue / 360, col._saturation, col._brightness);
|
var rgb = Color.HSBtoRGB(color._hue / 360, color._saturation,
|
||||||
return new RGBColor(rgb[0], rgb[1], rgb[2], col._alpha);
|
color._brightness);
|
||||||
|
return new RGBColor(rgb[0], rgb[1], rgb[2], color._alpha);
|
||||||
},
|
},
|
||||||
|
|
||||||
'rgb-gray': function(col) {
|
'rgb-gray': function(color) {
|
||||||
// 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
|
||||||
return new GrayColor(1 -
|
return new GrayColor(1 -
|
||||||
(col._red * 0.2989
|
(color._red * 0.2989
|
||||||
+ col._green * 0.587
|
+ color._green * 0.587
|
||||||
+ col._blue * 0.114),
|
+ color._blue * 0.114),
|
||||||
col._alpha
|
color._alpha
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
'gray-rgb': function(col) {
|
'gray-rgb': function(color) {
|
||||||
var comp = 1 - col.getGray();
|
var comp = 1 - color.getGray();
|
||||||
return new RGBColor(comp, comp, comp, col._alpha);
|
return new RGBColor(comp, comp, comp, color._alpha);
|
||||||
},
|
},
|
||||||
|
|
||||||
'hsb-gray': function(col) {
|
'hsb-gray': function(color) {
|
||||||
return converters['rgb-gray'](converters['hsb-rgb'](col));
|
return converters['rgb-gray'](converters['hsb-rgb'](color));
|
||||||
},
|
},
|
||||||
|
|
||||||
'gray-hsb': function(col) {
|
'gray-hsb': function(color) {
|
||||||
return new HSBColor(0, 0, 1 - col._gray, col._alpha);
|
return new HSBColor(0, 0, 1 - color._gray, color._alpha);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue