[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TPen

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Represents a pen used to draw on a canvas.

## Declaration

Source position: graphics.pp line 638

`type TPen = class(TFPCustomPen)`
`protected`
`procedure DoAllocateResources; override;` |  | Performs actions needed to allocate resources for the class instance.
`procedure DoDeAllocateResources; override;` |  | Performs actions to free resources allocated for the class instance.
`procedure DoCopyProps(); override;` |  | Copies properties from the specified source to the class instance.
`procedure SetColor();` |  | Sets the value for the Color property.
`procedure SetFPColor(); override;` |  | Sets the pen Color to the specified TFPColor value.
`procedure SetEndCap(); override;` |  | Specifies the type of end cap used for the pen if it is a geometric pen.
`procedure SetJoinStyle(); override;` |  | Sets the value for the JoinStyle property.
`procedure SetMode(); override;` |  | Sets the value for the Mode property.
`procedure SetStyle(); override;` |  | Sets the value for the Style property.
`procedure SetWidth(); override;` |  | Sets the value for the Width property.
`public`
`constructor Create; override;` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destructor for the class instance.
`procedure Assign(); override;` |  | Copies property values from the specified persistent object.
`property Handle: HPEN; [rw] deprecated ;` |  | The Operating System Handle for the current Pen.
`property Reference: TWSPenReference; [r]` |  | A Reference made to this Pen.
`function GetPattern;` |  | Gets the Pattern used in the Pen.
`procedure SetPattern();` |  | SetPattern - specifies the pattern for the pen.
`published`
`property Color: TColor; [rw]` |  | The Color of the current Pen.
`property Cosmetic: Boolean; [rw]` |  | Indicates whether the Pen is Cosmetic (non-geometric).
`property EndCap;` |  | The sort of EndCap used on the Pen.
`property JoinStyle;` |  | JoinStyle - the style of joint where two lines meet or cross.
`property Mode;` |  | Pen mode for the class instance.
`property Style;` |  | Contains the line drawing style for the pen.
`property Width;` |  | Width for lines drawn using the Pen.
`end;`

## Inheritance

`TPen` |  | Represents a pen used to draw on a canvas.
`TFPCustomPen`
?
`TObject`

## Description

TPen is a TFPCustomPen descendant which contains settings for a pen used to draw lines and shapes on a canvas. It includes properties that define the color for the pen, the end cap and join style used for line segments, and a pattern used for user-defined line drawing styles.

Essentially, TPen maps the types used for properties in the FCL ancestor class to the types used in the LCL.

TPen is the type used to implement the Pen property in TCanvas.

## See also

TCanvas.Pen |  | The Pen to be used for writing in this canvas.