Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b0c6539
Added tiles brush section
Feb 11, 2025
8648684
Added tiles brush section
Feb 13, 2025
089e594
Added acrylic brush sample
Feb 13, 2025
45838e6
Adding backdrop blur brush sample
Feb 13, 2025
bd295ad
Updated with Trex png
Feb 18, 2025
08f5e24
Added all brush sample types
Feb 18, 2025
ae7d897
Added markdowns for sample
Feb 19, 2025
ec616df
Updated acrylic and backdrop blur brush samples
Feb 19, 2025
50689de
Updated brush samples
Feb 19, 2025
909a8a5
Updating all the brush samples
Feb 20, 2025
69eb5b4
PipelineVisualFactory sample changes
Feb 20, 2025
c4c177f
Renaming namespace
Feb 20, 2025
36170ce
Naming bug fix
Feb 20, 2025
5df4ebb
Merge branch 'main' into erinwoo/media-samples
Arlodotexe Feb 24, 2025
1a6b938
Icon update + xaml styler
Feb 25, 2025
4ca78cc
Merge branch 'erinwoo/media-samples' of https://github.com/erinpwoo/W…
Feb 25, 2025
fbd104e
Merge branch 'main' of https://github.com/CommunityToolkit/Windows in…
Mar 3, 2025
58990e4
Small comments
Mar 3, 2025
54689fd
Update AcrylicBrush.md
erinpwoo Mar 3, 2025
5b3158e
Remove AcrylicBrushHostBackdropSample and update XAML files.
erinpwoo Mar 3, 2025
6fd6419
Updated Media .csproj file with new icon asset
erinpwoo Mar 3, 2025
6952f72
Removing new categories / subcategories
erinpwoo Mar 6, 2025
25e018c
Moved all samples to single markdown - Brushes section
erinpwoo Mar 11, 2025
fd738c0
Revert changes to tooling submodule
erinpwoo Mar 11, 2025
e514860
Reset tooling submodule to previous working state (611b3c8)
erinpwoo Mar 11, 2025
ce71a54
Update tooling submodule to latest main (11f8b64)
erinpwoo Mar 11, 2025
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added components/Media/samples/Assets/MediaBrushes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions components/Media/samples/Brushes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Brushes
author: erinwoo
description: Brush effects that can be applied to images and backgrounds.
keywords: brush, acrylic, acrylicbrush, backdrop, blur, gamma, transfer, invert, saturation, sepia, tiles, tile, image, blend, brushes
dev_langs:
- csharp
category: Xaml
subcategory: Effects
discussion-id: 0
issue-id: 0
icon: Assets/MediaBrushes.png
---

