GraphicsPath.AddPolygon 方法

定义

将多边形添加到此路径。

重载

AddPolygon(ReadOnlySpan<Point>)
AddPolygon(Point[])

将多边形添加到此路径。

AddPolygon(PointF[])

将多边形添加到此路径。

AddPolygon(ReadOnlySpan<PointF>)

AddPolygon(ReadOnlySpan<Point>)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
public:
 void AddPolygon(ReadOnlySpan<System::Drawing::Point> points);
public void AddPolygon (scoped ReadOnlySpan<System.Drawing.Point> points);
member this.AddPolygon : ReadOnlySpan<System.Drawing.Point> -> unit
Public Sub AddPolygon (points As ReadOnlySpan(Of Point))

参数

适用于

AddPolygon(Point[])

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

将多边形添加到此路径。

public:
 void AddPolygon(cli::array <System::Drawing::Point> ^ points);
public:
 void AddPolygon(... cli::array <System::Drawing::Point> ^ points);
public void AddPolygon (System.Drawing.Point[] points);
public void AddPolygon (params System.Drawing.Point[] points);
member this.AddPolygon : System.Drawing.Point[] -> unit
Public Sub AddPolygon (points As Point())
Public Sub AddPolygon (ParamArray points As Point())

参数

points
Point[]

定义要添加的多边形的 Point 结构的数组。

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:

  • 创建定义多边形的点数组。

  • 创建路径并将多边形添加到路径。

  • 绘制屏幕的路径。

private:
   void AddPolygonExample( PaintEventArgs^ e )
   {
      // Create an array of points.
      array<Point>^ myArray = {Point(23,20),Point(40,10),Point(57,20),Point(50,40),Point(30,40)};

      // Create a GraphicsPath object and add a polygon.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddPolygon( myArray );

      // Draw the path to the screen.
      Pen^ myPen = gcnew Pen( Color::Black,2.0f );
      e->Graphics->DrawPath( myPen, myPath );
   }
private void AddPolygonExample(PaintEventArgs e)
{
             
    // Create an array of points.
    Point[] myArray =
             {
                 new Point(23, 20),
                 new Point(40, 10),
                 new Point(57, 20),
                 new Point(50, 40),
                 new Point(30, 40)
             };
             
    // Create a GraphicsPath object and add a polygon.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddPolygon(myArray);
             
    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}
Public Sub AddPolygonExample(ByVal e As PaintEventArgs)

    ' Create an array of points.
    Dim myArray As Point() = {New Point(23, 20), New Point(40, 10), _
    New Point(57, 20), New Point(50, 40), New Point(30, 40)}

    ' Create a GraphicsPath object and add a polygon.
    Dim myPath As New GraphicsPath
    myPath.AddPolygon(myArray)

    ' Draw the path to the screen.
    Dim myPen As New Pen(Color.Black, 2)
    e.Graphics.DrawPath(myPen, myPath)
End Sub

注解

points 数组中的点指定多边形的顶点。 如果数组中的第一个点与最后一个点不同,则这两个点将连接到关闭多边形。

适用于

AddPolygon(PointF[])

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

将多边形添加到此路径。

public:
 void AddPolygon(cli::array <System::Drawing::PointF> ^ points);
public:
 void AddPolygon(... cli::array <System::Drawing::PointF> ^ points);
public void AddPolygon (System.Drawing.PointF[] points);
public void AddPolygon (params System.Drawing.PointF[] points);
member this.AddPolygon : System.Drawing.PointF[] -> unit
Public Sub AddPolygon (points As PointF())
Public Sub AddPolygon (ParamArray points As PointF())

参数

points
PointF[]

定义要添加的多边形的 PointF 结构的数组。

示例

有关示例,请参阅 AddPolygon(Point[])

注解

points 数组中的点指定多边形的顶点。 如果数组中的第一个点与最后一个点不同,则这两个点将连接到关闭多边形。

适用于

AddPolygon(ReadOnlySpan<PointF>)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
public:
 void AddPolygon(ReadOnlySpan<System::Drawing::PointF> points);
public void AddPolygon (scoped ReadOnlySpan<System.Drawing.PointF> points);
member this.AddPolygon : ReadOnlySpan<System.Drawing.PointF> -> unit
Public Sub AddPolygon (points As ReadOnlySpan(Of PointF))

参数

适用于