# Graphics.DrawCurve 方法

## 重载

 DrawCurve(Pen, Point[]) 绘制经过一组指定的 Point 结构的基数样条。Draws a cardinal spline through a specified array of Point structures. DrawCurve(Pen, PointF[]) 绘制经过一组指定的 PointF 结构的基数样条。Draws a cardinal spline through a specified array of PointF structures. DrawCurve(Pen, Point[], Single) 使用指定的张力绘制经过一组指定的 Point 结构的基数样条。Draws a cardinal spline through a specified array of Point structures using a specified tension. DrawCurve(Pen, PointF[], Single) 使用指定的张力绘制经过一组指定的 PointF 结构的基数样条。Draws a cardinal spline through a specified array of PointF structures using a specified tension. DrawCurve(Pen, PointF[], Int32, Int32) 绘制经过一组指定的 PointF 结构的基数样条。Draws a cardinal spline through a specified array of PointF structures. 从相对于数组开始位置的偏移量开始绘制。The drawing begins offset from the beginning of the array. DrawCurve(Pen, Point[], Int32, Int32, Single) 使用指定的张力绘制经过一组指定的 Point 结构的基数样条。Draws a cardinal spline through a specified array of Point structures using a specified tension. DrawCurve(Pen, PointF[], Int32, Int32, Single) 使用指定的张力绘制经过一组指定的 PointF 结构的基数样条。Draws a cardinal spline through a specified array of PointF structures using a specified tension. 从相对于数组开始位置的偏移量开始绘制。The drawing begins offset from the beginning of the array.

## DrawCurve(Pen, Point[])

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.Point[] points);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.Point[] -> unit``
``Public Sub DrawCurve (pen As Pen, points As Point())``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和高度。Pen that determines the color, width, and height of the curve.

points
Point[]

Point 结构数组，这些结构定义样条。Array of Point structures that define the spline.

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点以定义曲线。Creates seven points to define a curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 绘制经过七个点的打开的绿色曲线。Draws an open green curve through the seven points.

``````private:
void DrawCurvePoint( PaintEventArgs^ e )
{
// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
Point point1 = Point(50,50);
Point point2 = Point(100,25);
Point point3 = Point(200,5);
Point point4 = Point(250,50);
Point point5 = Point(300,100);
Point point6 = Point(350,200);
Point point7 = Point(250,250);
array<Point>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints );
}
``````
``````private void DrawCurvePoint(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
Point point1 = new Point(50, 50);
Point point2 = new Point(100, 25);
Point point3 = new Point(200, 5);
Point point4 = new Point(250, 50);
Point point5 = new Point(300, 100);
Point point6 = new Point(350, 200);
Point point7 = new Point(250, 250);
Point[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints);
}
``````
``````Private Sub DrawCurvePoint(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints)
End Sub
``````

## DrawCurve(Pen, PointF[])

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.PointF[] -> unit``
``Public Sub DrawCurve (pen As Pen, points As PointF())``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和样式。Pen that determines the color, width, and style of the curve.

points
PointF[]

PointF 结构数组，这些结构定义样条。Array of PointF structures that define the spline.

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点以定义曲线。Creates seven points to define a curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 绘制经过七个点的打开的绿色曲线。Draws an open green curve through the seven points.

``````private:
void DrawCurvePointF( PaintEventArgs^ e )
{
// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
PointF point1 = PointF(50.0F,50.0F);
PointF point2 = PointF(100.0F,25.0F);
PointF point3 = PointF(200.0F,5.0F);
PointF point4 = PointF(250.0F,50.0F);
PointF point5 = PointF(300.0F,100.0F);
PointF point6 = PointF(350.0F,200.0F);
PointF point7 = PointF(250.0F,250.0F);
array<PointF>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints );
}
``````
``````private void DrawCurvePointF(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
PointF point1 = new PointF(50.0F, 50.0F);
PointF point2 = new PointF(100.0F, 25.0F);
PointF point3 = new PointF(200.0F, 5.0F);
PointF point4 = new PointF(250.0F, 50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints);
}
``````
``````Private Sub DrawCurvePointF(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New PointF(50.0F, 50.0F)
Dim point2 As New PointF(100.0F, 25.0F)
Dim point3 As New PointF(200.0F, 5.0F)
Dim point4 As New PointF(250.0F, 50.0F)
Dim point5 As New PointF(300.0F, 100.0F)
Dim point6 As New PointF(350.0F, 200.0F)
Dim point7 As New PointF(250.0F, 250.0F)
Dim curvePoints As PointF() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints)
End Sub
``````

