Handle invalid color channel values from pl/color-xyz-to-apply-rgb
#171
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.
With the existing
pl/color-xyz-to-apply-rgb
function, it's possible thatpl/hex-color
will generate a-0.0e+NaN
color channel value for certain colors, such as those with zero B and/or G values. This will either result in an incorrect displayed color (e.g., in Emacs 26.2) or cause an error to be thrown (e.g., in Emacs 27.0). It's also possible thatpl/color-xyz-to-apply-rgb
will generate color channel values slightly outside of the valid range of 0.0 - 1.0, though that doesn't seem to cause any particular issues for Emacs.Screenshots below from a test function comparing the changes in this PR with master and the core
color-rgb-to-hex
.Emacs 26.2:
Emacs 27.0:
See https://gist.github.com/schellj/3a0ff288936322b59006d497bf607351 for the test function that I used for the screenshots above function (copy the PR
pl/color-xyz-to-apple-rgb
toschellj/color-xyz-to-apple-rgb
).I spent a long time (too much time) trying to figure out if the
pl/color-xyz-to-apply-rgb
matrix transformation was incorrect or if there was a better one, but that effort was unfruitful. Thus, I opted to just catch and handle the invalid color channel values.