--- title: "Graphics Paths in GDI+" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "graphics [Windows Forms], paths" - "GDI+, drawing paths" - "paths [Windows Forms], drawing" - "drawing [Windows Forms], paths" ms.assetid: a5500dec-666c-41fd-9da3-2169dd89c5eb --- # Graphics Paths in GDI+ Paths are formed by combining lines, rectangles, and simple curves. Recall from the [Vector Graphics Overview](vector-graphics-overview.md) that the following basic building blocks have proven to be the most useful for drawing pictures: - Lines - Rectangles - Ellipses - Arcs - Polygons - Cardinal splines - Bézier splines In GDI+, the object allows you to collect a sequence of these building blocks into a single unit. The entire sequence of lines, rectangles, polygons, and curves can then be drawn with one call to the method of the class. The following illustration shows a path created by combining a line, an arc, a Bézier spline, and a cardinal spline. ![Path](./media/aboutgdip02-art14.gif "Aboutgdip02_art14") ## Using a Path The class provides the following methods for creating a sequence of items to be drawn: , , , , , (for cardinal splines), and . Each of these methods is overloaded; that is, each method supports several different parameter lists. For example, one variation of the method receives four integers, and another variation of the method receives two objects. The methods for adding lines, rectangles, and Bézier splines to a path have plural companion methods that add several items to the path in a single call: , , and . Also, the and methods have companion methods, and , that add a closed curve or pie to the path. To draw a path, you need a object, a object, and a object. The object provides the method, and the object stores attributes, such as width and color, of the line used to render the path. The object stores the sequence of lines and curves that make up the path. The object and the object are passed as arguments to the method. The following example draws a path that consists of a line, an ellipse, and a Bézier spline: [!code-csharp[LinesCurvesAndShapes#101](~/samples/snippets/csharp/VS_Snippets_Winforms/LinesCurvesAndShapes/CS/Class1.cs#101)] [!code-vb[LinesCurvesAndShapes#101](~/samples/snippets/visualbasic/VS_Snippets_Winforms/LinesCurvesAndShapes/VB/Class1.vb#101)] The following illustration shows the path. ![Path](./media/aboutgdip02-art15.gif "Aboutgdip02_art15") In addition to adding lines, rectangles, and curves to a path, you can add paths to a path. This allows you to combine existing paths to form large, complex paths. [!code-csharp[LinesCurvesAndShapes#102](~/samples/snippets/csharp/VS_Snippets_Winforms/LinesCurvesAndShapes/CS/Class1.cs#102)] [!code-vb[LinesCurvesAndShapes#102](~/samples/snippets/visualbasic/VS_Snippets_Winforms/LinesCurvesAndShapes/VB/Class1.vb#102)] There are two other items you can add to a path: strings and pies. A pie is a portion of the interior of an ellipse. The following example creates a path from an arc, a cardinal spline, a string, and a pie: [!code-csharp[LinesCurvesAndShapes#103](~/samples/snippets/csharp/VS_Snippets_Winforms/LinesCurvesAndShapes/CS/Class1.cs#103)] [!code-vb[LinesCurvesAndShapes#103](~/samples/snippets/visualbasic/VS_Snippets_Winforms/LinesCurvesAndShapes/VB/Class1.vb#103)] The following illustration shows the path. Note that a path does not have to be connected; the arc, cardinal spline, string, and pie are separated. ![Paths](./media/aboutgdip02-art16.gif "Aboutgdip02_Art16") ## See also - - - [Lines, Curves, and Shapes](lines-curves-and-shapes.md) - [How to: Create Graphics Objects for Drawing](how-to-create-graphics-objects-for-drawing.md) - [Constructing and Drawing Paths](constructing-and-drawing-paths.md)