CompositionEffectBrush CompositionEffectBrush CompositionEffectBrush CompositionEffectBrush Class

Definition

Paints a SpriteVisual with the output of a filter effect. The filter effect description is defined using the CompositionEffectFactory class.

public : sealed class CompositionEffectBrush : CompositionBrush, ICompositionEffectBrushpublic sealed class CompositionEffectBrush : CompositionBrush, ICompositionEffectBrushPublic NotInheritable Class CompositionEffectBrush Inherits CompositionBrush Implements ICompositionEffectBrush// This API is not available in Javascript.
Inheritance
CompositionEffectBrushCompositionEffectBrushCompositionEffectBrushCompositionEffectBrush
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Inherited Members

Inherited methods

Inherited properties

Examples


// Create an effect description 
GaussianBlurEffect blurEffect = new GaussianBlurEffect() 
{ 
    Name = "Blur", 
    BlurAmount = 1.0f, 
    BorderMode = EffectBorderMode.Hard, 
    Optimization = EffectOptimization.Balanced 
}; 

blurEffect.Source = new CompositionEffectSourceParameter("source"); 

CompositionEffectFactory blurEffectFactory = _compositor.CreateEffectFactory(blurEffect); 
CompositionEffectBrush blurBrush = blurEffectFactory.CreateBrush(); 
// Create a BackdropBrush and bind it to the EffectSourceParameter “source” 
CompositionBackdropBrush backdropBrush = _compositor.CreateBackdropBrush(); 
blurBrush.SetSourceParameter("source", backdropBrush); 

// The SpriteVisual to apply the blur BackdropBrush to 
// This will cause everything behind this SpriteVisual to be blurred 
SpriteVisual blurSprite = _compositor.CreateSpriteVisual(); 
blurSprite.Brush = blurBrush; 

// Set blurSprite as a child visual of a XAML element 
ElementCompositionPreview.SetElementChildVisual(blurArea, blurSprite); 

Remarks

The effect APIs enable developers to customize how their UI is rendered. This can be something as simple as adjusting saturation levels on an image or something more complex like chaining numerous effects together and animating the effect properties to create interesting application transitions and user experiences. A composition effect is a graph of operations that define how to produce graphical content based on composition surfaces. For example, the pixel content of images. Effects are applied to visuals in the tree and can reference existing surfaces.

An instance of CompositionEffectBrush is created using a CompositionEffectFactory based on a specified effect description. CompositionEffectFactory uses the Win2D effect description format in the Microsoft.Graphics.Canvas.Effects namespace.

Note

Effects that are not supported are marked as [NoComposition] in the Win2D API Reference for effects namespace.

A CompositionEffectBrush is applied to a SpriteVisual in the composition tree.

Sources to CompositionEffectBrush can be an existing surface or texture, or another effect enabling effect chaining.

CompositionEffectBrush.Properties (inherited from CompositionObject.Properties) allows setting or animating the animatable properties that were specified in the call to Compositor.CreateEffectFactory using their full 'EffectName.PropertyName' name.

Effect sources can be set independently from other CompositionEffectBrush instances, and properties can be animated independently from other CompositionEffectBrush instances.

Once an effect graph is declared, the system compiles the effect using built-in shaders. Custom shaders cannot be specified.

Creating a CompositionEffect

To create and apply an effect you need to perform the following steps:

  1. Create an effect description. See the Win2D namespace, Microsoft.Graphics.Canvas.Effects, for valid effect types.
  2. Set any effect sources with either an instance of CompositionEffectSourceParameter or another effect. Specifying another effect creates an effect chain.
  3. Create a CompositionEffectFactory with Compositor.CreateEffectFactory using the effect description as input.
  4. Create an instance of the effect using CompositorEffectFactory.CreateBrush.
  5. Set any CompositionEffectSourceParameter using CompositionEffectBrush.SetSourceParameter and the name of the source parameter as previously specified using a CompositionEffectSourceParameter.
  6. Create an instance of SpriteVisual using Compositor.CreateSpriteVisual.
  7. Set the Brush property of the SpriteVisual to the created effect.
  8. Add the SpriteVisual to the composition tree by using the Children property of a ContainerVisual.

Methods

GetSourceParameter(String) GetSourceParameter(String) GetSourceParameter(String) GetSourceParameter(String)

Retrieves a CompositionBrush associated with a given CompositionEffectSourceParameter name.

public : CompositionBrush GetSourceParameter(PlatForm::String name)public CompositionBrush GetSourceParameter(String name)Public Function GetSourceParameter(name As String) As CompositionBrush// This API is not available in Javascript.
Parameters
name
PlatForm::String String String String

The name of the input.

Returns

SetSourceParameter(String, CompositionBrush) SetSourceParameter(String, CompositionBrush) SetSourceParameter(String, CompositionBrush) SetSourceParameter(String, CompositionBrush)

Associates a name declared using CompositionEffectSourceParameter to an effect source.

public : void SetSourceParameter(PlatForm::String name, CompositionBrush source)public void SetSourceParameter(String name, CompositionBrush source)Public Function SetSourceParameter(name As String, source As CompositionBrush) As void// This API is not available in Javascript.
Parameters
name
PlatForm::String String String String

The name of the source parameter.

source
CompositionBrush CompositionBrush CompositionBrush CompositionBrush

The source to pass to the effect.

See Also