## DrawCurve(Pen, Point[], Single)

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points, float tension);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.Point[] points, float tension);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.Point[] * single -> unit``
``Public Sub DrawCurve (pen As Pen, points As Point(), tension As Single)``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和样式。Pen that determines the color, width, and style of the curve.

points
Point[]

Point 结构数组，这些结构定义样条。Array of Point structures that define the spline.

tension
Single

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点来定义曲线。Creates seven points to define the curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 创建张力设置。Creates a tension setting.

• 绘制经过七个点的开放绿色闭合曲线。Draws an open green closed curve through the seven points.

``````private:
void DrawCurvePointTension( PaintEventArgs^ e )
{

// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
Point point1 = Point(50,50);
Point point2 = Point(100,25);
Point point3 = Point(200,5);
Point point4 = Point(250,50);
Point point5 = Point(300,100);
Point point6 = Point(350,200);
Point point7 = Point(250,250);
array<Point>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Create tension.
float tension = 1.0F;

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints, tension );
}
``````
``````private void DrawCurvePointTension(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
Point point1 = new Point(50, 50);
Point point2 = new Point(100, 25);
Point point3 = new Point(200, 5);
Point point4 = new Point(250, 50);
Point point5 = new Point(300, 100);
Point point6 = new Point(350, 200);
Point point7 = new Point(250, 250);
Point[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Create tension.
float tension = 1.0F;

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, tension);
}
``````
``````Private Sub DrawCurvePointTension(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Create tension.
Dim tension As Single = 1.0F

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, tension)
End Sub
``````

### 注解

`tension`参数确定样条的形状。The `tension` parameter determines the shape of the spline. 如果参数的值 `tension` 为 0.0 f，此方法将绘制直线段以连接点。If the value of the `tension` parameter is 0.0F, this method draws straight line segments to connect the points. 通常， `tension` 参数小于或等于 1.0 f。Usually, the `tension` parameter is less than or equal to 1.0F. 超过 1.0 F 的值会产生异常结果。Values over 1.0F produce unusual results.

## DrawCurve(Pen, PointF[], Single)

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points, float tension);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points, float tension);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.PointF[] * single -> unit``
``Public Sub DrawCurve (pen As Pen, points As PointF(), tension As Single)``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和样式。Pen that determines the color, width, and style of the curve.

points
PointF[]

PointF 结构的数组，这些结构表示定义曲线的点。Array of PointF structures that represent the points that define the curve.

tension
Single

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点来定义曲线。Creates seven points to define the curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 创建张力设置。Creates a tension setting.

• 绘制经过七个点的开放绿色闭合曲线。Draws an open green closed curve through the seven points.

