06-30-2014, 09:08 PM
(06-30-2014, 07:22 PM)puggsoy Wrote: That looks pretty cool! I might be able to port it to Haxe's version of GLSL (HxSL, which I just discovered) and use it myself. I was wondering a while ago how to go about finding the "closest" colour in a palette, so that should be a great help. Thanks!
That was a tough question to answer, how do you define how close a color is to another?
I do this by mapping colors in HSL space (Hue, Saturation, Luminosity) and comparing the square distance of them, but there's other ways to do it, like mapping it in a different color space, like XYZ or one of the many other color spaces.
Then the method of comparison, the square distance. You could also use a trigonometric comparison, like Cosine similarity, but so far this hasn't caused any artifacts, and is pretty fast.