次の方法で共有


Graphics.DrawPolygon メソッド (Pen, PointF )

PointF 構造体の配列で定義された多角形を描画します。

Overloads Public Sub DrawPolygon( _
   ByVal pen As Pen, _   ByVal points() As PointF _)
[C#]
public void DrawPolygon(Penpen,PointF[] points);
[C++]
public: void DrawPolygon(Pen* pen,PointFpoints[]);
[JScript]
public function DrawPolygon(
   pen : Pen,points : PointF[]);

パラメータ

  • pen
    多角形の色、幅、およびスタイルを決定する Pen オブジェクト。
  • points
    多角形の頂点を表す PointF 構造体の配列。

戻り値

このメソッドは値を返しません。

解説

配列内の連続する 2 つの点のペアは、それぞれ多角形の辺を指定します。また、配列内の最後の点と最初の点が一致しない場合は、多角形を閉じる最後の辺を指定します。

使用例

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

  • 黒いペンを作成します。
  • 多角形の頂点に使用する 7 つの点の配列を作成します。
  • 画面に多角形を描画します。
 
Public Sub DrawPolygonPoint(e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create points that define polygon.
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 polygon to screen.
e.Graphics.DrawPolygon(blackPen, curvePoints)
End Sub
        
[C#] 
public void DrawPolygonPoint(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create points that define polygon.
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 polygon to screen.
e.Graphics.DrawPolygon(blackPen, curvePoints);
}
        

[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.DrawPolygon オーバーロードの一覧