FrostedGlassEffect
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
| Property | Range and default |
|---|---|
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. | |
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 | |
|---|---|
FrostedGlassEffect | Creates the effect with its default settings: Frostiness 0.02, Seed 0. |
| Properties | |
Frostiness | Gets or sets how far each pixel may be scattered. |
Input | Gets or sets the picture the effect works on. |
Seed | Gets or sets which scatter pattern is used. |
| Fields | |
FrostinessProperty | Identifies the Frostiness dependency property. |
InputProperty | Identifies the Input dependency property. |
SeedProperty | Identifies the Seed dependency property. |
Constructors
FrostedGlassEffect
Creates the effect with its default settings: Frostiness 0.02, Seed 0.
Properties
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
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
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
Identifies the Frostiness dependency property.
InputProperty static
Identifies the Input dependency property.
SeedProperty static
Identifies the Seed dependency property.