Files
docs-desktop/dotnet-desktop-guide/framework/winforms/advanced/how-to-draw-cardinal-splines.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.5 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Draw Cardinal Splines 03/30/2017
csharp
vb
cardinal splines [Windows Forms], drawing
drawing [Windows Forms], cardinal splines
graphics [Windows Forms], cardinal splines
a4a41e80-4461-4b47-b6bd-2c5e68881994

How to: Draw Cardinal Splines

A cardinal spline is a curve that passes smoothly through a given set of points. To draw a cardinal spline, create a xref:System.Drawing.Graphics object and pass the address of an array of points to the xref:System.Drawing.Graphics.DrawCurve%2A method.

Drawing a Bell-Shaped Cardinal Spline

  • The following example draws a bell-shaped cardinal spline that passes through five designated points. The following illustration shows the curve and five points.

    Diagram that shows a bell-shaped cardinal spline.

[!code-csharpSystem.Drawing.ConstructingDrawingCurves#21] [!code-vbSystem.Drawing.ConstructingDrawingCurves#21]

Drawing a Closed Cardinal Spline

  • Use the xref:System.Drawing.Graphics.DrawClosedCurve%2A method of the xref:System.Drawing.Graphics class to draw a closed cardinal spline. In a closed cardinal spline, the curve continues through the last point in the array and connects with the first point in the array. The following example draws a closed cardinal spline that passes through six designated points. The following illustration shows the closed spline along with the six points:

Diagram that shows a closed cardinal spline.

[!code-csharpSystem.Drawing.ConstructingDrawingCurves#22] [!code-vbSystem.Drawing.ConstructingDrawingCurves#22]

Changing the Bend of a Cardinal Spline

  • Change the way a cardinal spline bends by passing a tension argument to the xref:System.Drawing.Graphics.DrawCurve%2A method. The following example draws three cardinal splines that pass through the same set of points. The following illustration shows the three splines along with their tension values. Note that when the tension is 0, the points are connected by straight lines.

Diagram that shows three cardinal splines.

[!code-csharpSystem.Drawing.ConstructingDrawingCurves#23] [!code-vbSystem.Drawing.ConstructingDrawingCurves#23]

Compiling the Code

The preceding examples are designed for use with Windows Forms, and they require xref:System.Windows.Forms.PaintEventArgs e, which is a parameter of the xref:System.Windows.Forms.Control.Paint event handler.

See also