omgovich / colord

👑 A tiny yet powerful tool for high-performance color manipulations and conversions
https://colord.omgovich.ru
MIT License
1.63k stars 48 forks source link

Harmonies plugin issue #123

Open jfagan1 opened 4 months ago

jfagan1 commented 4 months ago

I think there is an issue with the harmonies plugin for specific input values. For example if I start with certain hex values sometimes the result returned is slightly off. For example:

const color = colord("#03FF84"); color.harmonies("complementary").map((c) => c.toHex()); // ["#03FF85, "#FF037D"]

You can see that the original color changes from #03FF84 to #03FF85. This problem happens on all harmonies for this color: tetradic, analogous etc. I took a quick look at the source code and I suspect some kind of rounding might be occurring. Does anyone know a way around this?