jaames / iro.js

🎨 Modular color picker widget for JavaScript, with support for a bunch of color formats
https://iro.js.org
Mozilla Public License 2.0
1.3k stars 81 forks source link

sliderType kelvin values not accurate #249

Closed DenFin closed 1 year ago

DenFin commented 1 year ago

Hi @jaames,

first of all I want to give you some positive feedback. It's a great library, easy to use, good documentation (!) and really nice demo sit/docs site.

We faced an issue with the kelvin slider. When I drag the slider completely to the left or right the values are never the min oder max values. For example if I drag the slider completely to the left I would expect the value to be 2200, but it actually goes lower, something like 2193.9544677734375. When I drag the slider completely to the right I would expect the value to be 11000, but it is actually something like 10991.775512695312.

I created an example on Stackblitz.

jaames commented 1 year ago

thanks for the kind words :)

the discrepancy you're seeing is because iro.js colors are stored as hsv values internally (since it was originally only a hsv color picker) - unfortunately converting a kelvin temperature to hsv and back again isn't super precise and some precision is lost along the way

DenFin commented 1 year ago

@jaames thanks for your fast reply!

i see. we'll try to fix the problem on our side.