Fix ColorSpectrum third-component slider showing wrong colors#20945
Open
NathanDrake2406 wants to merge 2 commits intoAvaloniaUI:masterfrom
Open
Fix ColorSpectrum third-component slider showing wrong colors#20945NathanDrake2406 wants to merge 2 commits intoAvaloniaUI:masterfrom
NathanDrake2406 wants to merge 2 commits intoAvaloniaUI:masterfrom
Conversation
The ColorSpectrum's companion slider should show what each hue/saturation/value looks like at the actual 2D selection point — not at hardcoded S=1, V=1. IsPerceptive="True" was forcing non-varying HSV components to 1.0, producing vibrant gradients regardless of the current selection. This is correct for standalone sliders (pedagogical mode) but wrong for the spectrum's third axis, where accuracy is the contract. Fixes AvaloniaUI#20925
Verify that CreateComponentBitmapAsync with isPerceptive=false produces pixel output that reflects the actual HSV selection values. Covers all three component types (Hue, Saturation, Value) with assertions derived from HSV color math invariants. Also adds InternalsVisibleTo and project reference to enable testing the internal ColorPickerHelpers from Avalonia.Controls.UnitTests.
|
You can test this PR using the following package version. |
Contributor
|
I saw your issue but haven't had extra time to reply. The current functionality was intentional though so let's try reach consensus before this is merged. |
Contributor
|
Nevermind after reading the tests. This is testing the color calculation itself not the color picker. It might be better to do image-based comparisons for these tests though. We already have infrastructure for that. |
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.
Summary
Fixes #20925
IsPerceptiveon the ColorSpectrum's companion slider in all 4 theme templates (Fluent/Simple × ColorPicker/ColorView). The slider now renders using the actual HSV values from the 2D selection point instead of hardcoding S=1, V=1.ColorPickerHelpers.CreateComponentBitmapAsyncverifying that the non-perceptive path produces accurate pixel output for all three component types (Hue, Saturation, Value), with assertions derived from HSV color math invariants.Root cause
IsPerceptive="True"onColorSpectrumThirdComponentSlidercaused the slider gradient to force non-varying HSV components to 1.0 — producing a vibrant rainbow regardless of the actual selection. This is the correct behavior for standalone "pedagogical" sliders, but wrong for the spectrum's third axis where accuracy is the contract.What changed
Themes/Fluent/ColorPicker.xamlIsPerceptive="True"→"False"Themes/Fluent/ColorView.xamlIsPerceptive="True"→"False"Themes/Simple/ColorPicker.xamlIsPerceptive="True"→"False"Themes/Simple/ColorView.xamlIsPerceptive="True"→"False"ColorPicker.csprojInternalsVisibleTofor test projectControls.UnitTests.csprojColorPickerHelpersTests.csTest plan