refactor: gather the colour conversions in util::color - #940
Merged
Merged
Conversation
html, pdf and ooxml each had their own copy of the sRGB transfer and of the conversion from a channel to a byte. The dark fill had Oklab, and the xlsx tint had HSL. `util/color_util` now holds all of them, and each module keeps only its own rule on top: `dark_fill`, `apply_tint`, and the pdf Lab and CMYK spaces. The formulas do not change, so the reference output stays the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tigcf9he3w1aHfNPJoEGsd
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.
Stacked on #935.
Change
html, pdf and ooxml each had their own copy of some colour math.
src/odr/internal/util/color_util.{hpp,cpp}(namespaceutil::color) now holds it:to_byte, a channel in [0, 1] to a bytepdf_image.cppto_byte,html/pdf_file.cppto255,dark_fill,apply_tintsrgb_to_linear,linear_to_srgbhtml/common.cpp,pdf_color.cppOklabhtml/common.cppHslapply_tintinooxml_util.cppEach module keeps only its own rule:
html::dark_fill,ooxml::apply_tint(ECMA-376 18.8.19), and the pdf CIE Lab and CMYK spaces.Proof
ColorUtil,HslandOklabtests.🤖 Generated with Claude Code
https://claude.ai/code/session_01Tigcf9he3w1aHfNPJoEGsd