A brush object is used to paint graphical objects in XAML and can be layered with other visual elements such as images and backgrounds. For examples and further explanation of drawing concepts represented by Brush, see [Use brushes](https://learn.microsoft.com/en-us/windows/uwp/graphics/using-brushes).

## AcrylicBrush

Acrylic is a type of Brush that creates a translucent texture. You can apply acrylic to app surfaces to add depth and help establish a visual hierarchy.
To learn more about the acrylic material in Windows: [link](https://learn.microsoft.com/en-us/windows/apps/design/style/acrylic)

> [!SAMPLE AcrylicBrushSample]

#### *UWP only:*
There are two modes for setting the BackgroundSource property when using an `AcrylicBrush`.
Setting it to `Backdrop` results in the acrylic effect being applied to whatever is *behind the brush* in the application.

Setting BackgroundSource to `HostBackdrop` results in the acrylic effect being applied *behind the current application*.

## BackdropBlurBrush

A brush that blurs the background in the application.

> [!SAMPLE BackdropBlurBrushSample]

## BackdropGammaTransferBrush

A brush which modifies the color values of the brush's background in the application. Map the color intensities of an image using a gamma function created using an amplitude, exponent, and offset you provide for each channel.

> [!SAMPLE BackdropGammaTransferBrushSample]

## BackdropInvertBrush

A brush that inverts the colors of the brush's background in the application.

> [!SAMPLE BackdropInvertBrushSample]

## BackdropSaturationBrush

A brush that can increase or decrease the saturation of the brush's background in the application. The `Saturation` property specifies a double value for the amount of Saturation to apply from 0.0 - 1.0. Zero being monochrome, and one being fully saturated. The default is 0.5.

> [!SAMPLE BackdropSaturationBrushSample]

## BackdropSepiaBrush

A brush that applies the sepia effect to the brush's background. The `Intensity` property specifies a double value for the amount of Sepia to apply from 0.0 - 1.0. Zero being none, and one being full Sepia effect. The default is 0.5.

> [!SAMPLE BackdropSepiaBrushSample]

## ImageBlendBrush

A brush that blends the provided image with whatever is behind it in the application with the provided blend mode. The ImageBlendMode property specifies how the image should be blended with the backdrop. More info about the effect modes can be found [here](https://microsoft.github.io/Win2D/WinUI2/html/T_Microsoft_Graphics_Canvas_Effects_BlendEffectMode.htm).

> [!SAMPLE ImageBlendBrushSample]

## TilesBrush

A brush can be used to display a tiled image as a background.

> [!SAMPLE TilesBrushSample]
35 changes: 35 additions & 0 deletions components/Media/samples/Brushes/AcrylicBrushSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Page x:Class="MediaExperiment.Samples.Brushes.AcrylicBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Black"
BorderThickness=".5">
<Border.Background>
<media:AcrylicBrush BlurAmount="15"
TintColor="Black"
TintOpacity=".6" />
</Border.Background>
<!-- Foreground image -->
<Image Height="100"
VerticalAlignment="Center"
Source="ms-appx:///Assets/BrushAssets/Trex.png" />
</Border>
</Grid>
</StackPanel>
</Page>
16 changes: 16 additions & 0 deletions components/Media/samples/Brushes/AcrylicBrushSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

using CommunityToolkit.WinUI.Media;

namespace MediaExperiment.Samples.Brushes;

[ToolkitSample(id: nameof(AcrylicBrushSample), "AcrylicBrush", description: $"A sample for showing how to apply a {nameof(CommunityToolkit.WinUI.Media.AcrylicBrush)} effect to a background.")]
public sealed partial class AcrylicBrushSample : Page
{
public AcrylicBrushSample()
{
this.InitializeComponent();
}
}
33 changes: 33 additions & 0 deletions components/Media/samples/Brushes/BackdropBlurBrushSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Page x:Class="MediaExperiment.Samples.Brushes.BackdropBlurBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Black"
BorderThickness=".5">
<Border.Background>
<media:BackdropBlurBrush Amount="5.0" />
</Border.Background>
</Border>
<!-- Foreground image -->
<Image Height="100"
VerticalAlignment="Center"
Source="ms-appx:///Assets/BrushAssets/Trex.png" />
</Grid>
</StackPanel>
</Page>
16 changes: 16 additions & 0 deletions components/Media/samples/Brushes/BackdropBlurBrushSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

using CommunityToolkit.WinUI.Media;

namespace MediaExperiment.Samples.Brushes;

[ToolkitSample(id: nameof(BackdropBlurBrushSample), "BackdropBlurBrush", description: $"A sample that uses a {nameof(BackdropBlurBrush)} to blur whatever is behind the application.")]
public sealed partial class BackdropBlurBrushSample : Page
{
public BackdropBlurBrushSample()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Page x:Class="MediaExperiment.Samples.Brushes.BackdropGammaTransferBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Black"
BorderThickness=".5">
<Border.Background>
<media:BackdropGammaTransferBrush AlphaOffset=".2"
RedAmplitude="10" />
</Border.Background>
</Border>
</Grid>
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

using CommunityToolkit.WinUI.Media;

namespace MediaExperiment.Samples.Brushes;

[ToolkitSample(id: nameof(BackdropGammaTransferBrushSample), "BackdropGammaTransferBrush", description: $"A sample for showing how to apply a {nameof(CommunityToolkit.WinUI.Media.BackdropGammaTransferBrush)} effect to a background.")]
public sealed partial class BackdropGammaTransferBrushSample : Page
{
public BackdropGammaTransferBrushSample()
{
this.InitializeComponent();
}
}
29 changes: 29 additions & 0 deletions components/Media/samples/Brushes/BackdropInvertBrushSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Page x:Class="MediaExperiment.Samples.Brushes.BackdropInvertBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Black"
BorderThickness=".5">
<Border.Background>
<media:BackdropInvertBrush />
</Border.Background>
</Border>
</Grid>
</StackPanel>
</Page>
16 changes: 16 additions & 0 deletions components/Media/samples/Brushes/BackdropInvertBrushSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

using CommunityToolkit.WinUI.Media;

namespace MediaExperiment.Samples.Brushes;

[ToolkitSample(id: nameof(BackdropInvertBrushSample), "BackdropGammaTransferBrush", description: $"A sample for showing how to apply a {nameof(BackdropInvertBrush)} effect to a background.")]
public sealed partial class BackdropInvertBrushSample : Page
{
public BackdropInvertBrushSample()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Page x:Class="MediaExperiment.Samples.Brushes.BackdropSaturationBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Black"
BorderThickness=".5">
<Border.Background>
<media:BackdropSaturationBrush Saturation=".2" />
</Border.Background>
</Border>
</Grid>
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

using CommunityToolkit.WinUI.Media;

namespace MediaExperiment.Samples.Brushes;

[ToolkitSample(id: nameof(BackdropSaturationBrushSample), "BackdropGammaTransferBrush", description: $"A sample for showing how to apply a {nameof(BackdropSaturationBrush)} effect to a background.")]
public sealed partial class BackdropSaturationBrushSample : Page
{
public BackdropSaturationBrushSample()
{
this.InitializeComponent();
}
}
29 changes: 29 additions & 0 deletions components/Media/samples/Brushes/BackdropSepiaBrushSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Page x:Class="MediaExperiment.Samples.Brushes.BackdropSepiaBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Black"
BorderThickness=".5">
<Border.Background>
<media:BackdropSepiaBrush Intensity=".8" />
</Border.Background>
</Border>
</Grid>
</StackPanel>
</Page>
16 changes: 16 additions & 0 deletions components/Media/samples/Brushes/BackdropSepiaBrushSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

using CommunityToolkit.WinUI.Media;

namespace MediaExperiment.Samples.Brushes;

[ToolkitSample(id: nameof(BackdropSepiaBrushSample), "BackdropGammaTransferBrush", description: $"A sample for showing how to apply a {nameof(BackdropSepiaBrush)} effect to a background.")]
public sealed partial class BackdropSepiaBrushSample : Page
{
public BackdropSepiaBrushSample()
{
this.InitializeComponent();
}
}
29 changes: 29 additions & 0 deletions components/Media/samples/Brushes/ImageBlendBrushSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Page x:Class="MediaExperiment.Samples.Brushes.ImageBlendBrushSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">

<StackPanel VerticalAlignment="Center"
Spacing="32">
<Grid>
<!-- Background image -->
<Image Height="400"
Source="ms-appx:///Assets/Bloom.jpg" />
<!-- Brush area -->
<Border Width="550"
Height="300"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Border.Background>
<media:ImageBlendBrush Mode="ColorDodge"
Source="ms-appx:///Assets/BrushAssets/Trex.png"
Stretch="None" />
</Border.Background>
</Border>
</Grid>
</StackPanel>
</Page>
Loading