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

Conversion of HSV fails when V = 0 #35

Open
bdoss opened this issue Oct 23, 2017 · 6 comments
Open

Conversion of HSV fails when V = 0 #35

bdoss opened this issue Oct 23, 2017 · 6 comments

Comments

@bdoss
Copy link

bdoss commented Oct 23, 2017

This appears to be caused by division by zero, resulting in the saturation component evaluating to NaN.

Line 12 seems to be where the division by zero occurs:
https://github.com/toish/chromatism/blob/488020a1553d5aa0a0ffb1fbd98fc19a6be6503d/src/conversions/hsv.js#L9-L17

@bdoss
Copy link
Author

bdoss commented Oct 23, 2017

Only seems to impact the HSV case.

HSL conversion:

let { hex } = chroma.convert({ h: 0, s: 0, l: 0 });
// hex = #000000

HSV conversion:

let { hex } = chroma.convert({ h: 0, s: 0, v: 0 });
// hex = #NaNNaNNaN

@TehShrike
Copy link
Contributor

Good catch!

@TehShrike
Copy link
Contributor

Fix published upstream in chromatism2@3.0.2. Can be cherry-picked/merged from TehShrike@436d8b0

@bdoss
Copy link
Author

bdoss commented Oct 23, 2017

Thanks for the quick fix!

@graypegg
Copy link
Owner

graypegg commented Nov 4, 2017

Awesome! Thanks for the patch @TehShrike, and sorry for the radio silence on my end, this will be in a patch release as soon as I can get to my laptop today.

@graypegg graypegg closed this as completed Nov 4, 2017
@graypegg
Copy link
Owner

graypegg commented Nov 4, 2017

Oh wait, @TehShrike, when you’re able to, would you be able to make a pull request? Thanks!

@graypegg graypegg reopened this Nov 4, 2017
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

3 participants