Working with Vector Graphics in C#

Aspose.Drawing for .NET makes it easy for you to draw vector graphics using C#. The API lets you work with a variety of different vector graphics such as arcs, Bezier spline, Cardinal Spline, closed curves, ellipses, lines and a  number of other types. This article contains C# examples for drawing different types of vector graphics using the API.

Draw Arc in C#

To drawn an arc using C#:

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawArc method of Graphics class object to draw an arc
Draw Arc

Draw Bezier Spline in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawBezier method of Graphics class object to draw Bezier Spline
Draw Bezier Spline

Draw Cardinal Spline in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawCurve method of Graphics class object to draw Cardinal Spline
Draw Cardinal Spline

Draw Closed Curve in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawClosedCurve method of Graphics class object to draw closed curve
Draw Closed Curve

Draw Ellipse in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawEllipse method of Graphics class object to draw Ellipse
Draw Ellipse

Draw Lines in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawLine method of Graphics class object to draw lines
Draw Lines

Draw Path in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Initialize a new object of GraphicsPath class and add Lines to its path collection
Draw Path

Draw Polygon in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawPolygon method of Graphics class object to draw Polygon
Draw Polygon

Draw Rectangle in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Define a Pen object with desired parameters
  4. Use the DrawRectangle method of Graphics class object to draw Rectangle
Draw Rectangle

Fill Region in C#

  1. Instantiate an object of Bitmap class
  2. Initialize an object of Graphics class from this bitmap
  3. Instantiate a GraphicsPath class object
  4. Add polygon to the Path collection of GraphicsPath class object
  5. Use the FillRegion method of Graphics class to fill defined regions
Fill Region