Working with Vector Graphics in C#
Contents
[
Hide
]
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#:
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawArc method of Graphics class object to draw an arc
![Draw Arc](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawArc_out.png)
Draw Bezier Spline in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawBezier method of Graphics class object to draw Bezier Spline
![Draw Bezier Spline](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawBezierSpline_out.png)
Draw Cardinal Spline in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawCurve method of Graphics class object to draw Cardinal Spline
![Draw Cardinal Spline](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawCardinalSpline_out.png)
Draw Closed Curve in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawClosedCurve method of Graphics class object to draw closed curve
![Draw Closed Curve](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawClosedCurve_out.png)
Draw Ellipse in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawEllipse method of Graphics class object to draw Ellipse
![Draw Ellipse](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawEllipse_out.png)
Draw Lines in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawLine method of Graphics class object to draw lines
![Draw Lines](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawLines_out.png)
Draw Path in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Initialize a new object of GraphicsPath class and add Lines to its path collection
![Draw Path](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawPath_out.png)
Draw Polygon in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawPolygon method of Graphics class object to draw Polygon
![Draw Polygon](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawPolygon_out.png)
Draw Rectangle in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Define a Pen object with desired parameters
- Use the DrawRectangle method of Graphics class object to draw Rectangle
![Draw Rectangle](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/DrawRectangle_out.png)
Fill Region in C#
- Instantiate an object of Bitmap class
- Initialize an object of Graphics class from this bitmap
- Instantiate a GraphicsPath class object
- Add polygon to the Path collection of GraphicsPath class object
- Use the FillRegion method of Graphics class to fill defined regions
![Fill Region](https://github.com/aspose-drawing/Aspose.Drawing-for-.NET/raw/master/Examples/Data/LinesCurvesShapes/FillRegion_out.png)