mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Rearrange color converters to group by pairs.
This commit is contained in:
parent
d5fa3d7ae6
commit
cd80db14d8
1 changed files with 15 additions and 15 deletions
|
@ -264,18 +264,6 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
return new HSBColor(hue * 360, saturation, brightness, alpha);
|
return new HSBColor(hue * 360, saturation, brightness, alpha);
|
||||||
},
|
},
|
||||||
|
|
||||||
'rgb-gray': function(color) {
|
|
||||||
// Using the standard NTSC conversion formula that is used for
|
|
||||||
// calculating the effective luminance of an RGB color:
|
|
||||||
// http://www.mathworks.com/support/solutions/en/data/1-1ASCU/index.html?solution=1-1ASCU
|
|
||||||
return new GrayColor(1 -
|
|
||||||
(color._red * 0.2989
|
|
||||||
+ color._green * 0.587
|
|
||||||
+ color._blue * 0.114),
|
|
||||||
color._alpha
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
'hsb-rgb': function(color) {
|
'hsb-rgb': function(color) {
|
||||||
var h = color._hue,
|
var h = color._hue,
|
||||||
s = color._saturation,
|
s = color._saturation,
|
||||||
|
@ -295,9 +283,16 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'hsb-gray': function(color) {
|
'rgb-gray': function(color) {
|
||||||
var rgbColor = converters['hsb-rgb'](color);
|
// Using the standard NTSC conversion formula that is used for
|
||||||
return converters['rgb-gray'](rgbColor);
|
// calculating the effective luminance of an RGB color:
|
||||||
|
// http://www.mathworks.com/support/solutions/en/data/1-1ASCU/index.html?solution=1-1ASCU
|
||||||
|
return new GrayColor(1 -
|
||||||
|
(color._red * 0.2989
|
||||||
|
+ color._green * 0.587
|
||||||
|
+ color._blue * 0.114),
|
||||||
|
color._alpha
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
'gray-rgb': function(color) {
|
'gray-rgb': function(color) {
|
||||||
|
@ -305,6 +300,11 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
return new RGBColor(component, component, component, color._alpha);
|
return new RGBColor(component, component, component, color._alpha);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'hsb-gray': function(color) {
|
||||||
|
var rgbColor = converters['hsb-rgb'](color);
|
||||||
|
return converters['rgb-gray'](rgbColor);
|
||||||
|
},
|
||||||
|
|
||||||
'gray-hsb': function(color) {
|
'gray-hsb': function(color) {
|
||||||
return new HSBColor(0, 0, 1 - color._gray, color._alpha);
|
return new HSBColor(0, 0, 1 - color._gray, color._alpha);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue