Easy Way to Learn ASP.NET

GDI+ Tutorial

GDI+ Introduction
GDI+ Lines
GDI+ Rectangles
GDI+ Ellipses
GDI+ Arcs
GDI+ Polygons
GDI+ Cardinal Splines
GDI+ Bezier Splines
GDI+ Graphics Paths
GDI+ Brushes
GDI+ Regions
GDI+ Antialiasing
GDI+ Bitmaps
GDI+ Metafiles
GDI+ Transformations
GDI+ Text

Graphics Paths in GDI+

Paths are combination of lines, rectangles, simple curves, and other vector images. To draw a path you use the GraphicsPath object.

The following illustration shows a path created by combining a line, an arc, a Bézier spline, and a cardinal spline.

Graphics Paths 


Drawing a Path

To draw a path, call the DrawPath method of the Graphics object. The Pen object is passed as an argument. The other argument is the GraphicsPath object.

The GraphicsPath class provides the following methods for creating a sequence of items to be drawn: AddLine, AddRectangle, AddEllipse, AddArc, AddPolygon, AddCurve (for cardinal splines), and AddBezier.

Below is the syntax of DrawPath method:

DrawPath(ByVal pen As System.Drawing.Pen, ByVal path As System.Drawing.Drawing2D.GraphicsPath)

The following code example shows how to draw a path that consists of a line, an ellipse, and a bezier spline: