Skip to content

[patch] Fix sRGB/linear color-space slips in ThemeProvider#43

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/color-space-lows
Jul 15, 2026
Merged

[patch] Fix sRGB/linear color-space slips in ThemeProvider#43
matt-edmondson merged 1 commit into
mainfrom
fix/color-space-lows

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

Low-severity color-space fixes found in a linear/sRGB audit. The core library pipeline was already space-clean; these are the edge slips.

  • ThemeProviderDemo/Program.csAdjustBrightness: multiplied gamma-encoded sRGB channels by a factor. Multiplicative brightness is a linear-light operation, so it now scales the linear channels via Color.FromLinear, giving a perceptually correct result.
  • ThemeProviderDemo/Program.csToImVec4: hardcoded alpha = 1.0 and discarded color.A. Now preserves the color's alpha (alpha ?? (float)color.A) while still allowing an explicit override.
  • ThemeProvider/ColorRange.csIsSingleColor: compared the Oklab distance against double.Epsilon (~4.9e-324, effectively exact equality), contradicting the "single color" intent. Now uses a named 1e-6 perceptual threshold.
  • ThemeProvider/SemanticColorMapper.cs: collapsed a dead meaning == Neutral ? globalCenter : globalCenter no-op ternary.

Verification

  • ThemeProvider.sln builds with 0 warnings / 0 errors (warnings-as-errors).
  • ThemeProvider.Test passes (roundtrip, accessibility, semantic-mapper suites).

🤖 Generated with Claude Code

- Demo AdjustBrightness multiplied gamma-encoded sRGB channels; a
  multiplicative brightness change is a linear-light operation, so scale
  the linear channels via Color.FromLinear instead.
- Demo ToImVec4 hardcoded alpha=1.0 and dropped color.A; preserve the
  color's alpha while still allowing an explicit override.
- ColorRange.IsSingleColor compared the Oklab distance against
  double.Epsilon (effectively exact equality); use a small perceptual
  threshold (1e-6) matching the "single color" intent.
- Collapse a dead no-op ternary in SemanticColorMapper.
@matt-edmondson
matt-edmondson merged commit c97c0b4 into main Jul 15, 2026
2 checks passed
@matt-edmondson
matt-edmondson deleted the fix/color-space-lows branch July 15, 2026 07:43
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

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