ImageEn, unit iegdiplus

# TIECanvas.Polygon

### TIECanvas.Polygon

#### Declaration

procedure Polygon(Points: array of TPoint); overload;
procedure Polygon(Points: array of TPoint; PointCount: Integer); overload;

#### Description

Draw a polygon specified by multiple points.

Note:
For a double version use, PolygonD
For a polyline (polygon that is not closed), use Polyline

GDI+ Methods: GdipDrawPolygonI, GdipFillPolygonI

#### Example

// Draw an arrow at the end of a line that runs from x1, y1 to x2, y2
// brush and color must be already set
procedure IEDrawLineArrow(Canvas: TIECanvas; x1, y1, x2, y2: integer; w, h: integer);
const
A90 = PI / 2;
var
aa, bb, hw: double;
pp: array[0..2] of TPoint;
p1x, p1y: integer;
begin
with Canvas do
begin
hw := w / 2;
aa := IEAngle(x1, y1, x2, y2, x1, y2);
if x1 = x2 then
if y1 < y2 then
aa := -A90
else
aa := A90;
if ((x1 > x2) and (y2 < y1)) or ((x1 < x2) and (y1 < y2)) then
bb := 2 * pi - aa + A90
else
bb := aa + A90;
if ((x2 < x1) and (y2 > y1)) or ((x2 < x1) and (y2 < y1)) or ((x1 < x2) and (y1 = y2)) then
begin
p1x := x1 + trunc(cos(bb - A90) * h);
p1y := y1 + trunc(sin(bb - A90) * h);
end
else
begin
p1x := x1 + trunc(cos(bb + A90) * h);
p1y := y1 + trunc(sin(bb + A90) * h);
end;

pp[0].x := p1x + trunc(cos(bb) * hw);
pp[0].y := p1y + trunc(sin(bb) * hw);
pp[1].x := p1x + trunc(cos(bb + pi) * hw);
pp[1].y := p1y + trunc(sin(bb + pi) * hw);
pp[2].x := x1;
pp[2].y := y1;

Polygon(pp);
end;
end;