Skip to content

Commit

Permalink
New PipelineBuilder APIs with a source path
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Mar 29, 2019
1 parent ec51c9b commit 53cd6f5
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions UICompositionAnimations/Behaviours/PipelineBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ private PipelineBuilder([NotNull] Func<Task<IGraphicsEffectSource>> factory,
[Pure, NotNull]
public static PipelineBuilder FromEffect(Func<Task<IGraphicsEffectSource>> factory) => new PipelineBuilder(factory);

/// <summary>
/// Starts a new <see cref="PipelineBuilder"/> pipeline from a Win2D image
/// </summary>
/// <param name="relativePath">The relative path for the image to load (eg. "/Assets/image.png")</param>
/// <param name="dpiMode">Indicates the desired DPI mode to use when loading the image</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromImage([NotNull] string relativePath, DpiMode dpiMode = DpiMode.DisplayDpiWith96AsLowerBound, CacheMode cache = CacheMode.Default)
{
return FromImage(relativePath.ToAppxUri(), dpiMode, cache);
}

/// <summary>
/// Starts a new <see cref="PipelineBuilder"/> pipeline from a Win2D image
/// </summary>
Expand All @@ -186,6 +198,18 @@ public static PipelineBuilder FromImage([NotNull] Uri uri, DpiMode dpiMode = Dpi
return new PipelineBuilder(() => Win2DImageHelper.LoadImageAsync(Window.Current.Compositor, uri, dpiMode, cache).ContinueWith(t => t.Result as CompositionBrush));
}

/// <summary>
/// Starts a new <see cref="PipelineBuilder"/> pipeline from a Win2D image tiled to cover the available space
/// </summary>
/// <param name="relativePath">The relative path for the image to load (eg. "/Assets/image.png")</param>
/// <param name="dpiMode">Indicates the desired DPI mode to use when loading the image</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromTiles([NotNull] string relativePath, DpiMode dpiMode = DpiMode.DisplayDpiWith96AsLowerBound, CacheMode cache = CacheMode.Default)
{
return FromTiles(relativePath.ToAppxUri(), dpiMode, cache);
}

/// <summary>
/// Starts a new <see cref="PipelineBuilder"/> pipeline from a Win2D image tiled to cover the available space
/// </summary>
Expand Down Expand Up @@ -221,6 +245,19 @@ public static PipelineBuilder FromUIElement([NotNull] UIElement element)

#region Prebuilt 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="noiseRelativePath">The relative path for the noise texture to load (eg. "/Assets/noise.png")</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromHostBackdropAcrylic(Color tint, float mix, [NotNull] string noiseRelativePath, CacheMode cache = CacheMode.Default)
{
return FromHostBackdropAcrylic(tint, mix, noiseRelativePath.ToAppxUri(), cache);
}

/// <summary>
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the host backdrop acrylic effect
/// </summary>
Expand All @@ -239,6 +276,20 @@ public static PipelineBuilder FromHostBackdropAcrylic(Color tint, float mix, [No
.Blend(FromTiles(noiseUri, cache: cache), BlendEffectMode.Overlay, Placement.Background);
}

/// <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 animation to apply on the tint color of the effect</param>
/// <param name="mix">The amount of tint to apply over the current effect</param>
/// <param name="noiseRelativePath">The relative path for the noise texture to load (eg. "/Assets/noise.png")</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromHostBackdropAcrylic(Color tint, float mix, out EffectAnimation tintAnimation, [NotNull] string noiseRelativePath, CacheMode cache = CacheMode.Default)
{
return FromHostBackdropAcrylic(tint, mix, out tintAnimation, noiseRelativePath.ToAppxUri(), cache);
}

/// <summary>
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the host backdrop acrylic effect
/// </summary>
Expand All @@ -258,6 +309,20 @@ public static PipelineBuilder FromHostBackdropAcrylic(Color tint, float mix, out
.Blend(FromTiles(noiseUri, cache: cache), BlendEffectMode.Overlay, Placement.Background);
}

/// <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="noiseRelativePath">The relative path for the noise texture to load (eg. "/Assets/noise.png")</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromBackdropAcrylic(Color tint, float mix, float blur, [NotNull] string noiseRelativePath, CacheMode cache = CacheMode.Default)
{
return FromBackdropAcrylic(tint, mix, blur, noiseRelativePath.ToAppxUri(), cache);
}

/// <summary>
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
/// </summary>
Expand All @@ -275,6 +340,24 @@ public static PipelineBuilder FromBackdropAcrylic(Color tint, float mix, float b
.Blend(FromTiles(noiseUri, cache: cache), BlendEffectMode.Overlay, Placement.Background);
}

/// <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="tintAnimation">The animation to apply on the tint color of the effect</param>
/// <param name="blur">The amount of blur to apply to the acrylic brush</param>
/// <param name="noiseRelativePath">The relative path for the noise texture to load (eg. "/Assets/noise.png")</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromBackdropAcrylic(
Color tint, float mix, out EffectAnimation tintAnimation,
float blur,
[NotNull] string noiseRelativePath, CacheMode cache = CacheMode.Default)
{
return FromBackdropAcrylic(tint, mix, out tintAnimation, blur, noiseRelativePath.ToAppxUri(), cache);
}

/// <summary>
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
/// </summary>
Expand All @@ -296,6 +379,24 @@ public static PipelineBuilder FromBackdropAcrylic(
.Blend(FromTiles(noiseUri, cache: cache), BlendEffectMode.Overlay, Placement.Background);
}

/// <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="blurAnimation">The animation to apply on the blur effect in the pipeline</param>
/// <param name="noiseRelativePath">The relative path for the noise texture to load (eg. "/Assets/noise.png")</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromBackdropAcrylic(
Color tint, float mix,
float blur, out EffectAnimation blurAnimation,
[NotNull] string noiseRelativePath, CacheMode cache = CacheMode.Default)
{
return FromBackdropAcrylic(tint, mix, blur, out blurAnimation, noiseRelativePath.ToAppxUri(), cache);
}

/// <summary>
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
/// </summary>
Expand All @@ -317,6 +418,25 @@ public static PipelineBuilder FromBackdropAcrylic(
.Blend(FromTiles(noiseUri, cache: cache), BlendEffectMode.Overlay, Placement.Background);
}

/// <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="tintAnimation">The animation to apply on the tint color of the effect</param>
/// <param name="blur">The amount of blur to apply to the acrylic brush</param>
/// <param name="blurAnimation">The animation to apply on the blur effect in the pipeline</param>
/// <param name="noiseRelativePath">The relative path for the noise texture to load (eg. "/Assets/noise.png")</param>
/// <param name="cache">The cache mode to use to load the image</param>
[Pure, NotNull]
public static PipelineBuilder FromBackdropAcrylic(
Color tint, float mix, out EffectAnimation tintAnimation,
float blur, out EffectAnimation blurAnimation,
[NotNull] string noiseRelativePath, CacheMode cache = CacheMode.Default)
{
return FromBackdropAcrylic(tint, mix, out tintAnimation, blur, out blurAnimation, noiseRelativePath.ToAppxUri(), cache);
}

/// <summary>
/// Returns a new <see cref="PipelineBuilder"/> instance that implements the in-app backdrop acrylic effect
/// </summary>
Expand Down

0 comments on commit 53cd6f5

Please sign in to comment.