Skip to content

Conversation

Avid29
Copy link
Contributor

@Avid29 Avid29 commented Sep 25, 2025

Adds the first iteration of the AccentAnalyzer, a helper which allows for binding to colors extracted from images or other UIElements.

Example:
image

@Avid29 Avid29 changed the title Accent Analyzer Experiment addition Accent Analyzer Experiment Creation Sep 25, 2025
@Avid29 Avid29 changed the title Accent Analyzer Experiment Creation AccentAnalyzer Experiment Creation Sep 25, 2025
Copy link
Collaborator

@niels9001 niels9001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing! Can't wait to start using it 😁!!

@niels9001 niels9001 requested a review from Copilot September 25, 2025 10:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the AccentAnalyzer helper component, which enables extraction of color palettes from UIElements (particularly images) for use in XAML bindings. The AccentAnalyzer uses k-means clustering algorithms to identify dominant, primary, secondary, and tertiary colors from an image source, providing properties that can be bound to in XAML.

  • Implements k-means clustering algorithm for color analysis and extraction
  • Provides bindable color properties (PrimaryAccentColor, SecondaryAccentColor, etc.) and colorfulness metric
  • Includes complete sample application demonstrating color extraction from images with visual color palette display

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
AccentAnalyzer.cs Core analyzer class with dependency properties and async color extraction logic
AccentAnalyzer.Clustering.cs K-means clustering implementation and colorfulness calculation algorithms
AccentAnalyzerSample.xaml Sample page demonstrating color binding to visual elements
AccentAnalyzerSampleOptionsPane.xaml.cs Options pane allowing dynamic image URL input
Various project/config files Standard project structure and build configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@michael-hawker
Copy link
Member

Link to original discussion: #254

We should use the issue template to create a tracking experiment for this and use that in the doc link.

@Avid29
Copy link
Contributor Author

Avid29 commented Sep 25, 2025

Experiment Issue created
#736

@Arlodotexe
Copy link
Member

@Avid29 To make space for other color-related helpers in the future, I'm thinking we should rename the component to ColorAnalyzer while keeping the name/code for AccentAnalyzer as-is. Thoughts? @michael-hawker or @niels9001?

@Avid29
Copy link
Contributor Author

Avid29 commented Sep 29, 2025

@Arlodotexe Makes complete sense to me

@Arlodotexe Arlodotexe changed the title AccentAnalyzer Experiment Creation ColorAnalyzer Component Creation Sep 30, 2025
Copy link
Member

@Arlodotexe Arlodotexe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reviewable concerns were addressed in 9cd306f. Approved! 🚀

@Arlodotexe
Copy link
Member

Arlodotexe commented Sep 30, 2025

This is very strange, we're seeing issues with Marquee here stemming from #732:

         C:\a\Labs-Windows\Labs-Windows\components\Marquee\src\Marquee.Properties.cs(5,18): error CS0234: The type or namespace name 'Text' does not exist in the namespace 'Windows.UI' (are you missing an assembly reference?) [C:\a\Labs-Windows\Labs-Windows\components\Marquee\src\CommunityToolkit.WinUI.Controls.Marquee.csproj::TargetFramework=uap10.0.17763]
         C:\a\Labs-Windows\Labs-Windows\tooling\GlobalUsings_WinUI.cs(11,33): error CS0234: The type or namespace name 'Collections' does not exist in the namespace 'Windows.Foundation' (are you missing an assembly reference?) [C:\a\Labs-Windows\Labs-Windows\components\Marquee\src\CommunityToolkit.WinUI.Controls.Marquee.csproj::TargetFramework=uap10.0.17763]

There may have been an issue with the incremental builds when the component was renamed that prevented it from running properly. I'll have to branch off main and fix this before we continue.

I'm not seeing this same error on the wasdk multitarget. In the meantime, I'll rerun this to see if it helps there.

Update: I'm not seeing any build errors locally, even in release mode. Let's wait for the CI to retry to see if it self-corrects...

Update 2: The Wasdk error provides a bit more insight, still not enough to tell exactly what happened:

       CsWinRTGenerateProjection:
         Creating directory "C:\a\Labs-Windows\Labs-Windows\components\CanvasView\src\obj\x64\Release\net9.0-windows10.0.19041.0\Generated Files\CsWinRT\".
         "C:\Users\runneradmin\.nuget\packages\microsoft.windows.cswinrt\2.2.0\cswinrt.exe" @"C:\a\Labs-Windows\Labs-Windows\components\CanvasView\src\obj\x64\Release\net9.0-windows10.0.19041.0\Generated Files\CsWinRT\cswinrt.rsp"
         "C:\Users\runneradmin\.nuget\packages\microsoft.windows.cswinrt\2.2.0\cswinrt.exe" @"C:\a\Labs-Windows\Labs-Windows\components\CanvasView\src\obj\x64\Release\net9.0-windows10.0.19041.0\Generated Files\CsWinRT\cswinrt.rsp"
    10>EXEC : error : Could not read the Windows SDK's Platform.xml at C:\Program Files (x86)\Windows Kits\10\Platforms\UAP\10.0.19041.0\Platform.xml [C:\a\Labs-Windows\Labs-Windows\components\CanvasView\src\CommunityToolkit.WinUI.Controls.CanvasView.csproj::TargetFramework=net9.0-windows10.0.19041.0]

It almost looks like Windows SDKs were removed from the runner.

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need at least the images changed I think for licensing concerns.

Future discussion: I could see the calculations done in a .NET library without UI dependency, then maybe a behavior pattern could be better. As basically you could have a 'result' and just regular C# properties without so many DP that way, or you could encapsulate them in another POCO record/class and the result holder is the DP that gets updated and notify bindings and such (I think that'd work...) Anyway, for now this is a good thing to get more feedback on, I know folks have been looking for this type of stuff for a while.

Thanks for the contribution!

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.

4 participants