Class Pen
Defines a pen used to draw lines, curves, and shapes.
Implements
Inherited Members
Namespace: DRIT.Drawing.Pens
Assembly: DRIT.Drawing.dll
Syntax
public sealed class Pen : IDisposable
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Constructors
Pen(Brush)
Initializes a new Pen of the specified brush and width of 1.
Declaration
public Pen(Brush brush)
Parameters
| Type | Name | Description |
|---|---|---|
| Brush | brush | The brush that determines the fill properties of the pen. |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Pen(Brush, float)
Initializes a new Pen of the specified brush and width.
Declaration
public Pen(Brush brush, float width)
Parameters
| Type | Name | Description |
|---|---|---|
| Brush | brush | The brush that determines the fill properties of the pen. |
| float | width | The width of the pen. |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Pen(Color)
Initializes a new Pen of the specified color and width of 1.
Declaration
public Pen(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The color of the pen. |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Pen(Color, float)
Initializes a new Pen of the specified color and width.
Declaration
public Pen(Color color, float width)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The color of the pen. |
| float | width | The width of the pen. |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Properties
Alignment
Gets or sets the alignment of the pen relative to the stroke outline.
Declaration
public PenAlignment Alignment { get; set; }
Property Value
| Type | Description |
|---|---|
| PenAlignment |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Brush
Gets or sets the brush that determines the fill properties of this pen.
Declaration
public Brush Brush { get; set; }
Property Value
| Type | Description |
|---|---|
| Brush |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Color
Gets or sets the color of this pen.
Declaration
public Color Color { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
CompoundArray
Gets or sets the compound array for compound pen strokes.
Declaration
public float[]? CompoundArray { get; set; }
Property Value
| Type | Description |
|---|---|
| float[] |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
CustomEndCap
Gets or sets the custom end cap for the line.
Declaration
public CustomLineCap? CustomEndCap { get; set; }
Property Value
| Type | Description |
|---|---|
| CustomLineCap |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
CustomStartCap
Gets or sets the custom start cap for the line.
Declaration
public CustomLineCap? CustomStartCap { get; set; }
Property Value
| Type | Description |
|---|---|
| CustomLineCap |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
DashCap
Gets or sets the dash cap style for the ends of dashes.
Declaration
public DashCap DashCap { get; set; }
Property Value
| Type | Description |
|---|---|
| DashCap |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
DashOffset
Gets or sets the offset of the dash pattern.
Declaration
public float DashOffset { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
DashPattern
Gets or sets the dash pattern for custom line styles.
Declaration
public float[] DashPattern { get; set; }
Property Value
| Type | Description |
|---|---|
| float[] |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
DashStyle
Gets or sets the dash style for the line.
Declaration
public DashStyle DashStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| DashStyle |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
EndCap
Gets or sets the cap style at the end of the line.
Declaration
public LineCap EndCap { get; set; }
Property Value
| Type | Description |
|---|---|
| LineCap |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
LineJoin
Gets or sets the join style for connected line segments.
Declaration
public LineJoin LineJoin { get; set; }
Property Value
| Type | Description |
|---|---|
| LineJoin |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
MiterLimit
Gets or sets the miter limit for sharp join angles.
Declaration
public float MiterLimit { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
PenType
Gets the type of this pen (SolidColor, HatchFill, or LinearGradient).
Declaration
public PenType PenType { get; }
Property Value
| Type | Description |
|---|---|
| PenType |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
StartCap
Gets or sets the cap style at the start of the line.
Declaration
public LineCap StartCap { get; set; }
Property Value
| Type | Description |
|---|---|
| LineCap |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Transform
Gets or sets the transformation matrix for the pen.
Declaration
public Matrix Transform { get; set; }
Property Value
| Type | Description |
|---|---|
| Matrix |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Width
Gets or sets the width of this pen.
Declaration
public float Width { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Methods
Clone()
Creates an exact copy of this Pen.
Declaration
public Pen Clone()
Returns
| Type | Description |
|---|---|
| Pen | A new Pen with the same properties. |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
Dispose()
Releases all resources used by this pen.
Declaration
public void Dispose()
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
MultiplyTransform(Matrix, MatrixOrder)
Multiplies the transformation matrix by the specified matrix.
Declaration
public void MultiplyTransform(Matrix matrix, MatrixOrder order = MatrixOrder.Prepend)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | matrix | The matrix to multiply. |
| MatrixOrder | order | The order of multiplication (prepend or append). |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
ResetTransform()
Resets the transformation matrix to the identity matrix.
Declaration
public void ResetTransform()
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
RotateTransform(float, MatrixOrder)
Rotates the transformation matrix by the specified angle.
Declaration
public void RotateTransform(float angle, MatrixOrder order = MatrixOrder.Prepend)
Parameters
| Type | Name | Description |
|---|---|---|
| float | angle | The angle of rotation in degrees. |
| MatrixOrder | order | The order of multiplication (prepend or append). |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
ScaleTransform(float, float, MatrixOrder)
Scales the transformation matrix by the specified factors.
Declaration
public void ScaleTransform(float sx, float sy, MatrixOrder order = MatrixOrder.Prepend)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sx | The horizontal scale factor. |
| float | sy | The vertical scale factor. |
| MatrixOrder | order | The order of multiplication (prepend or append). |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.
TranslateTransform(float, float, MatrixOrder)
Translates the transformation matrix by the specified offsets.
Declaration
public void TranslateTransform(float dx, float dy, MatrixOrder order = MatrixOrder.Prepend)
Parameters
| Type | Name | Description |
|---|---|---|
| float | dx | The horizontal translation. |
| float | dy | The vertical translation. |
| MatrixOrder | order | The order of multiplication (prepend or append). |
Remarks
A Pen can be initialized with a color or brush, and customized with line caps, joins, dash patterns, and alignment. Pens are used with Graphics objects to draw outlines of shapes.