Skip to content

refactor: gather the colour conversions in util::color - #940

Merged
andiwand merged 1 commit into
fix/xlsx-cell-style-readfrom
refactor/color-util
Sep 28, 2026
Merged

andiwand merged 1 commit into
fix/xlsx-cell-style-readfrom
refactor/color-util

Conversation

@andiwand

Copy link
Copy Markdown
Member

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} (namespace util::color) now holds it:

Function Old copies
to_byte, a channel in [0, 1] to a byte pdf_image.cpp to_byte, html/pdf_file.cpp to255, dark_fill, apply_tint
srgb_to_linear, linear_to_srgb html/common.cpp, pdf_color.cpp
Oklab html/common.cpp
Hsl apply_tint in ooxml_util.cpp

Each 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

  • The formulas do not change. The full suite passes (1871 tests), with the new ColorUtil, Hsl and Oklab tests.
  • The full HTML output of the suite, public and private, is byte-identical to the pinned reference output, so no pin moves.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tigcf9he3w1aHfNPJoEGsd

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
@andiwand
andiwand merged commit 32c0872 into fix/xlsx-cell-style-read Sep 28, 2026
25 checks passed
@andiwand
andiwand deleted the refactor/color-util branch September 28, 2026 18:51
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.

1 participant