Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
afa5047
Merge pull request #10 from windows-toolkit/master
Sergio0694 Mar 15, 2020
e8cd4f7
Merge pull request #18 from windows-toolkit/master
Sergio0694 Mar 27, 2020
cbc80ef
Merge pull request #19 from windows-toolkit/master
Sergio0694 Apr 3, 2020
4079a75
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 Apr 9, 2020
f0b5bf0
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 Apr 23, 2020
6129c69
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 Apr 30, 2020
fdaa307
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 May 6, 2020
db41e0d
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 May 13, 2020
6bb8323
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 May 16, 2020
b5029a7
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 May 18, 2020
8de5d11
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 May 20, 2020
95d1575
Merge remote-tracking branch 'upstream/master' into master2
Sergio0694 May 27, 2020
6bf4a7f
Added missing ContentProperty to BlendEffect
Sergio0694 May 27, 2020
c2e803f
Removed unnecessary placement parameter for cross fade
Sergio0694 May 27, 2020
b0a10e3
Added CrossFadeEffect type
Sergio0694 May 27, 2020
bfe9847
Updated ShadeEffect default intensity value
Sergio0694 May 27, 2020
2c60f46
Inverted blend effect placement mode
Sergio0694 May 27, 2020
3fd58fb
Added CrossFadeEffect to shallow copy page
Sergio0694 May 27, 2020
387118e
Improved XML docs
Sergio0694 May 27, 2020
cbbe4ed
Added clamping for XAML effects for Win2D
Sergio0694 May 27, 2020
2ff52e3
Merge branch 'master' into refactoring/more-win2d-tweaks
michael-hawker May 28, 2020
d7ce515
Added auto clamping for AcrylicBrush tint opacity
Sergio0694 May 28, 2020
762e510
Clamped AcrylicBrush blur property for negative value
Sergio0694 May 28, 2020
21c25e1
Merge branch 'master' into refactoring/more-win2d-tweaks
Sergio0694 May 28, 2020
b5a04b5
Merge branch 'master' into refactoring/more-win2d-tweaks
Sergio0694 May 28, 2020
c8535bc
Merge branch 'master' into refactoring/more-win2d-tweaks
Sergio0694 May 28, 2020
1e3aba8
Merge branch 'master' into refactoring/more-win2d-tweaks
Sergio0694 May 29, 2020
a376298
Fixed default value for OpacityEffect
Sergio0694 May 29, 2020
86b80d1
Added ranges in XML docs for exposure effect
Sergio0694 May 29, 2020
8225e5e
Merge branch 'refactoring/more-win2d-tweaks' of https://github.com/Se…
Sergio0694 May 29, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<effects:ExposureEffect/>
<effects:GrayscaleEffect/>
<effects:HueRotationEffect/>
<effects:CrossFadeEffect/>
</media:PipelineBrush>
</Border.Background>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<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}"/>
<effects:BlendEffect Mode="Overlay" Source="{effects:TileSource Uri=ms-appx:///Assets/BrushAssets/NoiseTexture.png}"/>
<effects:BlendEffect Mode="Overlay" Source="{effects:ImageSource Uri=ms-appx:///SamplePages/DropShadowPanel/Unicorn.png}"/>
</brushes:PipelineBrush>
</Border.Background>
</Border>
Expand Down
10 changes: 5 additions & 5 deletions Microsoft.Toolkit.Uwp.UI.Media/Brushes/AcrylicBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ private static void OnSourcePropertyChanged(DependencyObject d, DependencyProper
}

/// <summary>
/// Gets or sets the blur amount for the effect
/// Gets or sets the blur amount for the effect (must be a positive value)
/// </summary>
/// <remarks>This property is ignored when the active mode is <see cref="AcrylicBackgroundSource.HostBackdrop"/></remarks>
public double BlurAmount
{
get => (double)GetValue(BlurAmountProperty);
set => SetValue(BlurAmountProperty, value);
set => SetValue(BlurAmountProperty, Math.Max(value, 0));
}

