This class describes the kind of line that is drawn when using the
Pens are resource-based entities, and it is
therefore important to manage their lifetime carefully, calling
Dispose() when you are finished with them, to
release the resource to the system.
You can construct a
Pen from a
Brush, or (optionally) a
Width. If you use a
line will be a solid, uniform color. If you use a
Brush, you can take advantage of specific
properties to render the line with a gradient or image texture. If
you do not specify a width, the default value of 1 is used.
The width of the
Pen is measured in pixels and is
modified by any transforms that apply during the rendering process.
As a geometric line has no intrinsic width, you can also specify an
Alignment property, which determines where the
pixels are rendered relative to the geometric line (see
System.Drawing.Drawing2D.PenAlignment for more
information on this). The default is to center the pixels across this
You can choose how to render the beginning and end of the line by
EndCap properties. You can choose one of several
different styles from the
including butt-ends, round-ends, and simple arrows. If the predefined
styles are not suitable, you can specify a
with an instance of the
System.Drawing.Drawing2D.CustomLineCap class. This allows you to render more complex ...