colorjs / color-space

Math & data behind color spaces and color conversions.
http://colorjs.github.io/color-space
The Unlicense
323 stars 25 forks source link

Minified HCG, HSV, HSL and HWB functions #18

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello. I made mini functions of these. Here is original. https://github.com/acterhd/hcg-color/tree/master/convert

dy commented 8 years ago

Please stick to the original formatting, es3 and pass the tests.

ghost commented 8 years ago

I reformatted HSV, HSL, HCG, HWB.

dy commented 8 years ago

Tabs vs spaces. Original formatting is tabs. Also I am not sure about contracting the formulas. They are taken from default sources, like wiki, and contracting them might puzzle reader, not familiar with the color-space models. Is there any performane improvement? Though I see they might be good for shaders, as there are way less conditions. So maybe just commit it to 'gl-color-space'? I will be glad to start/contribute to that.

ghost commented 8 years ago

In GLSL will hardly - they have no indexOf, or array functional. I other for HSV, HSL and HCG have short glsl functions. You can found in shadertoy.

https://www.shadertoy.com/view/ltSXRV

dy commented 8 years ago

Well there is a good reference for shader conversions here. As for the PR, I am not sure what are the profits of merging it. Current rgb/hsl/hsv/hwb code is default from wiki/referenced sources, so it is easy to read and compare with the reference. I don’t see any wins from the shorter version, as for me it is less readable. Is it faster? Calling array.indexOf seems to be really bad idea here, it is cheaper to compare per-element, in terms of performance. I don’t mind modifying hcg.js, but as for other spaces there should be a good argument for it. And once again, indentation should be tabs, same as the original.