导航:  GdiPlus Classes > GdiPlus Classes > CGpGraphics Class > Graphics Object >

DrawPolygon

上一页返回章节概述下一页

描述

 

画多边形.

 

C++ Syntax

 

Status DrawPolygon(

[in]  const Pen *pen,

[in]  const PointF *points,

[in]  INT *count

);

 

Status DrawPolygon(

[in]  const Pen *pen,

[in]  const Point *points,

[in]  INT *count

);

 

FreeBASIC 语法

 

FUNCTION DrawPolygon ( _

   BYVAL pPen AS CGpPen PTR, _

   BYVAL pts AS GpPointF PTR, _

   BYVAL count AS LONG _

) AS GpStatus

 

FUNCTION DrawPolygon ( _

   BYVAL pPen AS CGpPen PTR, _

   BYVAL pts AS GpPoint PTR, _

   BYVAL count AS LONG _

) AS GpStatus

 

参数

 

pPen

 

[in]指针的那一支钢笔是用来绘制多边形.

 

pts

 

[in]指针指向的对象PointF指定多边形的顶点数组.

 

nCount

 

[in]整数,指定的点的数组元素个数.

 

返回值

 

如果该方法成功,则返回Ok,这是对Status枚举元素.

如果这个方法失败,它返回一个枚举的其他元素的Status.

 

引用文件

 

CGpBitmap.inc (include CGdiPlus.inc)

 

示例

 

' ========================================================================================

' The following example draws a sequence of connected lines.

' ========================================================================================

SUB Example_DrawPolygons (BYVAL hdc AS HDC)

 

  ' // Create a graphics object from the window device context

  DIM graphics AS CGpGraphics = hdc

  ' // Get the DPI scaling ratio

  DIM rxRatio AS SINGLE = graphics.GetDpiX / 96

  DIM ryRatio AS SINGLE = graphics.GetDpiY / 96

  ' // Set the scale transform

  graphics.ScaleTransform(rxRatio, ryRatio)

 

  ' // Create a Pen object

  DIM blackPen AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 0, 0), 3)

 

  ' // Create an array of GpPoint objects that define the lines to draw

  DIM point1 AS GpPoint : point1.x = 100 : point1.y = 100

  DIM point2 AS GpPoint : point2.x = 200 : point2.y = 130

  DIM point3 AS GpPoint : point3.x = 150 : point3.y = 200

  DIM point4 AS GpPoint : point4.x =  50 : point4.y = 200

  DIM point5 AS GpPoint : point5.x =   0 : point5.y = 130

 

  DIM pts(0 TO 4) AS GpPoint

  pts(0) = point1

  pts(1) = point2

  pts(2) = point3

  pts(3) = point4

  pts(4) = point5

 

  ' // Draw the polygon

  graphics.DrawPolygon(@blackPen, @pts(0), 5)

 

END SUB

' ========================================================================================