Debian Codegraph @

texmf-dist/source/latex/l3experimental/l3draw/l3draw-softpath.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3draw-softpath.dtx
4 %
5 % Copyright (C) 2018-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % http://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "l3experimental bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/latex3/latex3
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \RequirePackage{expl3}
27 \documentclass[full]{l3doc}
28 \begin{document}
29 \DocInput{\jobname.dtx}
30 \end{document}
31 %</driver>
32 % \fi
33 %
34 % \title{^^A
35 % The \pkg{l3draw-softpath} package\\ Soft paths^^A
36 % }
37 %
38 % \author{^^A
39 % The \LaTeX{} Project\thanks
40 % {^^A
41 % E-mail:
42 % \href{mailto:[email protected]}
43 % {[email protected]}^^A
44 % }^^A
45 % }
46 %
47 % \date{Released 2026-05-26}
48 %
49 % \maketitle
50 %
51 % \begin{implementation}
52 %
53 % \section{\pkg{l3draw-softpath} implementation}
54 %
55 % \begin{macrocode}
56 %<*package>
57 % \end{macrocode}
58 %
59 % \begin{macrocode}
60 %<@@=draw>
61 % \end{macrocode}
62 %
63 % \subsection{Managing soft paths}
64 %
65 % There are two linked aims in the code here. The most significant is to
66 % provide a way to modify paths, for example to shorten the ends or round
67 % the corners. This means that the path cannot be written piecemeal as
68 % specials, but rather needs to be held in macros. The second aspect that
69 % follows from this is performance: simply adding to a single macro a piece
70 % at a time will have poor performance as the list gets long so we use
71 % \cs[no-index]{tl_build_\ldots{}} functions.
72 %
73 % Each marker (operation) token takes two arguments, which makes processing
74 % more straight-forward. As such, some operations have dummy arguments, whilst
75 % others have to be split over several tokens. As the code here is at a low
76 % level, all dimension arguments are assumed to be explicit and fully-expanded.
77 %
78 % \begin{variable}{\g_@@_softpath_main_tl}
79 % The soft path itself.
80 % \begin{macrocode}
81 \tl_new:N \g_@@_softpath_main_tl
82 % \end{macrocode}
83 % \end{variable}
84 %
85 % \begin{variable}{\l_@@_softpath_tmp_tl}
86 % Scratch space.
87 % \begin{macrocode}
88 \tl_new:N \l_@@_softpath_tmp_tl
89 % \end{macrocode}
90 % \end{variable}
91 %
92 % \begin{variable}{\g_@@_softpath_corners_bool}
93 % Allow for optimized path use.
94 % \begin{macrocode}
95 \bool_new:N \g_@@_softpath_corners_bool
96 % \end{macrocode}
97 % \end{variable}
98 %
99 % \begin{macro}{\@@_softpath_add:n, \@@_softpath_add:o, \@@_softpath_add:e}
100 % \begin{macrocode}
101 \cs_new_protected:Npn \@@_softpath_add:n
102 { \tl_build_gput_right:Nn \g_@@_softpath_main_tl }
103 \cs_generate_variant:Nn \@@_softpath_add:n { o, e }
104 % \end{macrocode}
105 % \end{macro}
106 %
107 % \begin{macro}{\@@_softpath_use:, \@@_softpath_clear:}
108 % Using and clearing is trivial.
109 % \begin{macrocode}
110 \cs_new_protected:Npn \@@_softpath_use:
111 {
112 \tl_build_get_intermediate:NN
113 \g_@@_softpath_main_tl
114 \l_@@_softpath_tmp_tl
115 \l_@@_softpath_tmp_tl
116 }
117 \cs_new_protected:Npn \@@_softpath_clear:
118 {
119 \tl_build_gbegin:N \g_@@_softpath_main_tl
120 \bool_gset_false:N \g_@@_softpath_corners_bool
121 }
122 % \end{macrocode}
123 % \end{macro}
124 %
125 % \begin{macro}{\@@_softpath_save:, \@@_softpath_restore:}
126 % Abstracted ideas to keep variables inside this submodule.
127 % \begin{macrocode}
128 \cs_new_protected:Npn \@@_softpath_save:
129 {
130 \tl_build_gend:N \g_@@_softpath_main_tl
131 \tl_set_eq:NN
132 \l_@@_softpath_main_tl
133 \g_@@_softpath_main_tl
134 \bool_set_eq:NN
135 \l_@@_softpath_corners_bool
136 \g_@@_softpath_corners_bool
137 \@@_softpath_clear:
138 }
139 \cs_new_protected:Npn \@@_softpath_restore:
140 {
141 \@@_softpath_clear:
142 \@@_softpath_add:o \l_@@_softpath_main_tl
143 \bool_gset_eq:NN
144 \g_@@_softpath_corners_bool
145 \l_@@_softpath_corners_bool
146 }
147 % \end{macrocode}
148 % \end{macro}
149 %
150 % \begin{variable}{\g_@@_softpath_lastx_dim, \g_@@_softpath_lasty_dim}
151 % For tracking the end of the path (to close it).
152 % \begin{macrocode}
153 \dim_new:N \g_@@_softpath_lastx_dim
154 \dim_new:N \g_@@_softpath_lasty_dim
155 % \end{macrocode}
156 % \end{variable}
157 %
158 % \begin{variable}{\g_@@_softpath_move_bool}
159 % Track if moving a point should update the close position.
160 % \begin{macrocode}
161 \bool_new:N \g_@@_softpath_move_bool
162 \bool_gset_true:N \g_@@_softpath_move_bool
163 % \end{macrocode}
164 % \end{variable}
165 %
166 % \begin{macro}{\@@_softpath_closepath:}
167 % \begin{macro}{\@@_softpath_curveto:nnnnnn}
168 % \begin{macro}
169 % {
170 % \@@_softpath_lineto:nn,
171 % \@@_softpath_moveto:nn
172 % }
173 % \begin{macro}{\@@_softpath_rectangle:nnnn}
174 % \begin{macro}{\@@_softpath_roundpoint:nn, \@@_softpath_roundpoint:VV}
175 % The various parts of a path expressed as the appropriate soft path
176 % functions.
177 % \begin{macrocode}
178 \cs_new_protected:Npn \@@_softpath_closepath:
179 {
180 \@@_softpath_add:e
181 {
182 \@@_softpath_close_op:nn
183 { \dim_use:N \g_@@_softpath_lastx_dim }
184 { \dim_use:N \g_@@_softpath_lasty_dim }
185 }
186 }
187 \cs_new_protected:Npn \@@_softpath_curveto:nnnnnn #1#2#3#4#5#6
188 {
189 \@@_softpath_add:n
190 {
191 \@@_softpath_curveto_opi:nn {#1} {#2}
192 \@@_softpath_curveto_opii:nn {#3} {#4}
193 \@@_softpath_curveto_opiii:nn {#5} {#6}
194 }
195 }
196 \cs_new_protected:Npn \@@_softpath_lineto:nn #1#2
197 {
198 \@@_softpath_add:n
199 { \@@_softpath_lineto_op:nn {#1} {#2} }
200 }
201 \cs_new_protected:Npn \@@_softpath_moveto:nn #1#2
202 {
203 \@@_softpath_add:n
204 { \@@_softpath_moveto_op:nn {#1} {#2} }
205 \bool_if:NT \g_@@_softpath_move_bool
206 {
207 \dim_gset:Nn \g_@@_softpath_lastx_dim {#1}
208 \dim_gset:Nn \g_@@_softpath_lasty_dim {#2}
209 }
210 }
211 \cs_new_protected:Npn \@@_softpath_rectangle:nnnn #1#2#3#4
212 {
213 \@@_softpath_add:n
214 {
215 \@@_softpath_rectangle_opi:nn {#1} {#2}
216 \@@_softpath_rectangle_opii:nn {#3} {#4}
217 }
218 }
219 \cs_new_protected:Npn \@@_softpath_roundpoint:nn #1#2
220 {
221 \@@_softpath_add:n
222 { \@@_softpath_roundpoint_op:nn {#1} {#2} }
223 \bool_gset_true:N \g_@@_softpath_corners_bool
224 }
225 \cs_generate_variant:Nn \@@_softpath_roundpoint:nn { VV }
226 % \end{macrocode}
227 % \end{macro}
228 % \end{macro}
229 % \end{macro}
230 % \end{macro}
231 % \end{macro}
232 %
233 % \begin{macro}
234 % {
235 % \@@_softpath_close_op:nn ,
236 % \@@_softpath_curveto_opi:nn ,
237 % \@@_softpath_curveto_opii:nn ,
238 % \@@_softpath_curveto_opiii:nn ,
239 % \@@_softpath_lineto_op:nn ,
240 % \@@_softpath_moveto_op:nn ,
241 % \@@_softpath_roundpoint_op:nn ,
242 % \@@_softpath_rectangle_opi:nn ,
243 % \@@_softpath_rectangle_opii:nn
244 % }
245 % \begin{macro}{\@@_softpath_curveto_opi:nnNnnNnn}
246 % \begin{macro}{\@@_softpath_rectangle_opi:nnNnn}
247 % The markers for operations: all the top-level ones take two arguments.
248 % The support tokens for curves have to be different in meaning to a
249 % round point, hence being quark-like.
250 % \begin{macrocode}
251 \cs_new_protected:Npn \@@_softpath_close_op:nn #1#2
252 { \@@_backend_closepath: }
253 \cs_new_protected:Npn \@@_softpath_curveto_opi:nn #1#2
254 { \@@_softpath_curveto_opi:nnNnnNnn {#1} {#2} }
255 \cs_new_protected:Npn \@@_softpath_curveto_opi:nnNnnNnn #1#2#3#4#5#6#7#8
256 { \@@_backend_curveto:nnnnnn {#1} {#2} {#4} {#5} {#7} {#8} }
257 \cs_new_protected:Npn \@@_softpath_curveto_opii:nn #1#2
258 { \@@_softpath_curveto_opii:nn }
259 \cs_new_protected:Npn \@@_softpath_curveto_opiii:nn #1#2
260 { \@@_softpath_curveto_opiii:nn }
261 \cs_new_protected:Npn \@@_softpath_lineto_op:nn #1#2
262 { \@@_backend_lineto:nn {#1} {#2} }
263 \cs_new_protected:Npn \@@_softpath_moveto_op:nn #1#2
264 { \@@_backend_moveto:nn {#1} {#2} }
265 \cs_new_protected:Npn \@@_softpath_roundpoint_op:nn #1#2
266 { \@@_softpath_roundpoint_op:nn }
267 \cs_new_protected:Npn \@@_softpath_rectangle_opi:nn #1#2
268 { \@@_softpath_rectangle_opi:nnNnn {#1} {#2} }
269 \cs_new_protected:Npn \@@_softpath_rectangle_opi:nnNnn #1#2#3#4#5
270 { \@@_backend_rectangle:nnnn {#1} {#2} {#4} {#5} }
271 \cs_new_protected:Npn \@@_softpath_rectangle_opii:nn #1#2
272 { \@@_softpath_rectangle_opii:nn }
273 % \end{macrocode}
274 % \end{macro}
275 % \end{macro}
276 % \end{macro}
277 %
278 % \subsection{Rounding soft path corners}
279 %
280 % The aim here is to find corner rounding points and to replace them with
281 % arcs of appropriate length. The approach is exactly that in \pkg{pgf}:
282 % step through, find the corners, find the supporting data, do the rounding.
283 %
284 % \begin{variable}{\l_@@_softpath_main_tl}
285 % For constructing the updated path.
286 % \begin{macrocode}
287 \tl_new:N \l_@@_softpath_main_tl
288 % \end{macrocode}
289 % \end{variable}
290 %
291 % \begin{variable}{\l_@@_softpath_part_tl}
292 % Data structures.
293 % \begin{macrocode}
294 \tl_new:N \l_@@_softpath_part_tl
295 \tl_new:N \l_@@_softpath_curve_end_tl
296 % \end{macrocode}
297 % \end{variable}
298 %
299 % \begin{variable}
300 % {\l_@@_softpath_lastx_fp, \l_@@_softpath_lasty_fp}
301 % \begin{variable}
302 % {\l_@@_softpath_corneri_dim, \l_@@_softpath_cornerii_dim}
303 % \begin{variable}{\l_@@_softpath_first_tl, \l_@@_softpath_move_tl}
304 % Position tracking: the token list data may be entirely empty or set to
305 % a coordinate.
306 % \begin{macrocode}
307 \fp_new:N \l_@@_softpath_lastx_fp
308 \fp_new:N \l_@@_softpath_lasty_fp
309 \dim_new:N \l_@@_softpath_corneri_dim
310 \dim_new:N \l_@@_softpath_cornerii_dim
311 \tl_new:N \l_@@_softpath_first_tl
312 \tl_new:N \l_@@_softpath_move_tl
313 % \end{macrocode}
314 % \end{variable}
315 % \end{variable}
316 % \end{variable}
317 %
318 % \begin{variable}{\c_@@_softpath_arc_fp}
319 % The magic constant.
320 % \begin{macrocode}
321 \fp_const:Nn \c_@@_softpath_arc_fp { 4/3 * (sqrt(2) - 1) }
322 % \end{macrocode}
323 % \end{variable}
324 %
325 % \begin{macro}{\@@_softpath_round_corners:}
326 % \begin{macro}{\@@_softpath_round_loop:Nnn}
327 % \begin{macro}{\@@_softpath_round_action:nn}
328 % \begin{macro}{\@@_softpath_round_action:Nnn}
329 % \begin{macro}{\@@_softpath_round_action_curveto:NnnNnn}
330 % \begin{macro}{\@@_softpath_round_action_close:}
331 % \begin{macro}{\@@_softpath_round_lookahead:NnnNnn}
332 % \begin{macro}{\@@_softpath_round_roundpoint:NnnNnnNnn}
333 % \begin{macro}{\@@_softpath_round_calc:NnnNnn}
334 % \begin{macro}[EXP]
335 % {\@@_softpath_round_calc:nnnnnn, \@@_softpath_round_calc:eVnnnn}
336 % \begin{macro}[EXP]{\@@_softpath_round_calc:nnnnw}
337 % \begin{macro}{\@@_softpath_round_close:nn}
338 % \begin{macro}[EXP]{\@@_softpath_round_close:w}
339 % \begin{macro}{\@@_softpath_round_end:}
340 % Rounding corners on a path means going through the entire path and
341 % adjusting it. As such, we avoid this entirely if we know there are no
342 % corners to deal with. Assuming there is work to do, we recover the existing
343 % path and start a loop.
344 % \begin{macrocode}
345 \cs_new_protected:Npn \@@_softpath_round_corners:
346 {
347 \bool_if:NT \g_@@_softpath_corners_bool
348 {
349 \group_begin:
350 \tl_clear:N \l_@@_softpath_main_tl
351 \tl_clear:N \l_@@_softpath_part_tl
352 \fp_zero:N \l_@@_softpath_lastx_fp
353 \fp_zero:N \l_@@_softpath_lasty_fp
354 \tl_clear:N \l_@@_softpath_first_tl
355 \tl_clear:N \l_@@_softpath_move_tl
356 \tl_build_gend:N \g_@@_softpath_main_tl
357 \exp_after:wN \@@_softpath_round_loop:Nnn
358 \g_@@_softpath_main_tl
359 \q_@@_recursion_tail ? ?
360 \q_@@_recursion_stop
361 \group_end:
362 }
363 \bool_gset_false:N \g_@@_softpath_corners_bool
364 }
365 % \end{macrocode}
366 % The loop can take advantage of the fact that all soft path operations are
367 % made up of a token followed by two arguments. At this stage, there is
368 % a simple split: have we round a round point. If so, is there any actual
369 % rounding to be done: if the arcs have come through zero, just ignore it.
370 % In cases where we are not at a corner, we simply move along the path,
371 % allowing for any new part starting due to a \texttt{moveto}.
372 % \begin{macrocode}
373 \cs_new_protected:Npn \@@_softpath_round_loop:Nnn #1#2#3
374 {
375 \@@_if_recursion_tail_stop_do:Nn #1 { \@@_softpath_round_end: }
376 \token_if_eq_meaning:NNTF #1 \@@_softpath_roundpoint_op:nn
377 { \@@_softpath_round_action:nn {#2} {#3} }
378 {
379 \tl_if_empty:NT \l_@@_softpath_first_tl
380 { \tl_set:Nn \l_@@_softpath_first_tl { {#2} {#3} } }
381 \fp_set:Nn \l_@@_softpath_lastx_fp {#2}
382 \fp_set:Nn \l_@@_softpath_lasty_fp {#3}
383 \token_if_eq_meaning:NNTF #1 \@@_softpath_moveto_op:nn
384 {
385 \tl_put_right:No \l_@@_softpath_main_tl
386 \l_@@_softpath_move_tl
387 \tl_put_right:No \l_@@_softpath_main_tl
388 \l_@@_softpath_part_tl
389 \tl_set:Nn \l_@@_softpath_move_tl { #1 {#2} {#3} }
390 \tl_clear:N \l_@@_softpath_first_tl
391 \tl_clear:N \l_@@_softpath_part_tl
392 }
393 { \tl_put_right:Nn \l_@@_softpath_part_tl { #1 {#2} {#3} } }
394 \@@_softpath_round_loop:Nnn
395 }
396 }
397 \cs_new_protected:Npn \@@_softpath_round_action:nn #1#2
398 {
399 \dim_set:Nn \l_@@_softpath_corneri_dim {#1}
400 \dim_set:Nn \l_@@_softpath_cornerii_dim {#2}
401 \bool_lazy_and:nnTF
402 { \dim_compare_p:nNn \l_@@_softpath_corneri_dim = { 0pt } }
403 { \dim_compare_p:nNn \l_@@_softpath_cornerii_dim = { 0pt } }
404 { \@@_softpath_round_loop:Nnn }
405 { \@@_softpath_round_action:Nnn }
406 }
407 % \end{macrocode}
408 % We now have a round point to work on and have grabbed the next item in
409 % the path. There are only a few cases where we have to do anything. Each of
410 % them is picked up by looking for the appropriate action.
411 % \begin{macrocode}
412 \cs_new_protected:Npn \@@_softpath_round_action:Nnn #1#2#3
413 {
414 \tl_if_empty:NT \l_@@_softpath_first_tl
415 { \tl_set:Nn \l_@@_softpath_first_tl { {#2} {#3} } }
416 \token_if_eq_meaning:NNTF #1 \@@_softpath_curveto_opi:nn
417 { \@@_softpath_round_action_curveto:NnnNnn }
418 {
419 \token_if_eq_meaning:NNTF #1 \@@_softpath_close_op:nn
420 { \@@_softpath_round_action_close: }
421 {
422 \token_if_eq_meaning:NNTF #1 \@@_softpath_lineto_op:nn
423 { \@@_softpath_round_lookahead:NnnNnn }
424 { \@@_softpath_round_loop:Nnn }
425 }
426 }
427 #1 {#2} {#3}
428 }
429 % \end{macrocode}
430 % For a curve, we collect the two control points then move on to grab the
431 % end point and add the curve there: the second control point becomes our
432 % starter.
433 % \begin{macrocode}
434 \cs_new_protected:Npn \@@_softpath_round_action_curveto:NnnNnn
435 #1#2#3#4#5#6
436 {
437 \tl_put_right:Nn \l_@@_softpath_part_tl
438 { #1 {#2} {#3} #4 {#5} {#6} }
439 \fp_set:Nn \l_@@_softpath_lastx_fp {#5}
440 \fp_set:Nn \l_@@_softpath_lasty_fp {#6}
441 \@@_softpath_round_lookahead:NnnNnn
442 }
443 \cs_new_protected:Npn \@@_softpath_round_action_close:
444 {
445 \bool_lazy_and:nnTF
446 { ! \tl_if_empty_p:N \l_@@_softpath_first_tl }
447 { ! \tl_if_empty_p:N \l_@@_softpath_move_tl }
448 {
449 \exp_after:wN \@@_softpath_round_close:nn
450 \l_@@_softpath_first_tl
451 }
452 { \@@_softpath_round_loop:Nnn }
453 }
454 % \end{macrocode}
455 % At this stage we have a current (sub)operation (|#1|) and the next
456 % operation (|#4|), and can therefore decide whether to round or not.
457 % In the case of yet another rounding marker, we have to look a bit
458 % further ahead.
459 % \begin{macrocode}
460 \cs_new_protected:Npn \@@_softpath_round_lookahead:NnnNnn #1#2#3#4#5#6
461 {
462 \bool_lazy_any:nTF
463 {
464 { \token_if_eq_meaning_p:NN #4 \@@_softpath_lineto_op:nn }
465 { \token_if_eq_meaning_p:NN #4 \@@_softpath_curveto_opi:nn }
466 { \token_if_eq_meaning_p:NN #4 \@@_softpath_close_op:nn }
467 }
468 {
469 \@@_softpath_round_calc:NnnNnn
470 \@@_softpath_round_loop:Nnn
471 {#5} {#6}
472 }
473 {
474 \token_if_eq_meaning:NNTF #4 \@@_softpath_roundpoint_op:nn
475 { \@@_softpath_round_roundpoint:NnnNnnNnn }
476 { \@@_softpath_round_loop:Nnn }
477 }
478 #1 {#2} {#3}
479 #4 {#5} {#6}
480 }
481 \cs_new_protected:Npn \@@_softpath_round_roundpoint:NnnNnnNnn
482 #1#2#3#4#5#6#7#8#9
483 {
484 \@@_softpath_round_calc:NnnNnn
485 \@@_softpath_round_loop:Nnn
486 {#8} {#9}
487 #1 {#2} {#3}
488 #4 {#5} {#6} #7 {#8} {#9}
489 }
490 % \end{macrocode}
491 % We now have all of the data needed to construct a rounded corner: all that
492 % is left to do is to work out the detail! At this stage, we have details
493 % of where the corner itself is (|#5|, |#6|), and where the next point is
494 % (|#2|, |#3|). There are two types of calculations to do. First, we
495 % need to interpolate from those two points in the direction of the
496 % corner, in order to work out where the curve we are adding will start
497 % and end. From those, plus the points we already have, we work out where
498 % the control points will lie. All of this is done in an expansion to
499 % avoid multiple calls to |\tl_put_right:Ne|. The end point of the line
500 % is worked out up-front and saved: we need that if dealing with a
501 % close-path operation.
502 % \begin{macrocode}
503 \cs_new_protected:Npn \@@_softpath_round_calc:NnnNnn #1#2#3#4#5#6
504 {
505 \tl_set:Ne \l_@@_softpath_curve_end_tl
506 {
507 \draw_point_interpolate_distance:nnn
508 \l_@@_softpath_cornerii_dim
509 { #5 , #6 } { #2 , #3 }
510 }
511 \tl_put_right:Ne \l_@@_softpath_part_tl
512 {
513 \exp_not:N #4
514 \@@_softpath_round_calc:eVnnnn
515 {
516 \draw_point_interpolate_distance:nnn
517 \l_@@_softpath_corneri_dim
518 { #5 , #6 }
519 {
520 \l_@@_softpath_lastx_fp ,
521 \l_@@_softpath_lasty_fp
522 }
523 }
524 \l_@@_softpath_curve_end_tl
525 {#5} {#6} {#2} {#3}
526 }
527 \fp_set:Nn \l_@@_softpath_lastx_fp {#5}
528 \fp_set:Nn \l_@@_softpath_lasty_fp {#6}
529 #1
530 }
531 % \end{macrocode}
532 % At this stage we have the two curve end points, but they are in
533 % coordinate form. So we split them up (with some more reordering).
534 % \begin{macrocode}
535 \cs_new:Npn \@@_softpath_round_calc:nnnnnn #1#2#3#4#5#6
536 {
537 \@@_softpath_round_calc:nnnnw {#3} {#4} {#5} {#6}
538 #1 \s_@@_mark #2 \s_@@_stop
539 }
540 \cs_generate_variant:Nn \@@_softpath_round_calc:nnnnnn { eV }
541 % \end{macrocode}
542 % The calculations themselves are relatively straight-forward, as we use a
543 % quadratic Bézier curve.
544 % \begin{macrocode}
545 \cs_new:Npn \@@_softpath_round_calc:nnnnw
546 #1#2#3#4 #5 , #6 \s_@@_mark #7 , #8 \s_@@_stop
547 {
548 {#5} {#6}
549 \exp_not:N \@@_softpath_curveto_opi:nn
550 {
551 \fp_to_dim:n
552 { #5 + \c_@@_softpath_arc_fp * ( #1 - #5 ) }
553 }
554 {
555 \fp_to_dim:n
556 { #6 + \c_@@_softpath_arc_fp * ( #2 - #6 ) }
557 }
558 \exp_not:N \@@_softpath_curveto_opii:nn
559 {
560 \fp_to_dim:n
561 { #7 + \c_@@_softpath_arc_fp * ( #1 - #7 ) }
562 }
563 {
564 \fp_to_dim:n
565 { #8 + \c_@@_softpath_arc_fp* ( #2 - #8 ) }
566 }
567 \exp_not:N \@@_softpath_curveto_opiii:nn
568 {#7} {#8}
569 }
570 % \end{macrocode}
571 % To deal with a close-path operation, we need to do some manipulation.
572 % It needs to be treated as a line operation for rounding, and then
573 % have the close path operation re-added at the point where the curve
574 % ends. That means saving the end point in the calculation step (see
575 % earlier), and shuffling a lot.
576 % \begin{macrocode}
577 \cs_new_protected:Npn \@@_softpath_round_close:nn #1#2
578 {
579 \use:e
580 {
581 \@@_softpath_round_calc:NnnNnn
582 {
583 \tl_set:Ne \exp_not:N \l_@@_softpath_move_tl
584 {
585 \@@_softpath_moveto_op:nn
586 \exp_not:N \exp_after:wN
587 \exp_not:N \@@_softpath_round_close:w
588 \exp_not:N \l_@@_softpath_curve_end_tl
589 \s_@@_stop
590 }
591 \use:e
592 {
593 \exp_not:N \exp_not:N \exp_not:N \use_i:nnnn
594 {
595 \@@_softpath_round_loop:Nnn
596 \@@_softpath_close_op:nn
597 \exp_not:N \exp_after:wN
598 \exp_not:N \@@_softpath_round_close:w
599 \exp_not:N \l_@@_softpath_curve_end_tl
600 \s_@@_stop
601 }
602 }
603 }
604 {#1} {#2}
605 \@@_softpath_lineto_op:nn
606 \exp_after:wN \use_none:n \l_@@_softpath_move_tl
607 }
608 }
609 \cs_new:Npn \@@_softpath_round_close:w #1 , #2 \s_@@_stop { {#1} {#2} }
610 % \end{macrocode}
611 % Tidy up the parts of the path, complete the built token list and put
612 % it back into action.
613 % \begin{macrocode}
614 \cs_new_protected:Npn \@@_softpath_round_end:
615 {
616 \tl_put_right:No \l_@@_softpath_main_tl
617 \l_@@_softpath_move_tl
618 \tl_put_right:No \l_@@_softpath_main_tl
619 \l_@@_softpath_part_tl
620 \tl_build_gbegin:N \g_@@_softpath_main_tl
621 \@@_softpath_add:o \l_@@_softpath_main_tl
622 }
623 % \end{macrocode}
624 % \end{macro}
625 % \end{macro}
626 % \end{macro}
627 % \end{macro}
628 % \end{macro}
629 % \end{macro}
630 % \end{macro}
631 % \end{macro}
632 % \end{macro}
633 % \end{macro}
634 % \end{macro}
635 % \end{macro}
636 % \end{macro}
637 % \end{macro}
638 %
639 % \begin{macrocode}
640 %</package>
641 % \end{macrocode}
642 %
643 % \end{implementation}
644 %
645 % \PrintIndex