``````private:
void DrawCurvePointFTension( PaintEventArgs^ e )
{
// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
PointF point1 = PointF(50.0F,50.0F);
PointF point2 = PointF(100.0F,25.0F);
PointF point3 = PointF(200.0F,5.0F);
PointF point4 = PointF(250.0F,50.0F);
PointF point5 = PointF(300.0F,100.0F);
PointF point6 = PointF(350.0F,200.0F);
PointF point7 = PointF(250.0F,250.0F);
array<PointF>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Create tension.
float tension = 1.0F;

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints, tension );
}
``````
``````private void DrawCurvePointFTension(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
PointF point1 = new PointF(50.0F, 50.0F);
PointF point2 = new PointF(100.0F, 25.0F);
PointF point3 = new PointF(200.0F, 5.0F);
PointF point4 = new PointF(250.0F, 50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Create tension.
float tension = 1.0F;

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, tension);
}
``````
``````Private Sub DrawCurvePointFTension(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New PointF(50.0F, 50.0F)
Dim point2 As New PointF(100.0F, 25.0F)
Dim point3 As New PointF(200.0F, 5.0F)
Dim point4 As New PointF(250.0F, 50.0F)
Dim point5 As New PointF(300.0F, 100.0F)
Dim point6 As New PointF(350.0F, 200.0F)
Dim point7 As New PointF(250.0F, 250.0F)
Dim curvePoints As PointF() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Create tension.
Dim tension As Single = 1.0F

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, tension)
End Sub
``````

### 注解

`tension`参数确定样条的形状。The `tension` parameter determines the shape of the spline. 如果参数的值 `tension` 为 0.0 f，此方法将绘制直线段以连接点。If the value of the `tension` parameter is 0.0F, this method draws straight line segments to connect the points. 通常， `tension` 参数小于或等于 1.0 f。Usually, the `tension` parameter is less than or equal to 1.0F. 超过 1.0 F 的值会产生异常结果。Values over 1.0F produce unusual results.

## DrawCurve(Pen, PointF[], Int32, Int32)

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points, int offset, int numberOfSegments);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points, int offset, int numberOfSegments);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.PointF[] * int * int -> unit``
``Public Sub DrawCurve (pen As Pen, points As PointF(), offset As Integer, numberOfSegments As Integer)``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和样式。Pen that determines the color, width, and style of the curve.

points
PointF[]

PointF 结构数组，这些结构定义样条。Array of PointF structures that define the spline.

offset
Int32

`points` 参数数组中的第一个元素到曲线中起始点的偏移量。Offset from the first element in the array of the `points` parameter to the starting point in the curve.

numberOfSegments
Int32

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点以定义曲线。Creates seven points to define a curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 定义起始点偏移量和段数。Defines the starting point offset and number of segments.

• 绘制一个 (从第三个点) 到最后五个点之间的开放绿色曲线。Draws an open green curve (starting at the third point) through the last five points.

``````private:
void DrawCurvePointFSegments( PaintEventArgs^ e )
{
// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
PointF point1 = PointF(50.0F,50.0F);
PointF point2 = PointF(100.0F,25.0F);
PointF point3 = PointF(200.0F,5.0F);
PointF point4 = PointF(250.0F,50.0F);
PointF point5 = PointF(300.0F,100.0F);
PointF point6 = PointF(350.0F,200.0F);
PointF point7 = PointF(250.0F,250.0F);
array<PointF>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Create offset and number of segments.
int offset = 2;
int numSegments = 4;

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints, offset, numSegments );
}
``````
``````private void DrawCurvePointFSegments(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
PointF point1 = new PointF(50.0F, 50.0F);
PointF point2 = new PointF(100.0F, 25.0F);
PointF point3 = new PointF(200.0F, 5.0F);
PointF point4 = new PointF(250.0F, 50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Create offset and number of segments.
int offset = 2;
int numSegments = 4;

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments);
}
``````
``````Private Sub DrawCurvePointFSegments(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New PointF(50.0F, 50.0F)
Dim point2 As New PointF(100.0F, 25.0F)
Dim point3 As New PointF(200.0F, 5.0F)
Dim point4 As New PointF(250.0F, 50.0F)
Dim point5 As New PointF(300.0F, 100.0F)
Dim point6 As New PointF(350.0F, 200.0F)
Dim point7 As New PointF(250.0F, 250.0F)
Dim curvePoints As PointF() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Create offset and number of segments.
Dim offset As Integer = 2
Dim numSegments As Integer = 4

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments)
End Sub
``````

### 注解

