* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
4.3 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Open and Closed Curves in GDI+ | 03/30/2017 |
|
|
08d2cc9a-dc9d-4eed-bcbb-2c8e2ca5d3ae |
Open and Closed Curves in GDI+
The following illustration shows two curves: one open and one closed.
Managed Interface for Curves
Closed curves have an interior and therefore can be filled with a brush. The xref:System.Drawing.Graphics class in GDI+ provides the following methods for filling closed shapes and curves: xref:System.Drawing.Graphics.FillRectangle%2A, xref:System.Drawing.Graphics.FillEllipse%2A, xref:System.Drawing.Graphics.FillPie%2A, xref:System.Drawing.Graphics.FillPolygon%2A, xref:System.Drawing.Graphics.FillClosedCurve%2A, xref:System.Drawing.Graphics.FillPath%2A, and xref:System.Drawing.Graphics.FillRegion%2A. Whenever you call one of these methods, you must pass one of the specific brush types (xref:System.Drawing.SolidBrush, xref:System.Drawing.Drawing2D.HatchBrush, xref:System.Drawing.TextureBrush, xref:System.Drawing.Drawing2D.LinearGradientBrush, or xref:System.Drawing.Drawing2D.PathGradientBrush) as an argument.
The xref:System.Drawing.Graphics.FillPie%2A method is a companion to the xref:System.Drawing.Graphics.DrawArc%2A method. Just as the xref:System.Drawing.Graphics.DrawArc%2A method draws a portion of the outline of an ellipse, the xref:System.Drawing.Graphics.FillPie%2A method fills a portion of the interior of an ellipse. The following example draws an arc and fills the corresponding portion of the interior of the ellipse:
[!code-csharpLinesCurvesAndShapes#21] [!code-vbLinesCurvesAndShapes#21]
The following illustration shows the arc and the filled pie.
The xref:System.Drawing.Graphics.FillClosedCurve%2A method is a companion to the xref:System.Drawing.Graphics.DrawClosedCurve%2A method. Both methods automatically close the curve by connecting the ending point to the starting point. The following example draws a curve that passes through (0, 0), (60, 20), and (40, 50). Then, the curve is automatically closed by connecting (40, 50) to the starting point (0, 0), and the interior is filled with a solid color.
[!code-csharpLinesCurvesAndShapes#22] [!code-vbLinesCurvesAndShapes#22]
The xref:System.Drawing.Graphics.FillPath%2A method fills the interiors of the separate pieces of a path. If a piece of a path doesn't form a closed curve or shape, the xref:System.Drawing.Graphics.FillPath%2A method automatically closes that piece of the path before filling it. The following example draws and fills a path that consists of an arc, a cardinal spline, a string, and a pie:
[!code-csharpLinesCurvesAndShapes#23] [!code-vbLinesCurvesAndShapes#23]
The following illustration shows the path with and without the solid fill. Note that the text in the string is outlined, but not filled, by the xref:System.Drawing.Graphics.DrawPath%2A method. It is the xref:System.Drawing.Graphics.FillPath%2A method that paints the interiors of the characters in the string.


