次の方法で共有


GraphicsPath.AddCurve メソッド (Point , Int32, Int32, Single)

現在の図形にスプライン曲線を追加します。

Overloads Public Sub AddCurve( _
   ByVal points() As Point, _   ByVal offset As Integer, _   ByVal numberOfSegments As Integer, _   ByVal tension As Single _)
[C#]
public void AddCurve(Point[] points,intoffset,intnumberOfSegments,floattension);
[C++]
public: void AddCurve(Pointpoints[],intoffset,intnumberOfSegments,floattension);
[JScript]
public function AddCurve(
   points : Point[],offset : int,numberOfSegments : int,tension : float);

パラメータ

  • points
    曲線を定義する複数の点を表す Point 構造体の配列。
  • offset
    曲線の最初の点として使用される、 points 配列の要素のインデックス。
  • numberOfSegments
    曲線が制御点の間で湾曲する度合いを指定する値。1 より大きい値の場合、予期しない結果が発生します。
  • tension
    曲線が制御点の間で湾曲する度合いを指定する値。1 より大きい値の場合、予期しない結果が発生します。

解説

必要に応じて、元の点を維持する必要があります。元の点は内部で 3 次ベジエ制御点に変換されるため、元の点を返す機構はありません。

曲線は、 offset パラメータで指定された配列の点から始まり、 numberOfSegments で指定された数の点 (セグメント) を含みます。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • (カーディナル スプラインを表す) 4 点の配列を作成します。
  • パスを作成し、点の配列を使用して、パスに曲線を追加します。
  • 画面にパスを描画します。

[Visual Basic, C#] 配列には 4 点が格納されていますが、3 つのセグメントしかありません。これは、 AddCurve の呼び出しの 3 番目の引数で指定された数です。

 
Public Sub AddCurveExample(e As PaintEventArgs)
' Create some points.
Dim point1 As New Point(20, 20)
Dim point2 As New Point(40, 0)
Dim point3 As New Point(60, 40)
Dim point4 As New Point(80, 20)
' Create an array of the points.
Dim curvePoints As Point() =  {point1, point2, point3, point4}
' Create a GraphicsPath object and add a curve.
Dim myPath As New GraphicsPath()
myPath.AddCurve(curvePoints, 0, 3, 0.8F)
' Draw the path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
End Sub
        
[C#] 
private void AddCurveExample(PaintEventArgs e)
{
// Create some points.
Point point1 = new Point(20, 20);
Point point2 = new Point(40, 0);
Point point3 = new Point(60, 40);
Point point4 = new Point(80, 20);
// Create an array of the points.
Point[] curvePoints = {point1, point2, point3, point4};
// Create a GraphicsPath object and add a curve.
GraphicsPath myPath = new GraphicsPath();
myPath.AddCurve(curvePoints, 0, 3, 0.8f);
// Draw the path to the screen.
Pen myPen = new Pen(Color.Black, 2);
e.Graphics.DrawPath(myPen, myPath);
}
        

[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 ファミリ

参照

GraphicsPath クラス | GraphicsPath メンバ | System.Drawing.Drawing2D 名前空間 | GraphicsPath.AddCurve オーバーロードの一覧