Table of Contents

Class Pen

Namespace
Aspose.Imaging
Assembly
Aspose.Imaging.dll

Defines an object used to draw lines, curves and figures.

public class Pen : TransparencySupporter
Inheritance
Pen
Inherited Members

Constructors

Pen(Brush)

Initializes a new instance of the Pen class with the specified Brush.

public Pen(Brush brush)

Parameters

brush Brush

A Brush that determines the fill properties of this Pen.

Exceptions

ArgumentNullException

brush is null.

Pen(Brush, float)

Initializes a new instance of the Pen class with the specified Brush and Width.

public Pen(Brush brush, float width)

Parameters

brush Brush

A Brush that determines the characteristics of this Pen.

width float

The width of the new Pen.

Exceptions

ArgumentNullException

brush is null.

Pen(Color)

Initializes a new instance of the Pen class with the specified color.

public Pen(Color color)

Parameters

color Color

A Color structure that indicates the color of this Pen.

Pen(Color, float)

Initializes a new instance of the Pen class with the specified Color and Width properties.

public Pen(Color color, float width)

Parameters

color Color

A Color structure that indicates the color of this Pen.

width float

A value indicating the width of this Pen.

Properties

Alignment

Gets or sets the alignment for this Pen.

public PenAlignment Alignment { get; set; }

Property Value

PenAlignment

A PenAlignment that represents the alignment for this Pen.

Exceptions

ArgumentException

The Alignment property is set on an immutable Pen, such as those returned by the Pen class.

Brush

Gets or sets the Brush that determines attributes of this Pen.

public Brush Brush { get; set; }

Property Value

Brush

A Brush that determines attributes of this Pen.

Exceptions

ArgumentException

The Brush property is set on an immutable Pen, such as those returned by the Pen class.

Color

Gets or sets the color of this Pen.

public Color Color { get; set; }

Property Value

Color

A Color structure that represents the color of this Pen.

Exceptions

ArgumentException

The Color property is set on an immutable Pen, such as those returned by the Pen class.

CompoundArray

Gets or sets an array of values that specifies a compound pen. A compound pen draws a compound line made up of parallel lines and spaces.

public float[] CompoundArray { get; set; }

Property Value

float[]

An array of real numbers that specifies the compound array. The elements in the array must be in increasing order, not less than 0, and not greater than 1.

Exceptions

ArgumentException

The CompoundArray property is set on an immutable Pen, such as those returned by the Pen class.

CustomEndCap

Gets or sets a custom cap to use at the end of lines drawn with this Pen.

public CustomLineCap CustomEndCap { get; set; }

Property Value

CustomLineCap

A CustomLineCap that represents the cap used at the end of lines drawn with this Pen.

Exceptions

ArgumentException

The CustomEndCap property is set on an immutable Pen, such as those returned by the Pen class.

CustomStartCap

Gets or sets a custom cap to use at the beginning of lines drawn with this Pen.

public CustomLineCap CustomStartCap { get; set; }

Property Value

CustomLineCap

A CustomLineCap that represents the cap used at the beginning of lines drawn with this Pen.

Exceptions

ArgumentException

The CustomStartCap property is set on an immutable Pen, such as those returned by the Pen class.

DashCap

Gets or sets the cap style used at the end of the dashes that make up dashed lines drawn with this Pen.

public DashCap DashCap { get; set; }

Property Value

DashCap

One of the DashCap values that represents the cap style used at the beginning and end of the dashes that make up dashed lines drawn with this Pen.

Exceptions

ArgumentException

The DashCap property is set on an immutable Pen, such as those returned by the Pen class.

DashOffset

Gets or sets the distance from the start of a line to the beginning of a dash pattern.

public float DashOffset { get; set; }

Property Value

float

The distance from the start of a line to the beginning of a dash pattern.

DashPattern

Gets or sets an array of custom dashes and spaces.

public float[] DashPattern { get; set; }

Property Value

float[]

An array of real numbers that specifies the lengths of alternating dashes and spaces in dashed lines.

Exceptions

ArgumentException

The DashPattern property is set on an immutable Pen, such as those returned by the Pen class.

DashStyle

Gets or sets the style used for dashed lines drawn with this Pen.

public DashStyle DashStyle { get; set; }

Property Value

DashStyle

A DashStyle that represents the style used for dashed lines drawn with this Pen.

Exceptions

ArgumentException

The DashStyle property is set on an immutable Pen, such as those returned by the Pen class.

EndCap

Gets or sets the cap style used at the end of lines drawn with this Pen.

public LineCap EndCap { get; set; }

Property Value

LineCap

One of the LineCap values that represents the cap style used at the end of lines drawn with this Pen.

Exceptions

ArgumentException

The EndCap property is set on an immutable Pen, such as those returned by the Pen class.

LineJoin

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

public LineJoin LineJoin { get; set; }

Property Value

LineJoin

