Repository navigation
Interpolate MixOklab, Lerp and Gradient premultiplied, so a transparent end adds no color [minor] - #528
Merged
Conversation
…nt end adds no color [minor] Each color's channels now count in proportion to its alpha, as CSS Color 4 specifies, so Transparent.MixOklab(White, 0.5) is #FFFFFF80 rather than #63636380 and a fade-in from Transparent no longer passes through dark grey. A result with alpha 0 is transparent black. Opaque inputs mix as before. Fixes #526 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5AXVu7aN3GSXPwGnx
|
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.



Fixes #526
What changed
MixOklabnow weights each color's L/a/b by its alpha, andLerpweights its linear R/G/B the same way. Both divide by the mixed alpha afterwards, as CSS Color 4 §12.3 specifies.Gradientgoes throughMixOklab, so it picks up the fix too.<remarks>now say interpolation is premultiplied. Colors are still stored with straight alpha.Results
Transparent.MixOklab(White, 0.5)#63636380#FFFFFF80Transparent.Lerp(White, 0.5)#BCBCBC80#FFFFFF80Transparent.Gradient(White, 5)#00000000 #22222240 #63636380 #AEAEAEBF #FFFFFF#00000000 #FFFFFF40 #FFFFFF80 #FFFFFFBF #FFFFFFRed.WithAlpha(0).MixOklab(Blue, 0.5)#8C53A280#0000FF80Tests
ColorGamutAndAlphaTests: mixing from Transparent in both directions, a fade-in gradient, an invisible end, two transparent ends, and an opaque control.Color.Operations.csmakes four of them fail. The opaque control passes both ways, which shows opaque mixes did not change.Semantics.Test: 1967 passed, 14 skipped, 0 failed.This changes behavior, so the commit is tagged
[minor].Generated by Claude Code