/// <summary>
Expand Down Expand Up @@ -132,12 +132,12 @@ private static void OnTintColorPropertyChanged(DependencyObject d, DependencyPro
}

/// <summary>
/// Gets or sets the tint opacity factor for the effect
/// Gets or sets the tint opacity factor for the effect (default is 0.5, must be in the [0, 1] range)
/// </summary>
public double TintOpacity
{
get => (double)GetValue(TintOpacityProperty);
set => SetValue(TintOpacityProperty, value);
set => SetValue(TintOpacityProperty, Math.Clamp(value, 0, 1));
}

/// <summary>
Expand All @@ -147,7 +147,7 @@ public double TintOpacity
nameof(TintOpacity),
typeof(double),
typeof(AcrylicBrush),
new PropertyMetadata(0.0, OnTintOpacityPropertyChanged));
new PropertyMetadata(0.5, OnTintOpacityPropertyChanged));

/// <summary>
/// Updates the UI when <see cref="TintOpacity"/> changes
Expand Down
2 changes: 2 additions & 0 deletions Microsoft.Toolkit.Uwp.UI.Media/Effects/BlendEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
using System.Collections.Generic;
using Microsoft.Graphics.Canvas.Effects;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
using Windows.UI.Xaml.Markup;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
{
/// <summary>
/// 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>
[ContentProperty(Name = nameof(Effects))]
public sealed class BlendEffect : IPipelineEffect
{
/// <summary>
Expand Down
11 changes: 9 additions & 2 deletions Microsoft.Toolkit.Uwp.UI.Media/Effects/BlurEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
Expand All @@ -12,10 +13,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.GaussianBlurEffect"/> effect</remarks>
public sealed class BlurEffect : IPipelineEffect
{
private double amount;

/// <summary>
/// Gets or sets the amount of gaussian blur to apply to the background.
/// Gets or sets the blur amount for the effect (must be a positive value)
/// </summary>
public double Amount { get; set; }
public double Amount
{
get => this.amount;
set => this.amount = Math.Max(value, 0);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
53 changes: 53 additions & 0 deletions Microsoft.Toolkit.Uwp.UI.Media/Effects/CrossFadeEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 System.Collections.Generic;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
using Windows.UI.Xaml.Markup;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
{
/// <summary>
/// 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.CrossFadeEffect"/> effect</remarks>
[ContentProperty(Name = nameof(Effects))]
public sealed class CrossFadeEffect : IPipelineEffect
{
/// <summary>
/// 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 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>();

private double factor = 0.5;

/// <summary>
/// Gets or sets the The cross fade factor to blend the input effects (default to 0.5, should be in the [0, 1] range)
/// </summary>
public double Factor
{
get => this.factor;
set => this.factor = Math.Clamp(value, 0, 1);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
{
PipelineBuilder inputBuilder = Source ?? PipelineBuilder.FromBackdrop();

foreach (IPipelineEffect effect in this.Effects)
{
inputBuilder = effect.AppendToPipeline(inputBuilder);
}

return builder.CrossFade(inputBuilder, (float)Factor);
}
}
}
9 changes: 8 additions & 1 deletion Microsoft.Toolkit.Uwp.UI.Media/Effects/ExposureEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
Expand All @@ -12,10 +13,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.ExposureEffect"/> effect</remarks>
public sealed class ExposureEffect : IPipelineEffect
{
private double amount;

/// <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; }
public double Amount
{
get => this.amount;
set => this.amount = Math.Clamp(value, -2, 2);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,33 @@ public sealed class AcrylicSourceExtension : MarkupExtension
/// </summary>
public AcrylicBackgroundSource BackgroundSource { get; set; } = AcrylicBackgroundSource.Backdrop;

private double blurAmount;

/// <summary>
/// Gets or sets the blur amount for the effect
/// Gets or sets the blur amount for the effect (must be a positive value)
/// </summary>
/// <remarks>This property is ignored when the active mode is <see cref="AcrylicBackgroundSource.HostBackdrop"/></remarks>
public double BlurAmount { get; set; }
public double BlurAmount
{
get => this.blurAmount;
set => this.blurAmount = Math.Max(value, 0);
}

/// <summary>
/// Gets or sets the tint for the effect
/// </summary>
public Color TintColor { get; set; }

private double tintOpacity = 0.5f;

/// <summary>
/// Gets or sets the color for the tint effect
/// Gets or sets the color for the tint effect (default is 0.5, must be in the [0, 1] range)
/// </summary>
public double TintOpacity { get; set; }
public double TintOpacity
{
get => this.tintOpacity;
set => this.tintOpacity = Math.Clamp(value, 0, 1);
}

/// <summary>
/// Gets or sets the <see cref="Uri"/> to the texture to use
Expand Down
9 changes: 8 additions & 1 deletion Microsoft.Toolkit.Uwp.UI.Media/Effects/OpacityEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
Expand All @@ -12,10 +13,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.OpacityEffect"/> effect</remarks>
public sealed class OpacityEffect : IPipelineEffect
{
private double value = 1;

/// <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;
public double Value
{
get => this.value;
set => this.value = Math.Clamp(value, 0, 1);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
9 changes: 8 additions & 1 deletion Microsoft.Toolkit.Uwp.UI.Media/Effects/SaturationEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
Expand All @@ -12,10 +13,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.SaturationEffect"/> effect</remarks>
public sealed class SaturationEffect : IPipelineEffect
{
private double value = 1;

/// <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;
public double Value
{
get => this.value;
set => this.value = Math.Clamp(value, 0, 1);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
9 changes: 8 additions & 1 deletion Microsoft.Toolkit.Uwp.UI.Media/Effects/SepiaEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
Expand All @@ -12,10 +13,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.SepiaEffect"/> effect</remarks>
public sealed class SepiaEffect : IPipelineEffect
{
private double intensity = 0.5;

/// <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;
public double Intensity
{
get => this.intensity;
set => this.intensity = Math.Clamp(value, 0, 1);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
11 changes: 9 additions & 2 deletions Microsoft.Toolkit.Uwp.UI.Media/Effects/ShadeEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
using Windows.UI;

Expand All @@ -17,10 +18,16 @@ public sealed class ShadeEffect : IPipelineEffect
/// </summary>
public Color Color { get; set; }

private double intensity = 0.5;

/// <summary>
/// Gets or sets the intensity of the color layer
/// Gets or sets the intensity of the color layer (default to 0.5, should be in the [0, 1] range)
/// </summary>
public double Intensity { get; set; }
public double Intensity
{
get => this.intensity;
set => this.intensity = Math.Clamp(value, 0, 1);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
21 changes: 17 additions & 4 deletions Microsoft.Toolkit.Uwp.UI.Media/Effects/TemperatureAndTintEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 System;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;

namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
Expand All @@ -12,15 +13,27 @@ namespace Microsoft.Toolkit.Uwp.UI.Media.Effects
/// <remarks>This effect maps to the Win2D <see cref="Graphics.Canvas.Effects.TemperatureAndTintEffect"/> effect</remarks>
public sealed class TemperatureAndTintEffect : IPipelineEffect
{
private double temperature;

/// <summary>
/// Gets or sets the value of the temperature for the current effect
/// Gets or sets the value of the temperature for the current effect (defaults to 0, should be in the [-1, 1] range)
/// </summary>
public double Temperature { get; set; }
public double Temperature
{
get => this.temperature;
set => this.temperature = Math.Clamp(value, -1, 1);
}

private double tint;

/// <summary>
/// Gets or sets the value of the tint for the current effect
/// Gets or sets the value of the tint for the current effect (defaults to 0, should be in the [-1, 1] range)
/// </summary>
public double Tint { get; set; }
public double Tint
{
get => this.tint;
set => this.tint = Math.Clamp(value, -1, 1);
}

/// <inheritdoc/>
public PipelineBuilder AppendToPipeline(PipelineBuilder builder)
Expand Down
Loading