Defines an object used to draw lines and curves.
Namespace:
Aurigma.GraphicsMill.Drawing
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
public sealed class Pen : IDisposable
Pen is an object which is used to draw lines, curves, and outline shapes. You can specify a number of pen settings: Color, Width, DashStyle. Some properties are used to determine a behaviour of lines conjunctions, such as LineJoin and MiterLimit. To specify a shape of the line ends, use StartCap and EndCap properties.
When you draw closed shapes such as rectangles, ellipses, etc. with a pen of large width (which is more than 1), there is an important parameter Alignment that specifies the direction to widen the line (both directions evenly or inside the shape).
using (var bitmap = new Bitmap(100, 40, PixelFormat.Format24bppRgb, RgbColor.White)) { using (Graphics graphics = bitmap.GetGraphics()) { //Dashed line var pen = new Pen(RgbColor.DarkOrange, 1, System.Drawing.Drawing2D.DashStyle.Dash); graphics.DrawLine(pen, 5, 5, 95, 5); //Line made of dash-dot patterns pen.Color = RgbColor.DarkGreen; pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; graphics.DrawLine(pen, 5, 15, 95, 15); //Line made of dash-dot-dot patterns pen.Color = RgbColor.Brown; pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; graphics.DrawLine(pen, 5, 25, 95, 25); //Dotted line pen.Color = RgbColor.DarkRed; pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; graphics.DrawLine(pen, 5, 35, 95, 35); bitmap.Save(@"Images\Output\pen.png"); } }