HypernovaDesktop Components · docs
Binarymission
WPF › Shaders Library › WaterRippleEffect

WaterRippleEffect

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

Ripples the picture in rings spreading out from a point, as if a stone had dropped into still water there.

public class WaterRippleEffect : ShaderEffect

Inherits from / implements: ShaderEffect

Remarks

The rings are evenly spaced, weaken with distance and fade out about the width of the element away. They stand still; move CenterXY – to where the user clicked, say – to move them. The point can be set through CenterXY or CentreXY, which are the same setting.

Settings

PropertyRange and default

CenterXY

Where the rings start, in relative coordinates: (0,0) is the top-left corner of the element and (1,1) its bottom-right. Default (0,0.5), the middle of the left edge.

Examples

Ripples from wherever the user clicks.

<Image Source="Photos/lake.jpg"
       xmlns:fx="clr-namespace:Binarymission.WPF.Shaders.Library.CustomEffects;assembly=Binarymission.WPF.Shaders.Library"
       MouseLeftButtonDown="OnPhotoClicked">
    <Image.Effect>
        <fx:WaterRippleEffect x:Name="Ripple" />
    </Image.Effect>
</Image>
private void OnPhotoClicked(object sender, MouseButtonEventArgs e)
{
    var photo = (Image)sender;
    Point position = e.GetPosition(photo);
    Ripple.CenterXY = new Point(position.X / photo.ActualWidth, position.Y / photo.ActualHeight);
}

See also

Members at a glance

Constructors
WaterRippleEffectCreates the effect with its default settings: CenterXY (0,0.5).
Properties
CenterXYGets or sets where the ripples start.
CentreXYGets or sets where the ripples start; the same setting as CenterXY.
InputGets or sets the picture the effect works on.
Fields
CenterXYPropertyIdentifies the CenterXY dependency property.
InputPropertyIdentifies the Input dependency property.

Constructors

WaterRippleEffect

public WaterRippleEffect()

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

Properties

CenterXY

public Point CenterXY

Gets or sets where the ripples start.

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,0.5), the middle of the left edge.
Remarks

This is the registered name of the dependency property, so it is the one to use in a binding path or a storyboard target. CentreXY sets the same value.

CentreXY

public Point CentreXY

Gets or sets where the ripples start; the same setting as CenterXY.

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,0.5), the middle of the left edge.
Remarks

The dependency property is registered as CenterXY. Setting this from code or from a XAML attribute works; a binding path or a storyboard target has to use the registered name, CenterXY.

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.

InputProperty static

public static readonly DependencyProperty InputProperty

Identifies the Input dependency property.