Repository navigation
Conversation
Everywhere in the library `gray` is a lightness percentage where 100 is white and 0 is black (gray.rgb, gray.hsl, gray.hsv, gray.lab, gray.hex, and the inverse rgb.gray). `gray.cmyk` instead put the lightness straight into the K (black) channel, which has the opposite polarity, so it inverted every value except the symmetric midpoint 50: convert.gray.cmyk([100]) // [0, 0, 0, 100] -> black, but gray 100 is white convert.gray.cmyk([0]) // [0, 0, 0, 0] -> white, but gray 0 is black K is the complement of lightness, so return `100 - gray[0]`. This matches the library's own gray -> rgb -> cmyk path for every input. The existing test only covered gray 50 (the fixed point where the bug is invisible); added assertions for 100 and 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Everywhere in color-convert,
grayis a lightness percentage where100is white and0is black —gray.rgb([100]) === [255, 255, 255],gray.hex([100]) === 'FFFFFF',gray.lab([100]) === [100, 0, 0], and the inversergb.gray([255, 255, 255]) === [100].gray.cmykput that lightness straight into the CMYK K (black/darkness) channel, which has the opposite polarity. So it inverted every value except the symmetric midpoint50:The library's own
gray -> rgb -> cmykpath gives the correct[0, 0, 0, 0]for white and[0, 0, 0, 100]for black, confirming the direct conversion is wrong.Fix
Kis the complement of lightness, so return100 - gray[0]. This now matches every siblinggray.*conversion and the routedgray -> rgb -> cmykresult for all inputs.Tests
The only existing
gray.cmykassertion used input50, the one value where the inversion is invisible (100 - 50 === 50). Added assertions for100and0; both fail onmasterand pass with the fix.xoandnode test/basic.jsare green.