Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/ColorAnalyzer/samples/ColorAnalyzer.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="ContrastHelper\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="ColorAnalyzerExperiment.Samples.AccentAnalyzerSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -11,10 +11,21 @@
mc:Ignorable="d">

<Page.Resources>
<helpers:AccentAnalyzer x:Name="AccentAnalyzer"
Source="{x:Bind AccentedImage}" />
<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>
</Page.Resources>

<!--
ConstrastHelper used to auto-adjust text Foreground against the dynamic background per WCAG.
This is not a ContrastHelper sample, but is used here to ensure text is always readable.
-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
Expand All @@ -23,19 +34,17 @@

<StackPanel Padding="20"
VerticalAlignment="Center">
<Image x:Name="AccentedImage"
<Image x:Name="SampledImage"
HorizontalAlignment="Center"
Source="/ColorAnalyzerExperiment.Samples/Assets/StockImages/Flowers.jpg"
Stretch="Uniform">
<interactivity:Interaction.Behaviors>
<interactivity:EventTriggerBehavior EventName="ImageOpened">
<interactivity:CallMethodAction MethodName="UpdateAccent"
TargetObject="{x:Bind AccentAnalyzer}" />
<interactivity:CallMethodAction MethodName="UpdatePalette"
TargetObject="{x:Bind ColorPaletteSampler}" />
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Image>
<TextBlock HorizontalAlignment="Center"
Text="{x:Bind AccentAnalyzer.Colorfulness, Mode=OneWay}" />
</StackPanel>

<Grid Grid.Column="1"
Expand All @@ -60,9 +69,9 @@
Margin="4"
Padding="2">
<Border.Background>
<SolidColorBrush Color="{x:Bind AccentAnalyzer.DominantColor, Mode=OneWay}" />
<SolidColorBrush Color="{x:Bind WeightedColorPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />
</Border.Background>
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.DominantColor, Mode=OneWay}"
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind WeightedColorPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}"
Text="Dominant" />
</Border>

Expand All @@ -72,14 +81,14 @@
Margin="4"
Padding="2">
<Border.Background>
<SolidColorBrush Color="{x:Bind AccentAnalyzer.BaseColor, Mode=OneWay}" />
<SolidColorBrush Color="{x:Bind BasePalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />
</Border.Background>
<TextBlock Text="Base">
<TextBlock.Foreground>
<!-- ConstrastHelper used to auto-adjust text Foreground against the dynamic background per WCAG -->

<SolidColorBrush helpers:ContrastHelper.MinRatio="5"
helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.BaseColor, Mode=OneWay}"
Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" />
helpers:ContrastHelper.Opponent="{x:Bind BasePalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}"
Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />
</TextBlock.Foreground>
</TextBlock>
</Border>
Expand All @@ -90,9 +99,9 @@
Margin="4"
Padding="2">
<Border.Background>
<SolidColorBrush Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" />
<SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />
</Border.Background>
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}"
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}"
Text="Primary" />
</Border>
<!-- Secondary -->
Expand All @@ -101,9 +110,9 @@
Margin="4"
Padding="2">
<Border.Background>
<SolidColorBrush Color="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" />
<SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" />
</Border.Background>
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}"
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}"
Text="Secondary" />
</Border>
<!-- Tertiary -->
Expand All @@ -112,9 +121,9 @@
Margin="4"
Padding="2">
<Border.Background>
<SolidColorBrush Color="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" />
<SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" />
</Border.Background>
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}"
<TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}"
Text="Tertiary" />
</Border>

Expand All @@ -125,9 +134,9 @@
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStopCollection>
<GradientStop Offset="0" Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" />
<GradientStop Offset="0.74" Color="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" />
<GradientStop Offset="1" Color="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" />
<GradientStop Offset="0" Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />
<GradientStop Offset="0.74" Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" />
<GradientStop Offset="1" Color="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" />
</GradientStopCollection>
</LinearGradientBrush>
</Rectangle.Fill>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ private void GridView_ItemClick(object sender, ItemClickEventArgs e)

private void SetImage(Uri uri)
{
_sample.AccentedImage.Source = new BitmapImage(uri);
_sample.SampledImage.Source = new BitmapImage(uri);
}
}
156 changes: 0 additions & 156 deletions components/ColorAnalyzer/src/AccentAnalyzer.Properties.cs

This file was deleted.

45 changes: 0 additions & 45 deletions components/ColorAnalyzer/src/AccentColorInfo.cs

This file was deleted.

Loading
Loading