Igpgraphicspath. setmarker // create a flag igpgraphicspath. clearmarkers // cancel all tags
You can create a marker at the same time for every image created in the path,
When these tags are actually used, the nextmarker () method of igpgraphicspathiterator is used.
The following is an example of creating and traversing a marker.CodeIgpgraphicspathiterator is not used.
Uses gdiplus; Procedure submit (Sender: tobject); var pt1, pt2: tgppoint; rect: tgprect; Path: igpgraphicspath; I: integer; STR: string; begin pt1.initialize (20, 20); pt2.initialize (150,150); rect. initializefromltrb (pt1.x, pt1.y, pt2.x, pt2.y); Path: = tgpgraphicspath. create; {the path consists of four graphs (or sub-paths), and a marker is created after each graph. The first graph does not need to be created .} path. addrectangle (rect); Path. setmarker; Path. addellipse (rect); Path. setmarker; Path. addline (pt1.x, pt1.y, pt2.x, pt2.y); Path. setmarker; Path. addline (pt1.x, pt2.y, pt2.x, pt1.y); Path. setmarker; {search to see which point has marker. Its Type ID is $20} STR: = ''; for I: = 0 to path. pointcount-1 do if path. pathtypes [I] And $20 = $20 then STR: = STR + inttostr (I + 1) + ''; showmessage (trimright (STR )); // 4 17 19 21 {execute clearmarkers and re-search to see} path. clearmarkers; STR: = ''; for I: = 0 to path. pointcount-1 do if path. pathtypes [I] And $20 = $20 then STR: = STR + inttostr (I + 1) + ''; showmessage (trimright (STR )); // Of course there will be no end;
An example of retrieving a marker using igpgraphicspathiterator:
Uses gdiplus; var path: igpgraphicspath; pathiterator: gradient; Procedure gradient (Sender: tobject); var pt1, pt2: tgppoint; rect: tgprect; begin pt1.initialize (20, 20 ); pt2.initialize (150,150); rect. initializefromltrb (pt1.x, pt1.y, pt2.x, pt2.y); Path: = tgpgraphicspath. create; // create four images and add two marked paths. addrectangle (rect); Path. setmarker; Path. addellipse (rect); Path. addline (pt1.x, Pt1.y, pt2.x, pt2.y); Path. setmarker; Path. addline (pt1.x, pt2.y, pt2.x, pt1.y); // create a pathiterator: = tgpgraphicspathiterator. create (PATH); end; Procedure tform1.button1click (Sender: tobject); var M1, M2: integer; I: integer; begin I: = 0; pathiterator. rewind; while pathiterator. nextmarker (M1, M2)> 0 do begin Inc (I); showmessagefmt ('% D-% d tag range: % d-% d', [I-1, i, M1, M2]); end; {0th -1 mark range: 0-3 1st-2 Mark range: 4-18 2nd-3 mark range: 19-20} // how can I retrieve three ranges by adding two tags? The two points divide the path into three sections! End; // igpgraphicspathiterator. the second method of nextmarker procedure tform1.button2click (Sender: tobject); var I, R: integer; begin I: = 0; pathiterator. rewind; While true do Begin R: = pathiterator. nextmarker (PATH); if r = 0 Then break; Inc (I); showmessagefmt ('% d-% d between signs % d vertices', [I-1, i, R]); end; {0th-1 tags have 4 points in total. 1st-2 tags have 15 points in total. 2nd-3 tags have 2 points in total.} end;