GraphicsPath::AddPolygon(constPointF*,INT) 方法 (gdipluspath.h)

GraphicsPath::AddPolygon 方法會將多邊形新增至此路徑。

語法

Status AddPolygon(
  const PointF *points,
  INT          count
);

參數

points

指定多邊形頂點之點陣列的指標。

count

整數,指定點陣列中的項目數目。

傳回值

類型:狀態

如果方法成功,它會傳回Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其他元素之一。

言論

GraphicsPath::AddPolygon 方法類似於 addLines 方法 。 差別在於多邊形是內建封閉的圖形,但除非您呼叫 GraphicsPath::CloseFigure,否則線條序列不是封閉圖。 當 Windows GDI+ 轉譯路徑時,該路徑中的每個多邊形都會關閉;也就是說,多邊形的最後一個頂點會透過直線連接到第一個頂點。

例子

下列範例會建立 GraphicsPath 對象路徑、將多邊形新增至路徑,然後繪製路徑。

VOID Example_AddPolygon(HDC hdc)
{
   Graphics graphics(hdc);

   PointF pts[] = {PointF(20.0f, 20.0f),
                   PointF(120.0f, 20.0f),
                   PointF(120.0f, 70.0f)};

   GraphicsPath path;
   path.AddPolygon(pts, 3);

   // Draw the path.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawPath(&pen, &path);
}

要求

要求 價值
標頭 gdipluspath.h

另請參閱

AddPolygon 方法

使用區域 進行裁剪

建構和繪製路徑

建立路徑漸層

GraphicsPath

路徑

PointF

多邊形