HypernovaDesktop Components · docs
Binarymission
WPF › Shaders Library › FrostedGlassEffect

FrostedGlassEffect

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

Scatters every pixel of the picture by a small random amount, so that it looks seen through frosted or etched glass.

public class FrostedGlassEffect : ShaderEffect

Inherits from / implements: ShaderEffect

Remarks

A good backdrop for a dialog or a sign-in panel laid over a photograph: the picture keeps its colours and loses its detail. The scatter is worked out from each pixel's position, so it is fixed for a given Seed; animate the seed, not just the frostiness, to make the glass shimmer.

Settings

PropertyRange and default

Frostiness

How far pixels scatter – up to half this, as a fraction of the element, in each direction. Default 0.02; 0 leaves the picture unchanged, 0.002 to 0.05 is the useful range.

Seed

Picks the scatter pattern; any value. Default 0.

Examples

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

See also

Members at a glance

Constructors
FrostedGlassEffectCreates the effect with its default settings: Frostiness 0.02, Seed 0.
Properties
FrostinessGets or sets how far each pixel may be scattered.
InputGets or sets the picture the effect works on.
SeedGets or sets which scatter pattern is used.
Fields
FrostinessPropertyIdentifies the Frostiness dependency property.
InputPropertyIdentifies the Input dependency property.
SeedPropertyIdentifies the Seed dependency property.

Constructors

FrostedGlassEffect

public FrostedGlassEffect()

Creates the effect with its default settings: Frostiness 0.02, Seed 0.

Properties

Frostiness

public double Frostiness

Gets or sets how far each pixel may be scattered.

Value
A fraction of the element's size: each pixel moves by up to half this in each direction. The default is 0.02; 0 leaves the picture unchanged, and 0.002 to 0.05 is the useful range – beyond it the picture stops being readable.

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.

Seed

public double Seed

Gets or sets which scatter pattern is used.

Value
Any value; the default is 0. A different seed gives a different arrangement of the same frostiness, so animating it makes the glass shimmer without changing how rough it looks.

Fields

FrostinessProperty static

public static readonly DependencyProperty FrostinessProperty

Identifies the Frostiness dependency property.

InputProperty static

public static readonly DependencyProperty InputProperty

Identifies the Input dependency property.

SeedProperty static

public static readonly DependencyProperty SeedProperty

Identifies the Seed dependency property.