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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-drawing/Aspose.Drawing-for-.NET
using System.Drawing;
Bitmap bitmap = new Bitmap(1000, 800, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
Graphics graphics = Graphics.FromImage(bitmap);
Pen pen = new Pen(Color.Blue, 2);
graphics.DrawClosedCurve(pen, new Point[] { new Point(100, 700), new Point(350, 600), new Point(500, 500), new Point(650, 600), new Point(900, 700) });
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters