public sealed class PenPublic NotInheritable Class Penpublic ref class Pen sealed[<SealedAttribute>]
type Pen = class endPens are used to draw the outline of shapes, or to draw primitive lines and curves.
A Pen instance is defined by a Brush (possibly implicitly by a single color) that determines the color or texture of the pen, and a Width that determines the width of the pen. The LineJoin, MiterLimit, StartCap, and EndCap properties determine how the ends and joins of lines are drawn.
The following table illustrates the behavior of some properties of the Pen class:
| Description | Image Example |
|---|---|
| LineJoin: Specifies how to join the consecutive line segments. Can be Miter, Bevel or Round. The example images demonstrate these join types from the top to the bottom. All examples use a 10 pixel wide pen. | ![]() ![]() ![]() |
| StartCap and EndCap: Specify the style of the start and end points of an open figure. Can be Flat, Square, Round or Triangle. The example images demonstrate these cap types from the top to the bottom, using the same cap style at both ends. Please note that the only difference between Flat and Square styles is that the Flat style has the originally specified length, whereas the Square style extends the line by half of the pen width. All examples use a 10 pixel wide pen. | ![]() ![]() ![]() ![]() |
| Brush: It allows setting a Brush explicitly, so the Pen can use not only a solid color but also a texture or any other brush. The example demonstrates a 10 pixel wide pen with a diagonal linear gradient brush using mirrored wrapping mode. | ![]() |
| Pen | Initializes a new instance of the Pen class with a black color and a width of 1. |
| Pen(Brush, Single) | Initializes a new instance of the Pen class with the specified brush and width. |
| Pen(Color32, Single) | Initializes a new instance of the Pen class with the specified color and width. |
| Brush |
Gets or sets the Brush that determines the color or texture of the Pen.
Default value: The Brush instance that was either passed to the corresponding constructor, or was created implicitly from a color by the other constructors. See the Examples section of the Pen class for image examples. |
| EndCap |
Gets or sets the LineCapStyle that specifies the style of the end point of an open figure.
Makes a difference only if the Width is greater than 1.
Default value: Flat. See the Examples section of the Pen class for image examples. |
| LineJoin |
Gets or sets the LineJoinStyle that specifies how to join the consecutive line segments.
Default value: Miter. See the Examples section of the Pen class for image examples. |
| MiterLimit |
If the LineJoin is Miter, then
gets or sets the limit for the ratio of the miter length to half the Width that determines whether the join is beveled or mitered.
Makes a difference only if the Width is greater than 1.
Default value: 10. |
| StartCap |
Gets or sets the LineCapStyle that specifies the style of the start point of an open figure.
Makes a difference only if the Width is greater than 1.
Default value: Flat. See the Examples section of the Pen class for image examples. |
| Width |
Gets or sets the width of the Pen.
Default value: the width that was passed to the constructor, or 1, if it was not specified. |