1
- unit Img32.Clipper ;
1
+ unit Img32.Clipper2 ;
2
2
3
3
(* ******************************************************************************
4
4
* Author : Angus Johnson *
5
- * Version : 2.24 *
6
- * Date : 26 June 2021 *
5
+ * Version : 4.2 *
6
+ * Date : 30 May 2022 *
7
7
* Website : http://www.angusj.com *
8
- * Copyright : Angus Johnson 2019-2021 *
8
+ * Copyright : Angus Johnson 2019-2022 *
9
9
* Purpose : Wrapper module for the Clipper library *
10
10
* License : http://www.boost.org/LICENSE_1_0.txt *
11
11
*******************************************************************************)
12
12
13
13
interface
14
14
15
15
uses
16
- ClipperCore, Clipper, ClipperOffset,
17
16
Img32, Img32.Draw, Img32.Vector;
18
17
19
18
// nb: InflatePath assumes that there's consistent winding where
@@ -48,14 +47,16 @@ function DifferencePolygons(const polygons1, polygons2: TPathsD;
48
47
49
48
implementation
50
49
50
+ uses Clipper, Clipper.Core, Clipper.Engine, Clipper.Offset;
51
+
51
52
// ------------------------------------------------------------------------------
52
53
// ------------------------------------------------------------------------------
53
54
54
- function InflatePath (const path: TPathD;
55
+ function InflatePath (const path: Img32. TPathD;
55
56
delta: Double; joinStyle: TJoinStyle; endStyle: TEndStyle;
56
- miterLimit: double; arcTolerance: double; minEdgeLength: double): TPathsD;
57
+ miterLimit: double; arcTolerance: double; minEdgeLength: double): Img32. TPathsD;
57
58
var
58
- paths: TPathsD;
59
+ paths: Img32. TPathsD;
59
60
begin
60
61
setLength(paths, 1 );
61
62
paths[0 ] := path;
@@ -64,11 +65,11 @@ function InflatePath(const path: TPathD;
64
65
end ;
65
66
// ------------------------------------------------------------------------------
66
67
67
- function InflatePaths (const paths: TPathsD;
68
+ function InflatePaths (const paths: Img32. TPathsD;
68
69
delta: Double; joinStyle: TJoinStyle; endStyle: TEndStyle;
69
- miterLimit: double; arcTolerance: double; minEdgeLength: double): TPathsD;
70
+ miterLimit: double; arcTolerance: double; minEdgeLength: double): Img32. TPathsD;
70
71
var
71
- jt: ClipperOffset .TJoinType;
72
+ jt: Clipper.Offset .TJoinType;
72
73
et: TEndType;
73
74
begin
74
75
case joinStyle of
@@ -84,93 +85,93 @@ function InflatePaths(const paths: TPathsD;
84
85
esRound: et := etRound;
85
86
else et := etPolygon;
86
87
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));
90
90
end ;
91
91
// ------------------------------------------------------------------------------
92
92
93
- function UnionPolygon (const polygon: TPathD; fillRule: TFillRule): TPathsD;
93
+ function UnionPolygon (const polygon: Img32.TPathD;
94
+ fillRule: Img32.Vector.TFillRule): Img32.TPathsD;
94
95
begin
95
96
with TClipperD.Create do
96
97
try
97
- AddPath(ClipperCore .TPathD(polygon));
98
+ AddSubject(Clipper.Core .TPathD(polygon));
98
99
Execute(ctUnion,
99
- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
100
+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
100
101
finally
101
102
Free;
102
103
end ;
103
104
end ;
104
105
// ------------------------------------------------------------------------------
105
106
106
- function UnionPolygons (const polygons: TPathsD;
107
- fillRule: TFillRule): TPathsD;
107
+ function UnionPolygons (const polygons: Img32. TPathsD;
108
+ fillRule: Img32.Vector. TFillRule): Img32. TPathsD;
108
109
begin
109
110
with TClipperD.Create do
110
111
try
111
- AddPaths(ClipperCore .TPathsD(polygons));
112
+ AddSubject(Clipper.Core .TPathsD(polygons));
112
113
Execute(ctUnion,
113
- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
114
+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
114
115
finally
115
116
Free;
116
117
end ;
117
118
end ;
118
119
// ------------------------------------------------------------------------------
119
120
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;
122
123
begin
123
124
with TClipperD.Create do
124
125
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));
127
128
Execute(ctUnion,
128
- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
129
+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
129
130
finally
130
131
Free;
131
132
end ;
132
133
end ;
133
134
// ------------------------------------------------------------------------------
134
135
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;
137
138
begin
138
139
with TClipperD.Create do
139
140
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));
142
143
Execute(ctUnion,
143
- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
144
+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
144
145
finally
145
146
Free;
146
147
end ;
147
148
end ;
148
149
// ------------------------------------------------------------------------------
149
150
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;
152
153
begin
153
154
with TClipperD.Create do
154
155
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));
157
158
Execute(ctIntersection,
158
- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
159
+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
159
160
finally
160
161
Free;
161
162
end ;
162
163
end ;
163
164
// ------------------------------------------------------------------------------
164
165
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;
167
168
begin
168
169
with TClipperD.Create do
169
170
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));
172
173
Execute(ctDifference,
173
- ClipperCore. TFillRule(fillRule), ClipperCore .TPathsD(result));
174
+ Clipper.Core. TFillRule(fillRule), Clipper.Core .TPathsD(result));
174
175
finally
175
176
Free;
176
177
end ;
0 commit comments