Table of Contents

Class Pen

Namespace
SixLabors.ImageSharp.Drawing.Processing
Assembly
SixLabors.ImageSharp.Drawing.dll

The base class for pens that can apply a pattern to a line with a set brush and thickness

public abstract class Pen : IEquatable<Pen>
Inheritance
Pen
Implements
Derived
Inherited Members

Remarks

The pattern will be in to the form of

new float[]{ 1f, 2f, 0.5f}

this will be converted into a pattern that is 3.5 times longer that the width with 3 sections.

  • Section 1 will be width long (making a square) and will be filled by the brush.
  • Section 2 will be width * 2 long and will be empty.
  • Section 3 will be width/2 long and will be filled.

The pattern will immediately repeat without gap.

Constructors

Pen(Brush)

Initializes a new instance of the Pen class.

protected Pen(Brush strokeFill)

Parameters

strokeFill Brush

The brush used to fill the stroke outline.

Pen(Brush, float)

Initializes a new instance of the Pen class.

protected Pen(Brush strokeFill, float strokeWidth)

Parameters

strokeFill Brush

The brush used to fill the stroke outline.

strokeWidth float

The stroke width in the path's local coordinate space before any drawing transform is applied.

Pen(Brush, float, float[])

Initializes a new instance of the Pen class.

protected Pen(Brush strokeFill, float strokeWidth, float[] strokePattern)

Parameters

strokeFill Brush

The brush used to fill the stroke outline.

strokeWidth float

The stroke width in the path's local coordinate space before any drawing transform is applied.

strokePattern float[]

The stroke pattern.

Pen(PenOptions)

Initializes a new instance of the Pen class.

protected Pen(PenOptions options)

Parameters

options PenOptions

The pen options.

Properties

StrokeFill

Gets the brush used to fill the stroke outline. Defaults to SolidBrush.

public Brush StrokeFill { get; }

Property Value

Brush

StrokeOptions

Gets or sets the stroke geometry options used to stroke paths drawn with this pen.

public StrokeOptions StrokeOptions { get; }

Property Value

StrokeOptions

StrokePattern

Gets the stroke pattern.

public ReadOnlyMemory<float> StrokePattern { get; }

Property Value

ReadOnlyMemory<float>

StrokeWidth

Gets the stroke width in the path's local coordinate space before any drawing transform is applied. Defaults to 1.

public float StrokeWidth { get; }

Property Value

float

Methods

Equals(Pen?)

Indicates whether the current object is equal to another object of the same type.

public virtual bool Equals(Pen? other)

Parameters

other Pen

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GeneratePath(IPath)

Applies the styling from the pen to a path and generate a new path with the final vector.

public IPath GeneratePath(IPath path)

Parameters

path IPath

The source path

Returns

IPath

The IPath with the pen styling applied.

GeneratePath(IPath, float)

Applies the styling from the pen to a path and generate a new path with the final vector.

public abstract IPath GeneratePath(IPath path, float strokeWidth)

Parameters

path IPath

The source path

strokeWidth float

The stroke width in the path's local coordinate space before any drawing transform is applied.

Returns

IPath

The IPath with the pen styling applied.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.