Declaration
procedure PolygonD(Points: array of TDPoint);
Description
Draw a polygon specified by multiple points.
Note:
◼For a TPoint version use,
Polygon
◼For a polyline (polygon that is not closed), use
PolylineD
◼For advanced polygon drawing, use
AdvancedDrawPolyline
◼You can create multiple polygons by specifying a break of point($FFFFF, $FFFFF)
GDI+ Methods: GdipDrawPolygon, GdipFillPolygon
// Draw a filled 5-pointed star
var
pp: array[0..10] of TDPoint;
begin
ImageEnView1.IEBitmap.IECanvas.Pen.Color := clOrangeRed;
ImageEnView1.IEBitmap.IECanvas.Pen.Width := 3;
ImageEnView1.IEBitmap.IECanvas.Brush.Color := clYellow;
pp[0] := DPoint(175, 50);
pp[1] := DPoint(205, 145);
pp[2] := DPoint(300, 145);
pp[3] := DPoint(225, 205);
pp[4] := DPoint(252.5, 300);
pp[5] := DPoint(175, 242.5);
pp[6] := DPoint(97.5, 300);
pp[7] := DPoint(127.5, 205);
pp[8] := DPoint(50, 145);
pp[9] := DPoint(147.5, 145);
pp[10] := DPoint(175, 50);
ImageEnView1.IEBitmap.IECanvas.PolygonD(pp);
ImageEnView1.Update();
end;
// Method to draw a pointer arrow from LineX1,LineY1 to LineX2, LineY2
// IEDrawLineArrow( ImageEnView1.IEBitmap.IECanvas, 650, 680, 850, 780, 30, 30, clBlack, 2, clYellow );
// ImageEnView1.Update();
procedure IEDrawLineArrow(Canvas: TIECanvas; LineX1, LineY1, LineX2, LineY2: integer; ArrowW, ArrowH: integer;
BorderColor: TColor; BorderWidth: Integer; FillColor: TColor);
const
A90 = PI / 2;
var
aa, bb, hw: double;
pp: array[0..2] of TPoint;
p1x, p1y: integer;
begin
// Border
if ( BorderColor = clNone ) or ( BorderWidth < 1 ) then
Canvas.Pen.Style := psClear
else
Canvas.Pen.Style := psSolid;
Canvas.Pen.Color := BorderColor;
Canvas.Pen.Width := BorderWidth;
// Fill
if ( FillColor = clNone ) then
Canvas.Brush.Style := bsClear
else
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := FillColor;
Canvas.DrawLine( LineX1, LineY1, LineX2, LineY2 );
hw := ArrowW / 2;
aa := IEAngle( LineX1, LineY1, LineX2, LineY2, LineX1, LineY2 );
if LineX1 = LineX2 then
if LineY1 < LineY2 then
aa := -A90
else
aa := A90;
if ((LineX1 > LineX2) and (LineY2 < LineY1)) or ((LineX1 < LineX2) and (LineY1 < LineY2)) then
bb := 2 * pi - aa + A90
else
bb := aa + A90;
if ((LineX2 < LineX1) and (LineY2 > LineY1)) or ((LineX2 < LineX1) and (LineY2 < LineY1)) or ((LineX1 < LineX2) and (LineY1 = LineY2)) then
begin
p1x := LineX1 + trunc(cos(bb - A90) * ArrowH);
p1y := LineY1 + trunc(sin(bb - A90) * ArrowH);
end
else
begin
p1x := LineX1 + trunc(cos(bb + A90) * ArrowH);
p1y := LineY1 + trunc(sin(bb + A90) * ArrowH);
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 := LineX1;
pp[2].y := LineY1;
Canvas.Polygon(pp);
end;