Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird result when doing Lab -> hsv with specific values #44

Open
FruitieX opened this issue Nov 1, 2018 · 1 comment
Open

Weird result when doing Lab -> hsv with specific values #44

FruitieX opened this issue Nov 1, 2018 · 1 comment

Comments

@FruitieX
Copy link

FruitieX commented Nov 1, 2018

Hi,

Great library, I'm using this for color calculations in my home automation lighting setup. :)

Notably, I'm using Lab colorspace for tweaking the "color temperature" of my lights based on time of day (yeah, probably not the best way, but anyway). My lights expect hsv, so I'm doing the conversion between these using chromatism.

I noticed that at a particular time every evening, my lights would briefly flash bright white as the color temperature slowly adjusts towards an orange color. I started digging into this, and got this far as to have a consistent repro of the bug:

$ node
> require('chromatism').convert({"L":50,"a":10.3777,"b":56.74016}).hsv
{ h: 214.9506072233,
  s: -226243866.03568426,
  v: 0.00001916702582205332 }
> require('chromatism').convert({"L":50,"a":10.3777,"b":56.7401}).hsv
{ h: 42.32831591829547,
  s: 99.99979165015888,
  v: 61.46835916922344 }

Notice how the first example gives totally crazy values, but tweaking any of the input params just slightly in any direction gives me a "sane" color again. My guess would be a division by zero occurring somewhere in chromatism. Converting to RGB (instead of HSV) works fine with these input parameters.

@TehShrike
Copy link
Contributor

Great reproduction, and possibly the best "how I discovered this bug" story I've heard!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants