Files
docs-desktop/dotnet-desktop-guide/framework/winforms/advanced/bezier-splines-in-gdi.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* 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
2020-09-01 16:26:21 -07:00

3.0 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
Bézier Splines in GDI+ 03/30/2017
csharp
vb
Bezier splines
splines [Windows Forms], Bezier
GDI+, Bezier splines
5774ce1e-87d4-4bc7-88c4-4862052781b8

Bézier Splines in GDI+

A Bézier spline is a curve specified by four points: two end points (p1 and p2) and two control points (c1 and c2). The curve begins at p1 and ends at p2. The curve does not pass through the control points, but the control points act as magnets, pulling the curve in certain directions and influencing the way the curve bends. The following illustration shows a Bézier curve along with its endpoints and control points.

Bezier Splines

The curve starts at p1 and moves toward the control point c1. The tangent line to the curve at p1 is the line drawn from p1 to c1. The tangent line at the endpoint p2 is the line drawn from c2 to p2.

Drawing Bézier Splines

To draw a Bézier spline, you need an instance of the xref:System.Drawing.Graphics class and a xref:System.Drawing.Pen. The instance of the xref:System.Drawing.Graphics class provides the xref:System.Drawing.Graphics.DrawBezier%2A method, and the xref:System.Drawing.Pen stores attributes, such as width and color, of the line used to render the curve. The xref:System.Drawing.Pen is passed as one of the arguments to the xref:System.Drawing.Graphics.DrawBezier%2A method. The remaining arguments passed to the xref:System.Drawing.Graphics.DrawBezier%2A method are the endpoints and the control points. The following example draws a Bézier spline with starting point (0, 0), control points (40, 20) and (80, 150), and ending point (100, 10):

[!code-csharpLinesCurvesAndShapes#71] [!code-vbLinesCurvesAndShapes#71]

The following illustration shows the curve, the control points, and two tangent lines.

Bezier Splines

Bézier splines were originally developed by Pierre Bézier for design in the automotive industry. They have since proven to be useful in many types of computer-aided design and are also used to define the outlines of fonts. Bézier splines can yield a wide variety of shapes, some of which are shown in the following illustration.

Paths

See also