graypegg / chromatism

:rainbow: A simple set of utility functions for colours.
1.78k stars 37 forks source link

Fix difference returning NaN with grayscale colors #52

Open e-domnenko opened 1 year ago

e-domnenko commented 1 year ago

This PR fixes issue #48 in difference function.

difference function returns NaN if one of colours provided as argument is garyscale (e.g. #f0f0f0, #4d4d4d, #eeeeee).

lulunac27a commented 5 months ago

The dH formula a^2+b^2-c^2 can be less than zero because of rounding errors caused by floating number precision.