Graphics.DrawPolygon 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
绘制由一组 Point 结构定义的多边形。
重载
DrawPolygon(Pen, Point[]) |
绘制由一组 Point 结构定义的多边形。 |
DrawPolygon(Pen, PointF[]) |
绘制由一组 PointF 结构定义的多边形。 |
DrawPolygon(Pen, ReadOnlySpan<Point>) | |
DrawPolygon(Pen, ReadOnlySpan<PointF>) |
DrawPolygon(Pen, Point[])
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
绘制由一组 Point 结构定义的多边形。
public:
void DrawPolygon(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points);
public:
void DrawPolygon(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::Point> ^ points);
public void DrawPolygon (System.Drawing.Pen pen, System.Drawing.Point[] points);
public void DrawPolygon (System.Drawing.Pen pen, params System.Drawing.Point[] points);
member this.DrawPolygon : System.Drawing.Pen * System.Drawing.Point[] -> unit
Public Sub DrawPolygon (pen As Pen, points As Point())
Public Sub DrawPolygon (pen As Pen, ParamArray points As Point())
参数
例外
pen
为 null
。
示例
下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
,这是事件处理程序的参数Paint。 此代码执行以下操作:
创建黑色笔。
为多边形的顶点创建一个包含 7 个点的数组。
在屏幕上绘制多边形。
public:
void DrawPolygonPoint( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create points that define polygon.
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 polygon to screen.
e->Graphics->DrawPolygon( blackPen, curvePoints );
}
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);
}
Public Sub DrawPolygonPoint(ByVal 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
注解
数组中每对连续的两个点指定多边形的一侧。 此外,如果数组的最后一个点和第一个点不重合,则它们指定多边形的最后一侧。
适用于
DrawPolygon(Pen, PointF[])
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
绘制由一组 PointF 结构定义的多边形。
public:
void DrawPolygon(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points);
public:
void DrawPolygon(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::PointF> ^ points);
public void DrawPolygon (System.Drawing.Pen pen, System.Drawing.PointF[] points);
public void DrawPolygon (System.Drawing.Pen pen, params System.Drawing.PointF[] points);
member this.DrawPolygon : System.Drawing.Pen * System.Drawing.PointF[] -> unit
Public Sub DrawPolygon (pen As Pen, points As PointF())
Public Sub DrawPolygon (pen As Pen, ParamArray points As PointF())
参数
例外
示例
下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
,这是事件处理程序的参数Paint。 此代码执行以下操作:
创建黑色笔。
为多边形的顶点创建一个包含 7 个点的数组。
在屏幕上绘制多边形。
public:
void DrawPolygonPointF( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create points that define polygon.
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 polygon curve to screen.
e->Graphics->DrawPolygon( blackPen, curvePoints );
}
public void DrawPolygonPointF(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create points that define polygon.
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 polygon curve to screen.
e.Graphics.DrawPolygon(blackPen, curvePoints);
}
Public Sub DrawPolygonPointF(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create points that define polygon.
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 polygon curve to screen.
e.Graphics.DrawPolygon(blackPen, curvePoints)
End Sub
注解
数组中每对连续的两个点指定多边形的一侧。 此外,如果最后一个点和数组点的第一个点不重合,则它们指定多边形的最后一侧。
适用于
DrawPolygon(Pen, ReadOnlySpan<Point>)
- Source:
- Graphics.cs
public:
void DrawPolygon(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::Point> points);
public void DrawPolygon (System.Drawing.Pen pen, ReadOnlySpan<System.Drawing.Point> points);
member this.DrawPolygon : System.Drawing.Pen * ReadOnlySpan<System.Drawing.Point> -> unit
Public Sub DrawPolygon (pen As Pen, points As ReadOnlySpan(Of Point))
参数
- pen
- Pen
- points
- ReadOnlySpan<Point>
适用于
DrawPolygon(Pen, ReadOnlySpan<PointF>)
- Source:
- Graphics.cs
public:
void DrawPolygon(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::PointF> points);
public void DrawPolygon (System.Drawing.Pen pen, ReadOnlySpan<System.Drawing.PointF> points);
member this.DrawPolygon : System.Drawing.Pen * ReadOnlySpan<System.Drawing.PointF> -> unit
Public Sub DrawPolygon (pen As Pen, points As ReadOnlySpan(Of PointF))
参数
- pen
- Pen
- points
- ReadOnlySpan<PointF>
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