提交 100d0e00 编写于 作者: B Ben Houston

remote flyweight pattern in ColorConverter.toHSV per @zz85's suggestion here:...

remote flyweight pattern in ColorConverter.toHSV per @zz85's suggestion here: https://github.com/mrdoob/three.js/pull/3109#issuecomment-13923276
上级 79050ff9
......@@ -46,26 +46,20 @@ THREE.ColorConverter = {
},
toHSV: function () {
toHSV: function( color ) {
var hsv = { h: 0, s: 0, v: 0 };
var hsl = color.getHSL();
return function( color ) {
// based on https://gist.github.com/xpansive/1337890#file-index-js
hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l );
var hsl = color.getHSL();
// based on https://gist.github.com/xpansive/1337890#file-index-js
hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l );
hsv.h = hsl.h;
hsv.s = 2 * hsl.s / ( hsl.l + hsl.s );
hsv.v = hsl.l + hsl.s;
return hsv;
}
return {
h: hsl.h,
s: 2 * hsl.s / ( hsl.l + hsl.s ),
v: hsl.l + hsl.s
};
}(),
},
fromStyle: function ( color, style ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册