chromatism
chromatism copied to clipboard
Conversion of HSV fails when V = 0
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
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
Good catch!
Fix published upstream in [email protected]. Can be cherry-picked/merged from https://github.com/TehShrike/chromatism/commit/436d8b09bc435845c3d31aff004cf77b83d91cc4
Thanks for the quick fix!
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.
Oh wait, @TehShrike, when you’re able to, would you be able to make a pull request? Thanks!