Working with Pens

Aspose.Drawing for .NET API provides the capability to draw graphics elements. Pens are one of the key elements of working with graphics and are used to draw different line objects such as an ellipse, circle, etc with the specified color.

Set Pen Width to Draw Graphics in C#

To draw graphics with a certain pen width, the following steps can be used.

  1. Create an object of the Bitmap class
  2. Initialize the Graphics object from the created bitmap
  3. Create a new Pen with the desired width
  4. Use the DrawLine method to draw a line with the desired width
  5. Save the output to any desired output image format

Pen width

Set Pen Color to Draw Graphics in C#

To draw graphics with a certain pen color, the following steps can be used.

  1. Create an object of the Bitmap class
  2. Initialize the Graphics object from the bitmap
  3. Create a new Pen with the desired color
  4. Use the DrawLine method to draw a line
  5. Save the output to any desired output image format

Pen color

Join lines to create Path in C#

Multiple lines can be joined to create a path. To join lines using C#, the following steps can be used.

  1. Create an object of the Bitmap class
  2. Initialize the Graphics object from the bitmap
  3. Create a GraphicsPath object to establish a path
  4. Use the LineJoin to join lines

Join lines