Table of Contents

Class Geometry

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll

Defines a geometric shape.

[TypeConverter(typeof(GeometryTypeConverter))]
public abstract class Geometry : AvaloniaObject, INotifyPropertyChanged
Inheritance
Geometry
Implements
Derived
Inherited Members
Extension Methods

Fields

TransformProperty

Defines the Transform property.

public static readonly StyledProperty<Transform?> TransformProperty

Field Value

StyledProperty<Transform>

Properties

Bounds

Gets the geometry's bounding rectangle.

public Rect Bounds { get; }

Property Value

Rect

ContourLength

Gets the geometry's total length as if all its contours are placed in a straight line.

public double ContourLength { get; }

Property Value

double

Transform

Gets or sets a transform to apply to the geometry.

public Transform? Transform { get; set; }

Property Value

Transform

Methods

AffectsGeometry(params AvaloniaProperty[])

Marks a property as affecting the geometry's Avalonia.Media.Geometry.PlatformImpl.

protected static void AffectsGeometry(params AvaloniaProperty[] properties)

Parameters

properties AvaloniaProperty[]

The properties.

Remarks

After a call to this method in a control's static constructor, any change to the property will cause InvalidateGeometry() to be called on the element.

Clone()

Clones the geometry.

public abstract Geometry Clone()

Returns

Geometry

A cloned geometry.

Combine(Geometry, RectangleGeometry, GeometryCombineMode, Transform?)

Combines the two geometries using the specified GeometryCombineMode and applies the specified transform to the resulting geometry.

public static Geometry Combine(Geometry geometry1, RectangleGeometry geometry2, GeometryCombineMode combineMode, Transform? transform = null)

Parameters

geometry1 Geometry

The first geometry to combine.

geometry2 RectangleGeometry

The second geometry to combine.

combineMode GeometryCombineMode

One of the enumeration values that specifies how the geometries are combined.

transform Transform

A transformation to apply to the combined geometry, or null.

Returns

Geometry

FillContains(Point)

Indicates whether the geometry's fill contains the specified point.

public bool FillContains(Point point)

Parameters

point Point

The point.

Returns

bool

true if the geometry contains the point; otherwise, false.

GetRenderBounds(IPen)

Gets the geometry's bounding rectangle with the specified pen.

public Rect GetRenderBounds(IPen pen)

Parameters

pen IPen

The stroke thickness.

Returns

Rect

The bounding rectangle.

GetWidenedGeometry(IPen)

Gets a Geometry that is the shape defined by the stroke on the Geometry produced by the specified Pen.

public Geometry GetWidenedGeometry(IPen pen)

Parameters

pen IPen

The pen to use.

Returns

Geometry

The outlined geometry.

InvalidateGeometry()

Invalidates the platform implementation of the geometry.

protected void InvalidateGeometry()

Parse(string)

Creates a Geometry from a string.

public static Geometry Parse(string s)

Parameters

s string

The string.

Returns

Geometry

A StreamGeometry.

StrokeContains(IPen, Point)

Indicates whether the geometry's stroke contains the specified point.

public bool StrokeContains(IPen pen, Point point)

Parameters

pen IPen

The pen to use.

point Point

The point.

Returns

bool

true if the geometry contains the point; otherwise, false.

TryGetPointAndTangentAtDistance(double, out Point, out Point)

Attempts to get the corresponding point and tangent from the specified distance along the contour of the geometry.

public bool TryGetPointAndTangentAtDistance(double distance, out Point point, out Point tangent)

Parameters

distance double

The contour distance to get from.

point Point

The point in the specified distance.

tangent Point

The tangent in the specified distance.

Returns

bool

If there's valid point and tangent at the specified distance.

TryGetPointAtDistance(double, out Point)

Attempts to get the corresponding point at the specified distance

public bool TryGetPointAtDistance(double distance, out Point point)

Parameters

distance double

The contour distance to get from.

point Point

The point in the specified distance.

Returns

bool

If there's valid point at the specified distance.

TryGetSegment(double, double, bool, out Geometry?)

Attempts to get the corresponding path segment given by the two distances specified. Imagine it like snipping a part of the current geometry.

public bool TryGetSegment(double startDistance, double stopDistance, bool startOnBeginFigure, out Geometry? segmentGeometry)

Parameters

startDistance double

The contour distance to start snipping from.

stopDistance double

The contour distance to stop snipping to.

startOnBeginFigure bool

If ture, the resulting snipped path will start with a BeginFigure call.

segmentGeometry Geometry

The resulting snipped path.

Returns

bool

If the snipping operation is successful.

Events

Changed

Raised when the geometry changes.

public event EventHandler? Changed

Event Type

EventHandler