A LineJoin that represents the join style for the ends of two consecutive lines drawn with this Pen.

Exceptions

ArgumentException

The LineJoin property is set on an immutable Pen, such as those returned by the Pen class.

MiterLimit

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

public float MiterLimit { get; set; }

Property Value

float

The limit of the thickness of the join on a mitered corner.

Exceptions

ArgumentException

The MiterLimit property is set on an immutable Pen, such as those returned by the Pen class.

PenType

Gets the style of lines drawn with this Pen.

public PenType PenType { get; }

Property Value

PenType

A PenType enumeration that specifies the style of lines drawn with this Pen.

StartCap

Gets or sets the cap style used at the beginning of lines drawn with this Pen.

public LineCap StartCap { get; set; }

Property Value

LineCap

One of the LineCap values that represents the cap style used at the beginning of lines drawn with this Pen.

Exceptions

ArgumentException

The StartCap property is set on an immutable Pen, such as those returned by the Pen class.

Transform

Gets or sets a copy of the geometric transformation for this Pen.

public Matrix Transform { get; set; }

Property Value

Matrix

A copy of the Matrix that represents the geometric transformation for this Pen.

Exceptions

ArgumentException

The Transform property is set on an immutable Pen, such as those returned by the Pen class.

Width

Gets or sets the width of this Pen, in units of the Graphics object used for drawing.

public float Width { get; set; }

Property Value

float

The width of this Pen.

Exceptions

ArgumentException

The Width property is set on an immutable Pen, such as those returned by the Pen class.

Methods

Equals(Pen)

Check if objects are equal.

protected bool Equals(Pen other)

Parameters

other Pen

The other object.

Returns

bool

The equality comparison result.

Equals(object)

Check if objects are equal.

public override bool Equals(object obj)

Parameters

obj object

The other object.

Returns

bool

The equality comparison result.

GetHashCode()

Get hash code of the current object.

public override int GetHashCode()

Returns

int

The hash code.

MultiplyTransform(Matrix)

Multiplies the transformation matrix for this Pen by the specified Matrix.

public void MultiplyTransform(Matrix matrix)

Parameters

matrix Matrix

The Matrix object by which to multiply the transformation matrix.

MultiplyTransform(Matrix, MatrixOrder)

Multiplies the transformation matrix for this Pen by the specified Matrix in the specified order.

public void MultiplyTransform(Matrix matrix, MatrixOrder order)

Parameters

matrix Matrix

The Matrix by which to multiply the transformation matrix.

order MatrixOrder

The order in which to perform the multiplication operation.

ResetTransform()

Resets the geometric transformation matrix for this Pen to identity.

public void ResetTransform()

RotateTransform(float)

Rotates the local geometric transformation by the specified angle. This method prepends the rotation to the transformation.

public void RotateTransform(float angle)

Parameters

angle float

The angle of rotation.

RotateTransform(float, MatrixOrder)

Rotates the local geometric transformation by the specified angle in the specified order.

public void RotateTransform(float angle, MatrixOrder order)

Parameters

angle float

The angle of rotation.

order MatrixOrder

A MatrixOrder that specifies whether to append or prepend the rotation matrix.

ScaleTransform(float, float)

Scales the local geometric transformation by the specified factors. This method prepends the scaling matrix to the transformation.

public void ScaleTransform(float sx, float sy)

Parameters

sx float

The factor by which to scale the transformation in the x-axis direction.

sy float

The factor by which to scale the transformation in the y-axis direction.

ScaleTransform(float, float, MatrixOrder)

Scales the local geometric transformation by the specified factors in the specified order.

public void ScaleTransform(float sx, float sy, MatrixOrder order)

Parameters

sx float

The factor by which to scale the transformation in the x-axis direction.

sy float

The factor by which to scale the transformation in the y-axis direction.

order MatrixOrder

A MatrixOrder that specifies whether to append or prepend the scaling matrix.

SetLineCap(LineCap, LineCap, DashCap)

Sets the values that determine the style of cap used to end lines drawn by this Pen.

public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)

Parameters

startCap LineCap

A LineCap that represents the cap style to use at the beginning of lines drawn with this Pen.

endCap LineCap

A LineCap that represents the cap style to use at the end of lines drawn with this Pen.

dashCap DashCap

A LineCap that represents the cap style to use at the beginning or end of dashed lines drawn with this Pen.

TranslateTransform(float, float)

Translates the local geometric transformation by the specified dimensions. This method prepends the translation to the transformation.

public void TranslateTransform(float dx, float dy)

Parameters

dx float

The value of the translation in x.

dy float

The value of the translation in y.

TranslateTransform(float, float, MatrixOrder)

Translates the local geometric transformation by the specified dimensions in the specified order.

public void TranslateTransform(float dx, float dy, MatrixOrder order)

Parameters

dx float

The value of the translation in x.

dy float

The value of the translation in y.

order MatrixOrder

The order (prepend or append) in which to apply the translation.