Method Initialize
- Namespace
- PaintDotNet.Direct2D1
- Assembly
- PaintDotNet.Windows.Core.dll
Initialize<TEffect>(TEffect, Action<TEffect>)
This extension method enables creating an effect and setting its properties without the need for a local variable.
public static TEffect Initialize<TEffect>(this TEffect effect, Action<TEffect> initFunction) where TEffect : class, IDeviceEffect
Parameters
effect
TEffectinitFunction
Action<TEffect>
Returns
- TEffect
The effect that was passed in for the
effect
parameter.
Type Parameters
TEffect
Remarks
In this example, the GaussianBlurEffect is created and initialized without needing
to declare and name a local variable:
InvertEffect invertedBlur = new InvertEffect(
deviceContext,
new GaussianBlurEffect(deviceContext).Initialize(e =>
{
e.Properties.Input.Set(sourceImage);
e.Properties.StandardDeviation.SetValue(30.0f);
e.Properties.BorderMode.SetValue(BorderMode.Hard);
e.Properties.Optimization.SetValue(GaussianBlurOptimization.Balanced);
}));
This simplifies the creation of effect graphs, especially when there are effects that are only used once.