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

Improved \color parsing and scaling for custom RGB directives #2223

Merged
merged 1 commit into from
Oct 8, 2023

Conversation

dginev
Copy link
Collaborator

@dginev dginev commented Oct 5, 2023

Fixes a Fatal error in ar5iv#388, as well as a subtle precision bug in color conversion.

I have added the offending examples to the t/graphics/xcolor.tex test, to avoid regressions.

There were 3 conceptual changes here:

  • allow spaces after the comma separators in custom rgb specifications used in \color
  • switch to a generalized conversion to hex via sprintf
  • and fix a subtle precision bug: ensure we switch to the target color scheme before a color is scaled. There was an interesting example with "yellow" scaled down by 0.25, which is represented via CMYK (0,0,1,0), resulting in (0,0,0.75,0). The issue is that if only then a conversion to the RGB model is performed, we lose the scaling information on all but the yellow axis (due to the zero components). If we instead first switch from CMYK to RGB and then scale down by 0.25, we get the exact right results as in the PDF.

This PR feels complete to me, welcoming a review.

…; convert to target color model *before* scaling
@dginev dginev requested a review from brucemiller October 5, 2023 02:18
@brucemiller
Copy link
Owner

Cool! Thanks!!!

@brucemiller brucemiller merged commit 013597e into brucemiller:master Oct 8, 2023
13 checks passed
@brucemiller brucemiller deleted the xcolor-rgb-parsing branch October 8, 2023 14:59
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

Successfully merging this pull request may close these issues.

2 participants