指定したテンションを使用して、指定した PointF 構造体の配列を通過するカーディナル スプラインを描画します。この描画は、配列の先頭からのオフセットから開始されます。
Overloads Public Sub DrawCurve( _
ByVal pen As Pen, _ ByVal points() As PointF, _ ByVal offset As Integer, _ ByVal numberOfSegments As Integer, _ ByVal tension As Single _)
[C#]
public void DrawCurve(Penpen,PointF[] points,intoffset,intnumberOfSegments,floattension);
[C++]
public: void DrawCurve(Pen* pen,PointFpoints[],intoffset,intnumberOfSegments,floattension);
[JScript]
public function DrawCurve(
pen : Pen,points : PointF[],offset : int,numberOfSegments : int,tension : float);
パラメータ
- pen
曲線の色、幅、および高さを決定する Pen オブジェクト。 - points
スプラインを定義する PointF 構造体の配列。 - offset
points パラメータの配列の最初の要素から曲線の開始点までのオフセット。 - numberOfSegments
曲線に含める開始点以降のセグメント数。 - tension
曲線のテンションを指定する 0.0F 以上の値。
戻り値
このメソッドは値を返しません。
解説
このメソッドは、配列の各点を通過するカーディナル スプラインを描画します。
点の配列には、4 つ以上の PointF 構造体を含める必要があります。
offset でスキップする要素数が指定されます。スキップされた要素以降の最初の要素は、曲線の開始点を表します。
numberOfSegments パラメータの値では、曲線を描画するための開始点以降のセグメント数が指定されます。 numberOfSegments パラメータの値は 1 以上にしてください。offset パラメータの値と numberOfSegments パラメータの値の合計は、points パラメータの配列内の要素数よりも小さい必要があります。
tension パラメータは、スプラインの形を決定します。 tension パラメータの値が 0.0F の場合、このメソッドは点をつなぐ直線セグメントを描画します。通常、 tension パラメータは 1.0F 以下です。値が 1.0F を超える場合は、予期しない結果になります。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- 赤と緑のペンを作成します。
- 曲線を定義する 7 つの点を作成します。
- 7 つの点の間に 6 本の赤い直線を描画して、不完全な多角形を形成します。
- 開始点のオフセットとセグメント数を定義します。
- テンションを定義します。
- 最後の 5 つの点を通過する (3 番目の点から開始)、開いた緑の曲線を描画します。
[Visual Basic, C#] このメソッドは、テンションを 1.0 に設定します。
Public Sub DrawCurvePointFSegmentTension(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(50F, 50F)
Dim point2 As New PointF(100F, 25F)
Dim point3 As New PointF(200F, 5F)
Dim point4 As New PointF(250F, 50F)
Dim point5 As New PointF(300F, 100F)
Dim point6 As New PointF(350F, 200F)
Dim point7 As New PointF(250F, 250F)
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 = 1F
' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, _
tension)
End Sub
[C#]
public 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);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.DrawCurve オーバーロードの一覧