Declaration
procedure PolylineD(Points: array of TDPoint; PolylineClosed: Boolean = False);
Description
Draw a series of joined lines specified by multiple points.
If PolylineClosed = True, then it performs a
PolygonD
Note:
◼For a TPoint version use,
Polyline
◼For advanced polygon drawing, use
AdvancedDrawPolyline
◼You can create multiple polylines by specifying a break of point($FFFFF, $FFFFF), or point($FFFEE, $FFFEE) if the break should close the polygon (i.e. with PolylineClosed=False, you can optionally close polylines)
GDI+ Method:
GdipDrawLines
// Draw a 5-pointed star
var
pp: array[0..10] of TDPoint;
begin
ImageEnView1.IEBitmap.IECanvas.Pen.Color := clOrangeRed;
ImageEnView1.IEBitmap.IECanvas.Pen.Width := 3;
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.PolylineD(pp);
ImageEnView1.Update();
end;
// Draw an arrow at the end of a line that runs from x1, y1 to x2, y2
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;
PolylineD(pp);
end;
end;