1- unit Img32.Clipper ;
1+ unit Img32.Clipper2 ;
22
33(* ******************************************************************************
44* Author : Angus Johnson *
5- * Version : 2.24 *
6- * Date : 26 June 2021 *
5+ * Version : 4.2 *
6+ * Date : 30 May 2022 *
77* Website : http://www.angusj.com *
8- * Copyright : Angus Johnson 2019-2021 *
8+ * Copyright : Angus Johnson 2019-2022 *
99* Purpose : Wrapper module for the Clipper library *
1010* License : http://www.boost.org/LICENSE_1_0.txt *
1111*******************************************************************************)
1212
1313interface
1414
1515uses
16- ClipperCore, Clipper, ClipperOffset,
1716 Img32, Img32.Draw, Img32.Vector;
1817
1918// nb: InflatePath assumes that there's consistent winding where
@@ -48,14 +47,16 @@ function DifferencePolygons(const polygons1, polygons2: TPathsD;
4847
4948implementation
5049
50+ uses Clipper, Clipper.Core, Clipper.Engine, Clipper.Offset;
51+
5152// ------------------------------------------------------------------------------
5253// ------------------------------------------------------------------------------
5354
54- function InflatePath (const path: TPathD;
55+ function InflatePath (const path: Img32. TPathD;
5556 delta: Double; joinStyle: TJoinStyle; endStyle: TEndStyle;
56- miterLimit: double; arcTolerance: double; minEdgeLength: double): TPathsD;
57+ miterLimit: double; arcTolerance: double; minEdgeLength: double): Img32. TPathsD;
5758var
58- paths: TPathsD;
59+ paths: Img32. TPathsD;
5960begin
6061 setLength(paths, 1 );
6162 paths[0 ] := path;
@@ -64,11 +65,11 @@ function InflatePath(const path: TPathD;
6465end ;
6566// ------------------------------------------------------------------------------
6667
67- function InflatePaths (const paths: TPathsD;
68+ function InflatePaths (const paths: Img32. TPathsD;
6869 delta: Double; joinStyle: TJoinStyle; endStyle: TEndStyle;
69- miterLimit: double; arcTolerance: double; minEdgeLength: double): TPathsD;
70+ miterLimit: double; arcTolerance: double; minEdgeLength: double): Img32. TPathsD;
7071var
71- jt: ClipperOffset .TJoinType;
72+ jt: Clipper.Offset .TJoinType;
7273 et: TEndType;
7374begin
7475 case joinStyle of
@@ -84,93 +85,93 @@ function InflatePaths(const paths: TPathsD;
8485 esRound: et := etRound;
8586 else et := etPolygon;
8687 end ;
87- Result := TPathsD(ClipperOffset.InflatePaths(
88- ClipperCore.TPathsD(paths), delta,
89- jt, et, miterLimit, arcTolerance, minEdgeLength));
88+ Result := Img32.TPathsD(Clipper.InflatePaths(
89+ Clipper.Core.TPathsD(paths), delta, jt, et));
9090end ;
9191// ------------------------------------------------------------------------------
9292
93- function UnionPolygon (const polygon: TPathD; fillRule: TFillRule): TPathsD;
93+ function UnionPolygon (const polygon: Img32.TPathD;
94+ fillRule: Img32.Vector.TFillRule): Img32.TPathsD;
9495begin
9596 with TClipperD.Create do
9697 try
97- AddPath(ClipperCore .TPathD(polygon));
98+ AddSubject(Clipper.Core .TPathD(polygon));
9899 Execute(ctUnion,
99- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
100+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
100101 finally
101102 Free;
102103 end ;
103104end ;
104105// ------------------------------------------------------------------------------
105106
106- function UnionPolygons (const polygons: TPathsD;
107- fillRule: TFillRule): TPathsD;
107+ function UnionPolygons (const polygons: Img32. TPathsD;
108+ fillRule: Img32.Vector. TFillRule): Img32. TPathsD;
108109begin
109110 with TClipperD.Create do
110111 try
111- AddPaths(ClipperCore .TPathsD(polygons));
112+ AddSubject(Clipper.Core .TPathsD(polygons));
112113 Execute(ctUnion,
113- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
114+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
114115 finally
115116 Free;
116117 end ;
117118end ;
118119// ------------------------------------------------------------------------------
119120
120- function UnionPolygons (const polygon1, polygon2: TPathD;
121- fillRule: TFillRule): TPathsD;
121+ function UnionPolygons (const polygon1, polygon2: Img32. TPathD;
122+ fillRule: Img32.Vector. TFillRule): Img32. TPathsD;
122123begin
123124 with TClipperD.Create do
124125 try
125- AddPath(ClipperCore. TPathD(polygon1), ptSubject );
126- AddPath(ClipperCore. TPathD(polygon2), ptClip );
126+ AddSubject(Clipper.Core. TPathD(polygon1));
127+ AddClip(Clipper.Core. TPathD(polygon2));
127128 Execute(ctUnion,
128- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
129+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
129130 finally
130131 Free;
131132 end ;
132133end ;
133134// ------------------------------------------------------------------------------
134135
135- function UnionPolygons (const polygons1, polygons2: TPathsD;
136- fillRule: TFillRule): TPathsD;
136+ function UnionPolygons (const polygons1, polygons2: Img32. TPathsD;
137+ fillRule: Img32.Vector. TFillRule): Img32. TPathsD;
137138begin
138139 with TClipperD.Create do
139140 try
140- AddPaths(ClipperCore. TPathsD(polygons1), ptSubject );
141- AddPaths(ClipperCore. TPathsD(polygons2), ptClip );
141+ AddSubject(Clipper.Core. TPathsD(polygons1));
142+ AddClip(Clipper.Core. TPathsD(polygons2));
142143 Execute(ctUnion,
143- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
144+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
144145 finally
145146 Free;
146147 end ;
147148end ;
148149// ------------------------------------------------------------------------------
149150
150- function IntersectPolygons (const polygons1, polygons2: TPathsD;
151- fillRule: TFillRule): TPathsD;
151+ function IntersectPolygons (const polygons1, polygons2: Img32. TPathsD;
152+ fillRule: Img32.Vector. TFillRule): Img32. TPathsD;
152153begin
153154 with TClipperD.Create do
154155 try
155- AddPaths(ClipperCore. TPathsD(polygons1), ptSubject );
156- AddPaths(ClipperCore. TPathsD(polygons2), ptClip );
156+ AddSubject(Clipper.Core. TPathsD(polygons1));
157+ AddClip(Clipper.Core. TPathsD(polygons2));
157158 Execute(ctIntersection,
158- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
159+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
159160 finally
160161 Free;
161162 end ;
162163end ;
163164// ------------------------------------------------------------------------------
164165
165- function DifferencePolygons (const polygons1, polygons2: TPathsD;
166- fillRule: TFillRule): TPathsD;
166+ function DifferencePolygons (const polygons1, polygons2: Img32. TPathsD;
167+ fillRule: Img32.Vector. TFillRule): Img32. TPathsD;
167168begin
168169 with TClipperD.Create do
169170 try
170- AddPaths(ClipperCore. TPathsD(polygons1), ptSubject );
171- AddPaths(ClipperCore. TPathsD(polygons2), ptClip );
171+ AddSubject(Clipper.Core. TPathsD(polygons1));
172+ AddClip(Clipper.Core. TPathsD(polygons2));
172173 Execute(ctDifference,
173- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
174+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
174175 finally
175176 Free;
176177 end ;
0 commit comments