Composition​Effect​Brush Composition​Effect​Brush Composition​Effect​Brush Composition​Effect​Brush Class

Definition

A brush contianing an effect created with the CompositionEffectFactory.CreateBrush method.

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:

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