`offset`参数值指定要在数组中跳过的元素数。The value of the `offset` parameter specifies the number of elements to skip in the array. 跳过元素后的第一个元素表示曲线的起始点。The first element after the skipped elements represents the starting point of the curve.

## DrawCurve(Pen, Point[], Int32, Int32, Single)

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points, int offset, int numberOfSegments, float tension);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.Point[] points, int offset, int numberOfSegments, float tension);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.Point[] * int * int * single -> unit``
``Public Sub DrawCurve (pen As Pen, points As Point(), offset As Integer, numberOfSegments As Integer, tension As Single)``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和样式。Pen that determines the color, width, and style of the curve.

points
Point[]

Point 结构数组，这些结构定义样条。Array of Point structures that define the spline.

offset
Int32

`points` 参数数组中的第一个元素到曲线中起始点的偏移量。Offset from the first element in the array of the `points` parameter to the starting point in the curve.

numberOfSegments
Int32

tension
Single

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点以定义曲线。Creates seven points to define a curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 定义起始点偏移量和段数。Defines the starting point offset and number of segments.

• 定义张力。Defines the tension.

• 绘制一个 (从第三个点) 到最后五个点之间的开放绿色曲线。Draws an open green curve (starting at the third point) through the last five points.

``````private:
void DrawCurvePointSegmentTension( PaintEventArgs^ e )
{
// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
Point point1 = Point(50,50);
Point point2 = Point(100,25);
Point point3 = Point(200,5);
Point point4 = Point(250,50);
Point point5 = Point(300,100);
Point point6 = Point(350,200);
Point point7 = Point(250,250);
array<Point>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Create offset, number of segments, and tension.
int offset = 2;
int numSegments = 4;
float tension = 1.0F;

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints, offset, numSegments, tension );
}
``````
``````private void DrawCurvePointSegmentTension(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
Point point1 = new Point(50, 50);
Point point2 = new Point(100, 25);
Point point3 = new Point(200, 5);
Point point4 = new Point(250, 50);
Point point5 = new Point(300, 100);
Point point6 = new Point(350, 200);
Point point7 = new Point(250, 250);
Point[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Create offset, number of segments, and tension.
int offset = 2;
int numSegments = 4;
float tension = 1.0F;

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, tension);
}
``````
``````Private Sub DrawCurvePointSegmentTension(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Create offset, number of segments, and tension.
Dim offset As Integer = 2
Dim numSegments As Integer = 4
Dim tension As Single = 1.0F

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, _
tension)
End Sub
``````

### 注解

`offset`参数值指定要在数组中跳过的元素数。The value of the `offset` parameter specifies the number of elements to skip in the array. 跳过元素后的第一个元素表示曲线的起始点。The first element after the skipped elements represents the starting point of the curve.

`tension`参数确定样条的形状。The `tension` parameter determines the shape of the spline. 如果参数的值 `tension` 为 0.0 f，此方法将绘制直线段以连接点。If the value of the `tension` parameter is 0.0F, this method draws straight line segments to connect the points. 通常， `tension` 参数小于或等于 1.0 f。Usually, the `tension` parameter is less than or equal to 1.0F. 超过 1.0 F 的值会产生异常结果。Values over 1.0F produce unusual results.

## DrawCurve(Pen, PointF[], Int32, Int32, Single)

``````public:
void DrawCurve(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points, int offset, int numberOfSegments, float tension);``````
``public void DrawCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points, int offset, int numberOfSegments, float tension);``
``member this.DrawCurve : System.Drawing.Pen * System.Drawing.PointF[] * int * int * single -> unit``
``Public Sub DrawCurve (pen As Pen, points As PointF(), offset As Integer, numberOfSegments As Integer, tension As Single)``

#### 参数

pen
Pen

Pen，它确定曲线的颜色、宽度和样式。Pen that determines the color, width, and style of the curve.

points
PointF[]

PointF 结构数组，这些结构定义样条。Array of PointF structures that define the spline.

offset
Int32

