Debian Codegraph @

texmf-dist/tex/latex/spath3/spath3.sty

raw
1 %%
2 %% This is file `spath3.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% spath3_code.dtx (with options: `spath3')
8 %% ----------------------------------------------------------------
9 %% spath3 --- Functions for manipulating PGF soft paths
10 %% E-mail: Andrew Stacey <[email protected]>
11 %% Released under the LaTeX Project Public License v1.3c or later
12 %% See http://www.latex-project.org/lppl.txt
13 %% ----------------------------------------------------------------
14 %%
15 \NeedsTeXFormat{LaTeX2e}
16 \RequirePackage{expl3}
17 \RequirePackage{pgf}
18 \ProvidesExplPackage {spath3} {2024/05/31} {2.8} {Functions for
19 manipulating PGF soft paths}
20 \RequirePackage{xparse}
21 \cs_new_protected:Nn \__spath_tl_put_right_braced:Nn
22 {
23 \tl_put_right:Nn #1 { { #2 } }
24 }
25 \cs_generate_variant:Nn \__spath_tl_put_right_braced:Nn { NV, cV, cv, Nx, cx }
26
27 \cs_new_protected:Nn \__spath_tl_gput_right_braced:Nn
28 {
29 \tl_gput_right:Nn #1 { { #2 } }
30 }
31 \cs_generate_variant:Nn \__spath_tl_gput_right_braced:Nn { NV, cV, cv, Nx, cx }
32 \cs_new_protected:Nn \__spath_tl_put_left_braced:Nn
33 {
34 \tl_put_left:Nn #1 { { #2 } }
35 }
36 \cs_generate_variant:Nn \__spath_tl_put_left_braced:Nn { NV, cV, cv, Nx, cx }
37
38 \cs_new_protected:Nn \__spath_tl_gput_left_braced:Nn
39 {
40 \tl_gput_left:Nn #1 { { #2 } }
41 }
42 \cs_generate_variant:Nn \__spath_tl_gput_left_braced:Nn { NV, cV, cv, Nx, cx }
43 \tl_new:N \g__spath_output_tl
44 \int_new:N \g__spath_output_int
45 \seq_new:N \g__spath_output_seq
46 \bool_new:N \g__spath_output_bool
47 \tl_new:N \l__spath_tmpa_tl
48 \tl_new:N \l__spath_tmpb_tl
49 \tl_new:N \l__spath_tmpc_tl
50 \tl_new:N \l__spath_tmpd_tl
51 \tl_new:N \l__spath_tmpe_tl
52 \tl_new:N \l__spath_tmpf_tl
53 \tl_new:N \l__spath_tmpg_tl
54 \tl_new:N \l__spath_tmph_tl
55 \tl_new:N \l__spath_tmpi_tl
56
57 \seq_new:N \l__spath_tmpa_seq
58 \seq_new:N \l__spath_tmpb_seq
59 \seq_new:N \l__spath_tmpc_seq
60
61 \dim_new:N \l__spath_tmpa_dim
62 \dim_new:N \l__spath_tmpb_dim
63
64 \fp_new:N \l__spath_tmpa_fp
65 \fp_new:N \l__spath_tmpb_fp
66 \fp_new:N \l__spath_tmpc_fp
67 \fp_new:N \l__spath_tmpd_fp
68 \fp_new:N \l__spath_tmpe_fp
69 \fp_new:N \l__spath_tmpf_fp
70
71 \int_new:N \l__spath_tmpa_int
72 \int_new:N \l__spath_tmpb_int
73
74 \bool_new:N \l__spath_tmpa_bool
75 \dim_new:N \l__spath_move_x_dim
76 \dim_new:N \l__spath_move_y_dim
77 \bool_new:N \l__spath_closed_bool
78 \dim_new:N \l__spath_rectx_dim
79 \dim_new:N \l__spath_recty_dim
80
81 \bool_new:N \l__spath_rect_bool
82 \bool_new:N \l_spath_movetorelevant_bool
83 \bool_new:N \l_spath_arrow_shortening_bool
84 \bool_set_true:N \l_spath_arrow_shortening_bool
85 \tl_new:N \l__spath_intersecta_tl
86 \tl_new:N \l__spath_intersectb_tl
87 \tl_const:Nn \c_spath_moveto_tl {\pgfsyssoftpath@movetotoken}
88 \tl_const:Nn \c_spath_lineto_tl {\pgfsyssoftpath@linetotoken}
89 \tl_const:Nn \c_spath_curveto_tl {\pgfsyssoftpath@curvetotoken}
90 \tl_const:Nn \c_spath_curvetoa_tl {\pgfsyssoftpath@curvetosupportatoken}
91 \tl_const:Nn \c_spath_curvetob_tl {\pgfsyssoftpath@curvetosupportbtoken}
92 \tl_const:Nn \c_spath_closepath_tl {\pgfsyssoftpath@closepathtoken}
93 \tl_const:Nn \c_spath_rectcorner_tl {\pgfsyssoftpath@rectcornertoken}
94 \tl_const:Nn \c_spath_rectsize_tl {\pgfsyssoftpath@rectsizetoken}
95 \int_new:N \g__spath_anon_int
96 \int_gzero:N \g__spath_anon_int
97 \cs_new_protected_nopar:Npn \spath_anonymous:N #1
98 {
99 \tl_set:Nx #1 {anonymous_\int_use:N \g__spath_anon_int}
100 \int_gincr:N \g__spath_anon_int
101 }
102 \cs_new_protected_nopar:Npn \spath_ganonymous:N #1
103 {
104 \tl_gset:Nx #1 {anonymous_\int_use:N \g__spath_anon_int}
105 \int_gincr:N \g__spath_anon_int
106 }
107 \cs_generate_variant:Nn \spath_anonymous:N {c}
108 \cs_generate_variant:Nn \spath_ganonymous:N {c}
109 \msg_new:nnn { spath3 } { unknown path construction }
110 { The~ path~ construction~ element~ #1~ is~ not~ currently~ supported.}
111 \cs_new_protected_nopar:Npn \__spath_segments_to_seq:n #1
112 {
113 \group_begin:
114 \tl_set:Nn \l__spath_tmpa_tl {#1}
115 \tl_clear:N \l__spath_tmpb_tl
116 \seq_clear:N \l__spath_tmpa_seq
117 \dim_zero:N \l__spath_tmpa_dim
118 \dim_zero:N \l__spath_tmpb_dim
119
120 \bool_until_do:nn {
121 \tl_if_empty_p:N \l__spath_tmpa_tl
122 }
123 {
124 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
125 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
126 \token_case_meaning:NnF \l__spath_tmpc_tl
127 {
128 \c_spath_moveto_tl
129 {
130 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_moveto_tl
131 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
132 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
133 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
134
135 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
136 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
137 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
138
139 \tl_set:Nx \l__spath_tmpd_tl {\tl_head:N \l__spath_tmpa_tl}
140 \tl_if_eq:NNF \l__spath_tmpd_tl \c_spath_moveto_tl
141 {
142 \tl_clear:N \l__spath_tmpb_tl
143 }
144
145 }
146
147 \c_spath_lineto_tl
148 {
149 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_moveto_tl
150 \tl_put_right:Nx \l__spath_tmpb_tl
151 {
152 {\dim_use:N \l__spath_tmpa_dim}
153 {\dim_use:N \l__spath_tmpb_dim}
154 }
155 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_lineto_tl
156
157 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
158 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
159 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
160
161 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
162 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
163 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
164
165 }
166
167 \c_spath_curvetoa_tl
168 {
169 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_moveto_tl
170 \tl_put_right:Nx \l__spath_tmpb_tl
171 {
172 {\dim_use:N \l__spath_tmpa_dim}
173 {\dim_use:N \l__spath_tmpb_dim}
174 }
175 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_curvetoa_tl
176
177 \prg_replicate:nn {2} {
178 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
179 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
180 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
181 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
182 \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
183 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
184 }
185
186 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
187 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
188 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
189
190 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
191 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
192 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
193
194 }
195
196 \c_spath_rectcorner_tl
197 {
198 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_rectcorner_tl
199
200 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
201 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
202 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
203 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
204 \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
205 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
206
207 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
208 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
209 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
210
211 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
212 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
213 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
214
215 }
216
217 \c_spath_closepath_tl
218 {
219 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_moveto_tl
220 \tl_put_right:Nx \l__spath_tmpb_tl
221 {
222 {\dim_use:N \l__spath_tmpa_dim}
223 {\dim_use:N \l__spath_tmpb_dim}
224 }
225 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_lineto_tl
226
227 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
228 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
229 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
230
231 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
232 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
233 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
234
235 }
236
237 }
238 {
239
240 \tl_set_eq:NN \l__spath_tmpb_tl \l__spath_tmpc_tl
241 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
242 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
243 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
244
245 \tl_put_right:Nx \l__spath_tmpb_tl {{\tl_head:N \l__spath_tmpa_tl}}
246 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
247 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
248
249 }
250
251 \tl_if_empty:NF \l__spath_tmpb_tl
252 {
253 \seq_put_right:NV \l__spath_tmpa_seq \l__spath_tmpb_tl
254 }
255 \tl_clear:N \l__spath_tmpb_tl
256 }
257
258 \seq_gclear:N \g__spath_output_seq
259 \seq_gset_eq:NN \g__spath_output_seq \l__spath_tmpa_seq
260 \group_end:
261 }
262 \cs_new_protected_nopar:Npn \spath_segments_to_seq:Nn #1#2
263 {
264 \__spath_segments_to_seq:n {#2}
265 \seq_clear_new:N #1
266 \seq_set_eq:NN #1 \g__spath_output_seq
267 \seq_gclear:N \g__spath_output_seq
268 }
269 \cs_generate_variant:Nn \spath_segments_to_seq:Nn {NV, cn, cV, Nv, cv}
270 \cs_new_protected_nopar:Npn \spath_segments_gto_seq:Nn #1#2
271 {
272 \__spath_segments_to_seq:n {#2}
273 \seq_clear_new:N #1
274 \seq_gset_eq:NN #1 \g__spath_output_seq
275 \seq_gclear:N \g__spath_output_seq
276 }
277 \cs_generate_variant:Nn \spath_segments_gto_seq:Nn {NV, cn, cV, Nv, cv}
278 \cs_new_protected_nopar:Npn \__spath_components_to_seq:n #1
279 {
280 \group_begin:
281 \tl_set:Nn \l__spath_tmpa_tl {#1}
282 \seq_clear:N \l__spath_tmpa_seq
283 \tl_set:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
284 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
285
286 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_moveto_tl
287
288 \bool_do_until:nn {
289 \tl_if_empty_p:N \l__spath_tmpa_tl
290 }
291 {
292 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
293 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_moveto_tl
294 {
295 \seq_put_right:NV \l__spath_tmpa_seq \l__spath_tmpb_tl
296 \tl_clear:N \l__spath_tmpb_tl
297 }
298 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
299 {
300 \seq_put_right:NV \l__spath_tmpa_seq \l__spath_tmpb_tl
301 \tl_clear:N \l__spath_tmpb_tl
302 }
303 \tl_if_single:NTF \l__spath_tmpc_tl
304 {
305 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
306 }
307 {
308 \tl_put_right:Nx \l__spath_tmpb_tl {{\l__spath_tmpc_tl}}
309 }
310 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
311 }
312
313 \seq_gclear:N \g__spath_output_seq
314 \seq_gset_eq:NN \g__spath_output_seq \l__spath_tmpa_seq
315 \group_end:
316 }
317 \cs_new_protected_nopar:Npn \spath_components_to_seq:Nn #1#2
318 {
319 \__spath_components_to_seq:n {#2}
320 \seq_clear_new:N #1
321 \seq_set_eq:NN #1 \g__spath_output_seq
322 \seq_gclear:N \g__spath_output_seq
323 }
324 \cs_generate_variant:Nn \spath_components_to_seq:Nn {NV, cn, cV, cv, Nv}
325 \cs_new_protected_nopar:Npn \spath_components_gto_seq:Nn #1#2
326 {
327 \__spath_components_to_seq:n {#2}
328 \seq_clear_new:N #1
329 \seq_gset_eq:NN #1 \g__spath_output_seq
330 \seq_gclear:N \g__spath_output_seq
331 }
332 \cs_generate_variant:Nn \spath_components_gto_seq:Nn {NV, cn, cV, cv, Nv}
333 \cs_new_protected_nopar:Npn \spath_components_to_clist:Nn #1#2
334 {
335 \__spath_components_to_seq:n {#2}
336 \clist_clear_new:N #1
337 \clist_set_from_seq:NN #1 \g__spath_output_seq
338 \seq_gclear:N \g__spath_output_seq
339 }
340 \cs_generate_variant:Nn \spath_components_to_clist:Nn {NV, cn, cV, cv, Nv}
341 \cs_new_protected_nopar:Npn \spath_components_gto_clist:Nn #1#2
342 {
343 \__spath_components_to_seq:n {#2}
344 \clist_clear_new:N #1
345 \clist_gset_from_seq:NN #1 \g__spath_output_seq
346 \seq_gclear:N \g__spath_output_seq
347 }
348 \cs_generate_variant:Nn \spath_components_gto_clist:Nn {NV, cn, cV, cv, Nv}
349 \cs_new_protected_nopar:Npn \spath_length:n #1
350 {
351 \int_eval:n {\tl_count:n {#1} / 3}
352 }
353 \cs_generate_variant:Nn \spath_length:n {V}
354 \cs_new_protected_nopar:Npn \__spath_reallength:n #1
355 {
356 \group_begin:
357 \int_set:Nn \l__spath_tmpa_int {0}
358 \tl_map_inline:nn {#1} {
359 \tl_set:Nn \l__spath_tmpa_tl {##1}
360 \token_case_meaning:NnT \l__spath_tmpa_tl
361 {
362 \c_spath_lineto_tl {}
363 \c_spath_curveto_tl {}
364 \c_spath_closepath_tl {}
365 \c_spath_rectsize_tl {}
366 }
367 {
368 \int_incr:N \l__spath_tmpa_int
369 }
370 }
371 \int_gzero:N \g__spath_output_int
372 \int_gset_eq:NN \g__spath_output_int \l__spath_tmpa_int
373 \group_end:
374 }
375 \cs_new_protected_nopar:Npn \spath_reallength:Nn #1#2
376 {
377 \__spath_reallength:n {#2}
378 \int_set_eq:NN #1 \g__spath_output_int
379 \int_gzero:N \g__spath_output_int
380 }
381 \cs_generate_variant:Nn \spath_reallength:Nn {NV, cn, cV, Nv, cv}
382 \cs_new_protected_nopar:Npn \spath_greallength:Nn #1#2
383 {
384 \__spath_reallength:n {#2}
385 \int_gset_eq:NN #1 \g__spath_output_int
386 \int_gzero:N \g__spath_output_int
387 }
388 \cs_generate_variant:Nn \spath_greallength:Nn {NV, cn, cV}
389 \cs_new_protected_nopar:Npn \__spath_numberofcomponents:n #1
390 {
391 \group_begin:
392 \int_set:Nn \l__spath_tmpa_int {0}
393 \tl_map_inline:nn {#1} {
394 \tl_set:Nn \l__spath_tmpa_tl {##1}
395 \token_case_meaning:Nn \l__spath_tmpa_tl
396 {
397 \c_spath_moveto_tl
398 {
399 \int_incr:N \l__spath_tmpa_int
400 }
401 \c_spath_rectcorner_tl
402 {
403 \int_incr:N \l__spath_tmpa_int
404 }
405 }
406 }
407 \int_gzero:N \g__spath_output_int
408 \int_gset_eq:NN \g__spath_output_int \l__spath_tmpa_int
409 \group_end:
410 }
411 \cs_new_protected_nopar:Npn \spath_numberofcomponents:Nn #1#2
412 {
413 \__spath_numberofcomponents:n {#2}
414 \int_set_eq:NN #1 \g__spath_output_int
415 \int_gzero:N \g__spath_output_int
416 }
417 \cs_generate_variant:Nn \spath_numberofcomponents:Nn {NV, cn, cV, Nv}
418 \cs_new_protected_nopar:Npn \spath_gnumberofcomponents:Nn #1#2
419 {
420 \__spath_numberofcomponents:n {#2}
421 \int_gset_eq:NN #1 \g__spath_output_int
422 \int_gzero:N \g__spath_output_int
423 }
424 \cs_generate_variant:Nn \spath_gnumberofcomponents:Nn {NV, cn, cV, Nv}
425 \cs_new_protected_nopar:Npn \__spath_initialpoint:n #1
426 {
427 \group_begin:
428 \tl_clear:N \l__spath_tmpa_tl
429 \tl_set:Nx \l__spath_tmpa_tl
430 {
431 { \tl_item:nn {#1} {2} }
432 { \tl_item:nn {#1} {3} }
433 }
434 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
435 \group_end:
436 }
437 \cs_new_protected_nopar:Npn \spath_initialpoint:Nn #1#2
438 {
439 \__spath_initialpoint:n {#2}
440 \tl_set_eq:NN #1 \g__spath_output_tl
441 \tl_gclear:N \g__spath_output_tl
442 }
443 \cs_generate_variant:Nn \spath_initialpoint:Nn {NV, cn, cV, Nv}
444 \cs_new_protected_nopar:Npn \spath_ginitialpoint:Nn #1#2
445 {
446 \__spath_initialpoint:n {#2}
447 \tl_gset_eq:NN #1 \g__spath_output_tl
448 \tl_gclear:N \g__spath_output_tl
449 }
450 \cs_generate_variant:Nn \spath_ginitialpoint:Nn {NV, cn, cV, Nv}
451 \cs_new_protected_nopar:Npn \__spath_finalpoint:n #1
452 {
453 \group_begin:
454 \tl_set:Nn \l__spath_tmpa_tl {#1}
455 \tl_reverse:N \l__spath_tmpa_tl
456 \tl_clear:N \l__spath_tmpb_tl
457 \tl_set:Nx \l__spath_tmpc_tl {\tl_item:Nn \l__spath_tmpa_tl {3}}
458 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_rectsize_tl
459 {
460 \tl_set:Nx \l__spath_tmpb_tl
461 {
462 {
463 \dim_eval:n
464 {
465 \tl_item:Nn \l__spath_tmpa_tl {2}
466 +
467 \tl_item:Nn \l__spath_tmpa_tl {5}
468 }
469 }
470 {
471 \dim_eval:n
472 {
473 \tl_item:Nn \l__spath_tmpa_tl {1}
474 +
475 \tl_item:Nn \l__spath_tmpa_tl {4}
476 }
477 }
478 }
479 }
480 {
481 \tl_set:Nx \l__spath_tmpb_tl
482 {
483 { \tl_item:Nn \l__spath_tmpa_tl {2} }
484 { \tl_item:Nn \l__spath_tmpa_tl {1} }
485 }
486 }
487 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
488 \group_end:
489 }
490 \cs_new_protected_nopar:Npn \spath_finalpoint:Nn #1#2
491 {
492 \__spath_finalpoint:n {#2}
493 \tl_set_eq:NN #1 \g__spath_output_tl
494 \tl_gclear:N \g__spath_output_tl
495 }
496 \cs_generate_variant:Nn \spath_finalpoint:Nn {NV, cn, cV, Nv}
497 \cs_new_protected_nopar:Npn \spath_gfinalpoint:Nn #1#2
498 {
499 \__spath_finalpoint:n {#2}
500 \tl_gset_eq:NN #1 \g__spath_output_tl
501 \tl_gclear:N \g__spath_output_tl
502 }
503 \cs_generate_variant:Nn \spath_gfinalpoint:Nn {NV, cn, cV, Nv}
504 \cs_new_protected_nopar:Npn \__spath_finalmovepoint:n #1
505 {
506 \group_begin:
507 \tl_set:Nn \l__spath_tmpc_tl { {0pt} {0pt} }
508 \tl_set:Nn \l__spath_tmpa_tl {#1}
509 \bool_do_until:nn
510 {
511 \tl_if_empty_p:N \l__spath_tmpa_tl
512 }
513 {
514 \tl_set:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
515 \token_case_meaning:Nn \l__spath_tmpb_tl
516 {
517 \c_spath_moveto_tl
518 {
519 \tl_set:Nx \l__spath_tmpc_tl
520 {
521 { \tl_item:Nn \l__spath_tmpa_tl {2} }
522 { \tl_item:Nn \l__spath_tmpa_tl {3} }
523 }
524 }
525
526 \c_spath_rectcorner_tl
527 {
528 \tl_set:Nx \l__spath_tmpc_tl
529 {
530 { \tl_item:Nn \l__spath_tmpa_tl {2} }
531 { \tl_item:Nn \l__spath_tmpa_tl {3} }
532 }
533 }
534
535 }
536 \prg_replicate:nn {3}
537 {
538 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
539 }
540 }
541 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpc_tl
542 \group_end:
543 }
544 \cs_new_protected_nopar:Npn \spath_finalmovepoint:Nn #1#2
545 {
546 \__spath_finalmovepoint:n {#2}
547 \tl_set_eq:NN #1 \g__spath_output_tl
548 \tl_gclear:N \g__spath_output_tl
549 }
550 \cs_generate_variant:Nn \spath_finalmovepoint:Nn {NV, cn, cV}
551 \cs_new_protected_nopar:Npn \spath_gfinalmovepoint:Nn #1#2
552 {
553 \__spath_finalmovepoint:n {#2}
554 \tl_gset_eq:NN #1 \g__spath_output_tl
555 \tl_gclear:N \g__spath_output_tl
556 }
557 \cs_generate_variant:Nn \spath_gfinalmovepoint:Nn {NV, cn, cV}
558 \cs_new_protected_nopar:Npn \__spath_initialtangent:n #1
559 {
560 \group_begin:
561 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:nn {#1} {4}}
562 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_curvetoa_tl
563 {
564 \fp_set:Nn \l__spath_tmpa_fp {3}
565 }
566 {
567 \fp_set:Nn \l__spath_tmpa_fp {1}
568 }
569 \tl_clear:N \l__spath_tmpa_tl
570 \tl_set:Nx \l__spath_tmpa_tl
571 {
572 {
573 \fp_to_dim:n {
574 \l__spath_tmpa_fp
575 *
576 (
577 \tl_item:nn {#1} {5}
578 -
579 \tl_item:nn {#1} {2}
580 )
581 }
582 }
583 {
584 \fp_to_dim:n {
585 \l__spath_tmpa_fp
586 *
587 (
588 \tl_item:nn {#1} {6}
589 -
590 \tl_item:nn {#1} {3}
591 )
592 }
593 }
594 }
595 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
596 \group_end:
597 }
598 \cs_new_protected_nopar:Npn \spath_initialtangent:Nn #1#2
599 {
600 \__spath_initialtangent:n {#2}
601 \tl_set_eq:NN #1 \g__spath_output_tl
602 \tl_gclear:N \g__spath_output_tl
603 }
604 \cs_generate_variant:Nn \spath_initialtangent:Nn {NV, cn, cV, Nv}
605 \cs_new_protected_nopar:Npn \spath_ginitialtangent:Nn #1#2
606 {
607 \__spath_initialtangent:n {#2}
608 \tl_gset_eq:NN #1 \g__spath_output_tl
609 \tl_gclear:N \g__spath_output_tl
610 }
611 \cs_generate_variant:Nn \spath_ginitialtangent:Nn {NV, cn, cV, Nv}
612 \cs_new_protected_nopar:Npn \__spath_finaltangent:n #1
613 {
614 \group_begin:
615 \tl_set:Nn \l__spath_tmpa_tl {#1}
616 \tl_reverse:N \l__spath_tmpa_tl
617 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:nn {#1} {6}}
618 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_curveto_tl
619 {
620 \fp_set:Nn \l__spath_tmpa_fp {3}
621 }
622 {
623 \fp_set:Nn \l__spath_tmpa_fp {1}
624 }
625 \tl_clear:N \l__spath_tmpb_tl
626 \tl_set:Nx \l__spath_tmpb_tl
627 {
628 {
629 \fp_to_dim:n {
630 \l__spath_tmpa_fp
631 *
632 (
633 \tl_item:Nn \l__spath_tmpa_tl {2}
634 -
635 \tl_item:Nn \l__spath_tmpa_tl {5}
636 )
637 }
638 }
639 {
640 \fp_to_dim:n {
641 \l__spath_tmpa_fp
642 *
643 (
644 \tl_item:Nn \l__spath_tmpa_tl {1}
645 -
646 \tl_item:Nn \l__spath_tmpa_tl {4}
647 )
648 }
649 }
650 }
651 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
652 \group_end:
653 }
654 \cs_new_protected_nopar:Npn \spath_finaltangent:Nn #1#2
655 {
656 \__spath_finaltangent:n {#2}
657 \tl_set_eq:NN #1 \g__spath_output_tl
658 \tl_gclear:N \g__spath_output_tl
659 }
660 \cs_generate_variant:Nn \spath_finaltangent:Nn {NV, cn, cV, Nv}
661 \cs_new_protected_nopar:Npn \spath_gfinaltangent:Nn #1#2
662 {
663 \__spath_finaltangent:n {#2}
664 \tl_gset_eq:NN #1 \g__spath_output_tl
665 \tl_gclear:N \g__spath_output_tl
666 }
667 \cs_generate_variant:Nn \spath_gfinaltangent:Nn {NV, cn, cV, Nv}
668 \cs_new_protected_nopar:Npn \__spath_finalmovetangent:n #1
669 {
670 \group_begin:
671 \tl_set:Nn \l__spath_tmpc_tl { {0pt} {0pt} }
672 \tl_set:Nn \l__spath_tmpa_tl {#1}
673 \bool_do_until:nn
674 {
675 \tl_if_empty_p:N \l__spath_tmpa_tl
676 }
677 {
678 \tl_set:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
679 \token_case_meaning:Nn \l__spath_tmpb_tl
680 {
681 \c_spath_moveto_tl
682 {
683 \tl_set:Nx \l__spath_tmpd_tl { \tl_item:Nn \l__spath_tmpa_tl {4} }
684 \tl_if_eq:NNTF \l__spath_tmpd_tl \c_spath_curveto_tl
685 {
686 \fp_set:Nn \l__spath_tmpa_fp {3}
687 }
688 {
689 \fp_set:Nn \l__spath_tmpa_fp {1}
690 }
691 \tl_set:Nx \l__spath_tmpc_tl
692 {
693 {
694 \fp_to_dim:n
695 {
696 \l__spath_tmpa_fp
697 *
698 (
699 \tl_item:Nn \l__spath_tmpa_tl {5}
700 -
701 \tl_item:Nn \l__spath_tmpa_tl {2}
702 )
703 }
704 }
705 {
706 \fp_to_dim:n
707 {
708 \l__spath_tmpa_fp
709 *
710 (
711 \tl_item:Nn \l__spath_tmpa_tl {6}
712 -
713 \tl_item:Nn \l__spath_tmpa_tl {3}
714 )
715 }
716 }
717 }
718 }
719 }
720 \prg_replicate:nn {3}
721 {
722 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
723 }
724 }
725 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpc_tl
726 \group_end:
727 }
728 \cs_new_protected_nopar:Npn \spath_finalmovetangent:Nn #1#2
729 {
730 \__spath_finalmovetangent:n {#2}
731 \tl_set_eq:NN #1 \g__spath_output_tl
732 \tl_gclear:N \g__spath_output_tl
733 }
734 \cs_generate_variant:Nn \spath_finalmovetangent:Nn {NV, cn, cV}
735 \cs_new_protected_nopar:Npn \spath_gfinalmovetangent:Nn #1#2
736 {
737 \__spath_finalmovetangent:n {#2}
738 \tl_gset_eq:NN #1 \g__spath_output_tl
739 \tl_gclear:N \g__spath_output_tl
740 }
741 \cs_generate_variant:Nn \spath_gfinalmovetangent:Nn {NV, cn, cV}
742 \cs_new_protected_nopar:Npn \__spath_reverse:n #1
743 {
744 \group_begin:
745 \tl_set:Nn \l__spath_tmpa_tl {#1}
746
747 \tl_clear:N \l__spath_tmpb_tl
748 \tl_clear:N \l__spath_tmpd_tl
749
750 \bool_set_false:N \l__spath_rect_bool
751
752 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
753 \bool_while_do:nn {
754 \tl_if_eq_p:NN \l__spath_tmpc_tl \c_spath_rectcorner_tl
755 }
756 {
757 \tl_put_left:Nx \l__spath_tmpd_tl
758 {
759 \tl_item:Nn \l__spath_tmpa_tl {1}
760 {\tl_item:Nn \l__spath_tmpa_tl {2}}
761 {\tl_item:Nn \l__spath_tmpa_tl {3}}
762 \tl_item:Nn \l__spath_tmpa_tl {4}
763 {\tl_item:Nn \l__spath_tmpa_tl {5}}
764 {\tl_item:Nn \l__spath_tmpa_tl {6}}
765 }
766 \prg_replicate:nn {6}
767 {
768 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
769 }
770 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
771 \bool_set_true:N \l__spath_rect_bool
772 }
773
774 \tl_if_empty:NF \l__spath_tmpa_tl
775 {
776 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
777 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
778 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
779 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
780 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
781
782 \tl_put_left:Nx \l__spath_tmpd_tl
783 {
784 {\dim_use:N \l__spath_tmpa_dim}
785 {\dim_use:N \l__spath_tmpb_dim}
786 }
787
788 \bool_set_false:N \l__spath_closed_bool
789
790 \bool_until_do:nn {
791 \tl_if_empty_p:N \l__spath_tmpa_tl
792 }
793 {
794 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
795 \bool_set_false:N \l__spath_rect_bool
796
797 \token_case_meaning:NnTF \l__spath_tmpc_tl
798 {
799 \c_spath_moveto_tl {
800
801 \bool_if:NT \l__spath_closed_bool
802 {
803 \tl_put_right:NV \l__spath_tmpd_tl \c_spath_closepath_tl
804 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpd_tl}
805 \tl_put_right:Nx \l__spath_tmpd_tl
806 {
807 { \tl_head:N \l__spath_tmpd_tl }
808 { \tl_head:N \l__spath_tmpe_tl }
809 }
810 }
811 \bool_set_false:N \l__spath_closed_bool
812 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_moveto_tl
813 \tl_put_left:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
814 \tl_clear:N \l__spath_tmpd_tl
815 }
816 \c_spath_rectcorner_tl {
817
818 \bool_if:NT \l__spath_closed_bool
819 {
820 \tl_put_right:NV \l__spath_tmpd_tl \c_spath_closepath_tl
821 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpd_tl}
822 \tl_put_right:Nx \l__spath_tmpd_tl
823 {
824 { \tl_head:N \l__spath_tmpd_tl }
825 { \tl_head:N \l__spath_tmpe_tl }
826 }
827 }
828 \bool_set_false:N \l__spath_closed_bool
829 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_moveto_tl
830 \tl_put_left:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
831 \tl_clear:N \l__spath_tmpd_tl
832
833 \bool_while_do:nn {
834 \tl_if_eq_p:NN \l__spath_tmpc_tl \c_spath_rectcorner_tl
835 }
836 {
837 \tl_put_left:Nx \l__spath_tmpb_tl
838 {
839 \tl_item:Nn \l__spath_tmpa_tl {1}
840 {\tl_item:Nn \l__spath_tmpa_tl {2}}
841 {\tl_item:Nn \l__spath_tmpa_tl {3}}
842 \tl_item:Nn \l__spath_tmpa_tl {4}
843 {\tl_item:Nn \l__spath_tmpa_tl {5}}
844 {\tl_item:Nn \l__spath_tmpa_tl {6}}
845 }
846 \prg_replicate:nn {6}
847 {
848 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
849 }
850 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
851 }
852 \bool_set_true:N \l__spath_rect_bool
853
854 }
855 \c_spath_lineto_tl {
856 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_lineto_tl
857 }
858 \c_spath_curveto_tl {
859 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_curvetoa_tl
860 }
861 \c_spath_curvetoa_tl {
862 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_curveto_tl
863 }
864 \c_spath_curvetob_tl {
865 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_curvetob_tl
866 }
867 }
868 {
869 \tl_if_empty:NF \l__spath_tmpa_tl
870 {
871 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
872
873 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
874 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
875 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
876 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
877
878 \tl_put_left:Nx \l__spath_tmpd_tl
879 {
880 {\dim_use:N \l__spath_tmpa_dim}
881 {\dim_use:N \l__spath_tmpb_dim}
882 }
883 }
884 }
885 {
886 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_closepath_tl
887 {
888 \bool_set_true:N \l__spath_closed_bool
889 }
890 {
891 \msg_warning:nnx
892 { spath3 }
893 { unknown path construction }
894 { \l__spath_tmpc_tl }
895 }
896
897 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
898 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
899 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
900
901 }
902 }
903
904 \bool_if:NT \l__spath_closed_bool
905 {
906 \tl_put_right:NV \l__spath_tmpd_tl \c_spath_closepath_tl
907 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpd_tl}
908 \tl_put_right:Nx \l__spath_tmpd_tl
909 {
910 { \tl_head:N \l__spath_tmpd_tl }
911 { \tl_head:N \l__spath_tmpe_tl }
912 }
913 }
914
915 \bool_set_false:N \l__spath_closed_bool
916 \bool_if:NF \l__spath_rect_bool
917 {
918 \tl_put_left:NV \l__spath_tmpd_tl \c_spath_moveto_tl
919 }
920 }
921
922 \tl_put_left:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
923 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
924 \group_end:
925 }
926 \cs_new_protected_nopar:Npn \spath_reverse:Nn #1#2
927 {
928 \__spath_reverse:n {#2}
929 \tl_set_eq:NN #1 \g__spath_output_tl
930 \tl_gclear:N \g__spath_output_tl
931 }
932 \cs_generate_variant:Nn \spath_reverse:Nn {NV, cn, cV, Nv}
933 \cs_new_protected_nopar:Npn \spath_reverse:N #1
934 {
935 \spath_reverse:NV #1#1
936 }
937 \cs_generate_variant:Nn \spath_reverse:N {c}
938 \cs_new_protected_nopar:Npn \spath_greverse:Nn #1#2
939 {
940 \__spath_reverse:n {#2}
941 \tl_gset_eq:NN #1 \g__spath_output_tl
942 \tl_gclear:N \g__spath_output_tl
943 }
944 \cs_generate_variant:Nn \spath_greverse:Nn {NV, cn, cV, Nv}
945 \cs_new_protected_nopar:Npn \spath_greverse:N #1
946 {
947 \spath_greverse:NV #1#1
948 }
949 \cs_generate_variant:Nn \spath_greverse:N {c}
950 \cs_new_protected_nopar:Npn \__spath_initialaction:n #1
951 {
952 \group_begin:
953 \tl_clear:N \l__spath_tmpa_tl
954 \tl_set:Nx \l__spath_tmpb_tl {\tl_head:n {#1}}
955 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_rectcorner_tl
956 {
957 \tl_set_eq:NN \l__spath_tmpa_tl \c_spath_rectcorner_tl
958 }
959 {
960 \int_compare:nT
961 {
962 \tl_count:n {#1} > 3
963 }
964 {
965 \tl_set:Nx \l__spath_tmpa_tl
966 {
967 \tl_item:Nn {#1} {4}
968 }
969 }
970 }
971 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
972 \group_end:
973 }
974 \cs_new_protected_nopar:Npn \spath_initialaction:Nn #1#2
975 {
976 \__spath_initialaction:n {#2}
977 \tl_set_eq:NN #1 \g__spath_output_tl
978 \tl_gclear:N \g__spath_output_tl
979 }
980 \cs_generate_variant:Nn \spath_initialaction:Nn {NV}
981 \cs_new_protected_nopar:Npn \spath_ginitialaction:Nn #1#2
982 {
983 \__spath_initialaction:n {#2}
984 \tl_gset_eq:NN #1 \g__spath_output_tl
985 \tl_gclear:N \g__spath_output_tl
986 }
987 \cs_generate_variant:Nn \spath_ginitialaction:Nn {NV}
988 \cs_new_protected_nopar:Npn \__spath_finalaction:n #1
989 {
990 \group_begin:
991 \tl_clear:N \l__spath_tmpb_tl
992 \int_compare:nT
993 {
994 \tl_count:n {#1} > 3
995 }
996 {
997 \tl_set:Nn \l__spath_tmpa_tl {#1}
998 \tl_reverse:N \l__spath_tmpa_tl
999 \tl_set:Nx \l__spath_tmpb_tl
1000 {
1001 \tl_item:Nn \l__spath_tmpa_tl {3}
1002 }
1003 \tl_if_eq:NNT \l__spath_tmpb_tl \c_spath_curvetoa_tl
1004 {
1005 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_curveto_tl
1006 }
1007 \tl_if_eq:NNT \l__spath_tmpb_tl \c_spath_rectsize_tl
1008 {
1009 \tl_set_eq:NN \l__spath_tmpb_tl \c_spath_rectcorner_tl
1010 }
1011 }
1012 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
1013 \group_end:
1014 }
1015 \cs_new_protected_nopar:Npn \spath_finalaction:Nn #1#2
1016 {
1017 \__spath_finalaction:n {#2}
1018 \tl_set_eq:NN #1 \g__spath_output_tl
1019 \tl_gclear:N \g__spath_output_tl
1020 }
1021 \cs_generate_variant:Nn \spath_finalaction:Nn {NV}
1022 \cs_new_protected_nopar:Npn \spath_gfinalaction:Nn #1#2
1023 {
1024 \__spath_finalaction:n {#2}
1025 \tl_gset_eq:NN #1 \g__spath_output_tl
1026 \tl_gclear:N \g__spath_output_tl
1027 }
1028 \cs_generate_variant:Nn \spath_gfinalaction:Nn {NV}
1029 \cs_new_protected_nopar:Npn \__spath_minbb:n #1
1030 {
1031 \group_begin:
1032 \tl_set:Nn \l__spath_tmpa_tl {#1}
1033
1034 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
1035 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1036
1037 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
1038 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1039
1040 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
1041 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1042
1043 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
1044 {
1045 \dim_set_eq:NN \l__spath_rectx_dim \l__spath_tmpa_dim
1046 \dim_set_eq:NN \l__spath_recty_dim \l__spath_tmpb_dim
1047 }
1048 \bool_until_do:nn {
1049 \tl_if_empty_p:N \l__spath_tmpa_tl
1050 }
1051 {
1052 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
1053 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1054
1055 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_rectsize_tl
1056 {
1057 \dim_set:Nn \l__spath_tmpa_dim
1058 {\dim_min:nn
1059 {\tl_head:N \l__spath_tmpa_tl + \l__spath_rectx_dim} {\l__spath_tmpa_dim}
1060 }
1061 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1062
1063 \dim_set:Nn \l__spath_tmpb_dim
1064 {\dim_min:nn
1065 {\tl_head:N \l__spath_tmpa_tl + \l__spath_recty_dim} {\l__spath_tmpb_dim}
1066 }
1067 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1068 }
1069 {
1070 \dim_set:Nn \l__spath_tmpa_dim
1071 {\dim_min:nn {\tl_head:N \l__spath_tmpa_tl} {\l__spath_tmpa_dim}}
1072 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
1073 {
1074 \dim_set:Nn \l__spath_rectx_dim {\tl_head:N \l__spath_tmpa_tl}
1075 }
1076 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1077
1078 \dim_set:Nn \l__spath_tmpb_dim
1079 {\dim_min:nn {\tl_head:N \l__spath_tmpa_tl} {\l__spath_tmpb_dim}}
1080 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
1081 {
1082 \dim_set:Nn \l__spath_recty_dim {\tl_head:N \l__spath_tmpa_tl}
1083 }
1084 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1085 }
1086
1087 }
1088 \tl_clear:N \l__spath_tmpb_tl
1089 \tl_put_right:Nx \l__spath_tmpb_tl
1090 {
1091 {\dim_use:N \l__spath_tmpa_dim}
1092 {\dim_use:N \l__spath_tmpb_dim}
1093 }
1094 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
1095 \group_end:
1096 }
1097 \cs_new_protected_nopar:Npn \spath_minbb:Nn #1#2
1098 {
1099 \__spath_minbb:n {#2}
1100 \tl_set_eq:NN #1 \g__spath_output_tl
1101 \tl_gclear:N \g__spath_output_tl
1102 }
1103 \cs_generate_variant:Nn \spath_minbb:Nn {NV, cn, cV}
1104 \cs_new_protected_nopar:Npn \spath_gminbb:Nn #1#2
1105 {
1106 \__spath_minbb:n {#2}
1107 \tl_gset_eq:NN #1 \g__spath_output_tl
1108 \tl_gclear:N \g__spath_output_tl
1109 }
1110 \cs_generate_variant:Nn \spath_gminbb:Nn {NV, cn, cV}
1111 \cs_new_protected_nopar:Npn \__spath_maxbb:n #1
1112 {
1113 \group_begin:
1114 \tl_set:Nn \l__spath_tmpa_tl {#1}
1115
1116 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
1117 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1118
1119 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
1120 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1121
1122 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
1123 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1124
1125 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
1126 {
1127 \dim_set_eq:NN \l__spath_rectx_dim \l__spath_tmpa_dim
1128 \dim_set_eq:NN \l__spath_recty_dim \l__spath_tmpb_dim
1129 }
1130 \bool_until_do:nn {
1131 \tl_if_empty_p:N \l__spath_tmpa_tl
1132 }
1133 {
1134 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
1135 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1136
1137 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_rectsize_tl
1138 {
1139 \dim_set:Nn \l__spath_tmpa_dim
1140 {\dim_max:nn
1141 {\tl_head:N \l__spath_tmpa_tl + \l__spath_rectx_dim} {\l__spath_tmpa_dim}
1142 }
1143 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1144
1145 \dim_set:Nn \l__spath_tmpb_dim
1146 {\dim_max:nn
1147 {\tl_head:N \l__spath_tmpa_tl + \l__spath_recty_dim} {\l__spath_tmpb_dim}
1148 }
1149 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1150 }
1151 {
1152 \dim_set:Nn \l__spath_tmpa_dim
1153 {\dim_max:nn {\tl_head:N \l__spath_tmpa_tl} {\l__spath_tmpa_dim}}
1154 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
1155 {
1156 \dim_set:Nn \l__spath_rectx_dim {\tl_head:N \l__spath_tmpa_tl}
1157 }
1158 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1159
1160 \dim_set:Nn \l__spath_tmpb_dim
1161 {\dim_max:nn {\tl_head:N \l__spath_tmpa_tl} {\l__spath_tmpb_dim}}
1162 \tl_if_eq:NNT \l__spath_tmpc_tl \c_spath_rectcorner_tl
1163 {
1164 \dim_set:Nn \l__spath_recty_dim {\tl_head:N \l__spath_tmpa_tl}
1165 }
1166 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1167 }
1168
1169 }
1170 \tl_clear:N \l__spath_tmpb_tl
1171 \tl_set:Nx \l__spath_tmpb_tl
1172 {
1173 {\dim_use:N \l__spath_tmpa_dim}
1174 {\dim_use:N \l__spath_tmpb_dim}
1175 }
1176 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
1177 \group_end:
1178 }
1179 \cs_new_protected_nopar:Npn \spath_maxbb:Nn #1#2
1180 {
1181 \__spath_maxbb:n {#2}
1182 \tl_set_eq:NN #1 \g__spath_output_tl
1183 \tl_gclear:N \g__spath_output_tl
1184 }
1185 \cs_generate_variant:Nn \spath_maxbb:Nn {NV, cn, cV}
1186 \cs_new_protected_nopar:Npn \spath_gmaxbb:Nn #1#2
1187 {
1188 \__spath_maxbb:n {#2}
1189 \tl_gset_eq:NN #1 \g__spath_output_tl
1190 \tl_gclear:N \g__spath_output_tl
1191 }
1192 \cs_generate_variant:Nn \spath_gmaxbb:Nn {NV, cn, cV}
1193 \int_set:Nn \l__spath_tmpa_int {\char_value_catcode:n {`@}}
1194 \char_set_catcode_letter:N @
1195 \cs_new_protected_nopar:Npn \spath_save_to_aux:Nn #1#2 {
1196 \tl_if_empty:nF {#2}
1197 {
1198 \tl_clear:N \l__spath_tmpa_tl
1199 \tl_put_right:Nn \l__spath_tmpa_tl {
1200 \ExplSyntaxOn
1201 \tl_gclear_new:N #1
1202 \tl_gset:Nn #1 {#2}
1203 \ExplSyntaxOff
1204 }
1205 \protected@write\@auxout{}{
1206 \tl_to_str:N \l__spath_tmpa_tl
1207 }
1208 }
1209 }
1210 \char_set_catcode:nn {`@} {\l__spath_tmpa_int}
1211 \cs_generate_variant:Nn \spath_save_to_aux:Nn {cn, cV, NV}
1212 \cs_new_protected_nopar:Npn \spath_save_to_aux:N #1
1213 {
1214 \tl_if_exist:NT #1
1215 {
1216 \spath_save_to_aux:NV #1#1
1217 }
1218 }
1219 \cs_generate_variant:Nn \spath_save_to_aux:N {c}
1220 \cs_new_protected_nopar:Npn \__spath_translate:nnn #1#2#3
1221 {
1222 \group_begin:
1223 \tl_set:Nn \l__spath_tmpa_tl {#1}
1224 \tl_clear:N \l__spath_tmpb_tl
1225 \bool_until_do:nn {
1226 \tl_if_empty_p:N \l__spath_tmpa_tl
1227 }
1228 {
1229 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
1230
1231 \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
1232 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1233
1234 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_rectsize_tl
1235 {
1236 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
1237 }
1238 {
1239 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl + #2}
1240 }
1241 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1242
1243 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_rectsize_tl
1244 {
1245 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
1246 }
1247 {
1248 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl + #3}
1249 }
1250 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1251
1252 \tl_put_right:Nx \l__spath_tmpb_tl
1253 {
1254 {\dim_use:N \l__spath_tmpa_dim}
1255 {\dim_use:N \l__spath_tmpb_dim}
1256 }
1257 }
1258 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
1259 \group_end:
1260 }
1261 \cs_generate_variant:Nn \__spath_translate:nnn {nVV}
1262 \cs_new_protected_nopar:Npn \spath_translate:Nnnn #1#2#3#4
1263 {
1264 \__spath_translate:nnn {#2}{#3}{#4}
1265 \tl_set_eq:NN #1 \g__spath_output_tl
1266 \tl_gclear:N \g__spath_output_tl
1267 }
1268 \cs_generate_variant:Nn \spath_translate:Nnnn {NVxx, NVVV, NVnn}
1269 \cs_new_protected_nopar:Npn \spath_translate:Nnn #1#2#3
1270 {
1271 \spath_translate:NVnn #1#1{#2}{#3}
1272 }
1273 \cs_generate_variant:Nn \spath_translate:Nnn {NVV, cnn, cVV}
1274 \cs_new_protected_nopar:Npn \spath_gtranslate:Nnnn #1#2#3#4
1275 {
1276 \__spath_translate:nnn {#2}{#3}{#4}
1277 \tl_gset_eq:NN #1 \g__spath_output_tl
1278 \tl_gclear:N \g__spath_output_tl
1279 }
1280 \cs_generate_variant:Nn \spath_gtranslate:Nnnn {NVxx, NVVV, NVnn}
1281 \cs_new_protected_nopar:Npn \spath_gtranslate:Nnn #1#2#3
1282 {
1283 \spath_gtranslate:NVnn #1#1{#2}{#3}
1284 }
1285 \cs_generate_variant:Nn \spath_gtranslate:Nnn {NVV, cnn, cVV}
1286 \cs_new_protected_nopar:Npn \spath_translate:Nn #1#2
1287 {
1288 \spath_translate:Nnn #1 #2
1289 }
1290 \cs_generate_variant:Nn \spath_translate:Nn {NV}
1291 \cs_new_protected_nopar:Npn \spath_gtranslate:Nn #1#2
1292 {
1293 \spath_gtranslate:Nnn #1 #2
1294 }
1295 \cs_generate_variant:Nn \spath_gtranslate:Nn {NV}
1296 \cs_new_protected_nopar:Npn \__spath_translate_to:nnn #1#2#3
1297 {
1298 \group_begin:
1299 \spath_initialpoint:Nn \l__spath_tmpa_tl {#1}
1300
1301 \dim_set:Nn \l__spath_tmpa_dim
1302 {
1303 #2
1304 -
1305 \tl_item:Nn \l__spath_tmpa_tl {1}
1306 }
1307 \dim_set:Nn \l__spath_tmpb_dim
1308 {
1309 #3
1310 -
1311 \tl_item:Nn \l__spath_tmpa_tl {2}
1312 }
1313
1314 \__spath_translate:nVV {#1} \l__spath_tmpa_dim \l__spath_tmpb_dim
1315 \group_end:
1316 }
1317 \cs_new_protected_nopar:Npn \spath_translate_to:Nnnn #1#2#3#4
1318 {
1319 \__spath_translate_to:nnn {#2}{#3}{#4}
1320 \tl_set_eq:NN #1 \g__spath_output_tl
1321 \tl_gclear:N \g__spath_output_tl
1322 }
1323 \cs_generate_variant:Nn \spath_translate_to:Nnnn {NVxx, NVVV, NVnn}
1324 \cs_new_protected_nopar:Npn \spath_translate_to:Nnn #1#2#3
1325 {
1326 \spath_translate_to:NVnn #1#1{#2}{#3}
1327 }
1328 \cs_generate_variant:Nn \spath_translate_to:Nnn {NVV, cnn, cVV}
1329 \cs_new_protected_nopar:Npn \spath_gtranslate_to:Nnnn #1#2#3#4
1330 {
1331 \__spath_translate_to:nnn {#2}{#3}{#4}
1332 \tl_gset_eq:NN #1 \g__spath_output_tl
1333 \tl_gclear:N \g__spath_output_tl
1334 }
1335 \cs_generate_variant:Nn \spath_gtranslate_to:Nnnn {NVxx, NVVV, NVnn}
1336 \cs_new_protected_nopar:Npn \spath_gtranslate_to:Nnn #1#2#3
1337 {
1338 \spath_gtranslate_to:NVnn #1#1{#2}{#3}
1339 }
1340 \cs_generate_variant:Nn \spath_gtranslate_to:Nnn {NVV, cnn, cVV}
1341 \cs_new_protected_nopar:Npn \spath_translate_to:Nn #1#2
1342 {
1343 \spath_translate_to:Nnn #1 #2
1344 }
1345 \cs_generate_variant:Nn \spath_translate_to:Nn {NV}
1346 \cs_new_protected_nopar:Npn \spath_gtranslate_to:Nn #1#2
1347 {
1348 \spath_gtranslate_to:Nnn #1 #2
1349 }
1350 \cs_generate_variant:Nn \spath_gtranslate_to:Nn {NV}
1351 \cs_new_protected_nopar:Npn \__spath_scale:nnn #1#2#3
1352 {
1353 \group_begin:
1354 \tl_set:Nn \l__spath_tmpa_tl {#1}
1355 \tl_clear:N \l__spath_tmpb_tl
1356 \bool_until_do:nn {
1357 \tl_if_empty_p:N \l__spath_tmpa_tl
1358 }
1359 {
1360 \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
1361 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1362
1363 \fp_set:Nn \l__spath_tmpa_fp {\tl_head:N \l__spath_tmpa_tl * #2}
1364 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1365
1366 \fp_set:Nn \l__spath_tmpb_fp {\tl_head:N \l__spath_tmpa_tl * #3}
1367 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1368
1369 \tl_put_right:Nx \l__spath_tmpb_tl
1370 {
1371 {\fp_to_dim:N \l__spath_tmpa_fp}
1372 {\fp_to_dim:N \l__spath_tmpb_fp}
1373 }
1374 }
1375 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
1376 \group_end:
1377 }
1378 \cs_new_protected_nopar:Npn \spath_scale:Nnnn #1#2#3#4
1379 {
1380 \__spath_scale:nnn {#2}{#3}{#4}
1381 \tl_set_eq:NN #1 \g__spath_output_tl
1382 \tl_gclear:N \g__spath_output_tl
1383 }
1384 \cs_generate_variant:Nn \spath_scale:Nnnn {NVnn, Nnxx}
1385 \cs_new_protected_nopar:Npn \spath_scale:Nnn #1#2#3
1386 {
1387 \spath_scale:NVnn #1#1{#2}{#3}
1388 }
1389 \cs_generate_variant:Nn \spath_scale:Nnn {cnn, cVV, NVV}
1390 \cs_new_protected_nopar:Npn \spath_gscale:Nnnn #1#2#3#4
1391 {
1392 \__spath_scale:nnn {#2}{#3}{#4}
1393 \tl_gset_eq:NN #1 \g__spath_output_tl
1394 \tl_gclear:N \g__spath_output_tl
1395 }
1396 \cs_generate_variant:Nn \spath_gscale:Nnnn {NVnn, Nnxx}
1397 \cs_new_protected_nopar:Npn \spath_gscale:Nnn #1#2#3
1398 {
1399 \spath_gscale:NVnn #1#1{#2}{#3}
1400 }
1401 \cs_generate_variant:Nn \spath_gscale:Nnn {cnn, cVV, NVV}
1402 \cs_new_protected_nopar:Npn \spath_scale:Nn #1#2
1403 {
1404 \spath_scale:Nnn #1 #2
1405 }
1406
1407 \cs_generate_variant:Nn \spath_scale:Nn {NV}
1408 \cs_new_protected_nopar:Npn \spath_gscale:Nn #1#2
1409 {
1410 \spath_gscale:Nnn #1 #2
1411 }
1412
1413 \cs_generate_variant:Nn \spath_gscale:Nn {NV}
1414 \cs_new_protected_nopar:Npn \__spath_transform:nnnnnnn #1#2#3#4#5#6#7
1415 {
1416 \group_begin:
1417 \tl_set:Nn \l__spath_tmpa_tl {#1}
1418 \tl_clear:N \l__spath_tmpb_tl
1419 \bool_until_do:nn {
1420 \tl_if_empty_p:N \l__spath_tmpa_tl
1421 }
1422 {
1423 \tl_set:Nx \l__spath_tmpe_tl {\tl_head:N \l__spath_tmpa_tl}
1424
1425 \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl}
1426 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1427 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
1428 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1429 \tl_set:Nx \l__spath_tmpd_tl {\tl_head:N \l__spath_tmpa_tl}
1430 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
1431
1432 \tl_if_eq:NNTF \l__spath_tmpe_tl \c_spath_rectsize_tl
1433 {
1434 \fp_set:Nn \l__spath_tmpa_fp
1435 {\l__spath_tmpc_tl * #2 + \l__spath_tmpd_tl * #4}
1436 \fp_set:Nn \l__spath_tmpb_fp
1437 {\l__spath_tmpc_tl * #3 + \l__spath_tmpd_tl * #5}
1438 }
1439 {
1440 \fp_set:Nn \l__spath_tmpa_fp
1441 {\l__spath_tmpc_tl * #2 + \l__spath_tmpd_tl * #4 + #6}
1442 \fp_set:Nn \l__spath_tmpb_fp
1443 {\l__spath_tmpc_tl * #3 + \l__spath_tmpd_tl * #5 + #7}
1444 }
1445
1446 \tl_put_right:Nx \l__spath_tmpb_tl
1447 {
1448 {\fp_to_dim:N \l__spath_tmpa_fp}
1449 {\fp_to_dim:N \l__spath_tmpb_fp}
1450 }
1451 }
1452
1453 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
1454 \group_end:
1455 }
1456 \cs_new_protected_nopar:Npn \spath_transform:Nnnnnnnn #1#2#3#4#5#6#7#8
1457 {
1458 \__spath_transform:nnnnnnn {#2}{#3}{#4}{#5}{#6}{#7}{#8}
1459 \tl_set_eq:NN #1 \g__spath_output_tl
1460 \tl_gclear:N \g__spath_output_tl
1461 }
1462 \cs_generate_variant:Nn \spath_transform:Nnnnnnnn
1463 {NVnnnnnn, Nnxxxxxx, cnnnnnnn}
1464 \cs_new_protected_nopar:Npn \spath_transform:Nnnnnnn #1#2#3#4#5#6#7
1465 {
1466 \spath_transform:NVnnnnnn #1#1{#2}{#3}{#4}{#5}{#6}{#7}
1467 }
1468 \cs_generate_variant:Nn \spath_transform:Nnnnnnn {cnnnnnn}
1469 \cs_new_protected_nopar:Npn \spath_transform:Nnn #1#2#3
1470 {
1471 \spath_transform:Nnnnnnnn #1{#2}#3
1472 }
1473 \cs_generate_variant:Nn \spath_transform:Nnn {cnn, cVn, NVn, NnV}
1474 \cs_new_protected_nopar:Npn \spath_transform:Nn #1#2
1475 {
1476 \spath_transform:NVnnnnnn #1#1#2
1477 }
1478 \cs_generate_variant:Nn \spath_transform:Nn {cn, cV, NV}
1479
1480 \cs_new_protected_nopar:Npn \spath_gtransform:Nnnnnnnn #1#2#3#4#5#6#7#8
1481 {
1482 \__spath_transform:nnnnnnn {#2}{#3}{#4}{#5}{#6}{#7}{#8}
1483 \tl_gset_eq:NN #1 \g__spath_output_tl
1484 \tl_gclear:N \g__spath_output_tl
1485 }
1486 \cs_generate_variant:Nn \spath_gtransform:Nnnnnnnn {NVnnnnnn, Nnxxxxxx, cnnnnnnn}
1487 \cs_new_protected_nopar:Npn \spath_gtransform:Nnnnnnn #1#2#3#4#5#6#7
1488 {
1489 \spath_gtransform:NVnnnnnn #1#1{#2}{#3}{#4}{#5}{#6}{#7}
1490 }
1491 \cs_generate_variant:Nn \spath_gtransform:Nnnnnnn {cnnnnnn}
1492 \cs_new_protected_nopar:Npn \spath_gtransform:Nnn #1#2#3
1493 {
1494 \spath_gtransform:Nnnnnnnn #1{#2}#3
1495 }
1496 \cs_generate_variant:Nn \spath_gtransform:Nnn {cnn, cVn, NVn, NnV}
1497 \cs_new_protected_nopar:Npn \spath_gtransform:Nn #1#2
1498 {
1499 \spath_gtransform:NVnnnnnn #1#1#2
1500 }
1501 \cs_generate_variant:Nn \spath_gtransform:Nn {cn, cV, NV}
1502 \cs_new_protected_nopar:Npn \__spath_span:nnn #1#2#3
1503 {
1504 \group_begin:
1505 \spath_initialpoint:Nn \l__spath_tmpa_tl {#1}
1506 \spath_finalpoint:Nn \l__spath_tmpb_tl {#1}
1507
1508 \fp_set:Nn \l__spath_tmpa_fp
1509 {
1510 (\tl_item:Nn \l__spath_tmpb_tl {1}) -
1511 (\tl_item:Nn \l__spath_tmpa_tl {1})
1512 }
1513 \fp_set:Nn \l__spath_tmpb_fp
1514 {
1515 (\tl_item:Nn \l__spath_tmpb_tl {2}) -
1516 (\tl_item:Nn \l__spath_tmpa_tl {2})
1517 }
1518 \fp_set:Nn \l__spath_tmpc_fp
1519 {
1520 (\l__spath_tmpa_fp) * (\l__spath_tmpa_fp)
1521 +
1522 (\l__spath_tmpb_fp * \l__spath_tmpb_fp)
1523 }
1524
1525 \fp_compare:nTF
1526 {
1527 \l__spath_tmpc_fp < 0.001
1528 }
1529 {
1530 \spath_translate_to:Nnnn \l__spath_tmpd_tl {#1} #2
1531 }
1532 {
1533 \fp_set:Nn \l__spath_tmpa_fp
1534 {
1535 (
1536 ((\tl_item:nn {#3} {1})
1537 -
1538 (\tl_item:nn {#2} {1}))
1539 *
1540 ((\tl_item:Nn \l__spath_tmpb_tl {1})
1541 -
1542 (\tl_item:Nn \l__spath_tmpa_tl {1}))
1543 +
1544 ((\tl_item:nn {#3} {2})
1545 -
1546 (\tl_item:nn {#2} {2}))
1547 *
1548 ((\tl_item:Nn \l__spath_tmpb_tl {2})
1549 -
1550 (\tl_item:Nn \l__spath_tmpa_tl {2}))
1551 )
1552 /
1553 \l__spath_tmpc_fp
1554 }
1555 \fp_set:Nn \l__spath_tmpb_fp
1556 {
1557 (
1558 ((\tl_item:nn {#3} {2})
1559 -
1560 (\tl_item:nn {#2} {2}))
1561 *
1562 ((\tl_item:Nn \l__spath_tmpb_tl {1})
1563 -
1564 (\tl_item:Nn \l__spath_tmpa_tl {1}))
1565 -
1566 ((\tl_item:nn {#3} {1})
1567 -
1568 (\tl_item:nn {#2} {1}))
1569 *
1570 ((\tl_item:Nn \l__spath_tmpb_tl {2})
1571 -
1572 (\tl_item:Nn \l__spath_tmpa_tl {2}))
1573 )
1574 /
1575 \l__spath_tmpc_fp
1576 }
1577
1578 \tl_set:Nx \l__spath_tmpc_tl
1579 {
1580 {
1581 \fp_to_decimal:N \l__spath_tmpa_fp
1582 }
1583 {
1584 \fp_to_decimal:N \l__spath_tmpb_fp
1585 }
1586 {
1587 \fp_eval:n { - \l__spath_tmpb_fp }
1588 }
1589 {
1590 \fp_to_decimal:N \l__spath_tmpa_fp
1591 }
1592 {
1593 \fp_to_dim:n
1594 {
1595 \tl_item:nn {#2} {1}
1596 -
1597 \l__spath_tmpa_fp * (\tl_item:Nn \l__spath_tmpa_tl {1})
1598 +
1599 \l__spath_tmpb_fp * (\tl_item:Nn \l__spath_tmpa_tl {2})
1600 }
1601 }
1602 {
1603 \fp_to_dim:n
1604 {
1605 \tl_item:nn {#2} {2}
1606 -
1607 \l__spath_tmpb_fp * (\tl_item:Nn \l__spath_tmpa_tl {1})
1608 -
1609 \l__spath_tmpa_fp * (\tl_item:Nn \l__spath_tmpa_tl {2})
1610 }
1611 }
1612 }
1613 \spath_transform:NnV \l__spath_tmpd_tl {#1} \l__spath_tmpc_tl
1614 }
1615 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpd_tl
1616 \group_end:
1617 }
1618 \cs_new_protected_nopar:Npn \spath_span:Nnnn #1#2#3#4
1619 {
1620 \__spath_span:nnn {#2}{#3}{#4}
1621 \tl_set_eq:NN #1 \g__spath_output_tl
1622 \tl_gclear:N \g__spath_output_tl
1623 }
1624 \cs_generate_variant:Nn \spath_span:Nnnn {NVnn, NVVV, NnVV}
1625 \cs_new_protected_nopar:Npn \spath_span:Nnn #1#2#3
1626 {
1627 \spath_span:NVnn #1#1{#2}{#3}
1628 }
1629 \cs_generate_variant:Nn \spath_span:Nnn {NVV, cnn, cvv, cVV}
1630 \cs_new_protected_nopar:Npn \spath_gspan:Nnnn #1#2#3#4
1631 {
1632 \__spath_span:nnn {#2}{#3}{#4}
1633 \tl_gset_eq:NN #1 \g__spath_output_tl
1634 \tl_gclear:N \g__spath_output_tl
1635 }
1636 \cs_generate_variant:Nn \spath_gspan:Nnnn {NVnn, NVVV}
1637 \cs_new_protected_nopar:Npn \spath_gspan:Nnn #1#2#3
1638 {
1639 \spath_gspan:NVnn #1#1{#2}{#3}
1640 }
1641 \cs_generate_variant:Nn \spath_gspan:Nnn {NVV, cnn, cvv, cVV}
1642 \cs_new_protected_nopar:Npn \__spath_normalise:n #1
1643 {
1644 \__spath_span:nnn {#1}{{0pt}{0pt}}{{1pt}{0pt}}
1645 }
1646 \cs_new_protected_nopar:Npn \spath_normalise:Nn #1#2
1647 {
1648 \__spath_normalise:n {#2}
1649 \tl_set_eq:NN #1 \g__spath_output_tl
1650 \tl_gclear:N \g__spath_output_tl
1651 }
1652 \cs_generate_variant:Nn \spath_normalise:Nn {cn,NV, cV, cv}
1653 \cs_new_protected_nopar:Npn \spath_normalise:N #1
1654 {
1655 \spath_normalise:NV #1#1
1656 }
1657 \cs_generate_variant:Nn \spath_normalise:N {c}
1658 \cs_new_protected_nopar:Npn \spath_gnormalise:Nn #1#2
1659 {
1660 \__spath_normalise:n {#2}
1661 \tl_gset_eq:NN #1 \g__spath_output_tl
1662 \tl_gclear:N \g__spath_output_tl
1663 }
1664 \cs_generate_variant:Nn \spath_gnormalise:Nn {cn,NV, cV, cv}
1665 \cs_new_protected_nopar:Npn \spath_gnormalise:N #1
1666 {
1667 \spath_gnormalise:NV #1#1
1668 }
1669 \cs_generate_variant:Nn \spath_gnormalise:N {c}
1670 \cs_new_protected_nopar:Npn \__spath_splice_between:nnn #1#2#3
1671 {
1672 \group_begin:
1673 \spath_finalpoint:Nn \l__spath_tmpd_tl {#1}
1674 \spath_initialpoint:Nn \l__spath_tmpe_tl {#3}
1675 \spath_span:NnVV \l__spath_tmpb_tl {#2} \l__spath_tmpd_tl \l__spath_tmpe_tl
1676 \spath_append_no_move:NnV \l__spath_tmpa_tl {#1} \l__spath_tmpb_tl
1677 \spath_append_no_move:Nn \l__spath_tmpa_tl {#3}
1678 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
1679 \group_end:
1680 }
1681 \cs_new_protected_nopar:Npn \spath_splice_between:Nnnn #1#2#3#4
1682 {
1683 \__spath_splice_between:nnn {#2}{#3}{#4}
1684 \tl_set_eq:NN #1 \g__spath_output_tl
1685 \tl_gclear:N \g__spath_output_tl
1686 }
1687 \cs_generate_variant:Nn \spath_splice_between:Nnnn {NVnn, NVVV}
1688 \cs_new_protected_nopar:Npn \spath_splice_between:Nnn #1#2#3
1689 {
1690 \spath_splice_between:NVnn #1#1{#2}{#3}
1691 }
1692 \cs_generate_variant:Nn \spath_splice_between:Nnn {NVV, cnn, cvv, Nvn, NVn}
1693 \cs_new_protected_nopar:Npn \spath_gsplice_between:Nnnn #1#2#3#4
1694 {
1695 \__spath_splice_between:nnn {#2}{#3}{#4}
1696 \tl_gset_eq:NN #1 \g__spath_output_tl
1697 \tl_gclear:N \g__spath_output_tl
1698 }
1699 \cs_generate_variant:Nn \spath_gsplice_between:Nnnn {NVnn, NVVV}
1700 \cs_new_protected_nopar:Npn \spath_gsplice_between:Nnn #1#2#3
1701 {
1702 \spath_gsplice_between:NVnn #1#1{#2}{#3}
1703 }
1704 \cs_generate_variant:Nn \spath_gsplice_between:Nnn {NVV, cnn, cvv, Nvn, NVn}
1705 \cs_new_protected_nopar:Npn \__spath_hobby_curve:nnnn #1#2#3#4
1706 {
1707 \group_begin:
1708 \fp_set:Nn \l__spath_tmpa_fp
1709 {
1710 (
1711 (\tl_item:nn {#2} {1})
1712 *
1713 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
1714 +
1715 (\tl_item:nn {#2} {2})
1716 *
1717 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
1718 )
1719 /
1720 sqrt
1721 (
1722 (
1723 (\tl_item:nn {#2} {1})^2
1724 +
1725 (\tl_item:nn {#2} {2})^2
1726 )
1727 *
1728 (
1729 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
1730 +
1731 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
1732 )
1733 )
1734 }
1735 \fp_set:Nn \l__spath_tmpb_fp
1736 {
1737 (
1738 -
1739 (\tl_item:nn {#2} {1})
1740 *
1741 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
1742 +
1743 (\tl_item:nn {#2} {2})
1744 *
1745 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
1746 )
1747 /
1748 sqrt
1749 (
1750 (
1751 (\tl_item:nn {#2} {1})^2
1752 +
1753 (\tl_item:nn {#2} {2})^2
1754 )
1755 *
1756 (
1757 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
1758 +
1759 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
1760 )
1761 )
1762 }
1763 \fp_set:Nn \l__spath_tmpc_fp
1764 {
1765 (
1766 (\tl_item:nn {#3} {1})
1767 *
1768 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
1769 +
1770 (\tl_item:nn {#3} {2})
1771 *
1772 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
1773 )
1774 /
1775 sqrt
1776 (
1777 (
1778 (\tl_item:nn {#3} {1})^2
1779 +
1780 (\tl_item:nn {#3} {2})^2
1781 )
1782 *
1783 (
1784 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
1785 +
1786 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
1787 )
1788 )
1789 }
1790 \fp_set:Nn \l__spath_tmpd_fp
1791 {
1792 (
1793 (\tl_item:nn {#3} {1})
1794 *
1795 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
1796 -
1797 (\tl_item:nn {#3} {2})
1798 *
1799 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
1800 )
1801 /
1802 sqrt
1803 (
1804 (
1805 (\tl_item:nn {#3} {1})^2
1806 +
1807 (\tl_item:nn {#3} {2})^2
1808 )
1809 *
1810 (
1811 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
1812 +
1813 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
1814 )
1815 )
1816 }
1817
1818 \fp_set:Nn \l__spath_tmpe_fp
1819 {
1820 (
1821 2 + sqrt(2) *
1822 (\l__spath_tmpb_fp - 1/16 * \l__spath_tmpd_fp)
1823 *
1824 (\l__spath_tmpd_fp - 1/16 * \l__spath_tmpb_fp)
1825 *
1826 (\l__spath_tmpa_fp - \l__spath_tmpc_fp)
1827 )
1828 /
1829 (
1830 1
1831 +
1832 (1 - (3 - sqrt(5))/2)
1833 *
1834 \l__spath_tmpa_fp
1835 +
1836 (3 - sqrt(5))/2
1837 *
1838 \l__spath_tmpc_fp
1839 )
1840 *
1841 sqrt
1842 (
1843 (
1844 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
1845 +
1846 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
1847 )
1848 /
1849 (
1850 (\tl_item:nn {#2} {1})^2
1851 +
1852 (\tl_item:nn {#2} {2})^2
1853 )
1854 )
1855 /3
1856 }
1857 \fp_set:Nn \l__spath_tmpf_fp
1858 {
1859 (
1860 2 - sqrt(2) *
1861 (\l__spath_tmpb_fp - 1/16 * \l__spath_tmpd_fp)
1862 *
1863 (\l__spath_tmpd_fp - 1/16 * \l__spath_tmpb_fp)
1864 *
1865 (\l__spath_tmpa_fp - \l__spath_tmpc_fp)
1866 )
1867 /
1868 (
1869 1
1870 +
1871 (1 - (3 - sqrt(5))/2)
1872 *
1873 \l__spath_tmpc_fp
1874 +
1875 (3 - sqrt(5))/2
1876 *
1877 \l__spath_tmpa_fp
1878 )
1879 *
1880 sqrt
1881 (
1882 (
1883 (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
1884 +
1885 (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
1886 )
1887 /
1888 (
1889 (\tl_item:nn {#3} {1})^2
1890 +
1891 (\tl_item:nn {#3} {2})^2
1892 )
1893 )
1894 /3
1895 }
1896
1897 \tl_set:Nx \l__spath_tmpa_tl
1898 {
1899 {
1900 \fp_to_dim:n
1901 {
1902 \tl_item:nn {#1} {1}
1903 +
1904 \l__spath_tmpe_fp
1905 *
1906 (\tl_item:nn {#2} {1})
1907 }
1908 }
1909 {
1910 \fp_to_dim:n
1911 {
1912 \tl_item:nn {#1} {2}
1913 +
1914 \l__spath_tmpe_fp
1915 *
1916 (\tl_item:nn {#2} {2})
1917 }
1918 }
1919 }
1920 \tl_set:Nx \l__spath_tmpb_tl
1921 {
1922 {
1923 \fp_to_dim:n
1924 {
1925 \tl_item:nn {#4} {1}
1926 -
1927 \l__spath_tmpf_fp
1928 *
1929 (\tl_item:nn {#3} {1})
1930 }
1931 }
1932 {
1933 \fp_to_dim:n
1934 {
1935 \tl_item:nn {#4} {2}
1936 -
1937 \l__spath_tmpf_fp
1938 *
1939 (\tl_item:nn {#3} {2})
1940 }
1941 }
1942 }
1943
1944 \tl_clear:N \l__spath_tmpc_tl
1945 \tl_set:NV \l__spath_tmpc_tl \c_spath_moveto_tl
1946 \tl_put_right:Nn \l__spath_tmpc_tl {#1}
1947 \tl_put_right:NV \l__spath_tmpc_tl \c_spath_curvetoa_tl
1948 \tl_put_right:NV \l__spath_tmpc_tl \l__spath_tmpa_tl
1949 \tl_put_right:NV \l__spath_tmpc_tl \c_spath_curvetob_tl
1950 \tl_put_right:NV \l__spath_tmpc_tl \l__spath_tmpb_tl
1951 \tl_put_right:NV \l__spath_tmpc_tl \c_spath_curveto_tl
1952 \tl_put_right:Nn \l__spath_tmpc_tl {#4}
1953 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpc_tl
1954 \group_end:
1955 }
1956 \cs_new_protected_nopar:Npn \spath_hobby_curve:Nnnnn #1#2#3#4#5
1957 {
1958 \__spath_hobby_curve:nnnn {#2}{#3}{#4}{#5}
1959 \tl_set_eq:NN #1 \g__spath_output_tl
1960 \tl_gclear:N \g__spath_output_tl
1961 }
1962 \cs_generate_variant:Nn \spath_hobby_curve:Nnnnn {NVVVV}
1963 \cs_new_protected_nopar:Npn \spath_ghobby_curve:Nnnnn #1#2#3#4#5
1964 {
1965 \__spath_hobby_curve:nnnn {#2}{#3}{#4}{#5}
1966 \tl_gset_eq:NN #1 \g__spath_output_tl
1967 \tl_gclear:N \g__spath_output_tl
1968 }
1969 \cs_generate_variant:Nn \spath_ghobby_curve:Nnnnn {NVVVV}
1970 \cs_new_protected_nopar:Npn \__spath_curve_between:nn #1#2
1971 {
1972 \group_begin:
1973 \spath_finalpoint:Nn \l__spath_tmpa_tl {#1}
1974 \spath_finaltangent:Nn \l__spath_tmpb_tl {#1}
1975 \spath_initialpoint:Nn \l__spath_tmpc_tl {#2}
1976 \spath_initialtangent:Nn \l__spath_tmpd_tl {#2}
1977
1978 \spath_hobby_curve:NVVVV \l__spath_tmpe_tl
1979 \l__spath_tmpa_tl \l__spath_tmpb_tl \l__spath_tmpd_tl \l__spath_tmpc_tl
1980
1981 \tl_set:Nn \l__spath_tmpa_tl {#1}
1982 \spath_append_no_move:NV \l__spath_tmpa_tl \l__spath_tmpe_tl
1983 \spath_append_no_move:Nn \l__spath_tmpa_tl {#2}
1984 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
1985 \group_end:
1986 }
1987 \cs_new_protected_nopar:Npn \spath_curve_between:Nnn #1#2#3
1988 {
1989 \__spath_curve_between:nn {#2}{#3}
1990 \tl_set_eq:NN #1 \g__spath_output_tl
1991 \tl_gclear:N \g__spath_output_tl
1992 }
1993 \cs_generate_variant:Nn \spath_curve_between:Nnn {NVn, NVV}
1994 \cs_new_protected_nopar:Npn \spath_curve_between:Nn #1#2
1995 {
1996 \spath_curve_between:NVn #1#1{#2}
1997 }
1998 \cs_generate_variant:Nn \spath_curve_between:Nn {NV, cn, cv}
1999 \cs_new_protected_nopar:Npn \spath_gcurve_between:Nnn #1#2#3
2000 {
2001 \__spath_curve_between:nn {#2}
2002 \tl_gset_eq:NN #1 \g__spath_output_tl
2003 \tl_gclear:N \g__spath_output_tl
2004 }
2005 \cs_generate_variant:Nn \spath_gcurve_between:Nnn {NVn, NVV}
2006 \cs_new_protected_nopar:Npn \spath_gcurve_between:Nn #1#2
2007 {
2008 \spath_gcurve_between:NVnn #1#1{#2}
2009 }
2010 \cs_generate_variant:Nn \spath_gcurve_between:Nn {NV, cn, cv}
2011 \cs_new_protected_nopar:Npn \__spath_close_with:nn #1#2
2012 {
2013 \group_begin:
2014 \spath_finalmovepoint:Nn \l__spath_tmpa_tl {#1}
2015 \spath_finalpoint:Nn \l__spath_tmpb_tl {#1}
2016 \dim_compare:nTF
2017 {
2018 \dim_abs:n
2019 {
2020 \tl_item:Nn \l__spath_tmpa_tl {1}
2021 -
2022 \tl_item:Nn \l__spath_tmpb_tl {1}
2023 }
2024 +
2025 \dim_abs:n
2026 {
2027 \tl_item:Nn \l__spath_tmpa_tl {2}
2028 -
2029 \tl_item:Nn \l__spath_tmpb_tl {2}
2030 }
2031 < 0.01pt
2032 }
2033 {
2034 \__spath_close:n {#1}
2035 }
2036 {
2037 \spath_span:NnVV \l__spath_tmpc_tl {#2} \l__spath_tmpb_tl \l__spath_tmpa_tl
2038 \spath_append_no_move:NnV \l__spath_tmpd_tl {#1} \l__spath_tmpc_tl
2039 \__spath_close:V \l__spath_tmpd_tl
2040 }
2041 \group_end:
2042 }
2043 \cs_new_protected_nopar:Npn \spath_close_with:Nnn #1#2#3
2044 {
2045 \__spath_close_with:nn {#2}{#3}
2046 \tl_set_eq:NN #1 \g__spath_output_tl
2047 \tl_gclear:N \g__spath_output_tl
2048 }
2049 \cs_generate_variant:Nn \spath_close_with:Nnn {cnn, cVV, cvv, NVn}
2050 \cs_new_protected_nopar:Npn \spath_close_with:Nn #1#2
2051 {
2052 \spath_close_with:NVn #1#1{#2}
2053 }
2054 \cs_generate_variant:Nn \spath_close_with:Nn {cn, cV, cv, NV}
2055 \cs_new_protected_nopar:Npn \spath_gclose_with:Nnn #1#2#3
2056 {
2057 \__spath_close_with:nn {#2}{#3}
2058 \tl_gset_eq:NN #1 \g__spath_output_tl
2059 \tl_gclear:N \g__spath_output_tl
2060 }
2061 \cs_generate_variant:Nn \spath_gclose_with:Nnn {cnn, cVV, cvv, NVn}
2062 \cs_new_protected_nopar:Npn \spath_gclose_with:Nn #1#2
2063 {
2064 \spath_gclose_with:NVn #1#1{#2}
2065 }
2066 \cs_generate_variant:Nn \spath_gclose_with:Nn {cn, cV, cv, NV}
2067 \cs_new_protected_nopar:Npn \__spath_close_with_curve:n #1
2068 {
2069 \group_begin:
2070 \spath_finalpoint:Nn \l__spath_tmpa_tl {#1}
2071 \spath_finaltangent:Nn \l__spath_tmpb_tl {#1}
2072 \spath_finalmovepoint:Nn \l__spath_tmpc_tl {#1}
2073 \spath_finalmovetangent:Nn \l__spath_tmpd_tl {#1}
2074 \dim_compare:nTF
2075 {
2076 \dim_abs:n
2077 {
2078 \tl_item:Nn \l__spath_tmpa_tl {1}
2079 -
2080 \tl_item:Nn \l__spath_tmpc_tl {1}
2081 }
2082 +
2083 \dim_abs:n
2084 {
2085 \tl_item:Nn \l__spath_tmpa_tl {2}
2086 -
2087 \tl_item:Nn \l__spath_tmpc_tl {2}
2088 }
2089 < 0.01pt
2090 }
2091 {
2092 \__spath_close:n {#1}
2093 }
2094 {
2095
2096 \spath_hobby_curve:NVVVV \l__spath_tmpe_tl
2097 \l__spath_tmpa_tl \l__spath_tmpb_tl \l__spath_tmpd_tl \l__spath_tmpc_tl
2098
2099 \tl_set:Nn \l__spath_tmpa_tl {#1}
2100 \spath_append_no_move:NV \l__spath_tmpa_tl \l__spath_tmpe_tl
2101 \__spath_close:V \l__spath_tmpa_tl
2102 }
2103 \group_end:
2104 }
2105 \cs_new_protected_nopar:Npn \spath_close_with_curve:Nn #1#2
2106 {
2107 \__spath_close_with_curve:n {#2}
2108 \tl_set_eq:NN #1 \g__spath_output_tl
2109 \tl_gclear:N \g__spath_output_tl
2110 }
2111 \cs_generate_variant:Nn \spath_close_with_curve:Nn {cn, cV, cv, NV}
2112 \cs_new_protected_nopar:Npn \spath_close_with_curve:N #1
2113 {
2114 \spath_close_with_curve:NV #1#1
2115 }
2116 \cs_generate_variant:Nn \spath_close_with_curve:N {c}
2117 \cs_new_protected_nopar:Npn \spath_gclose_with_curve:Nn #1#2
2118 {
2119 \__spath_close_with_curve:n {#2}
2120 \tl_gset_eq:NN #1 \g__spath_output_tl
2121 \tl_gclear:N \g__spath_output_tl
2122 }
2123 \cs_generate_variant:Nn \spath_gclose_with_curve:Nn {cn, cV, cv, NV}
2124 \cs_new_protected_nopar:Npn \spath_gclose_with_curve:N #1
2125 {
2126 \spath_gclose_with_curve:NV #1#1
2127 }
2128 \cs_generate_variant:Nn \spath_gclose_with_curve:N {c}
2129 \cs_new_protected_nopar:Npn \__spath_weld:nn #1#2
2130 {
2131 \group_begin:
2132 \tl_set:Nn \l__spath_tmpa_tl {#1}
2133 \tl_set:Nn \l__spath_tmpb_tl {#2}
2134 \spath_finalpoint:Nn \l__spath_tmpc_tl {#1}
2135 \spath_translate_to:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
2136
2137 \__spath_append_no_move:VV \l__spath_tmpa_tl \l__spath_tmpb_tl
2138 \group_end:
2139 }
2140 \cs_new_protected_nopar:Npn \spath_weld:Nnn #1#2#3
2141 {
2142 \__spath_weld:nn {#2}{#3}
2143 \tl_set_eq:NN #1 \g__spath_output_tl
2144 \tl_gclear:N \g__spath_output_tl
2145 }
2146 \cs_generate_variant:Nn \spath_weld:Nnn {NVV,NVn}
2147 \cs_new_protected_nopar:Npn \spath_weld:Nn #1#2
2148 {
2149 \spath_weld:NVn #1#1{#2}
2150 }
2151 \cs_generate_variant:Nn \spath_weld:Nn {NV, Nv, cV, cv}
2152 \cs_new_protected_nopar:Npn \spath_gweld:Nnn #1#2#3
2153 {
2154 \__spath_weld:nn {#2}{#3}
2155 \tl_gset_eq:NN #1 \g__spath_output_tl
2156 \tl_gclear:N \g__spath_output_tl
2157 }
2158 \cs_generate_variant:Nn \spath_gweld:Nnn {NVV, NVn}
2159 \cs_new_protected_nopar:Npn \spath_gweld:Nn #1#2
2160 {
2161 \spath_gweld:NVn #1#1{#2}
2162 }
2163 \cs_generate_variant:Nn \spath_gweld:Nn {NV, Nv, cV, cv}
2164 \cs_new_protected_nopar:Npn \__spath_append_no_move:nn #1#2
2165 {
2166 \group_begin:
2167 \tl_set:Nn \l__spath_tmpa_tl {#1}
2168 \tl_set:Nn \l__spath_tmpb_tl {#2}
2169 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpb_tl}
2170 \spath_finalaction:Nn \l__spath_tmpd_tl {#1}
2171 \bool_if:nT {
2172 ! \tl_if_eq_p:NN \l__spath_tmpd_tl \c_spath_closepath_tl
2173 &&
2174 ! \tl_if_eq_p:NN \l__spath_tmpd_tl \c_spath_rectcorner_tl
2175 &&
2176 \tl_if_eq_p:NN \l__spath_tmpc_tl \c_spath_moveto_tl
2177 }
2178 {
2179 \tl_set:Nx \l__spath_tmpb_tl {\tl_tail:N \l__spath_tmpb_tl}
2180 \tl_set:Nx \l__spath_tmpb_tl {\tl_tail:N \l__spath_tmpb_tl}
2181 \tl_set:Nx \l__spath_tmpb_tl {\tl_tail:N \l__spath_tmpb_tl}
2182 }
2183
2184 \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
2185 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
2186 \group_end:
2187 }
2188 \cs_generate_variant:Nn \__spath_append_no_move:nn {VV}
2189 \cs_new_protected_nopar:Npn \spath_append_no_move:Nnn #1#2#3
2190 {
2191 \__spath_append_no_move:nn {#2}{#3}
2192 \tl_set_eq:NN #1 \g__spath_output_tl
2193 \tl_gclear:N \g__spath_output_tl
2194 }
2195 \cs_generate_variant:Nn \spath_append_no_move:Nnn {NVV, NVn, NnV}
2196 \cs_new_protected_nopar:Npn \spath_append_no_move:Nn #1#2
2197 {
2198 \spath_append_no_move:NVn #1#1{#2}
2199 }
2200 \cs_generate_variant:Nn \spath_append_no_move:Nn {NV, cv, Nv, cV}
2201 \cs_new_protected_nopar:Npn \spath_gappend_no_move:Nnn #1#2#3
2202 {
2203 \__spath_append_no_move:nn {#2}{#3}
2204 \tl_gset_eq:NN #1 \g__spath_output_tl
2205 \tl_gclear:N \g__spath_output_tl
2206 }
2207 \cs_generate_variant:Nn \spath_gappend_no_move:Nnn {NVV, NVn}
2208 \cs_new_protected_nopar:Npn \spath_gappend_no_move:Nn #1#2
2209 {
2210 \spath_gappend_no_move:NVn #1#1{#2}
2211 }
2212 \cs_generate_variant:Nn \spath_gappend_no_move:Nn {NV, cv, Nv, cV}
2213 \cs_new_protected_nopar:Npn \spath_append:Nnn #1#2#3
2214 {
2215 \tl_set:Nn #1 {#2}
2216 \tl_put_right:Nn #1 {#3}
2217 }
2218 \cs_generate_variant:Nn \spath_append:Nnn {NVV, NVn}
2219 \cs_new_protected_nopar:Npn \spath_append:Nn #1#2
2220 {
2221 \spath_append:NVn #1#1{#2}
2222 }
2223 \cs_generate_variant:Nn \spath_append:Nn {NV, Nv, cv, cV}
2224 \cs_new_protected_nopar:Npn \spath_gappend:Nnn #1#2#3
2225 {
2226 \tl_gset:Nn #1 {#2}
2227 \tl_gput_right:Nn #1 {#3}
2228 }
2229 \cs_generate_variant:Nn \spath_gappend:Nnn {NVV, NVn}
2230 \cs_new_protected_nopar:Npn \spath_gappend:Nn #1#2
2231 {
2232 \spath_gappend:NVn #1#1{#2}
2233 }
2234 \cs_generate_variant:Nn \spath_gappend:Nn {NV, Nv, cv, cV}
2235 \cs_new_protected_nopar:Npn \spath_prepend_no_move:Nnn #1#2#3
2236 {
2237 \spath_append_no_move:Nnn #1{#3}{#2}
2238 }
2239 \cs_generate_variant:Nn \spath_prepend_no_move:Nnn {NVV, NVn}
2240 \cs_new_protected_nopar:Npn \spath_prepend_no_move:Nn #1#2
2241 {
2242 \spath_prepend_no_move:NVn #1#1{#2}
2243 }
2244 \cs_generate_variant:Nn \spath_prepend_no_move:Nn {NV, cv}
2245 \cs_new_protected_nopar:Npn \spath_gprepend_no_move:Nnn #1#2#3
2246 {
2247 \spath_gappend_no_move:Nnn #1{#3}{#2}
2248 }
2249 \cs_generate_variant:Nn \spath_gprepend_no_move:Nnn {NVV, NVn}
2250 \cs_new_protected_nopar:Npn \spath_gprepend_no_move:Nn #1#2
2251 {
2252 \spath_gprepend_no_move:NVn #1#1{#2}
2253 }
2254 \cs_generate_variant:Nn \spath_gprepend_no_move:Nn {NV, cv}
2255 \cs_new_protected_nopar:Npn \spath_prepend:Nnn #1#2#3
2256 {
2257 \spath_append:Nnn #1{#3}{#2}
2258 }
2259 \cs_generate_variant:Nn \spath_prepend:Nnn {NVV, NVn}
2260 \cs_new_protected_nopar:Npn \spath_prepend:Nn #1#2
2261 {
2262 \spath_prepend:NVn #1#1{#2}
2263 }
2264 \cs_generate_variant:Nn \spath_prepend:Nn {NV}
2265 \cs_new_protected_nopar:Npn \spath_gprepend:Nnn #1#2#3
2266 {
2267 \spath_gappend:Nnn #1{#3}{#2}
2268 }
2269 \cs_generate_variant:Nn \spath_gprepend:Nnn {NVV, NVn}
2270 \cs_new_protected_nopar:Npn \spath_gprepend:Nn #1#2
2271 {
2272 \spath_gprepend:NVn #1#1{#2}
2273 }
2274 \cs_generate_variant:Nn \spath_gprepend:Nn {NV}
2275 \cs_new_protected_nopar:Npn \__spath_bake_round:n #1
2276 {
2277 \group_begin:
2278 \tl_set:Nn \l__spath_tmpa_tl {#1}
2279 \pgf@@processround \l__spath_tmpa_tl\l__spath_tmpb_tl
2280 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
2281 \group_end:
2282 }
2283 \cs_new_protected_nopar:Npn \spath_bake_round:Nn #1#2
2284 {
2285 \__spath_bake_round:n {#2}
2286 \tl_set_eq:NN #1 \g__spath_output_tl
2287 \tl_gclear:N \g__spath_output_tl
2288 }
2289 \cs_generate_variant:Nn \spath_bake_round:Nn {NV}
2290 \cs_new_protected_nopar:Npn \spath_bake_round:N #1
2291 {
2292 \spath_bake_round:NV #1#1
2293 }
2294 \cs_generate_variant:Nn \spath_bake_round:N {c}
2295 \cs_new_protected_nopar:Npn \spath_gbake_round:Nn #1#2
2296 {
2297 \__spath_bake_round:n {#2}
2298 \tl_gset_eq:NN #1 \g__spath_output_tl
2299 \tl_gclear:N \g__spath_output_tl
2300 }
2301 \cs_generate_variant:Nn \spath_gbake_round:Nn {NV}
2302 \cs_new_protected_nopar:Npn \spath_gbake_round:N #1
2303 {
2304 \spath_gbake_round:NV #1#1
2305 }
2306 \cs_generate_variant:Nn \spath_gbake_round:N {c}
2307 \cs_new_protected_nopar:Npn \__spath_bake_shorten:n #1
2308 {
2309 \group_begin:
2310 \tl_set:Nn \l__spath_tmpa_tl {#1}
2311 \pgfsyssoftpath@getcurrentpath\l__spath_tmpb_tl
2312 \pgfsyssoftpath@setcurrentpath\l__spath_tmpa_tl
2313 \pgf@prepare@end@of@path
2314 \pgf@prepare@start@of@path
2315 \pgfsyssoftpath@getcurrentpath\l__spath_tmpa_tl
2316 \pgfsyssoftpath@setcurrentpath\l__spath_tmpb_tl
2317 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
2318 \group_end:
2319 }
2320 \cs_new_protected_nopar:Npn \spath_bake_shorten:Nn #1#2
2321 {
2322 \__spath_bake_shorten:n {#2}
2323 \tl_set_eq:NN #1 \g__spath_output_tl
2324 \tl_gclear:N \g__spath_output_tl
2325 }
2326 \cs_generate_variant:Nn \spath_bake_shorten:Nn {NV}
2327 \cs_new_protected_nopar:Npn \spath_bake_shorten:N #1
2328 {
2329 \spath_bake_shorten:NV #1#1
2330 }
2331 \cs_generate_variant:Nn \spath_bake_shorten:N {c}
2332 \cs_new_protected_nopar:Npn \spath_gbake_shorten:Nn #1#2
2333 {
2334 \__spath_bake_shorten:n {#2}
2335 \tl_gset_eq:NN #1 \g__spath_output_tl
2336 \tl_gclear:N \g__spath_output_tl
2337 }
2338 \cs_generate_variant:Nn \spath_gbake_shorten:Nn {NV}
2339 \cs_new_protected_nopar:Npn \spath_gbake_shorten:N #1
2340 {
2341 \spath_gbake_shorten:NV #1#1
2342 }
2343 \cs_generate_variant:Nn \spath_gbake_shorten:N {c}
2344 \cs_set_eq:Nc \__spath_pgf_arrow_compute_shortening:n {pgf@arrow@compute@shortening}
2345 \cs_new_nopar:Npn \__spath_arrow_compute_shortening:n #1
2346 {
2347 \__spath_pgf_arrow_compute_shortening:n {#1}
2348 \bool_if:NF \l_spath_arrow_shortening_bool
2349 {
2350 \dim_sub:cn {pgf@xb} {\dim_use:c {pgf@xa}}
2351 \dim_zero:c {pgf@xa}
2352 }
2353 }
2354
2355 \cs_set_eq:cN {pgf@arrow@compute@shortening} \__spath_arrow_compute_shortening:n
2356 \cs_new_protected_nopar:Npn \__spath_close:n #1
2357 {
2358 \group_begin:
2359 \tl_set:Nn \l__spath_tmpa_tl {#1}
2360 \spath_finalmovepoint:NV \l__spath_tmpb_tl \l__spath_tmpa_tl
2361 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_closepath_tl
2362 \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
2363 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
2364 \group_end:
2365 }
2366 \cs_generate_variant:Nn \__spath_close:n {V}
2367 \cs_new_protected_nopar:Npn \spath_close:Nn #1#2
2368 {
2369 \__spath_close:n {#2}
2370 \tl_set_eq:NN #1 \g__spath_output_tl
2371 \tl_gclear:N \g__spath_output_tl
2372 }
2373 \cs_generate_variant:Nn \spath_close:Nn {NV}
2374 \cs_new_protected_nopar:Npn \spath_close:N #1
2375 {
2376 \spath_close:NV #1#1
2377 }
2378 \cs_generate_variant:Nn \spath_close:N {c}
2379 \cs_new_protected_nopar:Npn \spath_gclose:Nn #1#2
2380 {
2381 \__spath_close:n {#2}
2382 \tl_gset_eq:NN #1 \g__spath_output_tl
2383 \tl_gclear:N \g__spath_output_tl
2384 }
2385 \cs_generate_variant:Nn \spath_gclose:Nn {NV}
2386 \cs_new_protected_nopar:Npn \spath_gclose:N #1
2387 {
2388 \spath_gclose:NV #1#1
2389 }
2390 \cs_generate_variant:Nn \spath_gclose:N {c}
2391 \cs_new_protected_nopar:Npn \__spath_adjust_close:n #1
2392 {
2393 \group_begin:
2394 \tl_set:Nn \l__spath_tmpa_tl {#1}
2395 \spath_finalmovepoint:NV \l__spath_tmpb_tl \l__spath_tmpa_tl
2396 \spath_finalpoint:NV \l__spath_tmpc_tl \l__spath_tmpa_tl
2397 \tl_reverse:N \l__spath_tmpa_tl
2398 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2399 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2400 \tl_set:Nx \l__spath_tmpd_tl {\tl_head:N \l__spath_tmpa_tl}
2401 \tl_if_eq:NNT \l__spath_tmpd_tl \c_spath_curveto_tl
2402 {
2403 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2404 \tl_clear:N \l__spath_tmpe_tl
2405 \tl_set:Nx \l__spath_tmpe_tl {
2406 {
2407 \dim_eval:n
2408 {
2409 \tl_item:Nn \l__spath_tmpa_tl {1}
2410 -
2411 \tl_item:Nn \l__spath_tmpc_tl {2}
2412 +
2413 \tl_item:Nn \l__spath_tmpb_tl {2}
2414 }
2415 }
2416 {
2417 \dim_eval:n
2418 {
2419 \tl_item:Nn \l__spath_tmpa_tl {2}
2420 -
2421 \tl_item:Nn \l__spath_tmpc_tl {1}
2422 +
2423 \tl_item:Nn \l__spath_tmpb_tl {1}
2424 }
2425 }
2426 }
2427 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2428 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2429 \tl_put_left:NV \l__spath_tmpa_tl \l__spath_tmpe_tl
2430 \tl_put_left:NV \l__spath_tmpa_tl \l__spath_tmpd_tl
2431 }
2432 \tl_reverse:N \l__spath_tmpa_tl
2433 \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
2434 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_closepath_tl
2435 \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
2436 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
2437 \group_end:
2438 }
2439 \cs_generate_variant:Nn \__spath_adjust_close:n {V}
2440 \cs_new_protected_nopar:Npn \spath_adjust_close:Nn #1#2
2441 {
2442 \__spath_adjust_close:n {#2}
2443 \tl_set_eq:NN #1 \g__spath_output_tl
2444 \tl_gclear:N \g__spath_output_tl
2445 }
2446 \cs_generate_variant:Nn \spath_adjust_close:Nn {NV}
2447 \cs_new_protected_nopar:Npn \spath_adjust_close:N #1
2448 {
2449 \spath_adjust_close:NV #1#1
2450 }
2451 \cs_generate_variant:Nn \spath_adjust_close:N {c}
2452 \cs_new_protected_nopar:Npn \spath_adjust_gclose:Nn #1#2
2453 {
2454 \__spath_adjust_close:n {#2}
2455 \tl_gset_eq:NN #1 \g__spath_output_tl
2456 \tl_gclear:N \g__spath_output_tl
2457 }
2458 \cs_generate_variant:Nn \spath_adjust_gclose:Nn {NV}
2459 \cs_new_protected_nopar:Npn \spath_adjust_gclose:N #1
2460 {
2461 \spath_adjust_gclose:NV #1#1
2462 }
2463 \cs_generate_variant:Nn \spath_adjust_gclose:N {c}
2464 \cs_new_protected_nopar:Npn \__spath_open:n #1
2465 {
2466 \group_begin:
2467 \spath_replace_rectangles:Nn \l__spath_tmpa_tl {#1}
2468 \tl_clear:N \l__spath_tmpb_tl
2469 \bool_until_do:nn {
2470 \tl_if_empty_p:N \l__spath_tmpa_tl
2471 }
2472 {
2473 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
2474 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2475
2476 \token_case_meaning:NnF \l__spath_tmpc_tl
2477 {
2478 \c_spath_closepath_tl {
2479
2480 \bool_if:nF
2481 {
2482 \dim_compare_p:n
2483 {
2484 \l__spath_move_x_dim == \l__spath_tmpa_dim
2485 }
2486 &&
2487 \dim_compare_p:n
2488 {
2489 \l__spath_move_y_dim == \l__spath_tmpb_dim
2490 }
2491 }
2492 {
2493 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_lineto_tl
2494
2495 \tl_put_right:Nx \l__spath_tmpb_tl {
2496 { \dim_use:N \l__spath_move_x_dim }
2497 { \dim_use:N \l__spath_move_y_dim }
2498 }
2499 }
2500
2501 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
2502 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2503 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
2504 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2505 }
2506
2507 \c_spath_moveto_tl {
2508 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
2509
2510 \dim_set:Nn \l__spath_move_x_dim {\tl_head:N \l__spath_tmpa_tl}
2511 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2512 \dim_set:Nn \l__spath_move_y_dim {\tl_head:N \l__spath_tmpa_tl}
2513 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2514
2515 \tl_put_right:Nx \l__spath_tmpb_tl {
2516 { \dim_use:N \l__spath_move_x_dim }
2517 { \dim_use:N \l__spath_move_y_dim }
2518 }
2519
2520 \dim_set_eq:NN \l__spath_tmpa_dim \l__spath_move_x_dim
2521 \dim_set_eq:NN \l__spath_tmpb_dim \l__spath_move_y_dim
2522 }
2523 }
2524 {
2525 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
2526
2527 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl}
2528 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2529 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl}
2530 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2531
2532 \tl_put_right:Nx \l__spath_tmpb_tl {
2533 { \dim_use:N \l__spath_tmpa_dim }
2534 { \dim_use:N \l__spath_tmpb_dim }
2535 }
2536 }
2537 }
2538 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
2539 \group_end:
2540 }
2541 \cs_generate_variant:Nn \__spath_open:n {V}
2542 \cs_new_protected_nopar:Npn \spath_open:Nn #1#2
2543 {
2544 \__spath_open:n {#2}
2545 \tl_set_eq:NN #1 \g__spath_output_tl
2546 \tl_gclear:N \g__spath_output_tl
2547 }
2548 \cs_generate_variant:Nn \spath_open:Nn {NV}
2549 \cs_new_protected_nopar:Npn \spath_open:N #1
2550 {
2551 \spath_open:NV #1#1
2552 }
2553 \cs_new_protected_nopar:Npn \spath_gopen:Nn #1#2
2554 {
2555 \__spath_open:n {#2}
2556 \tl_gset_eq:NN #1 \g__spath_output_tl
2557 \tl_gclear:N \g__spath_output_tl
2558 }
2559 \cs_generate_variant:Nn \spath_gopen:Nn {NV}
2560 \cs_new_protected_nopar:Npn \spath_gopen:N #1
2561 {
2562 \spath_gopen:NV #1#1
2563 }
2564 \cs_generate_variant:Nn \spath_open:N {c}
2565 \cs_generate_variant:Nn \spath_gopen:N {c}
2566 \cs_new_protected_nopar:Npn \__spath_replace_lines:n #1
2567 {
2568 \group_begin:
2569 \tl_set:Nn \l__spath_tmpa_tl {#1}
2570 \tl_clear:N \l__spath_tmpb_tl
2571 \dim_set:Nn \l__spath_tmpa_dim {0pt}
2572 \dim_set:Nn \l__spath_tmpb_dim {0pt}
2573
2574 \bool_do_until:nn
2575 {
2576 \tl_if_empty_p:N \l__spath_tmpa_tl
2577 }
2578 {
2579 \tl_set:Nx \l__spath_tmpc_tl {\tl_item:Nn \l__spath_tmpa_tl {1}}
2580 \tl_set:Nx \l__spath_tmpd_tl {\tl_item:Nn \l__spath_tmpa_tl {2}}
2581 \tl_set:Nx \l__spath_tmpe_tl {\tl_item:Nn \l__spath_tmpa_tl {3}}
2582
2583 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_lineto_tl
2584 {
2585 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_curvetoa_tl
2586 \tl_put_right:Nx \l__spath_tmpb_tl
2587 {
2588 {
2589 \fp_to_dim:n
2590 {
2591 2/3 * (\l__spath_tmpa_dim)
2592 +
2593 1/3 * (\l__spath_tmpd_tl)
2594 }
2595 }
2596 }
2597 \tl_put_right:Nx \l__spath_tmpb_tl
2598 {
2599 {
2600 \fp_to_dim:n
2601 {
2602 2/3 * (\l__spath_tmpb_dim)
2603 +
2604 1/3 * (\l__spath_tmpe_tl)
2605 }
2606 }
2607 }
2608 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_curvetob_tl
2609 \tl_put_right:Nx \l__spath_tmpb_tl
2610 {
2611 {
2612 \fp_to_dim:n
2613 {
2614 1/3 * (\l__spath_tmpa_dim)
2615 +
2616 2/3 * (\l__spath_tmpd_tl)
2617 }
2618 }
2619 }
2620 \tl_put_right:Nx \l__spath_tmpb_tl
2621 {
2622 {
2623 \fp_to_dim:n
2624 {
2625 1/3 * (\l__spath_tmpb_dim)
2626 +
2627 2/3 * (\l__spath_tmpe_tl)
2628 }
2629 }
2630 }
2631 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_curveto_tl
2632 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
2633 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
2634 }
2635 {
2636 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
2637 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
2638 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
2639 }
2640
2641 \dim_set:Nn \l__spath_tmpa_dim {\l__spath_tmpd_tl}
2642 \dim_set:Nn \l__spath_tmpb_dim {\l__spath_tmpe_tl}
2643
2644 \prg_replicate:nn {3}
2645 {
2646 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
2647 }
2648 }
2649 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
2650 \group_end:
2651 }
2652 \cs_generate_variant:Nn \__spath_replace_lines:n {V}
2653 \cs_new_protected_nopar:Npn \spath_replace_lines:Nn #1#2
2654 {
2655 \__spath_replace_lines:n {#2}
2656 \tl_set_eq:NN #1 \g__spath_output_tl
2657 \tl_gclear:N \g__spath_output_tl
2658 }
2659 \cs_generate_variant:Nn \spath_replace_lines:Nn {NV, cV, cv, Nv}
2660 \cs_new_protected_nopar:Npn \spath_replace_lines:N #1
2661 {
2662 \spath_replace_lines:NV #1#1
2663 }
2664 \cs_generate_variant:Nn \spath_replace_lines:N {c}
2665 \cs_new_protected_nopar:Npn \spath_greplace_lines:Nn #1#2
2666 {
2667 \__spath_replace_lines:n {#2}
2668 \tl_gset_eq:NN #1 \g__spath_output_tl
2669 \tl_gclear:N \g__spath_output_tl
2670 }
2671 \cs_generate_variant:Nn \spath_greplace_lines:Nn {NV, cV, cv, Nv}
2672 \cs_new_protected_nopar:Npn \spath_greplace_lines:N #1
2673 {
2674 \spath_greplace_lines:NV #1#1
2675 }
2676 \cs_generate_variant:Nn \spath_greplace_lines:N {c}
2677 \cs_new_protected_nopar:Npn \__spath_replace_rectangles:n #1
2678 {
2679 \group_begin:
2680 \tl_set:Nn \l__spath_tmpa_tl {#1}
2681 \tl_clear:N \l__spath_tmpb_tl
2682
2683 \bool_do_until:nn
2684 {
2685 \tl_if_empty_p:N \l__spath_tmpa_tl
2686 }
2687 {
2688 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl }
2689 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
2690 \tl_set:Nx \l__spath_tmpd_tl {\tl_head:N \l__spath_tmpa_tl }
2691 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
2692 \tl_set:Nx \l__spath_tmpe_tl {\tl_head:N \l__spath_tmpa_tl }
2693 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
2694
2695 \tl_if_eq:NNTF \l__spath_tmpc_tl \c_spath_rectcorner_tl
2696 {
2697
2698 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
2699 \dim_set:Nn \l__spath_tmpa_dim
2700 {
2701 \tl_item:Nn \l__spath_tmpa_tl {1}
2702 }
2703 \dim_set:Nn \l__spath_tmpb_dim
2704 {
2705 \tl_item:Nn \l__spath_tmpa_tl {2}
2706 }
2707
2708 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
2709 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
2710
2711 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_moveto_tl
2712 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
2713 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
2714
2715 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_lineto_tl
2716 \tl_put_right:Nx \l__spath_tmpb_tl
2717 {
2718 {
2719 \fp_to_dim:n { \l__spath_tmpd_tl + \l__spath_tmpa_dim }
2720 }
2721 }
2722 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
2723
2724 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_lineto_tl
2725 \tl_put_right:Nx \l__spath_tmpb_tl
2726 {
2727 {
2728 \fp_to_dim:n { \l__spath_tmpd_tl + \l__spath_tmpa_dim }
2729 }
2730 }
2731 \tl_put_right:Nx \l__spath_tmpb_tl
2732 {
2733 {
2734 \fp_to_dim:n { \l__spath_tmpe_tl + \l__spath_tmpb_dim }
2735 }
2736 }
2737
2738 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_lineto_tl
2739 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
2740 \tl_put_right:Nx \l__spath_tmpb_tl
2741 {
2742 {
2743 \fp_to_dim:n { \l__spath_tmpe_tl + \l__spath_tmpb_dim }
2744 }
2745 }
2746
2747 \tl_put_right:NV \l__spath_tmpb_tl \c_spath_closepath_tl
2748 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
2749 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
2750
2751 }
2752 {
2753 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
2754 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
2755 \__spath_tl_put_right_braced:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
2756 }
2757 }
2758 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
2759 \group_end:
2760 }
2761 \cs_generate_variant:Nn \__spath_replace_rectangles:n {V}
2762 \cs_new_protected_nopar:Npn \spath_replace_rectangles:Nn #1#2
2763 {
2764 \__spath_replace_rectangles:n {#2}
2765 \tl_set_eq:NN #1 \g__spath_output_tl
2766 \tl_gclear:N \g__spath_output_tl
2767 }
2768 \cs_generate_variant:Nn \spath_replace_rectangles:Nn {NV, cV, cv, Nv}
2769 \cs_new_protected_nopar:Npn \spath_replace_rectangles:N #1
2770 {
2771 \spath_replace_rectangles:NV #1#1
2772 }
2773 \cs_generate_variant:Nn \spath_replace_rectangles:N {c}
2774 \cs_new_protected_nopar:Npn \spath_greplace_rectangles:Nn #1#2
2775 {
2776 \__spath_replace_rectangles:n {#2}
2777 \tl_gset_eq:NN #1 \g__spath_output_tl
2778 \tl_gclear:N \g__spath_output_tl
2779 }
2780 \cs_generate_variant:Nn \spath_greplace_rectangles:Nn {NV, cV, cv, Nv}
2781 \cs_new_protected_nopar:Npn \spath_greplace_rectangles:N #1
2782 {
2783 \spath_greplace_rectangles:NV #1#1
2784 }
2785 \cs_generate_variant:Nn \spath_greplace_rectangles:N {c}
2786 \cs_new_protected_nopar:Npn \__spath_remove_empty_components:n #1
2787 {
2788 \group_begin:
2789 \spath_components_to_seq:Nn \l__spath_tmpa_seq {#1}
2790 \tl_clear:N \l__spath_tmpa_tl
2791 \seq_map_inline:Nn \l__spath_tmpa_seq
2792 {
2793 \int_compare:nF
2794 {
2795 \tl_count:n {##1} == 3
2796 }
2797 {
2798 \tl_put_right:Nn \l__spath_tmpa_tl {##1}
2799 }
2800 }
2801 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
2802 \group_end:
2803 }
2804 \cs_new_protected_nopar:Npn \spath_remove_empty_components:Nn #1#2
2805 {
2806 \__spath_remove_empty_components:n {#2}
2807 \tl_set_eq:NN #1 \g__spath_output_tl
2808 \tl_gclear:N \g__spath_output_tl
2809 }
2810 \cs_generate_variant:Nn \spath_remove_empty_components:Nn {NV}
2811 \cs_new_protected_nopar:Npn \spath_remove_empty_components:N #1
2812 {
2813 \spath_remove_empty_components:NV #1#1
2814 }
2815 \cs_generate_variant:Nn \spath_remove_empty_components:N {c}
2816 \cs_new_protected_nopar:Npn \spath_gremove_empty_components:Nn #1#2
2817 {
2818 \__spath_remove_empty_components:n {#2}
2819 \tl_gset_eq:NN #1 \g__spath_output_tl
2820 \tl_gclear:N \g__spath_output_tl
2821 }
2822 \cs_generate_variant:Nn \spath_gremove_empty_components:Nn {NV}
2823 \cs_new_protected_nopar:Npn \spath_gremove_empty_components:N #1
2824 {
2825 \spath_gremove_empty_components:NV #1#1
2826 }
2827 \cs_generate_variant:Nn \spath_gremove_empty_components:N {c}
2828 \prg_new_protected_conditional:Npnn \spath_if_eq:nn #1#2 { T, F, TF }
2829 {
2830 \group_begin:
2831 \tl_set:Nn \l__spath_tmpa_tl {#1}
2832 \tl_set:Nn \l__spath_tmpb_tl {#2}
2833 \bool_gset_true:N \g__spath_tmpa_bool
2834 \int_compare:nNnTF
2835 {\tl_count:N \l__spath_tmpa_tl}
2836 =
2837 {\tl_count:N \l__spath_tmpb_tl}
2838 {
2839 \int_step_inline:nnnn {1} {3} {\tl_count:N \l__spath_tmpa_tl}
2840 {
2841 \tl_set:Nx \l__spath_tmpc_tl {\tl_item:Nn \l__spath_tmpa_tl {##1}}
2842 \tl_set:Nx \l__spath_tmpd_tl {\tl_item:Nn \l__spath_tmpb_tl {##1}}
2843 \tl_if_eq:NNF \l__spath_tmpc_tl \l__spath_tmpd_tl
2844 {
2845 \bool_gset_false:N \g__spath_tmpa_bool
2846 }
2847 \dim_set:Nn \l__spath_tmpa_dim {\tl_item:Nn \l__spath_tmpa_tl {##1+1}}
2848 \dim_set:Nn \l__spath_tmpb_dim {\tl_item:Nn \l__spath_tmpb_tl {##1+1}}
2849 \dim_compare:nF
2850 {
2851 \dim_abs:n
2852 {
2853 \l__spath_tmpa_dim - \l__spath_tmpb_dim
2854 }
2855 < 0.001pt
2856 }
2857 {
2858 \bool_gset_false:N \g__spath_tmpa_bool
2859 }
2860 \dim_set:Nn \l__spath_tmpa_dim {\tl_item:Nn \l__spath_tmpa_tl {##1+2}}
2861 \dim_set:Nn \l__spath_tmpb_dim {\tl_item:Nn \l__spath_tmpb_tl {##1+2}}
2862 \dim_compare:nF
2863 {
2864 \dim_abs:n
2865 {
2866 \l__spath_tmpa_dim - \l__spath_tmpb_dim
2867 }
2868 < 0.001pt
2869 }
2870 {
2871 \bool_gset_false:N \g__spath_tmpa_bool
2872 }
2873 }
2874 }
2875 {
2876 \bool_gset_false:N \g__spath_tmpa_bool
2877 }
2878 \group_end:
2879 \bool_if:NTF \g__spath_tmpa_bool
2880 {
2881 \prg_return_true:
2882 }
2883 {
2884 \prg_return_false:
2885 }
2886 }
2887 \prg_generate_conditional_variant:Nnn \spath_if_eq:nn {VV, Vn, nV, vv} {TF, T, F}
2888 \cs_new_protected_nopar:Npn \__spath_split_curve:nn #1#2
2889 {
2890 \group_begin:
2891 \tl_set_eq:NN \l__spath_tmpa_tl \c_spath_moveto_tl
2892 \tl_put_right:Nx \l__spath_tmpa_tl {
2893 {\tl_item:nn {#1} {2}}
2894 {\tl_item:nn {#1} {3}}
2895 }
2896 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_curvetoa_tl
2897 \tl_put_right:Nx \l__spath_tmpa_tl
2898 {
2899 {\fp_to_dim:n
2900 {
2901 (1 - #2) * \tl_item:nn {#1} {2} + (#2) * \tl_item:nn {#1} {5}
2902 }}
2903 {\fp_to_dim:n
2904 {
2905 (1 - #2) * \tl_item:nn {#1} {3} + (#2) * \tl_item:nn {#1} {6}
2906 }}
2907 }
2908
2909 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_curvetob_tl
2910 \tl_put_right:Nx \l__spath_tmpa_tl
2911 {
2912 {\fp_to_dim:n
2913 {
2914 (1 - #2)^2 * \tl_item:nn {#1} {2}
2915 + 2 * (1 - #2) * (#2) * \tl_item:nn {#1} {5}
2916 + (#2)^2 * \tl_item:nn {#1} {8}
2917 }}
2918 {\fp_to_dim:n
2919 {
2920 (1 - #2)^2 * \tl_item:nn {#1} {3}
2921 + 2 * (1 - #2) * (#2) * \tl_item:nn {#1} {6}
2922 + (#2)^2 * \tl_item:nn {#1} {9}
2923 }}
2924 }
2925
2926 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_curveto_tl
2927 \tl_put_right:Nx \l__spath_tmpa_tl
2928 {
2929 {\fp_to_dim:n
2930 {
2931 (1 - #2)^3 * \tl_item:nn {#1} {2}
2932 + 3 * (1 - #2)^2 * (#2) * \tl_item:nn {#1} {5}
2933 + 3 * (1 - #2) * (#2)^2 * \tl_item:nn {#1} {8}
2934 + (#2)^3 * \tl_item:nn {#1} {11}
2935 }}
2936 {\fp_to_dim:n
2937 {
2938 (1 - #2)^3 * \tl_item:nn {#1} {3}
2939 + 3 * (1 - #2)^2 * (#2) * \tl_item:nn {#1} {6}
2940 + 3 * (1 - #2) * (#2)^2 * \tl_item:nn {#1} {9}
2941 + (#2)^3 * \tl_item:nn {#1} {12}
2942 }}
2943 }
2944
2945 \tl_gclear:N \g__spath_output_tl
2946 \__spath_tl_gput_right_braced:NV \g__spath_output_tl \l__spath_tmpa_tl
2947
2948 \tl_clear:N \l__spath_tmpa_tl
2949 \tl_set_eq:NN \l__spath_tmpa_tl \c_spath_moveto_tl
2950 \tl_put_right:Nx \l__spath_tmpa_tl
2951 {
2952 {\fp_to_dim:n
2953 {
2954 (1 - #2)^3 * \tl_item:nn {#1} {2}
2955 + 3 * (1 - #2)^2 * (#2) * \tl_item:nn {#1} {5}
2956 + 3 * (1 - #2) * (#2)^2 * \tl_item:nn {#1} {8}
2957 + (#2)^3 * \tl_item:nn {#1} {11}
2958 }}
2959 {\fp_to_dim:n
2960 {
2961 (1 - #2)^3 * \tl_item:nn {#1} {3}
2962 + 3 * (1 - #2)^2 * (#2) * \tl_item:nn {#1} {6}
2963 + 3 * (1 - #2) * (#2)^2 * \tl_item:nn {#1} {9}
2964 + (#2)^3 * \tl_item:nn {#1} {12}
2965 }}
2966 }
2967
2968 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_curvetoa_tl
2969 \tl_put_right:Nx \l__spath_tmpa_tl
2970 {
2971 {\fp_to_dim:n
2972 {
2973 (1 - #2)^2 * \tl_item:nn {#1} {5}
2974 + 2 * (1 - #2) * (#2) * \tl_item:nn {#1} {8}
2975 + (#2)^2 * \tl_item:nn {#1} {11}
2976 }}
2977 {\fp_to_dim:n
2978 {
2979 (1 - #2)^2 * \tl_item:nn {#1} {6}
2980 + 2 * (1 - #2) * (#2) * \tl_item:nn {#1} {9}
2981 + (#2)^2 * \tl_item:nn {#1} {12}
2982 }}
2983 }
2984 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_curvetob_tl
2985 \tl_put_right:Nx \l__spath_tmpa_tl
2986 {
2987 {\fp_to_dim:n
2988 {
2989 (1 - #2) * \tl_item:nn {#1} {8} + (#2) * \tl_item:nn {#1} {11}
2990 }}
2991 {\fp_to_dim:n
2992 {
2993 (1 - #2) * \tl_item:nn {#1} {9} + (#2) * \tl_item:nn {#1} {12}
2994 }}
2995 }
2996 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_curveto_tl
2997 \tl_put_right:Nx \l__spath_tmpa_tl {
2998 {\tl_item:nn {#1} {11}}
2999 {\tl_item:nn {#1} {12}}
3000 }
3001
3002 \__spath_tl_gput_right_braced:NV \g__spath_output_tl \l__spath_tmpa_tl
3003 \group_end:
3004 }
3005 \cs_generate_variant:Nn \__spath_split_curve:nn {nv, nV}
3006 \cs_new_protected_nopar:Npn \spath_split_curve:NNnn #1#2#3#4
3007 {
3008 \__spath_split_curve:nn {#3}{#4}
3009 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3010 \tl_set:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3011 \tl_gclear:N \g__spath_output_tl
3012 }
3013 \cs_generate_variant:Nn \spath_split_curve:NNnn {NNnV, NNVn, NNVV}
3014 \cs_new_protected_nopar:Npn \spath_gsplit_curve:NNnn #1#2#3#4
3015 {
3016 \__spath_split_curve:nn {#3}{#4}
3017 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3018 \tl_gset:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3019 \tl_gclear:N \g__spath_output_tl
3020 }
3021 \cs_generate_variant:Nn \spath_gsplit_curve:NNnn {NNnV, NNVn, NNVV}
3022 \cs_new_protected_nopar:Npn \__spath_maybe_split_curve:n #1
3023 {
3024 \group_begin:
3025 \fp_set:Nn \l__spath_tmpa_fp
3026 {
3027 (
3028 \tl_item:nn {#1} {3}
3029 - 3 * \tl_item:nn {#1} {6}
3030 + 3 * \tl_item:nn {#1} {9}
3031 - \tl_item:nn {#1} {12}
3032 )
3033 *
3034 (3 * \tl_item:nn {#1} {8} - 3 * \tl_item:nn {#1} {11})
3035 -
3036 (
3037 \tl_item:nn {#1} {2}
3038 - 3 * \tl_item:nn {#1} {5}
3039 + 3 * \tl_item:nn {#1} {8}
3040 - \tl_item:nn {#1} {11}
3041 )
3042 *
3043 (3 * \tl_item:nn {#1} {9} - 3 * \tl_item:nn {#1} {12})
3044 }
3045 \fp_set:Nn \l__spath_tmpb_fp
3046 {
3047 (
3048 \tl_item:nn {#1} {2}
3049 - 3 * \tl_item:nn {#1} {5}
3050 + 3 * \tl_item:nn {#1} {8}
3051 - \tl_item:nn {#1} {11}
3052 )
3053 *
3054 (
3055 3 * \tl_item:nn {#1} {6}
3056 - 6 * \tl_item:nn {#1} {9}
3057 + 3 * \tl_item:nn {#1} {12}
3058 )
3059 -
3060 (
3061 \tl_item:nn {#1} {3}
3062 - 3 * \tl_item:nn {#1} {6}
3063 + 3 * \tl_item:nn {#1} {9}
3064 - \tl_item:nn {#1} {12}
3065 )
3066 *
3067 (
3068 3 * \tl_item:nn {#1} {5}
3069 - 6 * \tl_item:nn {#1} {8}
3070 + 3 * \tl_item:nn {#1} {11}
3071 )
3072 }
3073 \fp_compare:nTF
3074 {
3075 \l__spath_tmpb_fp != 0
3076 }
3077 {
3078 \fp_set:Nn \l__spath_tmpa_fp {.5 * \l__spath_tmpa_fp / \l__spath_tmpb_fp}
3079 \bool_if:nTF
3080 {
3081 \fp_compare_p:n {0 < \l__spath_tmpa_fp}
3082 &&
3083 \fp_compare_p:n {\l__spath_tmpa_fp < 1}
3084 }
3085 {
3086 \__spath_split_curve:nV {#1} \l__spath_tmpa_fp
3087 }
3088 {
3089 \tl_gset:Nn \g__spath_output_tl { {#1} {} }
3090 }
3091 }
3092 {
3093 \tl_gset:Nn \g__spath_output_tl { {#1} {} }
3094 }
3095 \group_end:
3096 }
3097 \cs_new_protected_nopar:Npn \spath_maybe_split_curve:NNn #1#2#3
3098 {
3099 \__spath_maybe_split_curve:n {#3}
3100 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3101 \tl_set:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3102 \tl_gclear:N \g__spath_output_tl
3103 }
3104 \cs_generate_variant:Nn \spath_maybe_split_curve:NNn {NNn, NNV }
3105 \cs_new_protected_nopar:Npn \spath_maybe_gsplit_curve:NNn #1#2#3
3106 {
3107 \__spath_maybe_split_curve:n {#3}
3108 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3109 \tl_gset:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3110 \tl_gclear:N \g__spath_output_tl
3111 }
3112 \cs_generate_variant:Nn \spath_maybe_gsplit_curve:NNn {NNn, NNV}
3113 \cs_new_protected_nopar:Npn \__spath_split_curves:n #1
3114 {
3115 \group_begin:
3116 \tl_set:Nn \l__spath_tmpa_tl {#1}
3117 \tl_clear:N \l__spath_tmpb_tl
3118 \tl_clear:N \l__spath_tmpc_tl
3119 \bool_do_until:nn
3120 {
3121 \tl_if_empty_p:N \l__spath_tmpa_tl
3122 }
3123 {
3124 \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl}
3125 \token_case_meaning:NnF \l__spath_tmpc_tl
3126 {
3127 \c_spath_curvetoa_tl
3128 {
3129 \tl_clear:N \l__spath_tmpd_tl
3130 \tl_set_eq:NN \l__spath_tmpd_tl \c_spath_moveto_tl
3131 \tl_put_right:Nx \l__spath_tmpd_tl
3132 {
3133 { \dim_use:N \l__spath_tmpa_dim }
3134 { \dim_use:N \l__spath_tmpb_dim }
3135 }
3136 \dim_set:Nn \l__spath_tmpa_dim
3137 {
3138 \tl_item:Nn \l__spath_tmpa_tl {8}
3139 }
3140 \dim_set:Nn \l__spath_tmpb_dim
3141 {
3142 \tl_item:Nn \l__spath_tmpa_tl {9}
3143 }
3144 \prg_replicate:nn {3}
3145 {
3146 \tl_put_right:Nx \l__spath_tmpd_tl
3147 {
3148 \tl_item:Nn \l__spath_tmpa_tl {1}
3149 {\tl_item:Nn \l__spath_tmpa_tl {2}}
3150 {\tl_item:Nn \l__spath_tmpa_tl {3}}
3151 }
3152 \prg_replicate:nn {3}
3153 {
3154 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3155 }
3156 }
3157
3158 \spath_maybe_split_curve:NNV
3159 \l__spath_tmpd_tl
3160 \l__spath_tmpe_tl
3161 \l__spath_tmpd_tl
3162 \prg_replicate:nn {3}
3163 {
3164 \tl_set:Nx \l__spath_tmpd_tl {\tl_tail:N \l__spath_tmpd_tl}
3165 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl}
3166 }
3167 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpd_tl
3168 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
3169 }
3170 }
3171 {
3172 \dim_set:Nn \l__spath_tmpa_dim
3173 {
3174 \tl_item:Nn \l__spath_tmpa_tl {2}
3175 }
3176 \dim_set:Nn \l__spath_tmpb_dim
3177 {
3178 \tl_item:Nn \l__spath_tmpa_tl {3}
3179 }
3180 \tl_put_right:Nx \l__spath_tmpb_tl
3181 {
3182 \tl_item:Nn \l__spath_tmpa_tl {1}
3183 {\tl_item:Nn \l__spath_tmpa_tl {2}}
3184 {\tl_item:Nn \l__spath_tmpa_tl {3}}
3185 }
3186 \prg_replicate:nn {3}
3187 {
3188 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3189 }
3190 }
3191 }
3192 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
3193 \group_end:
3194 }
3195 \cs_new_protected_nopar:Npn \spath_split_curves:Nn #1#2
3196 {
3197 \__spath_split_curves:n {#2}
3198 \tl_set_eq:NN #1 \g__spath_output_tl
3199 \tl_gclear:N \g__spath_output_tl
3200 }
3201 \cs_generate_variant:Nn \spath_split_curves:Nn {NV, cV, cn, cv }
3202 \cs_new_protected_nopar:Npn \spath_split_curves:N #1
3203 {
3204 \spath_split_curves:NV #1#1
3205 }
3206 \cs_generate_variant:Nn \spath_split_curves:N {c}
3207 \cs_new_protected_nopar:Npn \spath_gsplit_curves:Nn #1#2
3208 {
3209 \__spath_split_curves:n {#2}
3210 \tl_gset_eq:NN #1 \g__spath_output_tl
3211 \tl_gclear:N \g__spath_output_tl
3212 }
3213 \cs_generate_variant:Nn \spath_gsplit_curves:Nn {NV, cV, cn, cv }
3214 \cs_new_protected_nopar:Npn \spath_gsplit_curves:N #1
3215 {
3216 \spath_gsplit_curves:NV #1#1
3217 }
3218 \cs_generate_variant:Nn \spath_gsplit_curves:N {c}
3219 \cs_new_protected_nopar:Npn \__spath_split_line:nn #1#2
3220 {
3221 \group_begin:
3222 \tl_set_eq:NN \l__spath_tmpa_tl \c_spath_moveto_tl
3223 \tl_put_right:Nx \l__spath_tmpa_tl {
3224 {\tl_item:nn {#1} {2}}
3225 {\tl_item:nn {#1} {3}}
3226 }
3227 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_lineto_tl
3228 \tl_put_right:Nx \l__spath_tmpa_tl
3229 {
3230 {\fp_to_dim:n
3231 {
3232 (1 - #2) * \tl_item:nn {#1} {2} + (#2) * \tl_item:nn {#1} {5}
3233 }}
3234 {\fp_to_dim:n
3235 {
3236 (1 - #2) * \tl_item:nn {#1} {3} + (#2) * \tl_item:nn {#1} {6}
3237 }}
3238 }
3239 \tl_gclear:N \g__spath_output_tl
3240 \__spath_tl_gput_right_braced:NV \g__spath_output_tl \l__spath_tmpa_tl
3241
3242 \tl_clear:N \l__spath_tmpa_tl
3243 \tl_set_eq:NN \l__spath_tmpa_tl \c_spath_moveto_tl
3244 \tl_put_right:Nx \l__spath_tmpa_tl
3245 {
3246 {\fp_to_dim:n
3247 {
3248 (1 - #2) * \tl_item:nn {#1} {2} + (#2) * \tl_item:nn {#1} {5}
3249 }}
3250 {\fp_to_dim:n
3251 {
3252 (1 - #2) * \tl_item:nn {#1} {3} + (#2) * \tl_item:nn {#1} {6}
3253 }}
3254 }
3255 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_lineto_tl
3256 \tl_put_right:Nx \l__spath_tmpa_tl {
3257 {\tl_item:nn {#1} {5}}
3258 {\tl_item:nn {#1} {6}}
3259 }
3260
3261 \__spath_tl_gput_right_braced:NV \g__spath_output_tl \l__spath_tmpa_tl
3262 \group_end:
3263 }
3264 \cs_new_protected_nopar:Npn \spath_split_line:NNnn #1#2#3#4
3265 {
3266 \__spath_split_line:nn {#3}{#4}
3267 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3268 \tl_set:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3269 \tl_gclear:N \g__spath_output_tl
3270 }
3271 \cs_generate_variant:Nn \spath_split_line:NNnn {NNnV, NNVn, NNVV}
3272 \cs_new_protected_nopar:Npn \spath_gsplit_line:NNnn #1#2#3#4
3273 {
3274 \__spath_split_line:nn {#3}{#4}
3275 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3276 \tl_gset:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3277 \tl_gclear:N \g__spath_output_tl
3278 }
3279 \cs_generate_variant:Nn \spath_gsplit_line:NNnn {NNnV, NNVn, NNVV}
3280 \cs_new_protected_nopar:Npn \__spath_split_rectangle:nn #1#2
3281 {
3282 \group_begin:
3283 \spath_open:Nn \l__spath_tmpa_tl {#1}
3284 \fp_set:Nn \l__spath_tmpa_fp {4*(#2)}
3285 \spath_split_at:NNVV
3286 \l__spath_tmpa_tl \l__spath_tmpb_tl \l__spath_tmpa_tl \l__spath_tmpa_fp
3287 \__spath_append_no_move:VV \l__spath_tmpb_tl \l__spath_tmpa_tl
3288 \group_end:
3289 }
3290 \cs_new_protected_nopar:Npn \spath_split_rectangle:Nnn #1#2#3
3291 {
3292 \__spath_split_rectangle:nn {#2}{#3}
3293 \tl_set_eq:NN #1 \g__spath_output_tl
3294 \tl_gclear:N \g__spath_output_tl
3295 }
3296 \cs_generate_variant:Nn \spath_split_rectangle:Nnn {NnV, NVn, NVV}
3297 \cs_new_protected_nopar:Npn \spath_gsplit_rectangle:Nnn #1#2#3
3298 {
3299 \__spath_split_rectangle:nn {#2}{#3}
3300 \tl_gset_eq:NN #1 \g__spath_output_tl
3301 \tl_gclear:N \g__spath_output_tl
3302 }
3303 \cs_generate_variant:Nn \spath_gsplit_rectangle:Nnn {NnV, NVn, NVV}
3304 \cs_new_protected_nopar:Npn \__spath_split_at:nn #1#2
3305 {
3306 \group_begin:
3307 \int_set:Nn \l__spath_tmpa_int {\fp_to_int:n {floor(#2) + 1}}
3308 \fp_set:Nn \l__spath_tmpa_fp {#2 - floor(#2)}
3309
3310 % Is split point near one end or other of a component?
3311 \fp_compare:nT
3312 {
3313 \l__spath_tmpa_fp < 0.01
3314 }
3315 {
3316 % Near the start, so we'll place it at the start
3317 \fp_set:Nn \l__spath_tmpa_fp {0}
3318 }
3319 \fp_compare:nT
3320 {
3321 \l__spath_tmpa_fp > 0.99
3322 }
3323 {
3324 % Near the end, so we'll place it at the end
3325 \fp_set:Nn \l__spath_tmpa_fp {0}
3326 \int_incr:N \l__spath_tmpa_int
3327 }
3328
3329 \int_zero:N \l__spath_tmpb_int
3330 \bool_set_true:N \l__spath_tmpa_bool
3331
3332 \tl_set:Nn \l__spath_tmpe_tl {#1}
3333
3334 \dim_zero:N \l__spath_tmpa_dim
3335 \dim_zero:N \l__spath_tmpb_dim
3336
3337 % Remember if the component is closed
3338 \spath_finalaction:NV \l__spath_tmpa_tl \l__spath_tmpe_tl
3339
3340 \bool_set:Nn \l__spath_closed_bool
3341 {
3342 \tl_if_eq_p:NN \l__spath_tmpa_tl \c_spath_closepath_tl
3343 ||
3344 \tl_if_eq_p:NN \l__spath_tmpa_tl \c_spath_rectcorner_tl
3345 }
3346
3347 % Open it
3348 \spath_open:N \l__spath_tmpe_tl
3349
3350 \tl_clear:N \l__spath_tmpa_tl
3351 \tl_clear:N \l__spath_tmpb_tl
3352 \tl_clear:N \l__spath_tmpc_tl
3353 \tl_clear:N \l__spath_tmpd_tl
3354
3355 \bool_until_do:nn {
3356 \tl_if_empty_p:N \l__spath_tmpe_tl
3357 ||
3358 \int_compare_p:n { \l__spath_tmpa_int == \l__spath_tmpb_int }
3359 }
3360 {
3361 \tl_set:Nx \l__spath_tmpf_tl {\tl_head:N \l__spath_tmpe_tl}
3362 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3363 \token_case_meaning:Nn \l__spath_tmpf_tl
3364 {
3365 \c_spath_lineto_tl
3366 {
3367 \int_incr:N \l__spath_tmpb_int
3368 }
3369 \c_spath_curvetoa_tl
3370 {
3371 \int_incr:N \l__spath_tmpb_int
3372 }
3373 \c_spath_rectcorner_tl
3374 {
3375 \int_incr:N \l__spath_tmpb_int
3376 }
3377 }
3378 \int_compare:nT { \l__spath_tmpb_int < \l__spath_tmpa_int }
3379 {
3380 \tl_put_right:NV \l__spath_tmpc_tl \l__spath_tmpf_tl
3381
3382 \tl_put_right:Nx \l__spath_tmpc_tl
3383 {{ \tl_head:N \l__spath_tmpe_tl }}
3384 \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpe_tl}
3385 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3386
3387 \tl_put_right:Nx \l__spath_tmpc_tl
3388 {{ \tl_head:N \l__spath_tmpe_tl }}
3389 \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpe_tl}
3390 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3391
3392 }
3393 }
3394
3395 \tl_clear:N \l__spath_tmpd_tl
3396 \tl_put_right:NV \l__spath_tmpd_tl \c_spath_moveto_tl
3397 \tl_put_right:Nx \l__spath_tmpd_tl
3398 {
3399 {\dim_use:N \l__spath_tmpa_dim}
3400 {\dim_use:N \l__spath_tmpb_dim}
3401 }
3402
3403 \fp_compare:nTF
3404 {
3405 \l__spath_tmpa_fp == 0
3406 }
3407 {
3408 \tl_set_eq:NN \l__spath_tmpb_tl \l__spath_tmpd_tl
3409 \tl_if_empty:NF \l__spath_tmpe_tl
3410 {
3411 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpf_tl
3412 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
3413 }
3414 }
3415 {
3416
3417 \token_case_meaning:Nn \l__spath_tmpf_tl
3418 {
3419 \c_spath_lineto_tl
3420 {
3421 \tl_put_right:NV \l__spath_tmpd_tl \l__spath_tmpf_tl
3422 \tl_put_right:Nx \l__spath_tmpd_tl
3423 {{ \tl_head:N \l__spath_tmpe_tl }}
3424 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3425
3426 \tl_put_right:Nx \l__spath_tmpd_tl
3427 {{ \tl_head:N \l__spath_tmpe_tl }}
3428 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3429
3430 \spath_split_line:NNVV
3431 \l__spath_tmpa_tl
3432 \l__spath_tmpb_tl
3433 \l__spath_tmpd_tl
3434 \l__spath_tmpa_fp
3435
3436 \prg_replicate:nn {3} {
3437 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3438 }
3439
3440 \tl_put_right:NV \l__spath_tmpc_tl \l__spath_tmpa_tl
3441 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
3442 }
3443 \c_spath_curvetoa_tl
3444 {
3445 \tl_put_right:NV \l__spath_tmpd_tl \l__spath_tmpf_tl
3446 \tl_put_right:Nx \l__spath_tmpd_tl
3447 {{ \tl_head:N \l__spath_tmpe_tl }}
3448 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3449
3450 \tl_put_right:Nx \l__spath_tmpd_tl
3451 {{ \tl_head:N \l__spath_tmpe_tl }}
3452 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3453
3454 \prg_replicate:nn {2} {
3455
3456 \tl_put_right:Nx \l__spath_tmpd_tl
3457 { \tl_head:N \l__spath_tmpe_tl }
3458 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3459
3460 \tl_put_right:Nx \l__spath_tmpd_tl
3461 {{ \tl_head:N \l__spath_tmpe_tl }}
3462 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3463
3464 \tl_put_right:Nx \l__spath_tmpd_tl
3465 {{ \tl_head:N \l__spath_tmpe_tl }}
3466 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl }
3467 }
3468
3469 \spath_split_curve:NNVV
3470 \l__spath_tmpa_tl
3471 \l__spath_tmpb_tl
3472 \l__spath_tmpd_tl \l__spath_tmpa_fp
3473
3474 \prg_replicate:nn {3} {
3475 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3476 }
3477
3478 \tl_put_right:NV \l__spath_tmpc_tl \l__spath_tmpa_tl
3479 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
3480 }
3481
3482 \c_spath_rectcorner_tl
3483 {
3484 \tl_clear:N \l__spath_tmpd_tl
3485 \tl_put_right:NV \l__spath_tmpd_tl \l__spath_tmpf_tl
3486
3487 \tl_put_right:Nx \l__spath_tmpd_tl {{\tl_head:N \l__spath_tmpe_tl}}
3488 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl}
3489 \tl_put_right:Nx \l__spath_tmpd_tl {{\tl_head:N \l__spath_tmpe_tl}}
3490 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl}
3491
3492 \tl_put_right:Nx \l__spath_tmpd_tl {\tl_head:N \l__spath_tmpe_tl}
3493 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl}
3494
3495 \tl_put_right:Nx \l__spath_tmpd_tl {{\tl_head:N \l__spath_tmpe_tl}}
3496 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl}
3497 \tl_put_right:Nx \l__spath_tmpd_tl {{\tl_head:N \l__spath_tmpe_tl}}
3498 \tl_set:Nx \l__spath_tmpe_tl {\tl_tail:N \l__spath_tmpe_tl}
3499
3500 \spath_split_rectangle:NVV
3501 \l__spath_tmpa_tl
3502 \l__spath_tmpd_tl
3503 \l__spath_tmpa_fp
3504
3505 \tl_put_right:NV \l__spath_tmpc_tl \l__spath_tmpa_tl
3506 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpe_tl
3507 }
3508
3509 }
3510 }
3511
3512 \bool_if:NT \l__spath_closed_bool
3513 {
3514 \prg_replicate:nn {3}
3515 {
3516 \tl_set:Nx \l__spath_tmpc_tl {\tl_tail:N \l__spath_tmpc_tl}
3517 }
3518 \tl_put_right:NV \l__spath_tmpb_tl \l__spath_tmpc_tl
3519 \tl_set_eq:NN \l__spath_tmpc_tl \l__spath_tmpb_tl
3520 \tl_clear:N \l__spath_tmpb_tl
3521 }
3522
3523 \tl_gclear:N \g__spath_output_tl
3524 \__spath_tl_gput_right_braced:NV \g__spath_output_tl \l__spath_tmpc_tl
3525 \__spath_tl_gput_right_braced:NV \g__spath_output_tl \l__spath_tmpb_tl
3526 \group_end:
3527 }
3528 \cs_generate_variant:Nn \__spath_split_at:nn {nV, VV}
3529 \cs_new_protected_nopar:Npn \__spath_split_at_normalised:nn #1#2
3530 {
3531 \group_begin:
3532 \spath_reallength:Nn \l__spath_tmpa_int {#1}
3533
3534 \tl_set:Nx \l__spath_tmpa_tl
3535 {\fp_to_decimal:n {(#2) * (\l__spath_tmpa_int)}}
3536 \__spath_split_at:nV {#1} \l__spath_tmpa_tl
3537 \group_end:
3538 }
3539 \cs_generate_variant:Nn \__spath_split_at_normalised:nn {nV}
3540 \cs_new_protected_nopar:Npn \spath_split_at:NNnn #1#2#3#4
3541 {
3542 \__spath_split_at:nn {#3}{#4}
3543 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3544 \tl_set:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3545 \tl_gclear:N \g__spath_output_tl
3546 }
3547 \cs_generate_variant:Nn \spath_split_at:NNnn {NNVn, NNVV, NNnV}
3548 \cs_new_protected_nopar:Npn \spath_gsplit_at:NNnn #1#2#3#4
3549 {
3550 \__spath_split_at:nn {#3}{#4}
3551 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3552 \tl_gset:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3553 \tl_gclear:N \g__spath_output_tl
3554 }
3555 \cs_generate_variant:Nn \spath_gsplit_at:NNnn {NNVn, NNVV, NNnV}
3556 \cs_new_protected_nopar:Npn \spath_split_at_keep_start:Nnn #1#2#3
3557 {
3558 \__spath_split_at:nn {#2}{#3}
3559 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3560 \tl_gclear:N \g__spath_output_tl
3561 }
3562 \cs_generate_variant:Nn \spath_split_at_keep_start:Nnn {NVn}
3563 \cs_new_protected_nopar:Npn \spath_split_at_keep_start:Nn #1#2
3564 {
3565 \spath_split_at_keep_start:NVn #1#1{#2}
3566 }
3567 \cs_new_protected_nopar:Npn \spath_gsplit_at_keep_start:Nnn #1#2#3
3568 {
3569 \__spath_split_at:nn {#2}{#3}
3570 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3571 \tl_gclear:N \g__spath_output_tl
3572 }
3573 \cs_generate_variant:Nn \spath_gsplit_at_keep_start:Nnn {NVn}
3574 \cs_new_protected_nopar:Npn \spath_gsplit_at_keep_start:Nn #1#2
3575 {
3576 \spath_gsplit_at_keep_start:NVn #1#1{#2}
3577 }
3578 \cs_new_protected_nopar:Npn \spath_split_at_keep_end:Nnn #1#2#3
3579 {
3580 \__spath_split_at:nn {#2}{#3}
3581 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {2}}
3582 \tl_gclear:N \g__spath_output_tl
3583 }
3584 \cs_generate_variant:Nn \spath_split_at_keep_end:Nnn {NVn}
3585 \cs_new_protected_nopar:Npn \spath_split_at_keep_end:Nn #1#2
3586 {
3587 \spath_split_at_keep_end:NVn #1#1{#2}
3588 }
3589 \cs_new_protected_nopar:Npn \spath_gsplit_at_keep_end:Nnn #1#2#3
3590 {
3591 \__spath_split_at:nn {#2}{#3}
3592 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {2}}
3593 \tl_gclear:N \g__spath_output_tl
3594 }
3595 \cs_generate_variant:Nn \spath_gsplit_at_keep_end:Nnn {NVn}
3596 \cs_new_protected_nopar:Npn \spath_gsplit_at_keep_end:Nn #1#2
3597 {
3598 \spath_gsplit_at_keep_end:NVn #1#1{#2}
3599 }
3600 \cs_new_protected_nopar:Npn \spath_split_at_normalised:NNnn #1#2#3#4
3601 {
3602 \__spath_split_at_normalised:nn {#3}{#4}
3603 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3604 \tl_set:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3605 \tl_gclear:N \g__spath_output_tl
3606 }
3607 \cs_generate_variant:Nn \spath_split_at_normalised:NNnn {NNVn, NNVV, NNnV, ccvn}
3608 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised:NNnn #1#2#3#4
3609 {
3610 \__spath_split_at_normalised:nn {#3}{#4}
3611 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3612 \tl_gset:Nx #2 {\tl_item:Nn \g__spath_output_tl {2}}
3613 \tl_gclear:N \g__spath_output_tl
3614 }
3615 \cs_generate_variant:Nn \spath_gsplit_at_normalised:NNnn {NNVn, NNVV, NNnV, ccvn}
3616 \cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_start:Nnn #1#2#3
3617 {
3618 \__spath_split_at_normalised:nn {#2}{#3}
3619 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3620 \tl_gclear:N \g__spath_output_tl
3621 }
3622 \cs_generate_variant:Nn \spath_split_at_normalised_keep_start:Nnn {NVn}
3623 \cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_start:Nn #1#2
3624 {
3625 \spath_split_at_normalised_keep_start:NVn #1#1{#2}
3626 }
3627 \cs_generate_variant:Nn \spath_split_at_normalised_keep_start:Nn {cn}
3628 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_start:Nnn #1#2#3
3629 {
3630 \__spath_split_at_normalised:nn {#2}{#3}
3631 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {1}}
3632 \tl_gclear:N \g__spath_output_tl
3633 }
3634 \cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_start:Nnn {NVn}
3635 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_start:Nn #1#2
3636 {
3637 \spath_gsplit_at_normalised_keep_start:NVn #1#1{#2}
3638 }
3639 \cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_start:Nn {cn}
3640 \cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_end:Nnn #1#2#3
3641 {
3642 \__spath_split_at_normalised:nn {#2}{#3}
3643 \tl_set:Nx #1 {\tl_item:Nn \g__spath_output_tl {2}}
3644 \tl_gclear:N \g__spath_output_tl
3645 }
3646 \cs_generate_variant:Nn \spath_split_at_normalised_keep_end:Nnn {NVn}
3647 \cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_end:Nn #1#2
3648 {
3649 \spath_split_at_normalised_keep_end:NVn #1#1{#2}
3650 }
3651 \cs_generate_variant:Nn \spath_split_at_normalised_keep_end:Nn {cn}
3652 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_end:Nnn #1#2#3
3653 {
3654 \__spath_split_at_normalised:nn {#2}{#3}
3655 \tl_gset:Nx #1 {\tl_item:Nn \g__spath_output_tl {2}}
3656 \tl_gclear:N \g__spath_output_tl
3657 }
3658 \cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_end:Nnn {NVn}
3659 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_end:Nn #1#2
3660 {
3661 \spath_gsplit_at_normalised_keep_end:NVn #1#1{#2}
3662 }
3663 \cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_end:Nn {cn}
3664 \cs_new_protected_nopar:Npn \spath_split_at:Nnn #1#2#3
3665 {
3666 \__spath_split_at:nn {#2}{#3}
3667 \tl_set:Nx #1
3668 {
3669 \tl_item:Nn \g__spath_output_tl {1}
3670 \tl_item:Nn \g__spath_output_tl {2}
3671 }
3672 \tl_gclear:N \g__spath_output_tl
3673 }
3674 \cs_generate_variant:Nn \spath_split_at:Nnn {NVn, NVV}
3675 \cs_new_protected_nopar:Npn \spath_split_at:Nn #1#2
3676 {
3677 \spath_split_at:NVn #1#1{#2}
3678 }
3679 \cs_new_protected_nopar:Npn \spath_gsplit_at:Nnn #1#2#3
3680 {
3681 \__spath_split_at:nn {#2}{#3}
3682 \tl_gset:Nx #1
3683 {
3684 \tl_item:Nn \g__spath_output_tl {1}
3685 \tl_item:Nn \g__spath_output_tl {2}
3686 }
3687 \tl_gclear:N \g__spath_output_tl
3688 }
3689 \cs_generate_variant:Nn \spath_gsplit_at:Nnn {NVn, NVV}
3690 \cs_new_protected_nopar:Npn \spath_gsplit_at:Nn #1#2
3691 {
3692 \spath_gsplit_at:NVn #1#1{#2}
3693 }
3694 \cs_new_protected_nopar:Npn \spath_split_at_normalised:Nnn #1#2#3
3695 {
3696 \__spath_split_at_normalised:nn {#2}{#3}
3697 \tl_set:Nx #1
3698 {
3699 \tl_item:Nn \g__spath_output_tl {1}
3700 \tl_item:Nn \g__spath_output_tl {2}
3701 }
3702 \tl_gclear:N \g__spath_output_tl
3703 }
3704 \cs_generate_variant:Nn \spath_split_at_normalised:Nnn {NVn, NVV}
3705 \cs_new_protected_nopar:Npn \spath_split_at_normalised:Nn #1#2
3706 {
3707 \spath_split_at_normalised:NVn #1#1{#2}
3708 }
3709 \cs_generate_variant:Nn \spath_split_at_normalised:Nn {cn}
3710 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised:Nnn #1#2#3
3711 {
3712 \__spath_split_at_normalised:nn {#2}{#3}
3713 \tl_gset:Nx #1
3714 {
3715 \tl_item:Nn \g__spath_output_tl {1}
3716 \tl_item:Nn \g__spath_output_tl {2}
3717 }
3718 \tl_gclear:N \g__spath_output_tl
3719 }
3720 \cs_generate_variant:Nn \spath_gsplit_at_normalised:Nnn {NVn, NVV}
3721 \cs_new_protected_nopar:Npn \spath_gsplit_at_normalised:Nn #1#2
3722 {
3723 \spath_gsplit_at_normalised:NVn #1#1{#2}
3724 }
3725 \cs_generate_variant:Nn \spath_gsplit_at_normalised:Nn {cn}
3726 \cs_new_protected_nopar:Npn \__spath_shorten_at_end:nn #1#2
3727 {
3728 \int_compare:nTF
3729 {
3730 \tl_count:n {#1} > 3
3731 }
3732 {
3733 \group_begin:
3734 \tl_set:Nn \l__spath_tmpa_tl {#1}
3735 \tl_reverse:N \l__spath_tmpa_tl
3736
3737 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:Nn \l__spath_tmpa_tl {3}}
3738
3739 \tl_clear:N \l__spath_tmpe_tl
3740 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_curveto_tl
3741 {
3742 \int_set:Nn \l__spath_tmpa_int {3}
3743 }
3744 {
3745 \int_set:Nn \l__spath_tmpa_int {1}
3746 }
3747
3748 \prg_replicate:nn { \l__spath_tmpa_int }
3749 {
3750 \tl_put_right:Nx \l__spath_tmpe_tl
3751 {
3752 {\tl_head:N \l__spath_tmpa_tl}
3753 }
3754 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3755 \tl_put_right:Nx \l__spath_tmpe_tl
3756 {
3757 {\tl_head:N \l__spath_tmpa_tl}
3758 }
3759 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3760 \tl_put_right:Nx \l__spath_tmpe_tl
3761 {
3762 \tl_head:N \l__spath_tmpa_tl
3763 }
3764 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3765 }
3766
3767 \tl_put_right:Nx \l__spath_tmpe_tl
3768 {
3769 {\tl_item:Nn \l__spath_tmpa_tl {1}}
3770 {\tl_item:Nn \l__spath_tmpa_tl {2}}
3771 }
3772 \tl_put_right:NV \l__spath_tmpe_tl \c_spath_moveto_tl
3773
3774 \tl_reverse:N \l__spath_tmpa_tl
3775
3776 \fp_set:Nn \l__spath_tmpa_fp
3777 {
3778 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {4}}
3779 -
3780 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {1}}
3781 }
3782
3783 \fp_set:Nn \l__spath_tmpb_fp
3784 {
3785 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {5}}
3786 -
3787 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {2}}
3788 }
3789
3790 \fp_set:Nn \l__spath_tmpc_fp
3791 {
3792 sqrt(
3793 \l__spath_tmpa_fp * \l__spath_tmpa_fp
3794 +
3795 \l__spath_tmpb_fp * \l__spath_tmpb_fp
3796 ) * \l__spath_tmpa_int
3797 }
3798
3799 \fp_compare:nTF
3800 {
3801 \l__spath_tmpc_fp > #2
3802 }
3803 {
3804
3805 \fp_set:Nn \l__spath_tmpc_fp
3806 {
3807 (\l__spath_tmpc_fp - #2)/ \l__spath_tmpc_fp
3808 }
3809
3810 \tl_reverse:N \l__spath_tmpe_tl
3811
3812 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_curveto_tl
3813 {
3814 \spath_split_curve:NNVV
3815 \l__spath_tmpc_tl
3816 \l__spath_tmpd_tl
3817 \l__spath_tmpe_tl
3818 \l__spath_tmpc_fp
3819 }
3820 {
3821 \spath_split_line:NNVV
3822 \l__spath_tmpc_tl
3823 \l__spath_tmpd_tl
3824 \l__spath_tmpe_tl
3825 \l__spath_tmpc_fp
3826 }
3827
3828 \prg_replicate:nn {3}
3829 {
3830 \tl_set:Nx \l__spath_tmpc_tl {\tl_tail:N \l__spath_tmpc_tl}
3831 }
3832
3833 \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpc_tl
3834
3835 }
3836 {
3837
3838 \int_compare:nT
3839 {
3840 \tl_count:N \l__spath_tmpa_tl > 3
3841 }
3842 {
3843 \dim_set:Nn \l__spath_tmpa_dim {\fp_to_dim:n {#2 - \l__spath_tmpc_fp } }
3844 \spath_shorten_at_end:NV \l__spath_tmpa_tl \l__spath_tmpa_dim
3845 }
3846 }
3847
3848 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
3849 \group_end:
3850 }
3851 {
3852 \tl_gset:Nn \g__spath_output_tl {#1}
3853 }
3854 }
3855 \cs_new_protected_nopar:Npn \spath_shorten_at_end:Nnn #1#2#3
3856 {
3857 \__spath_shorten_at_end:nn {#2}{#3}
3858 \tl_set_eq:NN #1 \g__spath_output_tl
3859 \tl_gclear:N \g__spath_output_tl
3860 }
3861 \cs_generate_variant:Nn \spath_shorten_at_end:Nnn {NVV, cnn, cVV, NVn}
3862 \cs_new_protected_nopar:Npn \spath_shorten_at_end:Nn #1#2
3863 {
3864 \spath_shorten_at_end:NVn #1#1{#2}
3865 }
3866 \cs_generate_variant:Nn \spath_shorten_at_end:Nn {cn, cV, NV}
3867 \cs_new_protected_nopar:Npn \spath_gshorten_at_end:Nnn #1#2#3
3868 {
3869 \__spath_shorten_at_end:nn {#2}{#3}
3870 \tl_gset_eq:NN #1 \g__spath_output_tl
3871 \tl_gclear:N \g__spath_output_tl
3872 }
3873 \cs_generate_variant:Nn \spath_gshorten_at_end:Nnn {NVV, cnn, cVV, NVn}
3874 \cs_new_protected_nopar:Npn \spath_gshorten_at_end:Nn #1#2
3875 {
3876 \spath_gshorten_at_end:NVn #1#1{#2}
3877 }
3878 \cs_generate_variant:Nn \spath_gshorten_at_end:Nn {cn, cV, NV}
3879 \cs_new_protected_nopar:Npn \__spath_shorten_at_start:nn #1#2
3880 {
3881 \int_compare:nTF
3882 {
3883 \tl_count:n {#1} > 3
3884 }
3885 {
3886 \group_begin:
3887 \tl_set:Nn \l__spath_tmpa_tl {#1}
3888
3889 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:Nn \l__spath_tmpa_tl {4}}
3890
3891 \tl_clear:N \l__spath_tmpe_tl
3892
3893 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_curvetoa_tl
3894 {
3895 \int_set:Nn \l__spath_tmpa_int {3}
3896 }
3897 {
3898 \int_set:Nn \l__spath_tmpa_int {1}
3899 }
3900
3901 \tl_set_eq:NN \l__spath_tmpe_tl \c_spath_moveto_tl
3902 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
3903
3904 \prg_replicate:nn { \l__spath_tmpa_int }
3905 {
3906 \__spath_tl_put_right_braced:Nx
3907 \l__spath_tmpe_tl
3908 {\tl_item:Nn \l__spath_tmpa_tl {1}}
3909 \__spath_tl_put_right_braced:Nx
3910 \l__spath_tmpe_tl
3911 {\tl_item:Nn \l__spath_tmpa_tl {2}}
3912 \tl_put_right:Nx \l__spath_tmpe_tl {\tl_item:Nn \l__spath_tmpa_tl {3}}
3913
3914 \prg_replicate:nn {3}
3915 {
3916 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl }
3917 }
3918 }
3919 \__spath_tl_put_right_braced:Nx
3920 \l__spath_tmpe_tl
3921 {\tl_item:Nn \l__spath_tmpa_tl {1}}
3922 \__spath_tl_put_right_braced:Nx
3923 \l__spath_tmpe_tl
3924 {\tl_item:Nn \l__spath_tmpa_tl {2}}
3925
3926 \fp_set:Nn \l__spath_tmpa_fp
3927 {
3928 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {5}}
3929 -
3930 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {2}}
3931 }
3932
3933 \fp_set:Nn \l__spath_tmpb_fp
3934 {
3935 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {6}}
3936 -
3937 \dim_to_fp:n {\tl_item:Nn \l__spath_tmpe_tl {3}}
3938 }
3939
3940 \fp_set:Nn \l__spath_tmpc_fp
3941 {
3942 sqrt(
3943 \l__spath_tmpa_fp * \l__spath_tmpa_fp
3944 +
3945 \l__spath_tmpb_fp * \l__spath_tmpb_fp
3946 )
3947 *
3948 \l__spath_tmpa_int
3949 }
3950
3951 \fp_compare:nTF
3952 {
3953 \l__spath_tmpc_fp > #2
3954 }
3955 {
3956
3957 \fp_set:Nn \l__spath_tmpc_fp
3958 {
3959 #2/ \l__spath_tmpc_fp
3960 }
3961
3962 \tl_if_eq:NNTF \l__spath_tmpb_tl \c_spath_curvetoa_tl
3963 {
3964 \spath_split_curve:NNVV
3965 \l__spath_tmpc_tl
3966 \l__spath_tmpd_tl
3967 \l__spath_tmpe_tl
3968 \l__spath_tmpc_fp
3969 }
3970 {
3971 \spath_split_line:NNVV
3972 \l__spath_tmpc_tl
3973 \l__spath_tmpd_tl
3974 \l__spath_tmpe_tl
3975 \l__spath_tmpc_fp
3976 }
3977
3978 \prg_replicate:nn {2}
3979 {
3980 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
3981 }
3982
3983 \tl_put_left:NV \l__spath_tmpa_tl \l__spath_tmpd_tl
3984
3985 }
3986 {
3987
3988 \tl_put_left:NV \l__spath_tmpa_tl \c_spath_moveto_tl
3989
3990 \int_compare:nT
3991 {
3992 \tl_count:N \l__spath_tmpa_tl > 3
3993 }
3994 {
3995 \dim_set:Nn \l__spath_tmpa_dim {\fp_to_dim:n {#2 - \l__spath_tmpc_fp } }
3996 \spath_shorten_at_start:NV \l__spath_tmpa_tl \l__spath_tmpa_dim
3997 }
3998 }
3999
4000 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
4001 \group_end:
4002 }
4003 {
4004 \tl_gset:Nn \g__spath_output_tl {#1}
4005 }
4006 }
4007 \cs_new_protected_nopar:Npn \spath_shorten_at_start:Nnn #1#2#3
4008 {
4009 \__spath_shorten_at_start:nn {#2}{#3}
4010 \tl_set_eq:NN #1 \g__spath_output_tl
4011 \tl_gclear:N \g__spath_output_tl
4012 }
4013 \cs_generate_variant:Nn \spath_shorten_at_start:Nnn {NVV, cnn, cVV, NVn}
4014 \cs_new_protected_nopar:Npn \spath_shorten_at_start:Nn #1#2
4015 {
4016 \spath_shorten_at_start:NVn #1#1{#2}
4017 }
4018 \cs_generate_variant:Nn \spath_shorten_at_start:Nn {cn, cV, NV}
4019 \cs_new_protected_nopar:Npn \spath_gshorten_at_start:Nnn #1#2#3
4020 {
4021 \__spath_shorten_at_start:nn {#2}{#3}
4022 \tl_gset_eq:NN #1 \g__spath_output_tl
4023 \tl_gclear:N \g__spath_output_tl
4024 }
4025 \cs_generate_variant:Nn \spath_gshorten_at_start:Nnn {NVV, cnn, cVV, NVn}
4026 \cs_new_protected_nopar:Npn \spath_gshorten_at_start:Nn #1#2
4027 {
4028 \spath_gshorten_at_start:NVn #1#1{#2}
4029 }
4030 \cs_generate_variant:Nn \spath_gshorten_at_start:Nn {cn, cV, NV}
4031 \cs_new_protected_nopar:Npn \spath_shorten_at_both_ends:Nnn #1#2#3
4032 {
4033 \spath_shorten_at_start:Nnn #1{#2}{#3}
4034 \spath_shorten_at_end:Nnn #1{#2}{#3}
4035 }
4036 \cs_new_protected_nopar:Npn \spath_shorten_at_both_ends:Nn #1#2
4037 {
4038 \spath_shorten_at_start:Nn #1{#2}
4039 \spath_shorten_at_end:Nn #1{#2}
4040 }
4041 \cs_generate_variant:Nn \spath_shorten_at_both_ends:Nn {cn, cV, NV}
4042 \cs_new_protected_nopar:Npn \spath_gshorten_at_both_ends:Nnn #1#2#3
4043 {
4044 \spath_gshorten_at_start:Nnn #1{#2}{#3}
4045 \spath_gshorten_at_end:Nnn #1{#2}{#3}
4046 }
4047 \cs_new_protected_nopar:Npn \spath_gshorten_at_both_ends:Nn #1#2
4048 {
4049 \spath_gshorten_at_start:Nn #1{#2}
4050 \spath_gshorten_at_end:Nn #1{#2}
4051 }
4052 \cs_generate_variant:Nn \spath_gshorten_at_both_ends:Nn {cn, cV, NV}
4053 \cs_new_protected_nopar:Npn \__spath_point_at:nn #1#2
4054 {
4055 \group_begin:
4056 \int_set:Nn \l__spath_tmpa_int {\fp_to_int:n {floor(#2) + 1}}
4057 \fp_set:Nn \l__spath_tmpa_fp {#2 - floor(#2)}
4058
4059 \spath_segments_to_seq:Nn \l__spath_tmpa_seq {#1}
4060
4061 \int_compare:nTF
4062 {
4063 \l__spath_tmpa_int < 1
4064 }
4065 {
4066 \spath_initialpoint:Nn \l__spath_tmpc_tl {#1}
4067 }
4068 {
4069 \int_compare:nTF
4070 {
4071 \l__spath_tmpa_int > \seq_count:N \l__spath_tmpa_seq
4072 }
4073 {
4074 \spath_finalpoint:Nn \l__spath_tmpc_tl {#1}
4075 }
4076 {
4077
4078 \tl_set:Nx
4079 \l__spath_tmpa_tl
4080 {\seq_item:Nn \l__spath_tmpa_seq { \l__spath_tmpa_int} }
4081
4082 \int_compare:nTF
4083 {
4084 \tl_count:N \l__spath_tmpa_tl > 3
4085 }
4086 {
4087 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:Nn \l__spath_tmpa_tl {4}}
4088 }
4089 {
4090 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:Nn \l__spath_tmpa_tl {1}}
4091 }
4092
4093 \tl_clear:N \l__spath_tmpc_tl
4094
4095 \token_case_meaning:Nn \l__spath_tmpb_tl
4096 {
4097 \c_spath_moveto_tl
4098 {
4099 \tl_set:Nx \l__spath_tmpc_tl
4100 {
4101 {
4102 \tl_item:Nn \l__spath_tmpa_tl {2}
4103 }
4104 {
4105 \tl_item:Nn \l__spath_tmpa_tl {3}
4106 }
4107 }
4108 }
4109
4110 \c_spath_lineto_tl
4111 {
4112 \tl_set:Nx \l__spath_tmpc_tl
4113 {
4114 {\fp_to_dim:n
4115 {
4116 (1 - \l__spath_tmpa_fp) * ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4117 +
4118 \l__spath_tmpa_fp * ( \tl_item:Nn \l__spath_tmpa_tl {5} )
4119 }
4120 }
4121 {\fp_to_dim:n
4122 {
4123 (1 - \l__spath_tmpa_fp) * ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4124 +
4125 \l__spath_tmpa_fp * ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4126 }
4127 }
4128 }
4129 }
4130
4131 \c_spath_rectsize_tl
4132 {
4133 \fp_compare:nTF
4134 {
4135 \l__spath_tmpa_fp <= .25
4136 }
4137 {
4138 \tl_set:Nx \l__spath_tmpc_tl
4139 {
4140 {\fp_to_dim:n
4141 {
4142 ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4143 +
4144 4 * \l__spath_tmpa_fp * ( \tl_item:Nn \l__spath_tmpa_tl {5} )
4145 }
4146 }
4147 {\fp_to_dim:n {\tl_item:Nn \l__spath_tmpa_tl {3} } }
4148 }
4149 }
4150 {
4151 \fp_compare:nTF
4152 {
4153 \l__spath_tmpa_fp <= .5
4154 }
4155 {
4156 \tl_set:Nx \l__spath_tmpc_tl
4157 {
4158 {\fp_to_dim:n
4159 {
4160 ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4161 +
4162 ( \tl_item:Nn \l__spath_tmpa_tl {5} )
4163 }
4164 }
4165 {\fp_to_dim:n
4166 {
4167 ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4168 +
4169 (4 * (\l__spath_tmpa_fp) - 1) * ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4170 }
4171 }
4172 }
4173 }
4174 {
4175 \fp_compare:nTF
4176 {
4177 \l__spath_tmpa_fp <= .75
4178 }
4179 {
4180 \tl_set:Nx \l__spath_tmpc_tl
4181 {
4182 {\fp_to_dim:n
4183 {
4184 ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4185 +
4186 (3 - 4 * (\l__spath_tmpa_fp)) *( \tl_item:Nn \l__spath_tmpa_tl {5} )
4187 }
4188 }
4189 {\fp_to_dim:n
4190 {
4191 ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4192 +
4193 ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4194 }
4195 }
4196 }
4197
4198 }
4199 {
4200 \tl_set:Nx \l__spath_tmpc_tl
4201 {
4202 {\fp_to_dim:n
4203 {
4204 ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4205 }
4206 }
4207 {\fp_to_dim:n
4208 {
4209 ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4210 +
4211 (4 - 4 *(\l__spath_tmpa_fp)) * ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4212 }
4213 }
4214 }
4215 }
4216 }
4217 }
4218 }
4219
4220 \c_spath_closepath_tl
4221 {
4222 \tl_set:Nx \l__spath_tmpc_tl
4223 {
4224 {\fp_to_dim:n
4225 {
4226 (1 - \l__spath_tmpa_fp) * ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4227 +
4228 \l__spath_tmpa_fp * ( \tl_item:Nn \l__spath_tmpa_tl {5} )
4229 }
4230 }
4231 {\fp_to_dim:n
4232 {
4233 (1 - \l__spath_tmpa_fp) * ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4234 +
4235 \l__spath_tmpa_fp * ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4236 }
4237 }
4238 }
4239 }
4240
4241 \c_spath_curvetoa_tl
4242 {
4243 \tl_set:Nx \l__spath_tmpc_tl
4244 {
4245 {\fp_to_dim:n
4246 {
4247 (1 - \l__spath_tmpa_fp)^3 * \tl_item:Nn \l__spath_tmpa_tl {2}
4248 + 3 * (1 - \l__spath_tmpa_fp)^2 * (\l__spath_tmpa_fp)
4249 * \tl_item:Nn \l__spath_tmpa_tl {5}
4250 + 3 * (1 - \l__spath_tmpa_fp) * (\l__spath_tmpa_fp)^2
4251 * \tl_item:Nn \l__spath_tmpa_tl {8}
4252 + (\l__spath_tmpa_fp)^3 * \tl_item:Nn \l__spath_tmpa_tl {11}
4253 }}
4254 {\fp_to_dim:n
4255 {
4256 (1 - \l__spath_tmpa_fp)^3 * \tl_item:Nn \l__spath_tmpa_tl {3}
4257 + 3 * (1 - \l__spath_tmpa_fp)^2 * (\l__spath_tmpa_fp)
4258 * \tl_item:Nn \l__spath_tmpa_tl {6}
4259 + 3 * (1 - \l__spath_tmpa_fp) * (\l__spath_tmpa_fp)^2
4260 * \tl_item:Nn \l__spath_tmpa_tl {9}
4261 + (\l__spath_tmpa_fp)^3 * \tl_item:Nn \l__spath_tmpa_tl {12}
4262 }}
4263 }
4264 }
4265 }
4266 }
4267 }
4268
4269 \tl_gclear:N \g__spath_output_tl
4270 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpc_tl
4271 \group_end:
4272 }
4273 \cs_new_protected_nopar:Npn \spath_point_at:Nnn #1#2#3
4274 {
4275 \__spath_point_at:nn {#2}{#3}
4276 \tl_set_eq:NN #1 \g__spath_output_tl
4277 \tl_gclear:N \g__spath_output_tl
4278 }
4279 \cs_generate_variant:Nn \spath_point_at:Nnn {NVn, NVV, NnV}
4280 \cs_new_protected_nopar:Npn \spath_gpoint_at:Nnn #1#2#3
4281 {
4282 \__spath_point_at:nn {#2}{#3}
4283 \tl_gset_eq:NN #1 \g__spath_output_tl
4284 \tl_gclear:N \g__spath_output_tl
4285 }
4286 \cs_generate_variant:Nn \spath_gpoint_at:Nnn {NVn, NVV, NnV}
4287 \cs_new_protected_nopar:Npn \__spath_tangent_at:nn #1#2
4288 {
4289 \group_begin:
4290 \int_set:Nn \l__spath_tmpa_int {\fp_to_int:n {floor(#2) + 1}}
4291 \fp_set:Nn \l__spath_tmpa_fp {#2 - floor(#2)}
4292
4293 \spath_segments_to_seq:Nn \l__spath_tmpa_seq {#1}
4294
4295 \int_compare:nTF
4296 {
4297 \l__spath_tmpa_int < 1
4298 }
4299 {
4300 \spath_initialpoint:Nn \l__spath_tmpc_tl {#1}
4301 }
4302 {
4303 \int_compare:nTF
4304 {
4305 \l__spath_tmpa_int > \seq_count:N \l__spath_tmpa_seq
4306 }
4307 {
4308 \spath_finalpoint:Nn \l__spath_tmpc_tl {#1}
4309 }
4310 {
4311
4312 \tl_set:Nx
4313 \l__spath_tmpa_tl
4314 {\seq_item:Nn \l__spath_tmpa_seq { \l__spath_tmpa_int} }
4315
4316 \int_compare:nTF
4317 {
4318 \tl_count:N \l__spath_tmpa_tl > 3
4319 }
4320 {
4321 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:Nn \l__spath_tmpa_tl {4}}
4322 }
4323 {
4324 \tl_set:Nx \l__spath_tmpb_tl {\tl_item:Nn \l__spath_tmpa_tl {1}}
4325 }
4326
4327 \tl_clear:N \l__spath_tmpc_tl
4328
4329 \token_case_meaning:Nn \l__spath_tmpb_tl
4330 {
4331 \c_spath_moveto_tl
4332 {
4333 \tl_set:Nx \l__spath_tmpc_tl
4334 {
4335 {
4336 \tl_item:Nn \l__spath_tmpa_tl {2}
4337 }
4338 {
4339 \tl_item:Nn \l__spath_tmpa_tl {3}
4340 }
4341 }
4342 }
4343
4344 \c_spath_lineto_tl
4345 {
4346 \tl_set:Nx \l__spath_tmpc_tl
4347 {
4348 {\fp_to_dim:n
4349 {
4350 ( \tl_item:Nn \l__spath_tmpa_tl {5} )
4351 -
4352 ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4353 }
4354 }
4355 {\fp_to_dim:n
4356 {
4357 ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4358 -
4359 ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4360 }
4361 }
4362 }
4363 }
4364
4365 \c_spath_rectsize_tl
4366 {
4367 \fp_compare:nTF
4368 {
4369 \l__spath_tmpa_fp <= .25
4370 }
4371 {
4372 \tl_set:Nx \l__spath_tmpc_tl
4373 {
4374 {\fp_to_dim:n
4375 {
4376 \tl_item:Nn \l__spath_tmpa_tl {5}
4377 }
4378 }
4379 {0pt}
4380 }
4381 }
4382 {
4383 \fp_compare:nTF
4384 {
4385 \l__spath_tmpa_fp <= .5
4386 }
4387 {
4388 \tl_set:Nx \l__spath_tmpc_tl
4389 {
4390 {0pt}
4391 {\fp_to_dim:n
4392 {
4393 ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4394 }
4395 }
4396 }
4397 }
4398 {
4399 \fp_compare:nTF
4400 {
4401 \l__spath_tmpa_fp <= .75
4402 }
4403 {
4404 \tl_set:Nx \l__spath_tmpc_tl
4405 {
4406 {\fp_to_dim:n
4407 {
4408 -( \tl_item:Nn \l__spath_tmpa_tl {5} )
4409 }
4410 }
4411 {0pt}
4412 }
4413
4414 }
4415 {
4416 \tl_set:Nx \l__spath_tmpc_tl
4417 {
4418 {0pt}
4419 {\fp_to_dim:n
4420 {
4421 - ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4422 }
4423 }
4424 }
4425 }
4426 }
4427 }
4428 }
4429
4430 \c_spath_closepath_tl
4431 {
4432 \tl_set:Nx \l__spath_tmpc_tl
4433 {
4434 {\fp_to_dim:n
4435 {
4436 ( \tl_item:Nn \l__spath_tmpa_tl {5} )
4437 -
4438 ( \tl_item:Nn \l__spath_tmpa_tl {2} )
4439 }
4440 }
4441 {\fp_to_dim:n
4442 {
4443 ( \tl_item:Nn \l__spath_tmpa_tl {6} )
4444 -
4445 ( \tl_item:Nn \l__spath_tmpa_tl {3} )
4446 }
4447 }
4448 }
4449 }
4450
4451 \c_spath_curvetoa_tl
4452 {
4453 \tl_set:Nx \l__spath_tmpc_tl
4454 {
4455 {\fp_to_dim:n
4456 {
4457 3*(1 - \l__spath_tmpa_fp)^2 * (\tl_item:Nn \l__spath_tmpa_tl {5}
4458 - \tl_item:Nn \l__spath_tmpa_tl {2})
4459 + 6 * (1 - \l__spath_tmpa_fp) * (\l__spath_tmpa_fp) *
4460 (\tl_item:Nn \l__spath_tmpa_tl {8}
4461 - \tl_item:Nn \l__spath_tmpa_tl {5})
4462 + 3*(\l__spath_tmpa_fp)^2 * (\tl_item:Nn \l__spath_tmpa_tl {11}
4463 - \tl_item:Nn \l__spath_tmpa_tl {8})
4464 }
4465 }
4466 {\fp_to_dim:n
4467 {
4468 3*(1 - \l__spath_tmpa_fp)^2 * (\tl_item:Nn \l__spath_tmpa_tl {6}
4469 - \tl_item:Nn \l__spath_tmpa_tl {3})
4470 + 6 * (1 - \l__spath_tmpa_fp) * (\l__spath_tmpa_fp) *
4471 (\tl_item:Nn \l__spath_tmpa_tl {9}
4472 - \tl_item:Nn \l__spath_tmpa_tl {6})
4473 + 3*(\l__spath_tmpa_fp)^2 * (\tl_item:Nn \l__spath_tmpa_tl {12}
4474 - \tl_item:Nn \l__spath_tmpa_tl {9})
4475 }}
4476 }
4477 }
4478 }
4479 }
4480 }
4481
4482 \tl_gclear:N \g__spath_output_tl
4483 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpc_tl
4484 \group_end:
4485 }
4486 \cs_new_protected_nopar:Npn \spath_tangent_at:Nnn #1#2#3
4487 {
4488 \__spath_tangent_at:nn {#2}{#3}
4489 \tl_set_eq:NN #1 \g__spath_output_tl
4490 \tl_gclear:N \g__spath_output_tl
4491 }
4492 \cs_generate_variant:Nn \spath_tangent_at:Nnn {NVn, NVV, NnV}
4493 \cs_new_protected_nopar:Npn \spath_gtangent_at:Nnn #1#2#3
4494 {
4495 \__spath_tangent_at:nn {#2}{#3}
4496 \tl_gset_eq:NN #1 \g__spath_output_tl
4497 \tl_gclear:N \g__spath_output_tl
4498 }
4499 \cs_generate_variant:Nn \spath_gtangent_at:Nnn {NVn, NVV, NnV}
4500 \cs_new_protected_nopar:Npn \__spath_transformation_at:nn #1#2
4501 {
4502 \group_begin:
4503 \tl_clear:N \l__spath_tmpa_tl
4504 \__spath_tangent_at:nn {#1}{#2}
4505 \tl_set_eq:NN \l__spath_tmpb_tl \g__spath_output_tl
4506 \fp_set:Nn \l__spath_tmpa_fp
4507 {
4508 sqrt(
4509 (\tl_item:Nn \l__spath_tmpb_tl {1})^2
4510 +
4511 (\tl_item:Nn \l__spath_tmpb_tl {2})^2
4512 )
4513 }
4514 \fp_compare:nTF {\l__spath_tmpa_fp = 0}
4515 {
4516 \fp_set:Nn \l__spath_tmpa_fp {1}
4517 \fp_set:Nn \l__spath_tmpb_fp {0}
4518 }
4519 {
4520 \fp_set:Nn \l__spath_tmpb_fp
4521 { (\tl_item:Nn \l__spath_tmpb_tl {2}) / \l__spath_tmpa_fp }
4522 \fp_set:Nn \l__spath_tmpa_fp
4523 { (\tl_item:Nn \l__spath_tmpb_tl {1}) / \l__spath_tmpa_fp }
4524 }
4525 \tl_set:Nx \l__spath_tmpa_tl
4526 {
4527 { \fp_to_decimal:n { \l__spath_tmpa_fp } }
4528 { \fp_to_decimal:n { \l__spath_tmpb_fp } }
4529 { \fp_to_decimal:n {- \l__spath_tmpb_fp } }
4530 { \fp_to_decimal:n { \l__spath_tmpa_fp } }
4531 }
4532 \__spath_point_at:nn {#1}{#2}
4533 \tl_put_right:NV \l__spath_tmpa_tl \g__spath_output_tl
4534 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
4535 \group_end:
4536 }
4537 \cs_new_protected_nopar:Npn \spath_transformation_at:Nnn #1#2#3
4538 {
4539 \__spath_transformation_at:nn {#2}{#3}
4540 \tl_set_eq:NN #1 \g__spath_output_tl
4541 \tl_gclear:N \g__spath_output_tl
4542 }
4543 \cs_generate_variant:Nn \spath_transformation_at:Nnn {NVn, NVV, NnV, NvV}
4544 \cs_new_protected_nopar:Npn \spath_gtransformation_at:Nnn #1#2#3
4545 {
4546 \__spath_transformation_at:nn {#2}{#3}
4547 \tl_gset_eq:NN #1 \g__spath_output_tl
4548 \tl_gclear:N \g__spath_output_tl
4549 }
4550 \cs_generate_variant:Nn \spath_gtransformation_at:Nnn {NVn, NVV, NnV}
4551 \cs_new_protected_nopar:Npn \spath_intersect:NN #1#2
4552 {
4553 \pgfintersectionofpaths%
4554 {%
4555 \pgfsetpath #1
4556 }{%
4557 \pgfsetpath #2
4558 }
4559 }
4560 \cs_new_protected_nopar:Npn \spath_intersect:nn #1#2
4561 {
4562 \tl_set:Nn \l__spath_intersecta_tl {#1}
4563 \tl_set:Nn \l__spath_intersectb_tl {#2}
4564 \spath_intersect:NN \l__spath_intersecta_tl \l__spath_intersectb_tl
4565 }
4566 \cs_new_protected_nopar:Npn \__spath_split_component_at_intersections:nn #1#2
4567 {
4568 \group_begin:
4569 \tl_clear:N \l__spath_tmpe_tl
4570 \seq_clear:N \l__spath_tmpb_seq
4571
4572 % Find the intersections of these segments
4573 \tl_set:Nn \l__spath_tmpb_tl {#1}
4574 \tl_set:Nn \l__spath_tmpc_tl {#2}
4575
4576 % Remember if the component is closed
4577 \spath_finalaction:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
4578
4579 \bool_set:Nn \l__spath_closed_bool
4580 {
4581 \tl_if_eq_p:NN \l__spath_tmpa_tl \c_spath_closepath_tl
4582 ||
4583 \tl_if_eq_p:NN \l__spath_tmpa_tl \c_spath_rectcorner_tl
4584 }
4585
4586 % Open it
4587 \spath_open:N \l__spath_tmpb_tl
4588
4589 \spath_reallength:NV \l__spath_tmpa_int \l__spath_tmpb_tl
4590
4591 % Sort intersections along the component
4592 \pgfintersectionsortbyfirstpath
4593 \spath_intersect:NN \l__spath_tmpb_tl \l__spath_tmpc_tl
4594
4595 % If we get intersections
4596 \int_compare:nT {\pgfintersectionsolutions > 0}
4597 {
4598 % Find the times of the intersections on the component
4599 \int_step_inline:nnnn {1} {1} {\pgfintersectionsolutions}
4600 {
4601 \pgfintersectiongetsolutiontimes{##1}{\l__spath_tmph_tl}{\l__spath_tmpi_tl}
4602 \seq_put_left:NV \l__spath_tmpb_seq \l__spath_tmph_tl
4603 }
4604
4605 \seq_get_left:NN \l__spath_tmpb_seq \l__spath_tmpa_tl
4606 \fp_compare:nT
4607 {
4608 \l__spath_tmpa_tl > \l__spath_tmpa_int - .01
4609 }
4610 {
4611 \bool_set_false:N \l__spath_closed_bool
4612 }
4613
4614 \seq_get_right:NN \l__spath_tmpb_seq \l__spath_tmpa_tl
4615 \fp_compare:nT
4616 {
4617 \l__spath_tmpa_tl < .01
4618 }
4619 {
4620 \bool_set_false:N \l__spath_closed_bool
4621 }
4622
4623 \tl_set:Nn \l__spath_tmpg_tl {-1}
4624
4625 \seq_map_inline:Nn \l__spath_tmpb_seq
4626 {
4627 \tl_set:Nn \l__spath_tmph_tl {##1}
4628
4629 \tl_set_eq:NN \l__spath_tmpa_tl \l__spath_tmph_tl
4630 \int_compare:nT
4631 {
4632 \fp_to_int:n {floor( \l__spath_tmph_tl) }
4633 =
4634 \fp_to_int:n {floor( \l__spath_tmpg_tl) }
4635 }
4636 {
4637 \tl_set:Nx \l__spath_tmph_tl
4638 {
4639 \fp_eval:n {
4640 floor( \l__spath_tmph_tl )
4641 +
4642 ( \l__spath_tmph_tl - floor( \l__spath_tmph_tl) )
4643 /
4644 ( \l__spath_tmpg_tl - floor( \l__spath_tmpg_tl) )
4645 }
4646 }
4647 }
4648 \tl_set_eq:NN \l__spath_tmpg_tl \l__spath_tmpa_tl
4649
4650 \spath_split_at:NNVV
4651 \l__spath_tmpd_tl
4652 \l__spath_tmpf_tl
4653 \l__spath_tmpb_tl
4654 \l__spath_tmph_tl
4655
4656 \tl_put_left:NV \l__spath_tmpe_tl \l__spath_tmpf_tl
4657 \tl_set_eq:NN \l__spath_tmpb_tl \l__spath_tmpd_tl
4658
4659 }
4660
4661 \tl_put_left:NV \l__spath_tmpe_tl \l__spath_tmpb_tl
4662
4663 \spath_remove_empty_components:N \l__spath_tmpe_tl
4664
4665 \tl_set_eq:NN \l__spath_tmpb_tl \l__spath_tmpe_tl
4666 }
4667
4668 \bool_if:NT \l__spath_closed_bool
4669 {
4670 \spath_join_component:Nn \l__spath_tmpb_tl {1}
4671 }
4672
4673 \tl_gclear:N \g__spath_output_tl
4674 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpb_tl
4675
4676 \group_end:
4677 }
4678 \cs_new_protected_nopar:Npn \spath_split_component_at_intersections:Nnn #1#2#3
4679 {
4680 \__spath_split_component_at_intersections:nn {#2}{#3}
4681 \tl_set_eq:NN #1 \g__spath_output_tl
4682 \tl_gclear:N \g__spath_output_tl
4683 }
4684 \cs_generate_variant:Nn \spath_split_component_at_intersections:Nnn {NVn, NVV}
4685 \cs_new_protected_nopar:Npn \spath_split_component_at_intersections:Nn #1#2
4686 {
4687 \spath_split_component_at_intersections:NVn #1#1{#2}
4688 }
4689 \cs_generate_variant:Nn \spath_split_component_at_intersections:Nn {cn, cv}
4690 \cs_new_protected_nopar:Npn \spath_gsplit_component_at_intersections:Nnn #1#2#3
4691 {
4692 \__spath_split_component_at_intersections:nn {#2}{#3}
4693 \tl_gset_eq:NN #1 \g__spath_output_tl
4694 \tl_gclear:N \g__spath_output_tl
4695 }
4696 \cs_generate_variant:Nn \spath_gsplit_component_at_intersections:Nnn {NVn, NVV}
4697 \cs_new_protected_nopar:Npn \spath_gsplit_component_at_intersections:Nn #1#2
4698 {
4699 \spath_gsplit_component_at_intersections:NVn #1#1{#2}
4700 }
4701 \cs_generate_variant:Nn \spath_gsplit_component_at_intersections:Nn {cn, cv}
4702 \cs_new_protected_nopar:Npn \__spath_split_path_at_intersections:nn #1#2
4703 {
4704 \group_begin:
4705
4706 \seq_clear:N \l__spath_tmpa_seq
4707 \seq_clear:N \l__spath_tmpb_seq
4708
4709 \spath_components_to_seq:Nn \l__spath_tmpa_seq {#1}
4710 \seq_map_inline:Nn \l__spath_tmpa_seq
4711 {
4712 \spath_split_component_at_intersections:Nnn \l__spath_tmpa_tl {##1} {#2}
4713 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpa_tl
4714 }
4715
4716 \tl_gclear:N \g__spath_output_tl
4717 \tl_gset:Nx \g__spath_output_tl {\seq_use:Nn \l__spath_tmpb_seq {} }
4718 \group_end:
4719 }
4720 \cs_new_protected_nopar:Npn \spath_split_path_at_intersections:Nnn #1#2#3
4721 {
4722 \__spath_split_path_at_intersections:nn {#2}{#3}
4723 \tl_set_eq:NN #1 \g__spath_output_tl
4724 \tl_gclear:N \g__spath_output_tl
4725 }
4726 \cs_generate_variant:Nn \spath_split_path_at_intersections:Nnn
4727 {NVn, NVV, cVn, cVV, cvn, cvv}
4728 \cs_new_protected_nopar:Npn \spath_split_path_at_intersections:Nn #1#2
4729 {
4730 \spath_split_path_at_intersections:NVn #1#1{#2}
4731 }
4732 \cs_generate_variant:Nn \spath_split_path_at_intersections:Nn {cv, NV}
4733 \cs_new_protected_nopar:Npn \spath_gsplit_path_at_intersections:Nnn #1#2#3
4734 {
4735 \__spath_split_path_at_intersections:nn {#2}{#3}
4736 \tl_gset_eq:NN #1 \g__spath_output_tl
4737 \tl_gclear:N \g__spath_output_tl
4738 }
4739 \cs_generate_variant:Nn \spath_gsplit_path_at_intersections:Nnn
4740 {NVn, NVV, cVn, cVV, cvn, cvv}
4741 \cs_new_protected_nopar:Npn \spath_gsplit_path_at_intersections:Nn #1#2
4742 {
4743 \spath_gsplit_path_at_intersections:NVn #1#1{#2}
4744 }
4745 \cs_generate_variant:Nn \spath_gsplit_path_at_intersections:Nn {cv, NV}
4746 \cs_new_protected_nopar:Npn \spath_split_at_intersections:NNnn #1#2#3#4
4747 {
4748 \__spath_split_path_at_intersections:nn {#3}{#4}
4749 \tl_set_eq:NN #1 \g__spath_output_tl
4750 \__spath_split_path_at_intersections:nn {#4}{#3}
4751 \tl_set_eq:NN #2 \g__spath_output_tl
4752 \tl_gclear:N \g__spath_output_tl
4753 }
4754 \cs_generate_variant:Nn \spath_split_at_intersections:NNnn
4755 {NNVn, NNVV, ccVn, ccVV, ccvn, ccvv}
4756 \cs_new_protected_nopar:Npn \spath_split_at_intersections:NN #1#2
4757 {
4758 \spath_split_at_intersections:NNVV #1#2#1#2
4759 }
4760 \cs_generate_variant:Nn \spath_split_at_intersections:NN {cc}
4761 \cs_new_protected_nopar:Npn \spath_gsplit_at_intersections:NNnn #1#2#3#4
4762 {
4763 \__spath_split_path_at_intersections:nn {#3}{#4}
4764 \tl_gset_eq:NN #1 \g__spath_output_tl
4765 \__spath_split_path_at_intersections:nn {#4}{#3}
4766 \tl_gset_eq:NN #2 \g__spath_output_tl
4767 \tl_gclear:N \g__spath_output_tl
4768 }
4769 \cs_generate_variant:Nn \spath_gsplit_at_intersections:NNnn
4770 {NNVn, NNVV, ccVn, ccVV, ccvn, ccvv}
4771 \cs_new_protected_nopar:Npn \spath_gsplit_at_intersections:NN #1#2
4772 {
4773 \spath_gsplit_at_intersections:NNVV #1#2#1#2
4774 }
4775 \cs_generate_variant:Nn \spath_gsplit_at_intersections:NN {cc}
4776 \cs_new_protected_nopar:Npn \__spath_split_component_at_self_intersections:n #1
4777 {
4778 \group_begin:
4779 \tl_set:Nn \l__spath_tmpe_tl {#1}
4780
4781 % Remember if the component is closed
4782 \spath_finalaction:NV \l__spath_tmpa_tl \l__spath_tmpe_tl
4783
4784 \bool_set:Nn \l__spath_closed_bool
4785 {
4786 \tl_if_eq_p:NN \l__spath_tmpa_tl \c_spath_closepath_tl
4787 }
4788
4789 % Copy the path
4790 \tl_set:Nn \l__spath_tmpe_tl {#1}
4791
4792 % Open the path
4793 \spath_open:N \l__spath_tmpe_tl
4794 % Ensure beziers don't self-intersect
4795 \spath_split_curves:N \l__spath_tmpe_tl
4796
4797 % Make a copy for later
4798 \tl_set_eq:NN \l__spath_tmpg_tl \l__spath_tmpe_tl
4799
4800 % Clear some token lists and sequences
4801 \tl_clear:N \l__spath_tmpd_tl
4802 \seq_clear:N \l__spath_tmpb_seq
4803 \int_zero:N \l__spath_tmpa_int
4804
4805 \pgfintersectionsortbyfirstpath
4806
4807 % Split the path into a sequence of segments
4808 \spath_segments_to_seq:NV \l__spath_tmpa_seq \l__spath_tmpe_tl
4809
4810 \seq_map_indexed_inline:Nn \l__spath_tmpa_seq
4811 {
4812 \seq_map_indexed_inline:Nn \l__spath_tmpa_seq
4813 {
4814 % Don't intersect a segment with itself
4815 \int_compare:nF
4816 {
4817 ##1 == ####1
4818 }
4819 {
4820 \spath_intersect:nn {##2} {####2}
4821
4822 \int_compare:nT {\pgfintersectionsolutions > 0}
4823 {
4824 % Find the times of the intersections on each path
4825 \int_step_inline:nnnn {1} {1} {\pgfintersectionsolutions}
4826 {
4827 \pgfintersectiongetsolutiontimes
4828 {########1}{\l__spath_tmpb_tl}{\l__spath_tmpc_tl}
4829
4830 \bool_if:nT
4831 {
4832 !(
4833 \fp_compare_p:n { \l__spath_tmpb_tl > .99 }
4834 &&
4835 \int_compare_p:n {##1 + 1 == ####1}
4836 )
4837 &&
4838 !(
4839 \fp_compare_p:n { \l__spath_tmpb_tl < .01 }
4840 &&
4841 \int_compare_p:n {##1 - 1 == ####1}
4842 )
4843 &&
4844 !(
4845 \l__spath_closed_bool
4846 &&
4847 \fp_compare_p:n { \l__spath_tmpb_tl < .01 }
4848 &&
4849 \int_compare_p:n {##1 == 1}
4850 &&
4851 \int_compare_p:n {\seq_count:N \l__spath_tmpa_seq == ####1}
4852 )
4853 &&
4854 !(
4855 \l__spath_closed_bool
4856 &&
4857 \fp_compare_p:n { \l__spath_tmpb_tl > .99 }
4858 &&
4859 \int_compare_p:n {####1 == 1}
4860 &&
4861 \int_compare_p:n {\seq_count:N \l__spath_tmpa_seq == ##1}
4862 )
4863 }
4864 {
4865 \tl_set:Nx \l__spath_tmpa_tl
4866 {\fp_to_decimal:n {\l__spath_tmpb_tl + ##1 - 1}}
4867 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpa_tl
4868 }
4869 }
4870 }
4871 }
4872 }
4873 }
4874
4875 % Sort the sequence by reverse order along the path
4876 \seq_sort:Nn \l__spath_tmpb_seq
4877 {
4878 \fp_compare:nNnTF { ##1 } < { ##2 }
4879 { \sort_return_swapped: }
4880 { \sort_return_same: }
4881 }
4882
4883 \seq_get_left:NN \l__spath_tmpb_seq \l__spath_tmpa_tl
4884 \fp_compare:nT
4885 {
4886 \l__spath_tmpa_tl > \seq_count:N \l__spath_tmpa_seq - .01
4887 }
4888 {
4889 \bool_set_false:N \l__spath_closed_bool
4890 }
4891 \seq_get_right:NN \l__spath_tmpb_seq \l__spath_tmpa_tl
4892 \fp_compare:nT
4893 {
4894 \l__spath_tmpa_tl < .01
4895 }
4896 {
4897 \bool_set_false:N \l__spath_closed_bool
4898 }
4899
4900 % Restore the original copy of the path
4901 \tl_set_eq:NN \l__spath_tmpe_tl \l__spath_tmpg_tl
4902
4903 % Clear the token lists
4904 \tl_clear:N \l__spath_tmpf_tl
4905 \tl_clear:N \l__spath_tmph_tl
4906 \tl_clear:N \l__spath_tmpg_tl
4907
4908 \tl_set:Nn \l__spath_tmpi_tl {-1}
4909
4910 \seq_map_inline:Nn \l__spath_tmpb_seq
4911 {
4912 \tl_set:Nn \l__spath_tmpb_tl {##1}
4913 \tl_set_eq:NN \l__spath_tmpa_tl \l__spath_tmpb_tl
4914 \int_compare:nT
4915 {
4916 \fp_to_int:n {floor( \l__spath_tmpb_tl ) }
4917 =
4918 \fp_to_int:n {floor( \l__spath_tmpi_tl) }
4919 }
4920 {
4921 \tl_set:Nx \l__spath_tmpb_tl
4922 {
4923 \fp_eval:n {
4924 floor( \l__spath_tmpb_tl )
4925 +
4926 ( \l__spath_tmpb_tl - floor( \l__spath_tmpb_tl) )
4927 /
4928 ( \l__spath_tmpi_tl - floor( \l__spath_tmpi_tl) )
4929 }
4930 }
4931 }
4932 \tl_set_eq:NN \l__spath_tmpi_tl \l__spath_tmpa_tl
4933
4934 \spath_split_at:NNVV
4935 \l__spath_tmpf_tl
4936 \l__spath_tmph_tl
4937 \l__spath_tmpe_tl
4938 \l__spath_tmpb_tl
4939
4940 \tl_put_left:NV \l__spath_tmpg_tl \l__spath_tmph_tl
4941 \tl_set_eq:NN \l__spath_tmpe_tl \l__spath_tmpf_tl
4942
4943 }
4944
4945 \tl_put_left:NV \l__spath_tmpg_tl \l__spath_tmpe_tl
4946
4947 \tl_if_empty:NT \l__spath_tmpg_tl
4948 {
4949 \tl_set_eq:NN \l__spath_tmpg_tl \l__spath_tmpe_tl
4950 }
4951
4952 \spath_remove_empty_components:N \l__spath_tmpg_tl
4953
4954 % Do something with closed
4955 \bool_if:NT \l__spath_closed_bool
4956 {
4957 \spath_join_component:Nn \l__spath_tmpg_tl {1}
4958 }
4959
4960 \tl_gclear:N \g__spath_output_tl
4961 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpg_tl
4962 \group_end:
4963 }
4964 \cs_new_protected_nopar:Npn \spath_split_component_at_self_intersections:Nn #1#2
4965 {
4966 \__spath_split_component_at_self_intersections:n {#2}
4967 \tl_set_eq:NN #1 \g__spath_output_tl
4968 \tl_gclear:N \g__spath_output_tl
4969 }
4970 \cs_generate_variant:Nn \spath_split_component_at_self_intersections:Nn {NV}
4971 \cs_new_protected_nopar:Npn \spath_split_component_at_self_intersections:N #1
4972 {
4973 \spath_split_component_at_self_intersections:NV #1#1
4974 }
4975 \cs_generate_variant:Nn \spath_split_component_at_self_intersections:N {c}
4976 \cs_new_protected_nopar:Npn \spath_gsplit_component_at_self_intersections:Nn #1#2
4977 {
4978 \__spath_split_component_at_self_intersections:n {#2}
4979 \tl_gset_eq:NN #1 \g__spath_output_tl
4980 \tl_gclear:N \g__spath_output_tl
4981 }
4982 \cs_generate_variant:Nn \spath_gsplit_component_at_self_intersections:Nn {NV}
4983 \cs_new_protected_nopar:Npn \spath_gsplit_component_at_self_intersections:N #1
4984 {
4985 \spath_gsplit_component_at_self_intersections:NV #1#1
4986 }
4987 \cs_generate_variant:Nn \spath_gsplit_component_at_self_intersections:N {c}
4988 \cs_new_protected_nopar:Npn \__spath_split_at_self_intersections:n #1
4989 {
4990 \group_begin:
4991 \spath_components_to_seq:Nn \l__spath_tmpa_seq {#1}
4992 \seq_clear:N \l__spath_tmpb_seq
4993 \seq_clear:N \l__spath_tmpc_seq
4994
4995 % Iterate over the components of the original path.
4996 \bool_do_until:nn
4997 {
4998 \seq_if_empty_p:N \l__spath_tmpa_seq
4999 }
5000 {
5001 % Get the next component
5002 \seq_pop_left:NN \l__spath_tmpa_seq \l__spath_tmpa_tl
5003 % Copy for later
5004 \tl_set_eq:NN \l__spath_tmpc_tl \l__spath_tmpa_tl
5005 \int_compare:nT
5006 {
5007 \tl_count:N \l__spath_tmpa_tl > 3
5008 }
5009 {
5010
5011 % Split against itself
5012 \spath_split_component_at_self_intersections:N \l__spath_tmpa_tl
5013 % Grab the rest of the path
5014 \tl_set:Nx \l__spath_tmpb_tl
5015 {
5016 \seq_use:Nn \l__spath_tmpb_seq {}
5017 \seq_use:Nn \l__spath_tmpa_seq {}
5018 }
5019 % Split against the rest of the path
5020 \spath_split_path_at_intersections:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
5021 }
5022 % Save the split path
5023 \seq_put_right:NV \l__spath_tmpc_seq \l__spath_tmpa_tl
5024 % Add the original copy to the sequence of processed components
5025 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpc_tl
5026 }
5027
5028 \tl_gclear:N \g__spath_output_tl
5029 \tl_gset:Nx \g__spath_output_tl {\seq_use:Nn \l__spath_tmpc_seq {} }
5030 \group_end:
5031 }
5032 \cs_generate_variant:Nn \__spath_split_at_self_intersections:n {V, v}
5033 \cs_new_protected_nopar:Npn \spath_split_at_self_intersections:Nn #1#2
5034 {
5035 \__spath_split_at_self_intersections:n {#2}
5036 \tl_set_eq:NN #1 \g__spath_output_tl
5037 \tl_gclear:N \g__spath_output_tl
5038 }
5039 \cs_generate_variant:Nn \spath_split_at_self_intersections:Nn {NV, cn, cV, cv}
5040 \cs_new_protected_nopar:Npn \spath_split_at_self_intersections:N #1
5041 {
5042 \spath_split_at_self_intersections:NV #1#1
5043 }
5044 \cs_generate_variant:Nn \spath_split_at_self_intersections:N {c}
5045 \cs_new_protected_nopar:Npn \spath_gsplit_at_self_intersections:Nn #1#2
5046 {
5047 \__spath_split_at_self_intersections:n {#2}
5048 \tl_gset_eq:NN #1 \g__spath_output_tl
5049 \tl_gclear:N \g__spath_output_tl
5050 }
5051 \cs_generate_variant:Nn \spath_gsplit_at_self_intersections:Nn {NV, cn, cV, cv}
5052 \cs_new_protected_nopar:Npn \spath_gsplit_at_self_intersections:N #1
5053 {
5054 \spath_gsplit_at_self_intersections:NV #1#1
5055 }
5056 \cs_generate_variant:Nn \spath_gsplit_at_self_intersections:N {c}
5057 \cs_new_protected_nopar:Npn \__spath_join_component:nn #1#2
5058 {
5059 \group_begin:
5060 \spath_numberofcomponents:Nn \l__spath_tmpa_int {#1}
5061
5062 \bool_if:nTF
5063 {
5064 \int_compare_p:n { #2 >= 1 }
5065 &&
5066 \int_compare_p:n { #2 <= \l__spath_tmpa_int }
5067 }
5068 {
5069 \int_compare:nTF
5070 {
5071 #2 == 1
5072 }
5073 {
5074 \int_compare:nTF
5075 {
5076 \l__spath_tmpa_int == 1
5077 }
5078 {
5079 \tl_set:Nn \l__spath_tmpa_tl {#1}
5080 \spath_initialpoint:Nn \l__spath_tmpb_tl {#1}
5081 \tl_put_right:NV \l__spath_tmpa_tl \c_spath_closepath_tl
5082 \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl
5083 \tl_gclear:N \g__spath_output_tl
5084 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
5085 }
5086 {
5087 \spath_components_to_seq:Nn \l__spath_tmpa_seq {#1}
5088 \seq_pop_left:NN \l__spath_tmpa_seq \l__spath_tmpa_tl
5089
5090 \prg_replicate:nn {3}
5091 {
5092 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
5093 }
5094
5095 \seq_put_right:NV \l__spath_tmpa_seq \l__spath_tmpa_tl
5096
5097 \tl_gclear:N \g__spath_output_tl
5098 \tl_gset:Nx \g__spath_output_tl {\seq_use:Nn \l__spath_tmpa_seq {}}
5099 }
5100 }
5101 {
5102 \spath_components_to_seq:Nn \l__spath_tmpa_seq {#1}
5103
5104 \seq_clear:N \l__spath_tmpb_seq
5105 \seq_map_indexed_inline:Nn \l__spath_tmpa_seq
5106 {
5107 \tl_set:Nn \l__spath_tmpa_tl {##2}
5108 \int_compare:nT {##1 = #2}
5109 {
5110 \prg_replicate:nn {3}
5111 {
5112 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
5113 }
5114 }
5115 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpa_tl
5116 }
5117
5118 \tl_gclear:N \g__spath_output_tl
5119 \tl_gset:Nx \g__spath_output_tl {\seq_use:Nn \l__spath_tmpb_seq {}}
5120 }
5121 }
5122 {
5123 \tl_gclear:N \g__spath_output_tl
5124 \tl_gset:Nn \g__spath_output_tl {#1}
5125 }
5126
5127 \group_end:
5128 }
5129 \cs_new_protected_nopar:Npn \spath_join_component:Nnn #1#2#3
5130 {
5131 \__spath_join_component:nn {#2}{#3}
5132 \tl_set_eq:NN #1 \g__spath_output_tl
5133 \tl_gclear:N \g__spath_output_tl
5134 }
5135 \cs_generate_variant:Nn \spath_join_component:Nnn {NVn, NVV}
5136 \cs_new_protected_nopar:Npn \spath_join_component:Nn #1#2
5137 {
5138 \spath_join_component:NVn #1#1{#2}
5139 }
5140 \cs_generate_variant:Nn \spath_join_component:Nn {cn, NV, cV}
5141 \cs_new_protected_nopar:Npn \spath_gjoin_component:Nnn #1#2#3
5142 {
5143 \__spath_join_component:nn {#2}{#3}
5144 \tl_gset_eq:NN #1 \g__spath_output_tl
5145 \tl_gclear:N \g__spath_output_tl
5146 }
5147 \cs_generate_variant:Nn \spath_gjoin_component:Nnn {NVn, NVV}
5148 \cs_new_protected_nopar:Npn \spath_gjoin_component:Nn #1#2
5149 {
5150 \spath_gjoin_component:NVn #1#1{#2}
5151 }
5152 \cs_generate_variant:Nn \spath_gjoin_component:Nn {cn, NV, cV}
5153 \cs_new_protected_nopar:Npn \__spath_spot_weld_components:n #1
5154 {
5155 \group_begin:
5156 \dim_zero:N \l__spath_move_x_dim
5157 \dim_zero:N \l__spath_move_y_dim
5158
5159 \spath_components_to_seq:Nn \l__spath_tmpa_seq {#1}
5160 \seq_clear:N \l__spath_tmpb_seq
5161 \dim_set:Nn \l__spath_move_x_dim {\tl_item:nn {#1} {2} + 10 pt}
5162 \dim_set:Nn \l__spath_move_y_dim {\tl_item:nn {#1} {3} + 10 pt}
5163
5164 \int_set:Nn \l__spath_tmpa_int {\seq_count:N \l__spath_tmpa_seq}
5165
5166 \seq_map_inline:Nn \l__spath_tmpa_seq
5167 {
5168 \tl_set:Nn \l__spath_tmpa_tl {##1}
5169 \bool_if:nT
5170 {
5171 \dim_compare_p:n
5172 {
5173 \dim_abs:n
5174 {\l__spath_move_x_dim - \tl_item:Nn \l__spath_tmpa_tl {2} }
5175 < 0.01pt
5176 }
5177 &&
5178 \dim_compare_p:n
5179 {
5180 \dim_abs:n
5181 {\l__spath_move_y_dim - \tl_item:Nn \l__spath_tmpa_tl {3} }
5182 < 0.01pt
5183 }
5184 }
5185 {
5186 \prg_replicate:nn {3}
5187 {
5188 \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl}
5189 }
5190 \int_decr:N \l__spath_tmpa_int
5191 }
5192 \tl_reverse:N \l__spath_tmpa_tl
5193 \dim_set:Nn \l__spath_move_x_dim {\tl_item:Nn \l__spath_tmpa_tl {2}}
5194 \dim_set:Nn \l__spath_move_y_dim {\tl_item:Nn \l__spath_tmpa_tl {1}}
5195 \tl_reverse:N \l__spath_tmpa_tl
5196 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpa_tl
5197 }
5198
5199 \tl_set:Nx \l__spath_tmpa_tl {\seq_use:Nn \l__spath_tmpb_seq {} }
5200 \spath_components_to_seq:NV \l__spath_tmpb_seq \l__spath_tmpa_tl
5201
5202 \spath_initialpoint:Nn \l__spath_tmpa_tl {#1}
5203 \spath_finalpoint:Nn \l__spath_tmpb_tl {#1}
5204
5205 \bool_if:nT
5206 {
5207 \dim_compare_p:n
5208 {
5209 \dim_abs:n
5210 {
5211 \tl_item:Nn \l__spath_tmpa_tl {1} - \tl_item:Nn \l__spath_tmpb_tl {1}
5212 }
5213 <
5214 0.01pt
5215 }
5216 &&
5217 \dim_compare_p:n
5218 {
5219 \dim_abs:n
5220 {
5221 \tl_item:Nn \l__spath_tmpa_tl {2} - \tl_item:Nn \l__spath_tmpb_tl {2}
5222 }
5223 <
5224 0.01pt
5225 }
5226 }
5227 {
5228 \int_compare:nTF
5229 {
5230 \seq_count:N \l__spath_tmpb_seq > 1
5231 }
5232 {
5233 \seq_pop_left:NN \l__spath_tmpb_seq \l__spath_tmpb_tl
5234
5235 \prg_replicate:nn {3}
5236 {
5237 \tl_set:Nx \l__spath_tmpb_tl {\tl_tail:N \l__spath_tmpb_tl}
5238 }
5239 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpb_tl
5240 }
5241 {
5242 \tl_set:NV \l__spath_tmpb_tl \c_spath_closepath_tl
5243 \tl_put_right:Nx \l__spath_tmpb_tl
5244 {
5245 { \tl_item:Nn \l__spath_tmpa_tl {1} }
5246 { \tl_item:Nn \l__spath_tmpa_tl {2} }
5247 }
5248 \seq_put_right:NV \l__spath_tmpb_seq \l__spath_tmpb_tl
5249 }
5250 }
5251
5252 \tl_gset:Nx \g__spath_output_tl {\seq_use:Nn \l__spath_tmpb_seq {}}
5253 \group_end:
5254 }
5255 \cs_new_protected_nopar:Npn \spath_spot_weld_components:Nn #1#2
5256 {
5257 \__spath_spot_weld_components:n {#2}
5258 \tl_set_eq:NN #1 \g__spath_output_tl
5259 \tl_gclear:N \g__spath_output_tl
5260 }
5261 \cs_generate_variant:Nn \spath_spot_weld_components:Nn {NV, cV, cn}
5262 \cs_new_protected_nopar:Npn \spath_spot_weld_components:N #1
5263 {
5264 \spath_spot_weld_components:NV #1#1
5265 }
5266 \cs_generate_variant:Nn \spath_spot_weld_components:N {c}
5267 \cs_new_protected_nopar:Npn \spath_spot_gweld_components:Nn #1#2
5268 {
5269 \__spath_spot_weld_components:n {#2}
5270 \tl_gset_eq:NN #1 \g__spath_output_tl
5271 \tl_gclear:N \g__spath_output_tl
5272 }
5273 \cs_generate_variant:Nn \spath_spot_gweld_components:Nn {NV, cV, cn}
5274 \cs_new_protected_nopar:Npn \spath_spot_gweld_components:N #1
5275 {
5276 \spath_spot_gweld_components:NV #1#1
5277 }
5278 \cs_generate_variant:Nn \spath_spot_gweld_components:N {c}
5279 \cs_new_protected_nopar:Npn \__spath_convert_to_svg:n #1
5280 {
5281 \group_begin:
5282 \tl_clear:N \l__spath_tmpa_tl
5283 \tl_put_right:Nn \l__spath_tmpa_tl
5284 {
5285 <?xml~ version="1.0"~ standalone="no"?>
5286 \iow_newline:
5287 <!DOCTYPE~ svg~ PUBLIC~ "-//W3C//DTD SVG 1.1//EN"~
5288 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
5289 \iow_newline:
5290 <svg~ xmlns="http://www.w3.org/2000/svg"~ version="1.1"~viewBox="
5291 }
5292
5293 \spath_minbb:Nn \l__spath_tmpb_tl {#1}
5294 \spath_maxbb:Nn \l__spath_tmpc_tl {#1}
5295 \tl_put_right:Nx \l__spath_tmpa_tl
5296 {
5297 \dim_to_decimal:n
5298 {
5299 \tl_item:Nn \l__spath_tmpb_tl {1} - 10pt
5300 }
5301 \exp_not:n {~}
5302 \dim_to_decimal:n
5303 {
5304 \tl_item:Nn \l__spath_tmpb_tl {2} - 10pt
5305 }
5306 \exp_not:n {~}
5307 \dim_to_decimal:n
5308 {
5309 \tl_item:Nn \l__spath_tmpc_tl {1}
5310 -
5311 \tl_item:Nn \l__spath_tmpb_tl {1}
5312 + 20pt
5313 }
5314 \exp_not:n {~}
5315 \dim_to_decimal:n
5316 {
5317 \tl_item:Nn \l__spath_tmpc_tl {2}
5318 -
5319 \tl_item:Nn \l__spath_tmpb_tl {2}
5320 + 20pt
5321 }
5322 }
5323
5324 \tl_put_right:Nn \l__spath_tmpa_tl
5325 {
5326 ">
5327 \iow_newline:
5328 <path~ d="
5329 }
5330 \tl_set:Nn \l__spath_tmpc_tl {use:n}
5331 \tl_map_inline:nn {#1}
5332 {
5333 \tl_set:Nn \l__spath_tmpb_tl {##1}
5334 \token_case_meaning:NnF \l__spath_tmpb_tl
5335 {
5336 \c_spath_moveto_tl
5337 {
5338 \tl_put_right:Nn \l__spath_tmpa_tl {M~}
5339 \tl_set:Nn \l__spath_tmpc_tl {use:n}
5340 }
5341 \c_spath_lineto_tl
5342 {
5343 \tl_put_right:Nn \l__spath_tmpa_tl {L~}
5344 \tl_set:Nn \l__spath_tmpc_tl {use:n}
5345 }
5346 \c_spath_closepath_tl
5347 {
5348 \tl_put_right:Nn \l__spath_tmpa_tl {Z~}
5349 \tl_set:Nn \l__spath_tmpc_tl {use_none:n}
5350 }
5351 \c_spath_curvetoa_tl
5352 {
5353 \tl_put_right:Nn \l__spath_tmpa_tl {C~}
5354 \tl_set:Nn \l__spath_tmpc_tl {use:n}
5355 }
5356 \c_spath_curvetob_tl {
5357 \tl_set:Nn \l__spath_tmpc_tl {use:n}
5358 }
5359 \c_spath_curveto_tl {
5360 \tl_set:Nn \l__spath_tmpc_tl {use:n}
5361 }
5362 }
5363 {
5364 \tl_put_right:Nx
5365 \l__spath_tmpa_tl
5366 {\use:c { \l__spath_tmpc_tl } {\dim_to_decimal:n {##1}} ~}
5367 }
5368 }
5369 \tl_put_right:Nn \l__spath_tmpa_tl
5370 {
5371 "~ fill="none"~ stroke="black"~ />
5372 \iow_newline:
5373 </svg>
5374 \iow_newline:
5375 }
5376 \tl_gset_eq:NN \g__spath_output_tl \l__spath_tmpa_tl
5377 \group_end:
5378 }
5379 \cs_new_protected_nopar:Npn \spath_convert_to_svg:Nn #1#2
5380 {
5381 \__spath_convert_to_svg:n {#2}
5382 \tl_set_eq:NN #1 \g__spath_output_tl
5383 \tl_gclear:N \g__spath_output_tl
5384 }
5385 \cs_new_protected_nopar:Npn \spath_gconvert_to_svg:Nn #1#2
5386 {
5387 \__spath_convert_to_svg:n {#2}
5388 \tl_gset_eq:NN #1 \g__spath_output_tl
5389 \tl_gclear:N \g__spath_output_tl
5390 }
5391 \iow_new:N \g__spath_stream
5392 \cs_new_protected_nopar:Npn \spath_export_to_svg:nn #1#2
5393 {
5394 \group_begin:
5395 \spath_convert_to_svg:Nn \l__spath_tmpa_tl {#2}
5396 \iow_open:Nn \g__spath_stream {#1 .svg}
5397 \iow_now:Nx \g__spath_stream
5398 {
5399 \tl_use:N \l__spath_tmpa_tl
5400 }
5401 \iow_close:N \g__spath_stream
5402 \group_end:
5403 }
5404 \cs_generate_variant:Nn \spath_export_to_svg:nn {nv, nV}
5405 \cs_new_protected_nopar:Npn \spath_show:n #1
5406 {
5407 \int_step_inline:nnnn {1} {3} {\tl_count:n {#1}}
5408 {
5409 \iow_term:x {
5410 \tl_item:nn {#1} {##1}
5411 {\tl_item:nn {#1} {##1+1}}
5412 {\tl_item:nn {#1} {##1+2}}
5413 }
5414 }
5415 }
5416 \cs_generate_variant:Nn \spath_show:n {V, v}
5417 \cs_new_protected_nopar:Npn \spath_get_current_path:N #1
5418 {
5419 \pgfsyssoftpath@getcurrentpath #1
5420 }
5421 \cs_generate_variant:Nn \spath_get_current_path:N {c}
5422 \cs_new_protected_nopar:Npn \spath_gget_current_path:N #1
5423 {
5424 \pgfsyssoftpath@getcurrentpath #1
5425 \tl_gset_eq:NN #1 #1
5426 }
5427 \cs_generate_variant:Nn \spath_gget_current_path:N {c}
5428 \cs_new_protected_nopar:Npn \spath_protocol_path:n #1
5429 {
5430 \spath_minbb:Nn \l__spath_tmpa_tl {#1}
5431 \dim_set:Nn \l__spath_tmpa_dim {\tl_item:Nn \l__spath_tmpa_tl {1}}
5432 \dim_set:Nn \l__spath_tmpb_dim {\tl_item:Nn \l__spath_tmpa_tl {2}}
5433 \pgf@protocolsizes\l__spath_tmpa_dim\l__spath_tmpb_dim
5434
5435 \spath_maxbb:Nn \l__spath_tmpa_tl {#1}
5436 \dim_set:Nn \l__spath_tmpa_dim {\tl_item:Nn \l__spath_tmpa_tl {1}}
5437 \dim_set:Nn \l__spath_tmpb_dim {\tl_item:Nn \l__spath_tmpa_tl {2}}
5438 \pgf@protocolsizes\l__spath_tmpa_dim\l__spath_tmpb_dim
5439 }
5440 \cs_generate_variant:Nn \spath_protocol_path:n {V}
5441 \cs_new_protected_nopar:Npn \spath_set_current_path:n #1
5442 {
5443 \spath_protocol_path:n {#1}
5444 \tl_set:Nn \l__spath_tmpa_tl {#1}
5445 \pgfsyssoftpath@setcurrentpath\l__spath_tmpa_tl
5446 }
5447 \cs_new_protected_nopar:Npn \spath_set_current_path:N #1
5448 {
5449 \spath_protocol_path:V #1
5450 \pgfsyssoftpath@setcurrentpath #1
5451 }
5452 \cs_generate_variant:Nn \spath_set_current_path:N {c}
5453 \cs_new_protected_nopar:Npn \spath_use_path:nn #1#2
5454 {
5455 \spath_set_current_path:n {#1}
5456 \pgfusepath{#2}
5457 }
5458 \cs_new_protected_nopar:Npn \spath_tikz_path:nn #1#2
5459 {
5460 \tl_if_empty:nF {#2}
5461 {
5462 \path[#1] \pgfextra{
5463 \spath_set_current_path:n {#2}
5464 \tl_put_left:Nn \tikz@preactions {\def\tikz@actions@path{#2}}
5465 };
5466 }
5467 }
5468 \cs_generate_variant:Nn \spath_tikz_path:nn {Vn, VV, nv, Vv, nV}
5469 \cs_new_protected_nopar:Npn \spath_set_tikz_data:n #1
5470 {
5471 \spath_finalpoint:Nn \l__spath_tmpa_tl {#1}
5472 \tl_set:Nx \l__spath_tmpa_tl
5473 {
5474 \exp_not:c {pgf@x}=\tl_item:Nn \l__spath_tmpa_tl {1} \relax
5475 \exp_not:c {pgf@y}=\tl_item:Nn \l__spath_tmpa_tl {2} \relax
5476 }
5477 \use:c {pgf@process}{%
5478 \tl_use:N \l__spath_tmpa_tl
5479 \pgftransforminvert
5480 \use:c {pgf@pos@transform@glob}
5481 }
5482 \tl_set:Nx \l__spath_tmpa_tl
5483 {
5484 \exp_not:c {tikz@lastx}=\exp_not:c {pgf@x} \relax
5485 \exp_not:c {tikz@lasty}=\exp_not:c {pgf@y} \relax
5486 \exp_not:c {tikz@lastxsaved}=\exp_not:c {pgf@x} \relax
5487 \exp_not:c {tikz@lastysaved}=\exp_not:c {pgf@y} \relax
5488 }
5489 \tl_use:N \l__spath_tmpa_tl
5490 \spath_finalmovepoint:Nn \l__spath_tmpa_tl {#1}
5491 \bool_if:NT \l_spath_movetorelevant_bool
5492 {
5493 \ifpgfsyssoftpathmovetorelevant%
5494 \tl_gset_eq:cN {pgfsyssoftpath@lastmoveto} \l__spath_tmpa_tl
5495 \fi
5496 }
5497 \tl_set:Nx \l__spath_tmpa_tl
5498 {
5499 \exp_not:c {pgf@x}=\tl_item:Nn \l__spath_tmpa_tl {1} \relax
5500 \exp_not:c {pgf@y}=\tl_item:Nn \l__spath_tmpa_tl {2} \relax
5501 }
5502 \use:c {pgf@process}{%
5503 \tl_use:N \l__spath_tmpa_tl
5504 \pgftransforminvert
5505 \use:c {pgf@pos@transform@glob}
5506 }
5507 \bool_if:NT \l_spath_movetorelevant_bool
5508 {
5509 \dim_if_exist:cT {tikz@lastmovetox}
5510 {
5511 \tl_set:Nx \l__spath_tmpa_tl
5512 {
5513 \exp_not:c {tikz@lastmovetox}=\exp_not:c {pgf@x} \relax
5514 \exp_not:c {tikz@lastmovetoy}=\exp_not:c {pgf@y} \relax
5515 }
5516 \tl_use:N \l__spath_tmpa_tl
5517 }
5518 }
5519 \tl_clear_new:c {tikz@timer}
5520 \tl_set:cn {tikz@timer}
5521 {
5522 \pgftransformreset
5523 \spath_reallength:Nn \l__spath_tmpa_int {#1}
5524 \tl_set_eq:Nc \l__spath_tmpb_tl {tikz@time}
5525 \tl_set:Nx \l__spath_tmpb_tl
5526 {\fp_to_decimal:n {(\l__spath_tmpb_tl) * (\l__spath_tmpa_int)}}
5527 \spath_transformation_at:NnV \l__spath_tmpc_tl {#1} \l__spath_tmpb_tl
5528
5529 \tl_set:Nx \l__spath_tmpa_tl
5530 {
5531 \exp_not:N \pgfpoint
5532 { \tl_item:Nn \l__spath_tmpc_tl {5} }
5533 { \tl_item:Nn \l__spath_tmpc_tl {6} }
5534 }
5535 \exp_args:NV \pgftransformshift \l__spath_tmpa_tl
5536
5537 \ifpgfresetnontranslationattime
5538 \pgftransformresetnontranslations
5539 \fi
5540
5541 \ifpgfslopedattime
5542
5543 \tl_set:Nx \l__spath_tmpa_tl
5544 {
5545 { \tl_item:Nn \l__spath_tmpc_tl {1} }
5546 { \tl_item:Nn \l__spath_tmpc_tl {2} }
5547 { \tl_item:Nn \l__spath_tmpc_tl {3} }
5548 { \tl_item:Nn \l__spath_tmpc_tl {4} }
5549 }
5550 \ifpgfallowupsidedownattime
5551 \else
5552 \fp_compare:nT { \tl_item:Nn \l__spath_tmpc_tl {4} < 0}
5553 {
5554 \tl_set:Nx \l__spath_tmpa_tl
5555 {
5556 { \fp_eval:n { - (\tl_item:Nn \l__spath_tmpc_tl {1})} }
5557 { \fp_eval:n { - (\tl_item:Nn \l__spath_tmpc_tl {2})} }
5558 { \fp_eval:n { - (\tl_item:Nn \l__spath_tmpc_tl {3})} }
5559 { \fp_eval:n { - (\tl_item:Nn \l__spath_tmpc_tl {4})} }
5560 }
5561 }
5562 \fi
5563 \tl_put_right:Nn \l__spath_tmpa_tl {{\pgfpointorigin}}
5564 \exp_last_unbraced:NV \pgftransformcm \l__spath_tmpa_tl
5565 \fi
5566 }
5567 }
5568 \cs_generate_variant:Nn \spath_set_tikz_data:n {V, v}
5569 %%
5570 %% Copyright (C) 2011-2024 by Andrew Stacey <[email protected]>
5571 %%
5572 %% This work may be distributed and/or modified under the
5573 %% conditions of the LaTeX Project Public License (LPPL), either
5574 %% version 1.3c of this license or (at your option) any later
5575 %% version. The latest version of this license is in the file:
5576 %%
5577 %% http://www.latex-project.org/lppl.txt
5578 %%
5579 %% This work is "maintained" (as per LPPL maintenance status) by
5580 %% Andrew Stacey.
5581 %%
5582 %% This work consists of the files spath3_code.dtx
5583 %% calligraphy_doc.tex
5584 %% knots_doc.tex
5585 %% spath3.tex
5586 %% and the derived files spath3.ins,
5587 %% spath3_code.pdf,
5588 %% spath3.sty,
5589 %% tikzlibrarycalligraphy.code.tex
5590 %% tikzlibraryknots.code.tex
5591 %% tikzlibraryspath3.code.tex
5592 %% calligraphy.pdf
5593 %% knots.pdf
5594 %% spath3.pdf
5595 %% README.txt
5596 %%
5597 %%
5598 %% End of file `spath3.sty'.