avp / spectra

A Javascript color library. Quickly manipulate and convert colors.
avp.github.io/spectra
MIT License
237 stars 18 forks source link

Add margin of error to .equals() method #21

Closed avp closed 10 years ago

avp commented 10 years ago

The .equals() method should be able to take an optional argument for a percentage error, for example: color.equals(color2, 0.1) would check to see that color2 was within 10% of color.

broox commented 10 years ago

or maybe a supplementary method since it's not really comparing a true equal state? Maybe something like color.near()?

avp commented 10 years ago

That's a valid way to do it too, and I think it's probably cleaner. We could just make color.equals() call color.near().