Merge branch 'master' into mhawker/dependency-update
This commit is contained in:
Коммит
07516d8b27
|
@ -20,9 +20,9 @@
|
|||
Grid.Column="2"
|
||||
Height="400">
|
||||
<Border.Background>
|
||||
<brushes:AcrylicBrush Source="@[Source:Enum:AcrylicBackgroundSource.Backdrop]"
|
||||
Tint="@[Tint:Brush:DarkCyan]"
|
||||
TintMix="@[TintMix:DoubleSlider:0.2:0.0-1.0]"
|
||||
<brushes:AcrylicBrush BackgroundSource="@[Source:Enum:AcrylicBackgroundSource.Backdrop]"
|
||||
TintColor="@[Tint:Brush:DarkCyan]"
|
||||
TintOpacity="@[TintMix:DoubleSlider:0.2:0.0-1.0]"
|
||||
BlurAmount="@[BlurAmount:DoubleSlider:12:0.0-32.0]"
|
||||
TextureUri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
|
||||
</Border.Background>
|
||||
|
|
|
@ -20,62 +20,37 @@
|
|||
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" Width="200" Height="200"/>
|
||||
<Border>
|
||||
<Border.Background>
|
||||
<media:PipelineBrush>
|
||||
<media:PipelineBrush.Effects>
|
||||
<effects:AcrylicEffect/>
|
||||
<effects:BlendEffect>
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:BackdropEffect Source="Backdrop"/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
<effects:BlurEffect/>
|
||||
<effects:ExposureEffect/>
|
||||
<effects:GrayscaleEffect/>
|
||||
<effects:HueRotationEffect/>
|
||||
</media:PipelineBrush.Effects>
|
||||
<media:PipelineBrush Source="{effects:AcrylicSource}">
|
||||
<effects:BlendEffect Source="{effects:BackdropSource BackgroundSource=Backdrop}"/>
|
||||
<effects:BlurEffect/>
|
||||
<effects:ExposureEffect/>
|
||||
<effects:GrayscaleEffect/>
|
||||
<effects:HueRotationEffect/>
|
||||
</media:PipelineBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Border>
|
||||
<Border.Background>
|
||||
<media:PipelineBrush>
|
||||
<media:PipelineBrush.Effects>
|
||||
<effects:AcrylicEffect/>
|
||||
<effects:HueRotationEffect/>
|
||||
<effects:BlendEffect>
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:ImageEffect Uri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
<effects:InvertEffect/>
|
||||
<effects:LuminanceToAlphaEffect/>
|
||||
<effects:OpacityEffect/>
|
||||
<effects:SaturationEffect/>
|
||||
<effects:SepiaEffect/>
|
||||
</media:PipelineBrush.Effects>
|
||||
<media:PipelineBrush Source="{effects:AcrylicSource}">
|
||||
<effects:HueRotationEffect/>
|
||||
<effects:BlendEffect Source="{effects:ImageSource Uri=ms-appx:///Assets/BrushAssets/NoiseTexture.png}"/>
|
||||
<effects:InvertEffect/>
|
||||
<effects:LuminanceToAlphaEffect/>
|
||||
<effects:OpacityEffect/>
|
||||
<effects:SaturationEffect/>
|
||||
<effects:SepiaEffect/>
|
||||
</media:PipelineBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Border>
|
||||
<Border.Background>
|
||||
<media:PipelineBrush>
|
||||
<media:PipelineBrush.Effects>
|
||||
<effects:AcrylicEffect/>
|
||||
<effects:SepiaEffect/>
|
||||
<effects:ShadeEffect/>
|
||||
<effects:BlendEffect>
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:SolidColorEffect/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
<effects:TemperatureAndTintEffect/>
|
||||
<effects:BlendEffect>
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:TileEffect Uri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
<effects:TintEffect/>
|
||||
</media:PipelineBrush.Effects>
|
||||
<media:PipelineBrush Source="{effects:AcrylicSource}">
|
||||
<effects:SepiaEffect/>
|
||||
<effects:ShadeEffect/>
|
||||
<effects:BlendEffect Source="{effects:SolidColorSource}"/>
|
||||
<effects:TemperatureAndTintEffect/>
|
||||
<effects:BlendEffect Source="{effects:TileSource Uri=ms-appx:///Assets/BrushAssets/NoiseTexture.png}"/>
|
||||
<effects:TintEffect/>
|
||||
</media:PipelineBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
|
|
|
@ -20,29 +20,14 @@
|
|||
Grid.Column="2"
|
||||
Height="400">
|
||||
<Border.Background>
|
||||
<brushes:PipelineBrush>
|
||||
<brushes:PipelineBrush.Effects>
|
||||
<effects:BackdropEffect Source="Backdrop"/>
|
||||
<effects:LuminanceToAlphaEffect/>
|
||||
<effects:OpacityEffect Value="0.4"/>
|
||||
<effects:BlendEffect Mode="Multiply">
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:BackdropEffect Source="Backdrop"/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
<effects:BlurEffect Value="16"/>
|
||||
<effects:ShadeEffect Color="#FF222222" Intensity="0.2"/>
|
||||
<effects:BlendEffect Mode="Overlay" Placement="Background">
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:TileEffect Uri="ms-appx:///Assets/BrushAssets/NoiseTexture.png"/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
<effects:BlendEffect Mode="Overlay" Placement="Background">
|
||||
<effects:BlendEffect.Input>
|
||||
<effects:ImageEffect Uri="ms-appx:///SamplePages/DropShadowPanel/Unicorn.png"/>
|
||||
</effects:BlendEffect.Input>
|
||||
</effects:BlendEffect>
|
||||
</brushes:PipelineBrush.Effects>
|
||||
<brushes:PipelineBrush Source="{effects:BackdropSource}">
|
||||
<effects:LuminanceToAlphaEffect/>
|
||||
<effects:OpacityEffect Value="0.4"/>
|
||||
<effects:BlendEffect Mode="Multiply" Source="{effects:BackdropSource}"/>
|
||||
<effects:BlurEffect Amount="16"/>
|
||||
<effects:ShadeEffect Color="#FF222222" Intensity="0.2"/>
|
||||
<effects:BlendEffect Mode="Overlay" Placement="Background" Source="{effects:TileSource Uri=ms-appx:///Assets/BrushAssets/NoiseTexture.png}"/>
|
||||
<effects:BlendEffect Mode="Overlay" Placement="Background" Source="{effects:ImageSource Uri=ms-appx:///SamplePages/DropShadowPanel/Unicorn.png}"/>
|
||||
</brushes:PipelineBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Composition;
|
||||
|
@ -20,42 +19,42 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
|
|||
/// <summary>
|
||||
/// The <see cref="EffectSetter{T}"/> instance in use to set the blur amount
|
||||
/// </summary>
|
||||
/// <remarks>This is only set when <see cref="Source"/> is <see cref="AcrylicBackgroundSource.Backdrop"/></remarks>
|
||||
/// <remarks>This is only set when <see cref="BackgroundSource"/> is <see cref="AcrylicBackgroundSource.Backdrop"/></remarks>
|
||||
private EffectSetter<float> blurAmountSetter;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="EffectSetter{T}"/> instance in use to set the tint color
|
||||
/// </summary>
|
||||
private EffectSetter<Color> tintSetter;
|
||||
private EffectSetter<Color> tintColorSetter;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="EffectSetter{T}"/> instance in use to set the tint mix amount
|
||||
/// </summary>
|
||||
private EffectSetter<float> tintMixSetter;
|
||||
private EffectSetter<float> tintOpacitySetter;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the source mode for the effect
|
||||
/// Gets or sets the background source mode for the effect (the default is <see cref="AcrylicBackgroundSource.Backdrop"/>).
|
||||
/// </summary>
|
||||
public AcrylicBackgroundSource Source
|
||||
public AcrylicBackgroundSource BackgroundSource
|
||||
{
|
||||
get => (AcrylicBackgroundSource)GetValue(SourceProperty);
|
||||
set => SetValue(SourceProperty, value);
|
||||
get => (AcrylicBackgroundSource)GetValue(BackgroundSourceProperty);
|
||||
set => SetValue(BackgroundSourceProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Source"/> dependency property.
|
||||
/// Identifies the <see cref="BackgroundSource"/> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
|
||||
nameof(Source),
|
||||
public static readonly DependencyProperty BackgroundSourceProperty = DependencyProperty.Register(
|
||||
nameof(BackgroundSource),
|
||||
typeof(AcrylicBackgroundSource),
|
||||
typeof(AcrylicBrush),
|
||||
new PropertyMetadata(AcrylicBackgroundSource.Backdrop, OnSourcePropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Updates the UI when <see cref="Source"/> changes
|
||||
/// Updates the UI when <see cref="BackgroundSource"/> changes
|
||||
/// </summary>
|
||||
/// <param name="d">The current <see cref="AcrylicBrush"/> instance</param>
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="SourceProperty"/></param>
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="BackgroundSourceProperty"/></param>
|
||||
private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is AcrylicBrush brush &&
|
||||
|
@ -86,14 +85,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
|
|||
new PropertyMetadata(0.0, OnBlurAmountPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Updates the UI when <see cref="Source"/> changes
|
||||
/// Updates the UI when <see cref="BackgroundSource"/> changes
|
||||
/// </summary>
|
||||
/// <param name="d">The current <see cref="AcrylicBrush"/> instance</param>
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="SourceProperty"/></param>
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="BackgroundSourceProperty"/></param>
|
||||
private static void OnBlurAmountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is AcrylicBrush brush &&
|
||||
brush.Source != AcrylicBackgroundSource.HostBackdrop && // Blur is fixed by OS when using HostBackdrop source.
|
||||
brush.BackgroundSource != AcrylicBackgroundSource.HostBackdrop && // Blur is fixed by OS when using HostBackdrop source.
|
||||
brush.CompositionBrush is CompositionBrush target)
|
||||
{
|
||||
brush.blurAmountSetter?.Invoke(target, (float)(double)e.NewValue);
|
||||
|
@ -103,60 +102,64 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
|
|||
/// <summary>
|
||||
/// Gets or sets the tint for the effect
|
||||
/// </summary>
|
||||
public Color Tint
|
||||
public Color TintColor
|
||||
{
|
||||
get => (Color)GetValue(TintProperty);
|
||||
set => SetValue(TintProperty, value);
|
||||
get => (Color)GetValue(TintColorProperty);
|
||||
set => SetValue(TintColorProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Tint"/> dependency property.
|
||||
/// Identifies the <see cref="TintColor"/> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TintProperty = DependencyProperty.Register(
|
||||
nameof(Tint),
|
||||
public static readonly DependencyProperty TintColorProperty = DependencyProperty.Register(
|
||||
nameof(TintColor),
|
||||
typeof(Color),
|
||||
typeof(AcrylicBrush),
|
||||
new PropertyMetadata(default(Color), OnTintPropertyChanged));
|
||||
new PropertyMetadata(default(Color), OnTintColorPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Updates the UI when <see cref="Tint"/> changes
|
||||
/// Updates the UI when <see cref="TintColor"/> changes
|
||||
/// </summary>
|
||||
/// <param name="d">The current <see cref="AcrylicBrush"/> instance</param>
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="TintProperty"/></param>
|
||||
private static void OnTintPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="TintColorProperty"/></param>
|
||||
private static void OnTintColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is AcrylicBrush brush &&
|
||||
brush.CompositionBrush is CompositionBrush target)
|
||||
{
|
||||
brush.tintSetter?.Invoke(target, (Color)e.NewValue);
|
||||
brush.tintColorSetter?.Invoke(target, (Color)e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tint mix factor for the effect
|
||||
/// Gets or sets the tint opacity factor for the effect
|
||||
/// </summary>
|
||||
public double TintMix { get; set; }
|
||||
public double TintOpacity
|
||||
{
|
||||
get => (double)GetValue(TintOpacityProperty);
|
||||
set => SetValue(TintOpacityProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="TintMix"/> dependency property.
|
||||
/// Identifies the <see cref="TintOpacity"/> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TintMixProperty = DependencyProperty.Register(
|
||||
nameof(TintMix),
|
||||
public static readonly DependencyProperty TintOpacityProperty = DependencyProperty.Register(
|
||||
nameof(TintOpacity),
|
||||
typeof(double),
|
||||
typeof(AcrylicBrush),
|
||||
new PropertyMetadata(0.0, OnTintMixPropertyChanged));
|
||||
new PropertyMetadata(0.0, OnTintOpacityPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Updates the UI when <see cref="TintMix"/> changes
|
||||
/// Updates the UI when <see cref="TintOpacity"/> changes
|
||||
/// </summary>
|
||||
/// <param name="d">The current <see cref="AcrylicBrush"/> instance</param>
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="TintMixProperty"/></param>
|
||||
private static void OnTintMixPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for <see cref="TintOpacityProperty"/></param>
|
||||
private static void OnTintOpacityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is AcrylicBrush brush &&
|
||||
brush.CompositionBrush is CompositionBrush target)
|
||||
{
|
||||
brush.tintMixSetter?.Invoke(target, (float)(double)e.NewValue);
|
||||
brush.tintOpacitySetter?.Invoke(target, (float)(double)e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,25 +199,25 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
|
|||
/// <inheritdoc/>
|
||||
protected override PipelineBuilder OnBrushRequested()
|
||||
{
|
||||
switch (this.Source)
|
||||
switch (BackgroundSource)
|
||||
{
|
||||
case AcrylicBackgroundSource.Backdrop:
|
||||
return PipelineBuilder.FromBackdropAcrylic(
|
||||
Tint,
|
||||
out tintSetter,
|
||||
(float)TintMix,
|
||||
out tintMixSetter,
|
||||
TintColor,
|
||||
out this.tintColorSetter,
|
||||
(float)TintOpacity,
|
||||
out this.tintOpacitySetter,
|
||||
(float)BlurAmount,
|
||||
out this.blurAmountSetter,
|
||||
out blurAmountSetter,
|
||||
TextureUri);
|
||||
case AcrylicBackgroundSource.HostBackdrop:
|
||||
return PipelineBuilder.FromHostBackdropAcrylic(
|
||||
Tint,
|
||||
out tintSetter,
|
||||
(float)TintMix,
|
||||
out tintMixSetter,
|
||||
TintColor,
|
||||
out this.tintColorSetter,
|
||||
(float)TintOpacity,
|
||||
out this.tintOpacitySetter,
|
||||
TextureUri);
|
||||
default: throw new ArgumentOutOfRangeException(nameof(this.Source), $"Invalid acrylic source: {this.Source}");
|
||||
default: throw new ArgumentOutOfRangeException(nameof(BackgroundSource), $"Invalid acrylic source: {BackgroundSource}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//// Example brush from https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.xamlcompositionbrushbase
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
|
@ -20,7 +19,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
|
|||
/// <summary>
|
||||
/// The <see cref="EffectSetter{T}"/> instance currently in use
|
||||
/// </summary>
|
||||
private EffectSetter<float> setter;
|
||||
private EffectSetter<float> amountSetter;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of gaussian blur to apply to the background.
|
||||
|
@ -50,14 +49,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
|
|||
if (d is BackdropBlurBrush brush &&
|
||||
brush.CompositionBrush is CompositionBrush target)
|
||||
{
|
||||
brush.setter?.Invoke(target, (float)brush.Amount);
|
||||
brush.amountSetter?.Invoke(target, (float)brush.Amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override PipelineBuilder OnBrushRequested()
|
||||
{
|
||||
return PipelineBuilder.FromBackdrop().Blur((float)Amount, out setter);
|
||||
return PipelineBuilder.FromBackdrop().Blur((float)Amount, out this.amountSetter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//// Example brush from https://blogs.windows.com/buildingapps/2017/07/18/working-brushes-content-xaml-visual-layer-interop-part-one/#z70vPv1QMAvZsceo.97
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
|
|
|
@ -7,7 +7,7 @@ using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
|||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Base
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom <see cref="XamlCompositionBrushBase"/> <see langword="class"/> that's ready to be used with a custom <see cref="PipelineBuilder"/> pipeline
|
||||
|
|
|
@ -2,131 +2,41 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using Microsoft.Graphics.Canvas.Effects;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using BlendEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.BlendEffect;
|
||||
using ExposureEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.ExposureEffect;
|
||||
using GrayscaleEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.GrayscaleEffect;
|
||||
using HueRotationEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.HueRotationEffect;
|
||||
using InvertEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.InvertEffect;
|
||||
using LuminanceToAlphaEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.LuminanceToAlphaEffect;
|
||||
using OpacityEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.OpacityEffect;
|
||||
using SaturationEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.SaturationEffect;
|
||||
using SepiaEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.SepiaEffect;
|
||||
using TemperatureAndTintEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.TemperatureAndTintEffect;
|
||||
using TileEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.TileEffect;
|
||||
using TintEffect = Microsoft.Toolkit.Uwp.UI.Media.Effects.TintEffect;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="Brush"/> that renders a customizable Composition/Win2D effects pipeline
|
||||
/// </summary>
|
||||
[ContentProperty(Name = nameof(Effects))]
|
||||
public sealed class PipelineBrush : XamlCompositionEffectBrushBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a new effects pipeline from the input effects sequence
|
||||
/// Gets or sets the input to merge with the current instance (defaults to a <see cref="BackdropSourceExtension"/> with <see cref="Windows.UI.Xaml.Media.AcrylicBackgroundSource.Backdrop"/> source).
|
||||
/// </summary>
|
||||
/// <param name="effects">The input collection of <see cref="IPipelineEffect"/> instance</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance with the items in <paramref name="effects"/></returns>
|
||||
[Pure]
|
||||
private static PipelineBuilder Build(IList<IPipelineEffect> effects)
|
||||
{
|
||||
if (effects.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("An effects pipeline can't be empty");
|
||||
}
|
||||
|
||||
return effects.Skip(1).Aggregate(Start(effects[0]), (b, e) => Append(e, b));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a new composition pipeline from the given effect
|
||||
/// </summary>
|
||||
/// <param name="effect">The initial <see cref="IPipelineEffect"/> instance</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance starting from <paramref name="effect"/></returns>
|
||||
[Pure]
|
||||
private static PipelineBuilder Start(IPipelineEffect effect)
|
||||
{
|
||||
switch (effect)
|
||||
{
|
||||
case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.Backdrop:
|
||||
return PipelineBuilder.FromBackdrop();
|
||||
case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.HostBackdrop:
|
||||
return PipelineBuilder.FromHostBackdrop();
|
||||
case SolidColorEffect color:
|
||||
return PipelineBuilder.FromColor(color.Color);
|
||||
case ImageEffect image:
|
||||
return PipelineBuilder.FromImage(image.Uri, image.DpiMode, image.CacheMode);
|
||||
case TileEffect tile:
|
||||
return PipelineBuilder.FromTiles(tile.Uri, tile.DpiMode, tile.CacheMode);
|
||||
case AcrylicEffect acrylic when acrylic.Source == AcrylicBackgroundSource.Backdrop:
|
||||
return PipelineBuilder.FromBackdropAcrylic(acrylic.Tint, (float)acrylic.TintMix, (float)acrylic.BlurAmount, acrylic.TextureUri);
|
||||
case AcrylicEffect acrylic when acrylic.Source == AcrylicBackgroundSource.HostBackdrop:
|
||||
return PipelineBuilder.FromHostBackdropAcrylic(acrylic.Tint, (float)acrylic.TintMix, acrylic.TextureUri);
|
||||
default:
|
||||
throw new ArgumentException($"Invalid initial pipeline effect: {effect.GetType()}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends an effect to an existing composition pipeline
|
||||
/// </summary>
|
||||
/// <param name="effect">The <see cref="IPipelineEffect"/> instance to append to the current pipeline</param>
|
||||
/// <param name="builder">The target <see cref="PipelineBuilder"/> instance to modify</param>
|
||||
/// <returns>The target <see cref="PipelineBuilder"/> instance in use</returns>
|
||||
private static PipelineBuilder Append(IPipelineEffect effect, PipelineBuilder builder)
|
||||
{
|
||||
switch (effect)
|
||||
{
|
||||
case OpacityEffect opacity:
|
||||
return builder.Opacity((float)opacity.Value);
|
||||
case LuminanceToAlphaEffect _:
|
||||
return builder.LuminanceToAlpha();
|
||||
case InvertEffect _:
|
||||
return builder.Invert();
|
||||
case GrayscaleEffect _:
|
||||
return builder.Grayscale();
|
||||
case ExposureEffect exposure:
|
||||
return builder.Exposure((float)exposure.Value);
|
||||
case SepiaEffect sepia:
|
||||
return builder.Sepia((float)sepia.Value);
|
||||
case ShadeEffect shade:
|
||||
return builder.Shade(shade.Color, (float)shade.Intensity);
|
||||
case HueRotationEffect hueRotation:
|
||||
return builder.HueRotation((float)hueRotation.Angle);
|
||||
case TintEffect tint:
|
||||
return builder.Tint(tint.Color);
|
||||
case TemperatureAndTintEffect temperatureAndTint:
|
||||
return builder.TemperatureAndTint((float)temperatureAndTint.Temperature, (float)temperatureAndTint.Tint);
|
||||
case BlurEffect blur:
|
||||
return builder.Blur((float)blur.Value);
|
||||
case SaturationEffect saturation:
|
||||
return builder.Saturation((float)saturation.Value);
|
||||
case BlendEffect blend:
|
||||
return builder.Blend(Build(blend.Input), (BlendEffectMode)blend.Mode, blend.Placement);
|
||||
default:
|
||||
throw new ArgumentException($"Invalid pipeline effect: {effect.GetType()}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override PipelineBuilder OnBrushRequested()
|
||||
{
|
||||
return Build(this.Effects);
|
||||
}
|
||||
public PipelineBuilder Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection of effects to use in the current pipeline
|
||||
/// </summary>
|
||||
public IList<IPipelineEffect> Effects { get; set; } = new List<IPipelineEffect>();
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override PipelineBuilder OnBrushRequested()
|
||||
{
|
||||
PipelineBuilder builder = Source ?? PipelineBuilder.FromBackdrop();
|
||||
|
||||
foreach (IPipelineEffect effect in Effects)
|
||||
{
|
||||
builder = effect.AppendToPipeline(builder);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Base;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// An image based effect that loads an image at the specified location
|
||||
/// </summary>
|
||||
public abstract class ImageEffectBase : IPipelineEffect
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(PipelineBuilder))]
|
||||
public abstract class ImageSourceBaseExtension : MarkupExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="System.Uri"/> for the image to load
|
|
@ -1,19 +0,0 @@
|
|||
// 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 Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// A base <see langword="class"/> for an effect that exposes a single <see cref="float"/> parameter
|
||||
/// </summary>
|
||||
public abstract class ValueEffectBase : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the parameter for the current effect
|
||||
/// </summary>
|
||||
public double Value { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// 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 Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// A backdrop effect that can sample from a specified source
|
||||
/// </summary>
|
||||
public sealed class BackdropEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the backdrop source to use to render the effect
|
||||
/// </summary>
|
||||
public AcrylicBackgroundSource Source { get; set; }
|
||||
}
|
||||
}
|
|
@ -3,20 +3,26 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Graphics.Canvas.Effects;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// A blend effect that merges the current pipeline with an input one
|
||||
/// A blend effect that merges the current builder with an input one
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.BlendEffect"/> effect</remarks>
|
||||
public sealed class BlendEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the input pipeline to merge with the current instance
|
||||
/// Gets or sets the input to merge with the current instance (defaults to a <see cref="BackdropSourceExtension"/> with <see cref="Windows.UI.Xaml.Media.AcrylicBackgroundSource.Backdrop"/> source).
|
||||
/// </summary>
|
||||
public IList<IPipelineEffect> Input { get; set; } = new List<IPipelineEffect>();
|
||||
public PipelineBuilder Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the effects to apply to the input to merge with the current instance
|
||||
/// </summary>
|
||||
public List<IPipelineEffect> Effects { get; set; } = new List<IPipelineEffect>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the blending mode to use (the default mode is <see cref="ImageBlendMode.Multiply"/>)
|
||||
|
@ -24,8 +30,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
public ImageBlendMode Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the placement of the input pipeline with respect to the current one (the default is <see cref="Placement.Foreground"/>)
|
||||
/// Gets or sets the placement of the input builder with respect to the current one (the default is <see cref="Media.Placement.Foreground"/>)
|
||||
/// </summary>
|
||||
public Placement Placement { get; set; } = Placement.Foreground;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
PipelineBuilder inputBuilder = Source ?? PipelineBuilder.FromBackdrop();
|
||||
|
||||
foreach (IPipelineEffect effect in this.Effects)
|
||||
{
|
||||
inputBuilder = effect.AppendToPipeline(inputBuilder);
|
||||
}
|
||||
|
||||
return builder.Blend(inputBuilder, (BlendEffectMode)Mode, Placement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// A gaussian blur effect
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.GaussianBlurEffect"/> effect</remarks>
|
||||
public sealed class BlurEffect : ValueEffectBase
|
||||
public sealed class BlurEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of gaussian blur to apply to the background.
|
||||
/// </summary>
|
||||
public double Amount { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Blur((float)Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// An exposure effect
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.ExposureEffect"/> effect</remarks>
|
||||
public sealed class ExposureEffect : ValueEffectBase
|
||||
public sealed class ExposureEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of exposure to apply to the background (defaults to 0, should be in the [-2, 2] range).
|
||||
/// </summary>
|
||||
public double Amount { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Exposure((float)Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
|
@ -13,12 +14,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// A custom acrylic effect that can be inserted into a pipeline
|
||||
/// </summary>
|
||||
/// <remarks>This effect mirrors the look of the default <see cref="AcrylicBrush"/> implementation</remarks>
|
||||
public sealed class AcrylicEffect : IPipelineEffect
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(PipelineBuilder))]
|
||||
public sealed class AcrylicSourceExtension : MarkupExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the source mode for the effect
|
||||
/// Gets or sets the background source mode for the effect (the default is <see cref="AcrylicBackgroundSource.Backdrop"/>).
|
||||
/// </summary>
|
||||
public AcrylicBackgroundSource Source { get; set; }
|
||||
public AcrylicBackgroundSource BackgroundSource { get; set; } = AcrylicBackgroundSource.Backdrop;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the blur amount for the effect
|
||||
|
@ -29,16 +31,27 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// <summary>
|
||||
/// Gets or sets the tint for the effect
|
||||
/// </summary>
|
||||
public Color Tint { get; set; }
|
||||
public Color TintColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color for the tint effect
|
||||
/// </summary>
|
||||
public double TintMix { get; set; }
|
||||
public double TintOpacity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Uri"/> to the texture to use
|
||||
/// </summary>
|
||||
public Uri TextureUri { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override object ProvideValue()
|
||||
{
|
||||
return BackgroundSource switch
|
||||
{
|
||||
AcrylicBackgroundSource.Backdrop => PipelineBuilder.FromBackdropAcrylic(this.TintColor, (float)this.TintOpacity, (float)BlurAmount, TextureUri),
|
||||
AcrylicBackgroundSource.HostBackdrop => PipelineBuilder.FromHostBackdropAcrylic(this.TintColor, (float)this.TintOpacity, TextureUri),
|
||||
_ => throw new ArgumentException($"Invalid source mode for acrylic effect: {BackgroundSource}")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// 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 System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// A backdrop effect that can sample from a specified source
|
||||
/// </summary>
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(PipelineBuilder))]
|
||||
public sealed class BackdropSourceExtension : MarkupExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the background source mode for the effect (the default is <see cref="AcrylicBackgroundSource.Backdrop"/>).
|
||||
/// </summary>
|
||||
public AcrylicBackgroundSource BackgroundSource { get; set; } = AcrylicBackgroundSource.Backdrop;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override object ProvideValue()
|
||||
{
|
||||
return BackgroundSource switch
|
||||
{
|
||||
AcrylicBackgroundSource.Backdrop => PipelineBuilder.FromBackdrop(),
|
||||
AcrylicBackgroundSource.HostBackdrop => PipelineBuilder.FromHostBackdrop(),
|
||||
_ => throw new ArgumentException($"Invalid source for backdrop effect: {BackgroundSource}")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,14 +2,19 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// An image effect, which displays an image loaded as a Win2D surface
|
||||
/// </summary>
|
||||
public sealed class ImageEffect : ImageEffectBase
|
||||
public sealed class ImageSourceExtension : ImageSourceBaseExtension
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override object ProvideValue()
|
||||
{
|
||||
return PipelineBuilder.FromImage(Uri, DpiMode, CacheMode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,19 +2,27 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// An effect that renders a standard 8bit SDR color on the available surface
|
||||
/// </summary>
|
||||
public sealed class SolidColorEffect : IPipelineEffect
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(PipelineBuilder))]
|
||||
public sealed class SolidColorSourceExtension : MarkupExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the color to display
|
||||
/// </summary>
|
||||
public Color Color { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override object ProvideValue()
|
||||
{
|
||||
return PipelineBuilder.FromColor(Color);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// An effect that loads an image and replicates it to cover all the available surface area
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.BorderEffect"/> effect</remarks>
|
||||
public sealed class TileEffect : ImageEffectBase
|
||||
public sealed class TileSourceExtension : ImageSourceBaseExtension
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override object ProvideValue()
|
||||
{
|
||||
return PipelineBuilder.FromTiles(Uri, DpiMode, CacheMode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -12,5 +12,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.GrayscaleEffect"/> effect</remarks>
|
||||
public sealed class GrayscaleEffect : IPipelineEffect
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Grayscale();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -16,5 +16,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// Gets or sets the angle to rotate the hue, in radians
|
||||
/// </summary>
|
||||
public double Angle { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.HueRotation((float)Angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,20 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// The base <see langword="interface"/> for all the pipeline effects to be used in a <see cref="PipelineBrush"/>
|
||||
/// The base <see langword="interface"/> for all the builder effects to be used in a <see cref="PipelineBrush"/>
|
||||
/// </summary>
|
||||
public interface IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Appends the current effect to the input <see cref="PipelineBuilder"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="builder">The source <see cref="PipelineBuilder"/> instance to add the effect to.</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> with the new effects added to it.</returns>
|
||||
PipelineBuilder AppendToPipeline(PipelineBuilder builder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -12,5 +12,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.InvertEffect"/> effect</remarks>
|
||||
public sealed class InvertEffect : IPipelineEffect
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Invert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -12,5 +12,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.LuminanceToAlphaEffect"/> effect</remarks>
|
||||
public sealed class LuminanceToAlphaEffect : IPipelineEffect
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.LuminanceToAlpha();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// An opacity effect
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.OpacityEffect"/> effect</remarks>
|
||||
public sealed class OpacityEffect : ValueEffectBase
|
||||
public sealed class OpacityEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the opacity value to apply to the background (defaults to 1, should be in the [0, 1] range).
|
||||
/// </summary>
|
||||
public double Value { get; set; } = 1;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Opacity((float)Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// A saturation effect
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.SaturationEffect"/> effect</remarks>
|
||||
public sealed class SaturationEffect : ValueEffectBase
|
||||
public sealed class SaturationEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the saturation amount to apply to the background (defaults to 1, should be in the [0, 1] range).
|
||||
/// </summary>
|
||||
public double Value { get; set; } = 1;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Saturation((float)Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// A sepia effect
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.SepiaEffect"/> effect</remarks>
|
||||
public sealed class SepiaEffect : ValueEffectBase
|
||||
public sealed class SepiaEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the intensity of the effect (defaults to 0.5, should be in the [0, 1] range).
|
||||
/// </summary>
|
||||
public double Intensity { get; set; } = 0.5;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Sepia((float)Intensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// An effect that overlays a color layer over the current pipeline, with a specified intensity
|
||||
/// An effect that overlays a color layer over the current builder, with a specified intensity
|
||||
/// </summary>
|
||||
public sealed class ShadeEffect : IPipelineEffect
|
||||
{
|
||||
|
@ -21,5 +21,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// Gets or sets the intensity of the color layer
|
||||
/// </summary>
|
||||
public double Intensity { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Shade(Color, (float)Intensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Abstract;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// A temperature and tint effect
|
||||
/// </summary>
|
||||
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.TemperatureAndTintEffect"/> effect</remarks>
|
||||
public sealed class TemperatureAndTintEffect : ValueEffectBase
|
||||
public sealed class TemperatureAndTintEffect : IPipelineEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the temperature for the current effect
|
||||
|
@ -21,5 +21,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// Gets or sets the value of the tint for the current effect
|
||||
/// </summary>
|
||||
public double Tint { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.TemperatureAndTint((float)Temperature, (float)Tint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Effects.Interfaces;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
|
||||
using Windows.UI;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
||||
|
@ -17,5 +17,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
|
|||
/// Gets or sets the int color to use
|
||||
/// </summary>
|
||||
public Color Color { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
|
||||
{
|
||||
return builder.Tint(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,16 +32,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Helpers
|
|||
/// <summary>
|
||||
/// Gets the local cache mapping for previously loaded Win2D images
|
||||
/// </summary>
|
||||
private static readonly CompositionObjectCache<Uri, CompositionSurfaceBrush> Cache = new CompositionObjectCache<Uri, CompositionSurfaceBrush>();
|
||||
private static readonly CompositionObjectCache<Uri, CompositionBrush> Cache = new CompositionObjectCache<Uri, CompositionBrush>();
|
||||
|
||||
/// <summary>
|
||||
/// Loads a <see cref="CompositionSurfaceBrush"/> instance with the target image from the shared <see cref="CanvasDevice"/> instance
|
||||
/// Loads a <see cref="CompositionBrush"/> instance with the target image from the shared <see cref="CanvasDevice"/> instance
|
||||
/// </summary>
|
||||
/// <param name="uri">The path to the image to load</param>
|
||||
/// <param name="dpiMode">Indicates the desired DPI mode to use when loading the image</param>
|
||||
/// <param name="cacheMode">Indicates the cache option to use to load the image</param>
|
||||
/// <returns>A <see cref="Task{T}"/> that returns the loaded <see cref="CompositionSurfaceBrush"/> instance</returns>
|
||||
public static async Task<CompositionSurfaceBrush> LoadImageAsync(Uri uri, DpiMode dpiMode, CacheMode cacheMode = CacheMode.Default)
|
||||
/// <returns>A <see cref="Task{T}"/> that returns the loaded <see cref="CompositionBrush"/> instance</returns>
|
||||
public static async Task<CompositionBrush> LoadImageAsync(Uri uri, DpiMode dpiMode, CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
var compositor = Window.Current.Compositor;
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Helpers
|
|||
}
|
||||
|
||||
// Load the image
|
||||
CompositionSurfaceBrush brush;
|
||||
CompositionBrush brush;
|
||||
try
|
||||
{
|
||||
// This will throw and the canvas will re-initialize the Win2D device if needed
|
||||
|
@ -82,14 +82,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Helpers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a <see cref="CompositionSurfaceBrush"/> from the input <see cref="System.Uri"/>, and prepares it to be used in a tile effect
|
||||
/// Loads a <see cref="CompositionBrush"/> from the input <see cref="System.Uri"/>, and prepares it to be used in a tile effect
|
||||
/// </summary>
|
||||
/// <param name="canvasDevice">The device to use to process the Win2D image</param>
|
||||
/// <param name="compositor">The compositor instance to use to create the final brush</param>
|
||||
/// <param name="uri">The path to the image to load</param>
|
||||
/// <param name="dpiMode">Indicates the desired DPI mode to use when loading the image</param>
|
||||
/// <returns>A <see cref="Task{T}"/> that returns the loaded <see cref="CompositionSurfaceBrush"/> instance</returns>
|
||||
private static async Task<CompositionSurfaceBrush> LoadSurfaceBrushAsync(
|
||||
/// <returns>A <see cref="Task{T}"/> that returns the loaded <see cref="CompositionBrush"/> instance</returns>
|
||||
private static async Task<CompositionBrush> LoadSurfaceBrushAsync(
|
||||
CanvasDevice canvasDevice,
|
||||
Compositor compositor,
|
||||
Uri uri,
|
||||
|
|
|
@ -271,7 +271,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
[Pure]
|
||||
public static PipelineBuilder FromImage(Uri uri, DpiMode dpiMode = DpiMode.DisplayDpiWith96AsLowerBound, CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
return new PipelineBuilder(async () => await SurfaceLoader.LoadImageAsync(uri, dpiMode, cacheMode));
|
||||
return new PipelineBuilder(() => new ValueTask<CompositionBrush>(SurfaceLoader.LoadImageAsync(uri, dpiMode, cacheMode)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -34,15 +34,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
PipelineBuilder right,
|
||||
Placement placement)
|
||||
{
|
||||
switch (placement)
|
||||
return placement switch
|
||||
{
|
||||
case Placement.Foreground:
|
||||
return (left, right);
|
||||
case Placement.Background:
|
||||
return (right, left);
|
||||
default:
|
||||
throw new ArgumentException($"Invalid placement value: {placement}");
|
||||
}
|
||||
Placement.Foreground => (left, right),
|
||||
Placement.Background => (right, left),
|
||||
_ => throw new ArgumentException($"Invalid placement value: {placement}")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -17,15 +17,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
/// <summary>
|
||||
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the host backdrop acrylic effect
|
||||
/// </summary>
|
||||
/// <param name="tint">The tint color to use</param>
|
||||
/// <param name="mix">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="tintColor">The tint color to use</param>
|
||||
/// <param name="tintOpacity">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="noiseUri">The <see cref="Uri"/> for the noise texture to load for the acrylic effect</param>
|
||||
/// <param name="cacheMode">The cache mode to use to load the image</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance to use to keep adding new effects</returns>
|
||||
[Pure]
|
||||
public static PipelineBuilder FromHostBackdropAcrylic(
|
||||
Color tint,
|
||||
float mix,
|
||||
Color tintColor,
|
||||
float tintOpacity,
|
||||
Uri noiseUri,
|
||||
CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
.LuminanceToAlpha()
|
||||
.Opacity(0.4f)
|
||||
.Blend(FromHostBackdrop(), BlendEffectMode.Multiply)
|
||||
.Shade(tint, mix);
|
||||
.Shade(tintColor, tintOpacity);
|
||||
|
||||
if (noiseUri != null)
|
||||
{
|
||||
|
@ -47,19 +47,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
/// <summary>
|
||||
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the host backdrop acrylic effect
|
||||
/// </summary>
|
||||
/// <param name="tint">The tint color to use</param>
|
||||
/// <param name="tintSetter">The optional tint color setter for the effect</param>
|
||||
/// <param name="mix">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="mixSetter">The optional tint mix setter for the effect</param>
|
||||
/// <param name="tintColor">The tint color to use</param>
|
||||
/// <param name="tintColorSetter">The optional tint color setter for the effect</param>
|
||||
/// <param name="tintOpacity">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="tintOpacitySetter">The optional tint mix setter for the effect</param>
|
||||
/// <param name="noiseUri">The <see cref="Uri"/> for the noise texture to load for the acrylic effect</param>
|
||||
/// <param name="cacheMode">The cache mode to use to load the image</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance to use to keep adding new effects</returns>
|
||||
[Pure]
|
||||
public static PipelineBuilder FromHostBackdropAcrylic(
|
||||
Color tint,
|
||||
out EffectSetter<Color> tintSetter,
|
||||
float mix,
|
||||
out EffectSetter<float> mixSetter,
|
||||
Color tintColor,
|
||||
out EffectSetter<Color> tintColorSetter,
|
||||
float tintOpacity,
|
||||
out EffectSetter<float> tintOpacitySetter,
|
||||
Uri noiseUri,
|
||||
CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
.LuminanceToAlpha()
|
||||
.Opacity(0.4f)
|
||||
.Blend(FromHostBackdrop(), BlendEffectMode.Multiply)
|
||||
.Shade(tint, out tintSetter, mix, out mixSetter);
|
||||
.Shade(tintColor, out tintColorSetter, tintOpacity, out tintOpacitySetter);
|
||||
|
||||
if (noiseUri != null)
|
||||
{
|
||||
|
@ -81,19 +81,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
/// <summary>
|
||||
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the host backdrop acrylic effect
|
||||
/// </summary>
|
||||
/// <param name="tint">The tint color to use</param>
|
||||
/// <param name="tintAnimation">The optional tint color animation for the effect</param>
|
||||
/// <param name="mix">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="mixAnimation">The optional tint mix animation for the effect</param>
|
||||
/// <param name="tintColor">The tint color to use</param>
|
||||
/// <param name="tintColorAnimation">The optional tint color animation for the effect</param>
|
||||
/// <param name="tintOpacity">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="tintOpacityAnimation">The optional tint mix animation for the effect</param>
|
||||
/// <param name="noiseUri">The <see cref="Uri"/> for the noise texture to load for the acrylic effect</param>
|
||||
/// <param name="cacheMode">The cache mode to use to load the image</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance to use to keep adding new effects</returns>
|
||||
[Pure]
|
||||
public static PipelineBuilder FromHostBackdropAcrylic(
|
||||
Color tint,
|
||||
out EffectAnimation<Color> tintAnimation,
|
||||
float mix,
|
||||
out EffectAnimation<float> mixAnimation,
|
||||
Color tintColor,
|
||||
out EffectAnimation<Color> tintColorAnimation,
|
||||
float tintOpacity,
|
||||
out EffectAnimation<float> tintOpacityAnimation,
|
||||
Uri noiseUri,
|
||||
CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
.LuminanceToAlpha()
|
||||
.Opacity(0.4f)
|
||||
.Blend(FromHostBackdrop(), BlendEffectMode.Multiply)
|
||||
.Shade(tint, out tintAnimation, mix, out mixAnimation);
|
||||
.Shade(tintColor, out tintColorAnimation, tintOpacity, out tintOpacityAnimation);
|
||||
|
||||
if (noiseUri != null)
|
||||
{
|
||||
|
@ -115,24 +115,24 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
/// <summary>
|
||||
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
|
||||
/// </summary>
|
||||
/// <param name="tint">The tint color to use</param>
|
||||
/// <param name="mix">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="blur">The amount of blur to apply to the acrylic brush</param>
|
||||
/// <param name="tintColor">The tint color to use</param>
|
||||
/// <param name="tintOpacity">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="blurAmount">The amount of blur to apply to the acrylic brush</param>
|
||||
/// <param name="noiseUri">The <see cref="Uri"/> for the noise texture to load for the acrylic effect</param>
|
||||
/// <param name="cacheMode">The cache mode to use to load the image</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance to use to keep adding new effects</returns>
|
||||
[Pure]
|
||||
public static PipelineBuilder FromBackdropAcrylic(
|
||||
Color tint,
|
||||
float mix,
|
||||
float blur,
|
||||
Color tintColor,
|
||||
float tintOpacity,
|
||||
float blurAmount,
|
||||
Uri noiseUri,
|
||||
CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
var pipeline =
|
||||
FromBackdrop()
|
||||
.Shade(tint, mix)
|
||||
.Blur(blur);
|
||||
.Shade(tintColor, tintOpacity)
|
||||
.Blur(blurAmount);
|
||||
|
||||
if (noiseUri != null)
|
||||
{
|
||||
|
@ -145,30 +145,30 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
/// <summary>
|
||||
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
|
||||
/// </summary>
|
||||
/// <param name="tint">The tint color to use</param>
|
||||
/// <param name="tintSetter">The optional tint color setter for the effect</param>
|
||||
/// <param name="mix">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="mixSetter">The optional tint mix setter for the effect</param>
|
||||
/// <param name="blur">The amount of blur to apply to the acrylic brush</param>
|
||||
/// <param name="blurSetter">The optional blur setter for the effect</param>
|
||||
/// <param name="tintColor">The tint color to use</param>
|
||||
/// <param name="tintColorSetter">The optional tint color setter for the effect</param>
|
||||
/// <param name="tintOpacity">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="tintOpacitySetter">The optional tint mix setter for the effect</param>
|
||||
/// <param name="blurAmount">The amount of blur to apply to the acrylic brush</param>
|
||||
/// <param name="blurAmountSetter">The optional blur setter for the effect</param>
|
||||
/// <param name="noiseUri">The <see cref="Uri"/> for the noise texture to load for the acrylic effect</param>
|
||||
/// <param name="cacheMode">The cache mode to use to load the image</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance to use to keep adding new effects</returns>
|
||||
[Pure]
|
||||
public static PipelineBuilder FromBackdropAcrylic(
|
||||
Color tint,
|
||||
out EffectSetter<Color> tintSetter,
|
||||
float mix,
|
||||
out EffectSetter<float> mixSetter,
|
||||
float blur,
|
||||
out EffectSetter<float> blurSetter,
|
||||
Color tintColor,
|
||||
out EffectSetter<Color> tintColorSetter,
|
||||
float tintOpacity,
|
||||
out EffectSetter<float> tintOpacitySetter,
|
||||
float blurAmount,
|
||||
out EffectSetter<float> blurAmountSetter,
|
||||
Uri noiseUri,
|
||||
CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
var pipeline =
|
||||
FromBackdrop()
|
||||
.Shade(tint, out tintSetter, mix, out mixSetter)
|
||||
.Blur(blur, out blurSetter);
|
||||
.Shade(tintColor, out tintColorSetter, tintOpacity, out tintOpacitySetter)
|
||||
.Blur(blurAmount, out blurAmountSetter);
|
||||
|
||||
if (noiseUri != null)
|
||||
{
|
||||
|
@ -181,30 +181,30 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Pipelines
|
|||
/// <summary>
|
||||
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
|
||||
/// </summary>
|
||||
/// <param name="tint">The tint color to use</param>
|
||||
/// <param name="tintColor">The tint color to use</param>
|
||||
/// <param name="tintAnimation">The optional tint color animation for the effect</param>
|
||||
/// <param name="mix">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="mixAnimation">The optional tint mix animation for the effect</param>
|
||||
/// <param name="blur">The amount of blur to apply to the acrylic brush</param>
|
||||
/// <param name="blurAnimation">The optional blur animation for the effect</param>
|
||||
/// <param name="tintOpacity">The amount of tint to apply over the current effect</param>
|
||||
/// <param name="tintOpacityAnimation">The optional tint mix animation for the effect</param>
|
||||
/// <param name="blurAmount">The amount of blur to apply to the acrylic brush</param>
|
||||
/// <param name="blurAmountAnimation">The optional blur animation for the effect</param>
|
||||
/// <param name="noiseUri">The <see cref="Uri"/> for the noise texture to load for the acrylic effect</param>
|
||||
/// <param name="cacheMode">The cache mode to use to load the image</param>
|
||||
/// <returns>A new <see cref="PipelineBuilder"/> instance to use to keep adding new effects</returns>
|
||||
[Pure]
|
||||
public static PipelineBuilder FromBackdropAcrylic(
|
||||
Color tint,
|
||||
Color tintColor,
|
||||
out EffectAnimation<Color> tintAnimation,
|
||||
float mix,
|
||||
out EffectAnimation<float> mixAnimation,
|
||||
float blur,
|
||||
out EffectAnimation<float> blurAnimation,
|
||||
float tintOpacity,
|
||||
out EffectAnimation<float> tintOpacityAnimation,
|
||||
float blurAmount,
|
||||
out EffectAnimation<float> blurAmountAnimation,
|
||||
Uri noiseUri,
|
||||
CacheMode cacheMode = CacheMode.Default)
|
||||
{
|
||||
var pipeline =
|
||||
FromBackdrop()
|
||||
.Shade(tint, out tintAnimation, mix, out mixAnimation)
|
||||
.Blur(blur, out blurAnimation);
|
||||
.Shade(tintColor, out tintAnimation, tintOpacity, out tintOpacityAnimation)
|
||||
.Blur(blurAmount, out blurAmountAnimation);
|
||||
|
||||
if (noiseUri != null)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче