Table of Contents

Class Pen

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll

Describes how a stroke is drawn.

public sealed class Pen : AvaloniaObject, INotifyPropertyChanged, IPen
Inheritance
Pen
Implements
Inherited Members
Extension Methods

Constructors

Pen()

Initializes a new instance of the Pen class.

public Pen()

Pen(IBrush?, double, IDashStyle?, PenLineCap, PenLineJoin, double)

Initializes a new instance of the Pen class.

public Pen(IBrush? brush, double thickness = 1, IDashStyle? dashStyle = null, PenLineCap lineCap = PenLineCap.Flat, PenLineJoin lineJoin = PenLineJoin.Miter, double miterLimit = 10)

Parameters

brush IBrush

The brush used to draw.

thickness double

The stroke thickness.

dashStyle IDashStyle

The dash style.

lineCap PenLineCap

The line cap.

lineJoin PenLineJoin

The line join.

miterLimit double

The miter limit.

Pen(uint, double, IDashStyle?, PenLineCap, PenLineJoin, double)

Initializes a new instance of the Pen class.

public Pen(uint color, double thickness = 1, IDashStyle? dashStyle = null, PenLineCap lineCap = PenLineCap.Flat, PenLineJoin lineJoin = PenLineJoin.Miter, double miterLimit = 10)

Parameters

color uint

The stroke color.

thickness double

The stroke thickness.

dashStyle IDashStyle

The dash style.

lineCap PenLineCap

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

lineJoin PenLineJoin

The line join.

miterLimit double

The miter limit.

Fields

BrushProperty

Defines the Brush property.

public static readonly StyledProperty<IBrush?> BrushProperty

Field Value

StyledProperty<IBrush>

DashStyleProperty

Defines the DashStyle property.

public static readonly StyledProperty<IDashStyle?> DashStyleProperty

Field Value

StyledProperty<IDashStyle>

LineCapProperty

Defines the LineCap property.

public static readonly StyledProperty<PenLineCap> LineCapProperty

Field Value

StyledProperty<PenLineCap>

LineJoinProperty

Defines the LineJoin property.

public static readonly StyledProperty<PenLineJoin> LineJoinProperty

Field Value

StyledProperty<PenLineJoin>

MiterLimitProperty

Defines the MiterLimit property.

public static readonly StyledProperty<double> MiterLimitProperty

Field Value

StyledProperty<double>

ThicknessProperty

Defines the Thickness property.

public static readonly StyledProperty<double> ThicknessProperty

Field Value

StyledProperty<double>

Properties

Brush

Gets or sets the brush used to draw the stroke.

public IBrush? Brush { get; set; }

Property Value

IBrush

DashStyle

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

public IDashStyle? DashStyle { get; set; }

Property Value

IDashStyle

LineCap

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

public PenLineCap LineCap { get; set; }

Property Value

PenLineCap

LineJoin

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

public PenLineJoin LineJoin { get; set; }

Property Value

PenLineJoin

MiterLimit

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

public double MiterLimit { get; set; }

Property Value

double

Thickness

Gets or sets the stroke thickness.

public double Thickness { get; set; }

Property Value

double

Methods

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

ToImmutable()

Creates an immutable clone of the brush.

public ImmutablePen ToImmutable()

Returns

ImmutablePen

The immutable clone.