Refactor AccentAnalyzer into ColorPaletteSampler#746
Merged
Arlodotexe merged 7 commits intoCommunityToolkit:mainfrom Oct 10, 2025
Merged
Refactor AccentAnalyzer into ColorPaletteSampler#746Arlodotexe merged 7 commits intoCommunityToolkit:mainfrom
Arlodotexe merged 7 commits intoCommunityToolkit:mainfrom
Conversation
ea97b51 to
4e2e14b
Compare
- Trimmed colorfulness info from AccentColorInfo - Renamed AccentColorInfo to PaletteColor - Removed colorfulness calculations for AccentAnalyzer - Renamed AccentAnalyzer to ColorPaletteSampler - Replaced statically enumerated PaletteSelector properties with index bindable SelectedColors with dynamic min count - Replaced phrase 'prominence' with 'weight' and 'fraction'
Arlodotexe
approved these changes
Oct 10, 2025
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.
This PR builds on #734 by removing the explicit 5 accent color properties on the
AccentAnalyzerand replaces it with anIList<ColorPaletteSelector>property.New XAML usage example:
<*.Resources> <helpers:ColorPaletteSampler x:Name="ColorPaletteSampler" Source="{x:Bind SampledImage}"> <helpers:AccentColorPaletteSelector x:Name="AccentPalette" MinColorCount="3" /> <helpers:ColorWeightPaletteSelector x:Name="WeightedColorPalette" MinColorCount="1" /> <helpers:BaseColorPaletteSelector x:Name="BasePalette" MinColorCount="1" /> </helpers:ColorPaletteSampler> </*.Resources> ... <!-- Any number of bindings you'd like with indexed SelectedColors! --> <SolidColorBrush Color="{x:Bind WeightedColorPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" />This allows a dynamic number of extracted color properties through combinations of color palette selectors, and even more by implementing your own custom
ColorPaletteSelector!Similar behavior was previously possible by making a derived class from the
AccentAnalyzerand overriding theSelectAccentColorsmethod. I believe this is a cleaner solution though, moving even dynamic numbers of extracted colors into pure XAML.Example in use:
