HypernovaDesktop Components · docs
Binarymission
WPF › Shaders Library › ChromaticSplitEffect

ChromaticSplitEffect

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Shaders.Library.CustomEffects

Pulls the red and blue channels of the picture apart towards its edges, leaving green in place – the colour fringing a cheap lens leaves at the corners of a photograph.

public class ChromaticSplitEffect : ShaderEffect

Inherits from / implements: ShaderEffect

Remarks

The separation grows with the distance from CenterXY, so the middle of the picture stays sharp and the corners fringe. Animating Displacement over a small range reads as a focus pull; over a large one, as a glitch.

Settings

PropertyRange and default

Displacement

How far the channels part, growing towards the edges. Default 0.02; 0 leaves the picture unchanged, and 0.005 to 0.08 is the useful range.

CenterXY

Where the picture stays sharp, in relative coordinates: (0,0) is the top-left corner of the element and (1,1) its bottom-right. Default (0.5,0.5).

Examples

<Image Source="Photos/harbour.jpg"
       xmlns:fx="clr-namespace:Binarymission.WPF.Shaders.Library.CustomEffects;assembly=Binarymission.WPF.Shaders.Library">
    <Image.Effect>
        <fx:ChromaticSplitEffect Displacement="0.03" />
    </Image.Effect>
</Image>

See also

Members at a glance

Constructors
ChromaticSplitEffectCreates the effect with its default settings: Displacement 0.02, CenterXY (0.5,0.5).
Properties
CenterXYGets or sets the point the separation spreads out from, where the picture stays sharp.
DisplacementGets or sets how far the red and blue channels are pushed apart.
InputGets or sets the picture the effect works on.
Fields
CenterXYPropertyIdentifies the CenterXY dependency property.
DisplacementPropertyIdentifies the Displacement dependency property.
InputPropertyIdentifies the Input dependency property.

Constructors

ChromaticSplitEffect

public ChromaticSplitEffect()

Creates the effect with its default settings: Displacement 0.02, CenterXY (0.5,0.5).

Properties

CenterXY

public Point CenterXY

Gets or sets the point the separation spreads out from, where the picture stays sharp.

Value
A point in relative coordinates: (0,0) is the top-left corner of the element and (1,1) its bottom-right. The default is (0.5,0.5), the middle.

Displacement

public double Displacement

Gets or sets how far the red and blue channels are pushed apart.

Value
A fraction of each pixel's distance from CenterXY; the default is 0.02. 0 leaves the picture unchanged, 0.005 to 0.08 is the useful range, and a negative value swaps the directions red and blue move in.

Input

public Brush Input

Gets or sets the picture the effect works on.

Value
A brush. The default is the element the effect is applied to, as WPF renders it – the effect's implicit input.
Remarks

Leave it unset in the usual case, where the effect is set as an element's Effect. Set it to a ImageBrush or VisualBrush to have the effect work on that picture instead.

Fields

CenterXYProperty static

public static readonly DependencyProperty CenterXYProperty

Identifies the CenterXY dependency property.

DisplacementProperty static

public static readonly DependencyProperty DisplacementProperty

Identifies the Displacement dependency property.

InputProperty static

public static readonly DependencyProperty InputProperty

Identifies the Input dependency property.