`points` 参数数组中的第一个元素到曲线中起始点的偏移量。Offset from the first element in the array of the `points` parameter to the starting point in the curve.

numberOfSegments
Int32

tension
Single

#### 例外

`pen``null``pen` is `null`.

- 或 --or- `points``null``points` is `null`.

### 示例

• 创建红色和绿色笔。Creates red and green pens.

• 创建七个点以定义曲线。Creates seven points to define a curve.

• 在七个点之间绘制六个红色直线，形成一个不完整的多边形。Draws six red straight lines between the seven points to form an incomplete polygon.

• 定义起始点偏移量和段数。Defines the starting point offset and number of segments.

• 定义张力。Defines the tension.

• 绘制一个 (从第三个点) 到最后五个点之间的开放绿色曲线。Draws an open green curve (starting at the third point) through the last five points.

``````private:
void DrawCurvePointFSegmentTension( PaintEventArgs^ e )
{
// Create pens.
Pen^ redPen = gcnew Pen( Color::Red,3.0f );
Pen^ greenPen = gcnew Pen( Color::Green,3.0f );

// Create points that define curve.
PointF point1 = PointF(50.0F,50.0F);
PointF point2 = PointF(100.0F,25.0F);
PointF point3 = PointF(200.0F,5.0F);
PointF point4 = PointF(250.0F,50.0F);
PointF point5 = PointF(300.0F,100.0F);
PointF point6 = PointF(350.0F,200.0F);
PointF point7 = PointF(250.0F,250.0F);
array<PointF>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

// Draw lines between original points to screen.
e->Graphics->DrawLines( redPen, curvePoints );

// Create offset, number of segments, and tension.
int offset = 2;
int numSegments = 4;
float tension = 1.0F;

// Draw curve to screen.
e->Graphics->DrawCurve( greenPen, curvePoints, offset, numSegments, tension );
}
``````
``````private void DrawCurvePointFSegmentTension(PaintEventArgs e)
{

// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);

// Create points that define curve.
PointF point1 = new PointF(50.0F, 50.0F);
PointF point2 = new PointF(100.0F, 25.0F);
PointF point3 = new PointF(200.0F, 5.0F);
PointF point4 = new PointF(250.0F, 50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

// Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints);

// Create offset, number of segments, and tension.
int offset = 2;
int numSegments = 4;
float tension = 1.0F;

// Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, tension);
}
``````
``````Private Sub DrawCurvePointFSegmentTension(ByVal e As PaintEventArgs)

' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)

' Create points that define curve.
Dim point1 As New PointF(50.0F, 50.0F)
Dim point2 As New PointF(100.0F, 25.0F)
Dim point3 As New PointF(200.0F, 5.0F)
Dim point4 As New PointF(250.0F, 50.0F)
Dim point5 As New PointF(300.0F, 100.0F)
Dim point6 As New PointF(350.0F, 200.0F)
Dim point7 As New PointF(250.0F, 250.0F)
Dim curvePoints As PointF() = {point1, point2, point3, point4, _
point5, point6, point7}

' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)

' Create offset, number of segments, and tension.
Dim offset As Integer = 2
Dim numSegments As Integer = 4
Dim tension As Single = 1.0F

' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, _
tension)
End Sub
``````

### 注解

`offset`参数值指定要在数组中跳过的元素数。The value of the `offset` parameter specifies the number of elements to skip in the array. 跳过元素后的第一个元素表示曲线的起始点。The first element after the skipped elements represents the starting point of the curve.

`tension`参数确定样条的形状。The `tension` parameter determines the shape of the spline. 如果参数的值 `tension` 为 0.0 f，此方法将绘制直线段以连接点。If the value of the `tension` parameter is 0.0F, this method draws straight line segments to connect the points. 通常， `tension` 参数小于或等于 1.0 f。Usually, the `tension` parameter is less than or equal to 1.0F. 超过 1.0 F 的值会产生异常结果。Values over 1.0F produce unusual results.