The startcap and endcap attributes are used to read and write the line caps of the two segments respectively. Test figure:
Startcap and endcap TestCode:
Uses gdiplus; Procedure tform1.formpaint (Sender: tobject); const caparr: array [0 .. 8] of byte = (0, 1, 2, 3, $10, $11, $12, $13, $14); var graphics: igpgraphics; pen: igppen; pt1, pt2: tgppoint; I: integer; begin pt1.initialize (20, 20); pt2.initialize (200, 20); graphics: = tgpgraphics. create (handle); pen: = tgppen. create ($ ff2e8b57, 11); for I: = 0 to length (caparr)-1 do begin pen. startcap: = tgplinecap (caparr [I]); pen. endcap: = pen. startcap; graphics. drawline (pen, pt1, pt2); graphics. translatetransform (0, pt1.y * 1.5); end;
The dashcap attribute is used to read and write the dotted line cap, which has no effect in the solid line. test diagram:
Dashcap test code:
Uses gdiplus; Procedure injection (Sender: tobject); var graphics: igpgraphics; pen: igppen; pt1, pt2: tgppoint; begin pt1.initialize (20, 20); pt2.initialize (240, 20); graphics: = tgpgraphics. create (handle); pen: = tgppen. create ($ ff4169e1, 11); pen. dashstyle: = dashstyledashdot; pen. dashcap: = dashcapflat; graphics. drawline (pen, pt1, pt2); graphics. translatetransform (0, pt1.y * 1.5); pen. dashcap: = dashcapround; graphics. drawline (pen, pt1, pt2); graphics. translatetransform (0, pt1.y * 1.5); pen. dashcap: = dashcaptriangle; graphics. drawline (pen, pt1, pt2); end;
You can use the setlinecap method to set startcap, endcap, and dashcap. The test diagram is as follows:
Setlinecap test code:
Uses gdiplus; Procedure tform1.formpaint (Sender: tobject); var graphics: igpgraphics; pen: igppen; begin graphics: = tgpgraphics. create (handle); pen: = tgppen. create ($ ffc71585, 11); pen. dashstyle: = dashstyledashdot; pen. setlinecap (linecaproundanchor, linecaparrowanchor, dashcaptriangle); graphics. drawline (pen, 20, 30,300, 30); end;