Skip to main content

Pen Class

Definition

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia
Source:Pen.cs

Describes how a stroke is drawn.

public class Pen

Inheritance: object -> AvaloniaObject -> Pen

Implements: IPen, ICompositionRenderResource, ICompositionRenderResource<IPen>, ICompositorSerializable

Constructors

NameDescription
Pen (3 overloads)Initializes a new instance of the Avalonia.Media.Pen class.

Pen overloads

Pen Constructor

Initializes a new instance of the Avalonia.Media.Pen class.

public Pen()

Pen Constructor

Initializes a new instance of the Avalonia.Media.Pen class.

public Pen(Avalonia.Media.IBrush brush, double thickness, Avalonia.Media.IDashStyle dashStyle, Avalonia.Media.PenLineCap lineCap, Avalonia.Media.PenLineJoin lineJoin, double miterLimit)
Parameters

brush Avalonia.Media.IBrush

The brush used to draw.

thickness double

The stroke thickness.

dashStyle Avalonia.Media.IDashStyle

The dash style.

lineCap Avalonia.Media.PenLineCap

The line cap.

lineJoin Avalonia.Media.PenLineJoin

The line join.

miterLimit double

The miter limit.

Pen Constructor

Initializes a new instance of the Avalonia.Media.Pen class.

public Pen(uint color, double thickness, Avalonia.Media.IDashStyle dashStyle, Avalonia.Media.PenLineCap lineCap, Avalonia.Media.PenLineJoin lineJoin, double miterLimit)
Parameters

color uint

The stroke color.

thickness double

The stroke thickness.

dashStyle Avalonia.Media.IDashStyle

The dash style.

lineCap Avalonia.Media.PenLineCap

Specifies the type of graphic shape to use on both ends of a line.

lineJoin Avalonia.Media.PenLineJoin

The line join.

miterLimit double

The miter limit.

Methods

NameDescription
ToImmutableCreates an immutable clone of the brush.
Bind (8 overloads)Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject.
CheckAccessReturns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject.
ClearValue (4 overloads)Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject.
CoerceValueCoerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject.
EqualsCompares two objects using reference equality. Inherited from AvaloniaObject.
GetBaseValueInherited from AvaloniaObject.
GetHashCodeGets the hash code for the object. Inherited from AvaloniaObject.
GetValue (3 overloads)Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
IsAnimatingChecks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject.
IsSetChecks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject.
SetCurrentValue (2 overloads)Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject.
SetValue (3 overloads)Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
VerifyAccessChecks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject.

ToImmutable Method

Creates an immutable clone of the brush.

public Avalonia.Media.Immutable.ImmutablePen ToImmutable()

Returns

Avalonia.Media.Immutable.ImmutablePen

The immutable clone.

Properties

NameDescription
BrushGets or sets the brush used to draw the stroke.
DashStyleGets or sets the style of dashed lines drawn with a Avalonia.Media.Pen object.
LineCapGets or sets the type of shape to use on both ends of a line.
LineJoinGets or sets the join style for the ends of two consecutive lines drawn with this Avalonia.Media.Pen.
MiterLimitGets or sets the limit of the thickness of the join on a mitered corner.
ThicknessGets or sets the stroke thickness.
DispatcherReturns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject.
ItemInherited from AvaloniaObject.

Brush Property

Gets or sets the brush used to draw the stroke.

public Avalonia.Media.IBrush Brush { get; set; }

DashStyle Property

Gets or sets the style of dashed lines drawn with a Avalonia.Media.Pen object.

public Avalonia.Media.IDashStyle DashStyle { get; set; }

LineCap Property

Gets or sets the type of shape to use on both ends of a line.

public Avalonia.Media.PenLineCap LineCap { get; set; }

LineJoin Property

Gets or sets the join style for the ends of two consecutive lines drawn with this Avalonia.Media.Pen.

public Avalonia.Media.PenLineJoin LineJoin { get; set; }

MiterLimit Property

Gets or sets the limit of the thickness of the join on a mitered corner.

public double MiterLimit { get; set; }

Thickness Property

Gets or sets the stroke thickness.

public double Thickness { get; set; }

Fields

BrushProperty Field

Defines the Avalonia.Media.Pen.Brush property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.IBrush> BrushProperty

DashStyleProperty Field

Defines the Avalonia.Media.Pen.DashStyle property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.IDashStyle> DashStyleProperty

LineCapProperty Field

Defines the Avalonia.Media.Pen.LineCap property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.PenLineCap> LineCapProperty

LineJoinProperty Field

Defines the Avalonia.Media.Pen.LineJoin property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.PenLineJoin> LineJoinProperty

MiterLimitProperty Field

Defines the Avalonia.Media.Pen.MiterLimit property.

public Avalonia.StyledProperty<TValue><double> MiterLimitProperty

ThicknessProperty Field

Defines the Avalonia.Media.Pen.Thickness property.

public Avalonia.StyledProperty<TValue><double> ThicknessProperty

Events

NameDescription
PropertyChangedRaised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject.