Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3draw.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|package>
26 \RequirePackage{expl3}
27 %</driver|package>
28 %<*driver>
29 \documentclass[full]{l3doc}
30 \usepackage{l3draw}
31 % For creating code demonstrations
32 % This needs access to some code-level interfaces in listings
33 \usepackage{listings}
34 \makeatletter
35 \lst@RequireAspects{writefile}
36 \newsavebox\demo@box
37 \lstnewenvironment{demo}[1][code and example]
38 {%
39 \global\let\lst@intname\@empty
40 \edef\demo@end{%
41 \expandafter\noexpand\csname demo@@#1@end\endcsname
42 }%
43 \@nameuse{demo@@#1}%
44 }
45 {\demo@end}
46 \newcommand\demo@new[3]{%
47 \@namedef{demo@@#1}{#2}%
48 \@namedef{demo@@#1@end}{#3}%
49 }
50 \newcommand*\demo@common{%
51 \setkeys{lst}
52 {%
53 basicstyle = \small\ttfamily,
54 basewidth = 0.51em,
55 gobble = 5,
56 language = [LaTeX]{TeX},
57 }%
58 }
59 \newcommand*\demo@input{%
60 \ExplSyntaxOn
61 \catcode`\^^M = 10\relax
62 \catcode`\% = 14\relax
63 \input{\jobname.tmp}%
64 \ExplSyntaxOff
65 }
66 \demo@new{code and example}{%
67 \setbox\demo@box=\hbox\bgroup
68 \lst@BeginAlsoWriteFile{\jobname.tmp}%
69 \demo@common
70 }{%
71 \lst@EndWriteFile
72 \egroup
73 \begin{center}
74 \ifdim\wd\demo@box > 0.75\linewidth
75 \begin{minipage}{\linewidth}
76 \usebox\demo@box
77 \end{minipage}%
78 \par
79 \begin{minipage}{\linewidth}
80 \demo@input
81 \end{minipage}
82 \else
83 \begin{minipage}{0.25\linewidth}
84 \demo@input
85 \end{minipage}%
86 \hfil
87 \begin{minipage}{0.75\linewidth}
88 \usebox\demo@box
89 \end{minipage}%
90 \fi
91 \end{center}
92 }
93 \makeatother
94 \begin{document}
95 \DocInput{\jobname.dtx}
96 \end{document}
97 %</driver>
98 % \fi
99 %
100 % \title{^^A
101 % The \pkg{l3draw} package\\ Core drawing support^^A
102 % }
103 %
104 % \author{^^A
105 % The \LaTeX{} Project\thanks
106 % {^^A
107 % E-mail:
108 % \href{mailto:[email protected]}
109 % {[email protected]}^^A
110 % }^^A
111 % }
112 %
113 % \date{Released 2026-05-26}
114 %
115 % \maketitle
116 %
117 % \begin{documentation}
118 %
119 % \section{\pkg{l3draw} documentation}
120 %
121 % The \pkg{l3draw} package provides a set of tools for creating (vector)
122 % drawings in \pkg{expl3}. It is heavily inspired by the \pkg{pgf} layer of
123 % the Ti\textit{k}Z system, with many of the interfaces having the same form.
124 % However, the code provided here is build entirely on core \pkg{expl3} ideas
125 % and uses the \LaTeX3 FPU for numerical support.
126 %
127 % Numerical expressions in \pkg{l3draw} are handled as floating point
128 % expressions, unless otherwise noted. This means that they may contain or
129 % omit explicit units. Where units are omitted, they will automatically be
130 % taken as given in (\TeX{}) points.
131 %
132 % The code here is \emph{highly} experimental.
133 %
134 % \subsection{Drawings}
135 %
136 % \begin{function}{\draw_begin:, \draw_end:}
137 % \begin{syntax}
138 % \cs{draw_begin:}
139 % ...
140 % \cs{draw_end:}
141 % \end{syntax}
142 % Each drawing should be created within a \cs{draw_begin:}/\cs{draw_end:}
143 % function pair. The \texttt{begin} function sets up a number of key
144 % data structures for the rest of the functions here: unless otherwise
145 % specified, use of |\draw_...| functions outside of this
146 % \enquote{environment} is \emph{not supported}.
147 %
148 % The drawing created within the environment will be inserted into
149 % the typesetting stream by the \cs{draw_end:} function, which will
150 % switch out of vertical mode if required.
151 % \begin{demo}
152 % \dim_new:N \l_mypos_dim
153 % \draw_begin:
154 % \draw_path_moveto:n { 0cm , \l_mypos_dim }
155 % \draw_path_lineto:n { 1cm , \l_mypos_dim }
156 % \dim_set:Nn \l_mypos_dim { 1cm }
157 % \draw_path_lineto:n { 1cm , \l_mypos_dim }
158 % \draw_path_close:
159 % \draw_path_use_clear:n { stroke }
160 % \draw_end:
161 % \end{demo}
162 %
163 % Within a drawing, the only commands that should appear are those directly
164 % aimed at drawing (from \pkg{l3draw}) and those which produce \emph{no}
165 % typeset output. For example, it is possible to include loops inside a
166 % drawing using |\int_step_function:nnnn| or similar. On the other hand,
167 % text should not be included directly in drawings, but should rather be
168 % inserted using the appropriate \pkg{l3draw} command.
169 %
170 % The drawing environment sets the following standard behaviors
171 % \begin{itemize}
172 % \item Non-zero rule for fill overlaps
173 % \item Butt caps for lines
174 % \item Mitering for line joins with a miter factor of $10$
175 % \item Solid line strokes
176 % \end{itemize}
177 % \end{function}
178 %
179 % Within a drawing, there are different ways of referring to a position.
180 % The coordinates of a point are given relative to the current
181 % \emph{drawing axes}. These can be manipulated and tracked at the code
182 % level. Underlying this is the \meta{canvas}, which is at the \pkg{draw}
183 % level essentially fixed and in line with the paper. Initially, the two
184 % sets of axes are coincident. (It is possible to manipulate the canvas
185 % axes at the driver level: this is then \enquote{transparent} to the
186 % \pkg{draw} level, and so should be used only when strictly required.)
187 %
188 % The bounding box of the drawing is determined by tracking the size of the
189 % \pkg{draw} commands between the start and end. The bounding box is (roughly)
190 % the smallest box that contains all of the coordinates mentioned within the
191 % drawing. This can include those automatically generated, for example the
192 % supporting points needed to construct an arc.
193 %
194 % \begin{function}{\draw_set_baseline:n}
195 % \begin{syntax}
196 % \cs{draw_set_baseline:n} \Arg{length}
197 % \end{syntax}
198 % As standard, the baseline of the bounding box of a drawing is calculated
199 % automatically at the bottom of the drawing. It is possible to adjust this
200 % using the \cs{draw_set_baseline:n} function. If the drawing coordinates lead
201 % to lower $y$-axis values than the \meta{length}, then the drawing will have
202 % a depth as well as a height.
203 % \begin{demo}
204 % text
205 % \draw_begin:
206 % \draw_path_rectangle:nn { 0 , 0 } { 2ex , 1ex }
207 % \draw_path_use:n { stroke }
208 % \draw_end:
209 % text
210 % \draw_begin:
211 % \draw_path_rectangle:nn { 0 , 1ex } { 2ex , 1ex }
212 % \draw_set_baseline:n { 0pt }
213 % \draw_path_use:n { stroke }
214 % \draw_end:
215 % text
216 % \draw_begin:
217 % \draw_path_rectangle:nn { 0 , -1ex } { 2ex , 1ex }
218 % \draw_set_baseline:n { -0.5ex }
219 % \draw_path_use:n { stroke }
220 % \draw_end:
221 % text
222 % \end{demo}
223 % \end{function}
224 %
225 % \begin{function}{\draw_suspend_begin:, \draw_suspend_end:}
226 % \begin{syntax}
227 % \cs{draw_suspend_begin:}
228 % ...
229 % \cs{draw_suspend_end:}
230 % \end{syntax}
231 % Suspends all of the drawing mechanisms to allow \enquote{normal}
232 % material to be created. Typically, this environment will be applied
233 % inside a box which may contain nested pictures.
234 % \begin{demo}
235 % \draw_begin:
236 % \draw_path_moveto:n { 0cm , 0cm }
237 % \hbox_set:Nn \l_tmpa_box
238 % {
239 % \draw_suspend_begin:
240 % This~is~normal~text.
241 % \draw_begin: % A subpicture
242 % \draw_path_moveto:n { 1cm , 0cm }
243 % \draw_path_lineto:n { 1cm , 1cm }
244 % \draw_path_use_clear:n { stroke }
245 % \draw_end:
246 % More~text.
247 % \draw_suspend_end:
248 % }
249 % \draw_box_use:N \l_tmpa_box
250 % \draw_path_lineto:n { 0cm , 1cm }
251 % \draw_path_use_clear:n { stroke }
252 % \draw_end:
253 % \end{demo}
254 % \end{function}
255 %
256 % \begin{variable}{\g_draw_id_int}
257 % Each drawing is given a unique identity: this is incremented each time
258 % \cs{draw_begin:} is used.
259 % \end{variable}
260 %
261 % \subsection{Setting the graphics state}
262 %
263 % Within the drawing environment, a number of functions control how drawings
264 % will appear. Note that these all apply \emph{globally}, though some are
265 % reset at the start of each drawing (\cs{draw_begin:}).
266 %
267 % \begin{variable}{\l_draw_default_linewidth_dim}
268 % The default value of the linewidth for stokes, set at the start
269 % of every drawing (\cs{draw_begin:}).
270 % \end{variable}
271 %
272 % \begin{function}{\draw_set_linewidth:n}
273 % \begin{syntax}
274 % \cs{draw_set_linewidth:n} \Arg{width}
275 % \end{syntax}
276 % Sets the width to be used for stroking to the \meta{width} (an
277 % \meta{fp expr}).
278 % \end{function}
279 %
280 % \begin{function}{\draw_set_dash_pattern:nn}
281 % \begin{syntax}
282 % \cs{draw_set_dash_pattern:nn} \Arg{pattern} \Arg{phase}
283 % \end{syntax}
284 % Specifies a dash pattern. The \meta{pattern} itself is a comma-separated
285 % list of entries which represent the \enquote{on} and \enquote{off}
286 % parts of the line. These are all \meta{fp expr} and repeat as required.
287 % Thus the \meta{pattern} may be of arbitrary length. The \meta{phase}
288 % specifies where during the first \enquote{on} line the pattern should
289 % start.
290 % \begin{demo}
291 % \draw_begin:
292 % \draw_set_dash_pattern:nn
293 % { 0.5cm , 0.5cm , 0.1cm , 0.2cm }
294 % { 0cm }
295 % \draw_path_moveto:n { 0cm , 0cm }
296 % \draw_path_lineto:n { 2cm , 0cm }
297 % \draw_path_use_clear:n { stroke }
298 % \draw_set_dash_pattern:nn
299 % { 0.5cm , 0.5cm , 0.1cm , 0.2cm }
300 % { 0.1cm }
301 % \draw_path_moveto:n { 0cm , 1mm }
302 % \draw_path_lineto:n { 2cm , 1mm }
303 % \draw_path_use_clear:n { stroke }
304 % \draw_set_dash_pattern:nn
305 % { 0.5cm , 0.5cm , 0.1cm , 0.2cm }
306 % { 0.2cm }
307 % \draw_path_moveto:n { 0cm , 2mm }
308 % \draw_path_lineto:n { 2cm , 2mm }
309 % \draw_path_use_clear:n { stroke }
310 % \draw_end:
311 % \end{demo}
312 % Setting an empty pattern will produce a solid line.
313 %
314 % Note the \meta{pattern} interface here is different from that in \pkg{pgf}:
315 % the list is comma-separated not given in brace groups.
316 % \end{function}
317 %
318 % \begin{function}{\draw_set_nonzero_rule:, \draw_set_evenodd_rule:}
319 % \begin{syntax}
320 % \cs{draw_set_nonzero_rule:}
321 % \end{syntax}
322 % Active either the non-zero winding number or the even-odd rule,
323 % respectively, for determining what is inside a fill or clip area.
324 % For technical reasons, these command are not influenced by scoping
325 % and apply on an ongoing basis.
326 % \end{function}
327 %
328 % \begin{function}
329 % {
330 % \draw_set_cap_butt: ,
331 % \draw_set_cap_rectangle: ,
332 % \draw_set_cap_round:
333 % }
334 % \begin{syntax}
335 % \cs{draw_set_cap_butt:}
336 % \end{syntax}
337 % Sets the style of terminal stroke position to one of butt, rectangle or
338 % round.
339 % \end{function}
340 %
341 % \begin{function}
342 % {
343 % \draw_set_join_bevel: ,
344 % \draw_set_join_miter: ,
345 % \draw_set_join_round:
346 % }
347 % \begin{syntax}
348 % \cs{draw_set_join_miter:}
349 % \end{syntax}
350 % Sets the style of stroke joins to one of bevel, miter or round.
351 % \end{function}
352 %
353 % \begin{function}{\draw_set_miterlimit:n}
354 % \begin{syntax}
355 % \cs{draw_set_miterlimit:n} \Arg{factor}
356 % \end{syntax}
357 % Sets the miter \meta{factor} of lines joined as a miter, as described in the
358 % PDF and PostScript manuals. The \meta{factor} is an \meta{fp expr}.
359 % \end{function}
360 %
361 % \subsection{Scoping drawing elements}
362 %
363 % Scoping drawing elements is necessary to allowing nesting of subparts.
364 % These features have specific use requirements: the preconditions must be
365 % met. In particular, each type of drawing scope also constitutes a
366 % group (\cs{group_begin:}/\cs{group_end:} pair): as such, they must be
367 % nested correctly.
368 %
369 % \begin{function}{\draw_scope_begin:, \draw_scope_end:}
370 % \begin{syntax}
371 % \cs{draw_scope_begin:}
372 % ...
373 % \cs{draw_scope_end:}
374 % \end{syntax}
375 % Creates a scope for localization of state settings within a drawing.
376 % A scope forms a \TeX{} group but will also localize global state
377 % variables (such as \cs{l_draw_default_linewidth_dim}), and driver-level
378 % concepts such as the termination of lines.
379 % \begin{demo}
380 % \draw_begin:
381 % \draw_scope_begin:
382 % \group_begin:
383 % \draw_set_linewidth:n { 2pt }
384 % \draw_path_rectangle:nn { 0 , 0 } { 2ex , 2ex }
385 % \draw_path_use:n { stroke }
386 % \group_end:
387 % \draw_path_rectangle:nn { 3ex , 0ex } { 2ex , 2ex }
388 % \draw_path_use:n { stroke }
389 % \draw_scope_end:
390 % \draw_path_rectangle:nn { 6ex , 0ex } { 2ex , 2ex }
391 % \draw_path_use_clear:n { stroke }
392 % \draw_end:
393 % \end{demo}
394 % Global graphical concepts restricted by scope are
395 % \begin{itemize}
396 % \item Line width
397 % \item Stroke and fill color
398 % \item Dash pattern
399 % \item Line joining and capping, including the miter limit
400 % \item Clipping paths
401 % \item Canvas (driver) transformations
402 % \end{itemize}
403 % \end{function}
404 %
405 % \subsection{Points}
406 %
407 % Functions supporting the calculation of points (coordinates) are expandable
408 % and may be used outside of the drawing environment. The outputs of all of the
409 % point functions are tuples. This output form is then suitable as \emph{input}
410 % for subsequent point calculations, i.e., where a \meta{point} is required
411 % it may be given as a tuple. This \emph{may} include units and surrounding
412 % parentheses, for example
413 % \begin{verbatim}
414 % 1,2
415 % (1,2)
416 % 1cm,3pt
417 % (1pt,2cm)
418 % 2 * sind(30), 2^4in
419 % \end{verbatim}
420 % are all valid input forms. Notice that each part of the tuple may itself
421 % be a float point expression.
422 %
423 % Point coordinates are relative to the canvas axes, but can be transformed
424 % by \cs{draw_point_transform:n}. These manipulation is applied by many
425 % higher-level functions, for example path construction, and allows parts of
426 % a drawing to be rotated, scaled or skewed. This occurs before writing any
427 % data to the driver, and so such manipulations are tracked by the drawing
428 % mechanisms. See \cs{@@_backend_cm:nnnn} for backend-level
429 % manipulation of the canvas axes themselves.
430 %
431 % Notice that in contrast to \pkg{pgf} it is possible to give the positions
432 % of points \emph{directly}.
433 %
434 % \subsubsection{Basic point functions}
435 %
436 % \begin{function}[EXP]{\draw_point:n}
437 % \begin{syntax}
438 % \cs{draw_point:n} \Arg{point}
439 % \end{syntax}
440 % Evaluates the position of the \meta{point} as described above
441 % and expands to a comma-separated pair of dimensions in |pt|. The
442 % result is \emph{not} surrounded by braces.
443 % \end{function}
444 %
445 % \begin{function}[EXP]{\draw_point_polar:nn, \draw_point_polar:nnn}
446 % \begin{syntax}
447 % \cs{draw_point_polar:nn} \Arg{radius} \Arg{angle}
448 % \cs{draw_point_polar:nnn} \Arg{radius-a} \Arg{radius-b} \Arg{angle}
449 % \end{syntax}
450 % Gives the coordinates of the point at \meta{angle} (an \meta{fp expr} in
451 % \emph{degrees}) and \meta{radius}. The three-argument version accepts
452 % two radii of different lengths.
453 %
454 % Note the interface here is somewhat different from that in \pkg{pgf}:
455 % the one- and two-radii versions in \pkg{l3draw} use separate functions,
456 % whilst in \pkg{pgf} they use the same function and a keyword.
457 % \end{function}
458 %
459 % \begin{function}[EXP]{\draw_point_unit_vector:n}
460 % \begin{syntax}
461 % \cs{draw_point_unit_vector:n} \Arg{point}
462 % \end{syntax}
463 % Expands to the coordinates of a unit vector in the direction of the
464 % \meta{point} from the origin. If the \meta{point} is at the origin,
465 % a vertical unit vector is returned.
466 % \end{function}
467 %
468 % \begin{function}[EXP]{\draw_point_transform:n}
469 % \begin{syntax}
470 % \cs{draw_point_transform:n} \Arg{point}
471 % \end{syntax}
472 % Evaluates the position of the \meta{point} subject to the current
473 % transformation matrix. This operation is applied automatically by
474 % most higher-level functions (e.g., path manipulations).
475 % \end{function}
476 %
477 % \subsubsection{Points on a vector basis}
478 %
479 % As well as giving explicit values, it is possible to describe points
480 % in terms of underlying direction vectors. The latter are initially
481 % co-incident with the standard Cartesian axes, but may be altered by
482 % the user.
483 %
484 % \begin{function}{\draw_xvec:n, \draw_yvec:n, \draw_zvec:n}
485 % \begin{syntax}
486 % \cs{draw_xvec:n} \Arg{point}
487 % \end{syntax}
488 % Defines the appropriate base vector to point toward the \meta{point}
489 % on the canvas. The standard settings for the $x$- and $y$-vectors are
490 % $1\,\mathrm{cm}$ along the relevant canvas axis, whilst for the
491 % $z$-vector an appropriate direction is taken.
492 % \end{function}
493 %
494 % \begin{function}[EXP]{\draw_point_vec:nn, \draw_point_vec:nnn}
495 % \begin{syntax}
496 % \cs{draw_point_vec:nn} \Arg{xscale} \Arg{yscale}
497 % \cs{draw_point_vec:nnn} \Arg{xscale} \Arg{yscale} \Arg{zscale}
498 % \end{syntax}
499 % Expands to the coordinate of the point at \meta{xscale} times the
500 % $x$-vector and \meta{yscale} times the $y$-vector. The three-argument
501 % version extends this to include the $z$-vector.
502 % \end{function}
503 %
504 % \begin{function}[EXP]{\draw_point_vec_polar:nn, \draw_point_vec_polar:nnn}
505 % \begin{syntax}
506 % \cs{draw_point_vec_polar:nn} \Arg{radius} \Arg{angle}
507 % \cs{draw_point_vec_polar:nnn} \Arg{radius-a} \Arg{radius-b} \Arg{angle}
508 % \end{syntax}
509 % Gives the coordinates of the point at \meta{angle} (an \meta{fp expr} in
510 % \emph{degrees}) and \meta{radius}, relative to the prevailing
511 % $x$- and $y$-vectors. The three-argument version accepts two radii of
512 % different lengths.
513 %
514 % Note the interface here is somewhat different from that in \pkg{pgf}:
515 % the one- and two-radii versions in \pkg{l3draw} use separate functions,
516 % whilst in \pkg{pgf} they use the same function and a keyword.
517 % \end{function}
518 %
519 % \subsubsection{Intersections}
520 %
521 % \begin{function}[EXP]{\draw_point_intersect_lines:nnnn}
522 % \begin{syntax}
523 % \cs{draw_point_intersect_lines:nnnn} \Arg{point1} \Arg{point2} \Arg{point3} \Arg{point4}
524 % \end{syntax}
525 % Evaluates the point at the intersection of one line, joining
526 % \meta{point1} and \meta{point2}, and a second line joining \meta{point3}
527 % and \meta{point4}. If the lines do not intersect, or are coincident, and
528 % error will occur.
529 % \end{function}
530 %
531 % \begin{function}[EXP]{\draw_point_intersect_circles:nnnnn}
532 % \begin{syntax}
533 % \cs{draw_point_intersect_circles:nnnnn}
534 % \Arg{center1} \Arg{radius1} \Arg{center2} \Arg{radius2} \Arg{root}
535 % \end{syntax}
536 % Evaluates the point at the intersection of one circle with
537 % \meta{center1} and \meta{radius1}, and a second circle with \meta{center2}
538 % and \meta{radius2}. If the circles do not intersect, or are coincident, and
539 % error will occur.
540 %
541 % Note the interface here has a different argument ordering from that in
542 % \pkg{pgf}, which has the two centers then the two radii.
543 % \end{function}
544 %
545 % \begin{function}[EXP]{\draw_point_intersect_line_circle:nnnnn}
546 % \begin{syntax}
547 % \cs{draw_point_intersect_line_circle:nnnnn}
548 % \Arg{point1} \Arg{point2} \Arg{center} \Arg{radius} \Arg{root}
549 % \end{syntax}
550 % Evaluates the point at the intersection of one line, joining
551 % \meta{point1} and \meta{point2}, and a circle with \meta{center}
552 % and \meta{radius}. If the lines and circle do not intersect and
553 % error will occur.
554 % \end{function}
555 %
556 % \subsubsection{Interpolations}
557 %
558 % \begin{function}[EXP]{\draw_point_interpolate_line:nnn}
559 % \begin{syntax}
560 % \cs{draw_point_interpolate_line:nnn} \Arg{part} \Arg{point1} \Arg{point2}
561 % \end{syntax}
562 % Expands to the point which is \meta{part} way along the line joining
563 % \meta{point1} and \meta{point2}. The \meta{part} may be an interpolation or
564 % an extrapolation, and is a floating point value expressing a percentage
565 % along the line, e.g., a value of \texttt{0.5} would be half-way
566 % between the two points.
567 % \end{function}
568 %
569 % \begin{function}[EXP]{\draw_point_interpolate_distance:nnn}
570 % \begin{syntax}
571 % \cs{draw_point_interpolate_distance:nnn} \Arg{distance} \Arg{point expr1} \Arg{point expr2}
572 % \end{syntax}
573 % Expands to the point which is \meta{distance} way along the line joining
574 % \meta{point1} and \meta{point2}. The \meta{distance} may be an interpolation
575 % or an extrapolation.
576 % \end{function}
577 %
578 % \begin{function}[EXP]{\draw_point_interpolate_curve:nnnn, \draw_point_interpolate_curve:nnnnn}
579 % \begin{syntax}
580 % \cs{draw_point_interpolate_curve:nnnn} \Arg{part}
581 % \Arg{start} \Arg{control} \Arg{end}
582 % \cs{draw_point_interpolate_curve:nnnnn} \Arg{part}
583 % \Arg{start} \Arg{control1} \Arg{control2} \Arg{end}
584 % \end{syntax}
585 % Expands to the point which is \meta{part} way along the Bézier curve between
586 % \meta{start} and \meta{end}. The four-argument version operates on a quadratic
587 % Bézier curve defined by a single \meta{control} point. The five-argument version
588 % operates on a cubic Bézier curve defined by two control points (\meta{control1} and
589 % \meta{control2}).
590 %
591 % The \meta{part} parameter is an expression evaluating to a floating point
592 % value expressing the position along the curve (typically between \texttt{0.0}
593 % and \texttt{1.0}, though extrapolation is supported), where \texttt{0.5}
594 % represents the half-way point.
595 % \end{function}
596 %
597 % \begin{function}[EXP]{\draw_point_interpolate_arc_axes:nnnnnn}
598 % \begin{syntax}
599 % \cs{draw_point_interpolate_arc_axes:nnnnnn} \Arg{part}
600 % \Arg{center} \Arg{axis1} \Arg{axis2} \Arg{start} \Arg{end}
601 % \end{syntax}
602 % Expands to the point which is \meta{part} way along the arc between
603 % \meta{start} and \meta{end} and defined by the ellipse centered at
604 % \meta{center} with axes at \meta{axis1} and \meta{axis2}.
605 % The \meta{part} may be an interpolation or
606 % an extrapolation, and is a floating point value expressing a percentage
607 % along the curve, e.g., a value of \texttt{0.5} would be half-way
608 % along the curve.
609 % \end{function}
610 %
611 % \subsection{Paths}
612 %
613 % Paths are constructed by combining one or more operations before applying
614 % one or more actions. Thus until a path is \enquote{used}, it may be
615 % manipulated or indeed discarded entirely. Only one path is active at
616 % any one time, and the path is \emph{not} affected by \TeX{} grouping.
617 %
618 % \begin{function}{\draw_path_corner_arc:nn}
619 % \begin{syntax}
620 % \cs{draw_path_corner_arc:nn} \Arg{length1} \Arg{length2}
621 % \end{syntax}
622 % Sets the degree of rounding applied to corners in a path: the two
623 % \meta{length} values are the distances from the corner at which the curving
624 % should start. The first \meta{length} applies to the part of the path
625 % \enquote{leading in} to the corner (i.e., from the previous path
626 % operation), and the second to that \enquote{leading out}. If both
627 % values are \texttt{0pt} then corners will not be rounded. The values
628 % apply within the scope of the current \TeX{} group.
629 % \begin{demo}
630 % \draw_begin:
631 % \draw_path_corner_arc:nn { 5mm } { 5mm }
632 % \draw_path_rectangle_corners:nn
633 % { 0cm , 0cm } { 3cm , 2cm }
634 % \draw_path_use_clear:n { stroke }
635 % \draw_end:
636 % \end{demo}
637 % \begin{demo}
638 % \draw_begin:
639 % \draw_path_corner_arc:nn { 10mm } { 5mm }
640 % \draw_path_moveto:n { 0cm , 0cm }
641 % \draw_path_lineto:n { 0cm , 2cm }
642 % \draw_path_lineto:n { 3cm , 2cm }
643 % \draw_path_curveto:nnn
644 % { 3cm , 0cm } { 2cm , 0cm } { 1cm , 0cm }
645 % \draw_path_use_clear:n { stroke }
646 % \draw_end:
647 % \end{demo}
648 % The corners created are quarter-circles for exact right-angles and
649 % close approximations otherwise. Closing a path will result in rounding
650 % correctly.
651 % \begin{demo}
652 % \draw_begin:
653 % \draw_path_corner_arc:nn { 4pt } { 4pt }
654 % \draw_path_moveto:n
655 % { \draw_point_polar:nn { 1cm } { 0 } }
656 % \int_step_inline:nnnn { 72 } { 72 } { 359 }
657 % {
658 % \draw_path_lineto:n
659 % { \draw_point_polar:nn { 1cm } { #1 } }
660 % }
661 % \draw_path_close:
662 % \draw_path_use_clear:n { stroke }
663 % \draw_end:
664 % \end{demo}
665 % \end{function}
666 %
667 % \begin{function}{\draw_path_close:}
668 % \begin{syntax}
669 % \cs{draw_path_close:}
670 % \end{syntax}
671 % Closes the current part of the path by appending a straight line from
672 % the current point to the starting point of the path. In general, any
673 % path to be \emph{filled} should include a close instructions.
674 % \end{function}
675 %
676 % \begin{function}{\draw_path_use:n, \draw_path_use_clear:n}
677 % \begin{syntax}
678 % \cs{draw_path_use:n} \Arg{action(s)}
679 % \end{syntax}
680 % Inserts the current path, carrying out one or more possible \meta{actions}
681 % (a comma list):
682 % \begin{itemize}
683 % \item \texttt{stroke} Draws a line along the current path
684 % \item \texttt{draw} A synonym for \texttt{stroke}
685 % \item \texttt{fill} Fills the interior of the path with the current
686 % file color
687 % \item \texttt{clip} Clips any content outside of the path
688 % \end{itemize}
689 % Actions are applied in the order given irrespective of the input order.
690 % Note that whilst it is possible to use a path without clearing it, the
691 % normal use case would be to clear the path (this resets data structures
692 % at the macro level).
693 % \end{function}
694 %
695 % \begin{function}{\draw_path_replace_bb:}
696 % \begin{syntax}
697 % \cs{draw_path_replace_bb:}
698 % \end{syntax}
699 % Replaces the current bounding box of the drawing with one specified by the
700 % current path: this will be applied even when \cs{l_draw_bb_update_bool}
701 % is \texttt{false}. The current path is then cleared. Note that
702 % \cs{l_draw_bb_update_bool} is \emph{not} changed by this function:
703 % the user may wish to set it to \texttt{false} so that the bounding box
704 % is then left unchanged by further operations.
705 % \end{function}
706 %
707 % \begin{function}[EXP]{\draw_path_lastx:, \draw_path_lasty:}
708 % \begin{syntax}
709 % \cs{draw_path_lastx:}
710 % \end{syntax}
711 % Expand to the last $x$ or $y$ coordinate of the path, expressed in |pt|.
712 % In some cases, the coordinates are not know to the user (for example when
713 % an arc is created).
714 % \end{function}
715 %
716 % \subsubsection{Path operations on drawing axes}
717 %
718 % The standard path functions are all influenced by the active transformation
719 % matrix, i.e., the work relative to the drawing axes rather than
720 % the canvas.
721 %
722 % \begin{function}{\draw_path_moveto:n}
723 % \begin{syntax}
724 % \cs{draw_path_moveto:n} \Arg{point}
725 % \end{syntax}
726 % Moves the reference point of the path to the \meta{point}, but will
727 % not join this to any previous point.
728 % \end{function}
729 %
730 % \begin{function}{\draw_path_lineto:n}
731 % \begin{syntax}
732 % \cs{draw_path_lineto:n} \Arg{point}
733 % \end{syntax}
734 % Joins the current path to the \meta{point} with a straight line.
735 % In general, for reliable treatment by viewers, a \cs{draw_path_moveto:n}
736 % operation should precede the first use of a \cs{draw_path_lineto:n}
737 % on a path.
738 % \begin{demo}
739 % \draw_begin:
740 % \draw_path_moveto:n { 0cm , 0cm }
741 % \draw_path_lineto:n { 1cm , 1cm }
742 % \draw_path_lineto:n { 2cm , 1cm }
743 % \draw_path_lineto:n { 3cm , 0.5cm }
744 % \draw_path_lineto:n { 3cm , 0cm }
745 % \color_fill:n { yellow!80!black }
746 % \draw_path_use_clear:n { fill , stroke }
747 % \draw_end:
748 % \end{demo}
749 % \begin{demo}
750 % \draw_begin:
751 % \draw_path_moveto:n { 0cm , 0cm }
752 % \draw_path_lineto:n { 1cm , 1cm }
753 % \draw_path_lineto:n { 2cm , 1cm }
754 % \draw_path_moveto:n { 2cm , 1cm } % Begins a new part
755 % \draw_path_lineto:n { 3cm , 0.5cm }
756 % \draw_path_lineto:n { 3cm , 0cm }
757 % \color_fill:n { yellow!80!black }
758 % \draw_path_use_clear:n { fill , stroke }
759 % \draw_end:
760 % \end{demo}
761 % \end{function}
762 %
763 % \begin{function}{\draw_path_curveto:nnn}
764 % \begin{syntax}
765 % \cs{draw_path_curveto:nnn} \Arg{control1} \Arg{control2} \Arg{end}
766 % \end{syntax}
767 % Joins the current path to the \meta{end} with a curved line defined by
768 % cubic Bézier points \meta{control1} and \meta{control2}. The bounding box
769 % of the path (and image) will fully-contain the curve and control points,
770 % i.e., it may be bigger than strictly necessary to contain the curve
771 % \emph{alone}.
772 % \begin{demo}
773 % \draw_begin:
774 % \draw_path_moveto:n { 0cm , 0cm }
775 % \draw_path_curveto:nnn
776 % { 1cm , 1cm } % First control
777 % { 2cm , 1cm } % Second control
778 % { 3cm , 0cm } % End
779 % \color_fill:n { yellow!80!black }
780 % \draw_path_use_clear:n { fill , stroke }
781 % \draw_end:
782 % \end{demo}
783 % \end{function}
784 %
785 % \begin{function}{\draw_path_curveto:nn}
786 % \begin{syntax}
787 % \cs{draw_path_curveto:nn} \Arg{control} \Arg{end}
788 % \end{syntax}
789 % Joins the current path to the \meta{end} with a curved line defined by
790 % quadratic Bézier point \meta{control}. The bounding box
791 % of the path (and image) will fully-contain the curve and computed (cubic)
792 % control points, i.e., it may be bigger than strictly necessary to
793 % contain the curve \emph{alone}.
794 % \begin{demo}
795 % \draw_begin:
796 % \draw_path_moveto:n { 0cm , 0cm }
797 % \draw_path_curveto:nn
798 % { 1cm , 1cm }
799 % { 2cm , 0cm }
800 % \color_fill:n { yellow!80!black }
801 % \draw_path_use_clear:n { fill , stroke }
802 % \draw_end:
803 % \end{demo}
804 % \end{function}
805 %
806 % \begin{function}{\draw_path_arc:nnn, \draw_path_arc:nnnn}
807 % \begin{syntax}
808 % \cs{draw_path_arc:nnn} \Arg{radius} \Arg{angle1} \Arg{angle2}
809 % \cs{draw_path_arc:nnnn} \Arg{radius-a} \Arg{radius-b} \Arg{angle1} \Arg{angle2}
810 % \end{syntax}
811 % Joins the current path with an arc between \meta{angle1} and \meta{angle2}
812 % and of \meta{radius}. The four-argument version accepts two radii of
813 % different lengths.
814 % \begin{demo}
815 % \draw_begin:
816 % \draw_path_moveto:n { 0cm , 0cm }
817 % \draw_path_lineto:n { 0cm , 1cm }
818 % \draw_path_arc:nnn { 0.5cm } { 180 } { 90 }
819 % \draw_path_lineto:n { 3cm , 1.5cm }
820 % \draw_path_arc:nnn { 0.5cm } { 90 } { -45 }
821 % \draw_path_use_clear:n { fill }
822 % \draw_end:
823 % \end{demo}
824 %
825 % Note the interface here has a different argument ordering from that in
826 % \pkg{pgf}, which has the two centers then the two radii.
827 % \begin{demo}
828 % \draw_begin:
829 % \draw_path_moveto:n { 0cm , 0cm }
830 % \draw_path_arc:nnnn { 2cm } { 1cm } { 180 } { 45 }
831 % \draw_path_use_clear:n { stroke }
832 % \draw_end:
833 % \end{demo}
834 % \end{function}
835 %
836 % \begin{function}{\draw_path_arc_axes:nnnn}
837 % \begin{syntax}
838 % \cs{draw_path_arc_axes:nnnn} \Arg{vector1} \Arg{vector2} \Arg{angle1} \Arg{angle2}
839 % \end{syntax}
840 % Appends the portion of an ellipse from \meta{angle1} to \meta{angle2} of an
841 % ellipse with axes along \meta{vector1} and \meta{vector2} to the current
842 % path.
843 % \begin{demo}
844 % \draw_begin:
845 % \draw_path_moveto:n { 0cm , 0cm }
846 % \draw_path_lineto:n { 2cm , 5mm }
847 % \draw_path_moveto:n { 0cm , 0cm }
848 % \draw_path_lineto:n { 0cm , 1cm }
849 % \draw_path_moveto:n { 2cm , 5mm }
850 % \draw_path_arc_axes:nnnn { 2cm , 5mm } { 0cm , 1cm }
851 % { 0 } { 90 }
852 % \draw_path_use_clear:n { stroke }
853 % \draw_end:
854 % \end{demo}
855 % \end{function}
856 %
857 % \begin{function}{\draw_path_ellipse:nnn}
858 % \begin{syntax}
859 % \cs{draw_path_ellipse:nnn} \Arg{center} \Arg{vector1} \Arg{vector2}
860 % \end{syntax}
861 % Appends an ellipse at \meta{center} with axes along \meta{vector1} and
862 % \meta{vector2} to the current path. A new part is started if the path
863 % is already non-empty. Notice that the underlying drawing is constructed
864 % from arcs with appropriate moves: the interfaces is a more efficient
865 % convenience.
866 % \begin{demo}
867 % \draw_begin:
868 % \draw_path_ellipse:nnn
869 % { 1cm , 0cm }
870 % { 1.5cm , 0cm }
871 % { 0cm , 1cm }
872 % \draw_path_use_clear:n { stroke }
873 % \color_select:n { red }
874 % \draw_path_ellipse:nnn
875 % { 1cm , 0cm }
876 % { 1cm , 1cm }
877 % { -0.5cm , 0.5cm }
878 % \draw_path_use_clear:n { stroke }
879 % \draw_end:
880 % \end{demo}
881 %
882 % Note that any transformation is applied to the completed ellipse rather than
883 % to the axes.
884 % \end{function}
885 %
886 % \begin{function}{\draw_path_circle:nn}
887 % \begin{syntax}
888 % \cs{draw_path_circle:nn} \Arg{center} \Arg{radius}
889 % \end{syntax}
890 % Appends a circle of \meta{radius} at \meta{center} to the current path.
891 % This is a shortcut for \cs{draw_path_ellipse:nnn}.
892 % \end{function}
893 %
894 % \begin{function}{\draw_path_rectangle:nn, \draw_path_rectangle_corners:nn}
895 % \begin{syntax}
896 % \cs{draw_path_rectangle:nn} \Arg{lower-left} \Arg{displacement}
897 % \cs{draw_path_rectangle_corners:nn} \Arg{lower-left} \Arg{top-right}
898 % \end{syntax}
899 % Appends a rectangle starting at \meta{lower-left} to the current path,
900 % with the size of the rectangle determined either by a \meta{displacement}
901 % or the position of the \meta{top-right}.
902 % \begin{demo}
903 % \draw_begin:
904 % \draw_path_rectangle:nn
905 % { 1cm , 0cm }
906 % { 1.5cm , 1cm }
907 % \draw_path_rectangle:nn
908 % { 1.5cm , 0.25cm }
909 % { 1.5cm , 1cm }
910 % \draw_path_rectangle:nn
911 % { 2cm , 0.5cm }
912 % { 1.5cm , 1cm }
913 % \draw_path_use_clear:n { draw }
914 % \draw_end:
915 % \end{demo}
916 % \begin{demo}
917 % \draw_begin:
918 % \draw_path_rectangle_corners:nn
919 % { 1cm , 0cm }
920 % { 1.5cm , 1cm }
921 % \draw_path_use_clear:n { draw }
922 % \draw_end:
923 % \end{demo}
924 % \end{function}
925 %
926 % \begin{function}{\draw_path_grid:nnnn}
927 % \begin{syntax}
928 % \cs{draw_path_grid:nnnn} \Arg{xstep} \Arg{ystep} \Arg{lower-left} \Arg{upper-right}
929 % \end{syntax}
930 % Constructs a grid of \meta{xstep} and \meta{ystep} inside the rectangle
931 % defined by the \meta{lower-left} and the \meta{upper-right}, and appends
932 % this to the current path. The grid will be aligned such that grid lines
933 % pass through the origin, which may result in \enquote{protruding} ends
934 % if the start/end positions do not fully align.
935 % \begin{demo}
936 % \draw_begin:
937 % \draw_set_linewidth:n { 0.8pt }
938 % \draw_path_grid:nnnn
939 % { 1cm } { 1cm }
940 % { -3mm , -3mm }
941 % { 33mm , 23mm }
942 % \draw_path_use_clear:n { stroke }
943 % \draw_set_linewidth:n { 0.4pt }
944 % \draw_path_grid:nnnn
945 % { 1mm } { 1mm }
946 % { -1.5mm , -1.5mm }
947 % { 31.5mm , 21.5mm }
948 % \draw_path_use_clear:n { stroke }
949 % \draw_end:
950 % \end{demo}
951 %
952 % Any transformation is applied to the finished grid.
953 % \begin{demo}
954 % \draw_begin:
955 % \draw_transform_rotate:n { 10 }
956 % \draw_path_grid:nnnn
957 % { 1mm } { 2mm }
958 % { 0mm , 0mm }
959 % { 30mm , 30mm }
960 % \draw_path_use_clear:n { stroke }
961 % \draw_end:
962 % \end{demo}
963 % \end{function}
964 %
965 % \subsubsection{Path scope}
966 %
967 % \begin{function}{\draw_path_scope_begin:, \draw_path_scope_end:}
968 % \begin{syntax}
969 % \cs{draw_path_scope_begin:}
970 % ...
971 % \cs{draw_path_scope_end:}
972 % \end{syntax}
973 % Suspends (and saves) the current (partial) path, initializing a new
974 % path within the scope. Path operations are written to output only when
975 % used, so the scoped path is stored at the \pkg{expl3} level, not
976 % in the output.
977 % \end{function}
978 %
979 % \subsubsection{Path operations on canvas axes}
980 %
981 % For \emph{specialist} work, a small number of functions are provided
982 % which work relative to the canvas axes, i.e., these functions
983 % ignore the transformation matrix.
984 %
985 % \begin{function}{\draw_path_canvas_moveto:n}
986 % \begin{syntax}
987 % \cs{draw_path_canvas_moveto:n} \Arg{canvas point}
988 % \end{syntax}
989 % Moves the reference point of the path to the \meta{canvas point}, but will
990 % not join this to any previous point.
991 % \end{function}
992 %
993 % \begin{function}{\draw_path_canvas_lineto:n}
994 % \begin{syntax}
995 % \cs{draw_path_canvas_lineto:n} \Arg{canvas point}
996 % \end{syntax}
997 % Joins the current path to the \meta{canvas point} with a straight line.
998 % \end{function}
999 %
1000 % \begin{function}{\draw_path_canvas_curveto:nnn}
1001 % \begin{syntax}
1002 % \cs{draw_path_canvas_curveto:nnn} \Arg{control1} \Arg{control2} \Arg{end}
1003 % \end{syntax}
1004 % Joins the current path to the \meta{end} with a curved line defined by
1005 % cubic Bézier points \meta{control1} and \meta{control2}. These positions
1006 % are given as canvas points.
1007 % \end{function}
1008 %
1009 % \subsection{Bounding box}
1010 %
1011 % \begin{variable}
1012 % {
1013 % \g_draw_bb_xmin_dim ,
1014 % \g_draw_bb_ymin_dim ,
1015 % \g_draw_bb_xmax_dim ,
1016 % \g_draw_bb_ymax_dim
1017 % }
1018 % The values for the corners of the automatically-calculated bounding box.
1019 % Note that this is the apparent size of the drawing: material may be placed
1020 % outside of the bounding box, see \cs{l_draw_bb_update_bool}.
1021 % \end{variable}
1022 %
1023 % \begin{variable}{\l_draw_bb_update_bool}
1024 % All functions automatically update the bounding box of the image, unless
1025 % specified otherwise. This behavior is selectable using the
1026 % \cs{l_draw_bb_update_bool} boolean.
1027 % \end{variable}
1028 %
1029 % In \LaTeX{}, the absolute position of the origin for each drawing is
1030 % recorded as a property: the attributes \texttt{xpos}, \texttt{ypos} and
1031 % \texttt{abspage} are saved. The drawings are identified as
1032 % \texttt{draw.\meta{id}}, where \meta{id} is the value of \cs{g_draw_id_int}.
1033 %
1034 % \subsection{Boxes and coffins}
1035 %
1036 % \begin{function}{\draw_box_use:N, \draw_box_use:Nn}
1037 % \begin{syntax}
1038 % \cs{draw_box_use:N} \meta{box}
1039 % \cs{draw_box_use:Nn} \meta{box} \Arg{point}
1040 % \end{syntax}
1041 % Inserts the \meta{box} into a drawing, taking account of the current
1042 % transformation matrix and shift, and adjusting the drawing bounding
1043 % box to contain the (apparent) size of the box if this is active
1044 % (see \cs{l_draw_bb_update_bool}).
1045 % \begin{demo}
1046 % \draw_begin:
1047 % \draw_path_moveto:n { 0cm , 0cm }
1048 % \draw_path_lineto:n { 0cm , 1cm }
1049 % \draw_path_use_clear:n { stroke }
1050 % \hbox_set:Nn \l_tmpa_box
1051 % { This~is~text. }
1052 % \draw_box_use:N \l_tmpa_box
1053 % \draw_end:
1054 % \end{demo}
1055 % \begin{demo}
1056 % \draw_begin:
1057 % \draw_transform_matrix_absolute:nnnn { 2 } { 0 } { 1 } { 2 }
1058 % \draw_path_moveto:n { 0cm , 0cm }
1059 % \draw_path_lineto:n { 0cm , 1cm }
1060 % \draw_path_use_clear:n { stroke }
1061 % \hbox_set:Nn \l_tmpa_box
1062 % { This~is~text. }
1063 % \draw_box_use:N \l_tmpa_box
1064 % \draw_end:
1065 % \end{demo}
1066 % If the \meta{point} is given, the reference point of the box is placed there:
1067 % otherwise it is positioned at the origin of the drawing.
1068 % \end{function}
1069 %
1070 % \begin{function}{\draw_coffin_use:Nnn, \draw_coffin_use:Nnnn}
1071 % \begin{syntax}
1072 % \cs{draw_coffin_use:Nnn} \meta{coffin} \Arg{hpole} \Arg{vpole}
1073 % \cs{draw_coffin_use:Nnnn} \meta{coffin} \Arg{hpole} \Arg{vpole} \Arg{point}
1074 % \end{syntax}
1075 % Inserts the \meta{coffin} into a drawing, taking account of the current
1076 % transformation matrix and shift, and adjusting the drawing bounding
1077 % box to contain the (apparent) size of the box if this is active
1078 % (see \cs{l_draw_bb_update_bool}). The alignment point of the coffin to
1079 % the origin is specified by the intersection of the \meta{hpole} and the
1080 % \meta{vpole}.
1081 % \begin{demo}
1082 % \draw_begin:
1083 % \draw_path_moveto:n { 0cm , 0cm }
1084 % \draw_path_lineto:n { 0cm , 1cm }
1085 % \draw_path_use_clear:n { stroke }
1086 % \hcoffin_set:Nn \l_tmpa_coffin
1087 % { This~is~text. }
1088 % \draw_coffin_use:Nnn \l_tmpa_coffin { hc } { vc }
1089 % \draw_end:
1090 % \end{demo}
1091 % If the \meta{point} is given, the pole intersection of the coffine is
1092 % placed there: otherwise it is positioned at the origin of the drawing.
1093 % \end{function}
1094 %
1095 % \subsection{Transformations}
1096 %
1097 % Points are normally used unchanged relative to the canvas axes. This can
1098 % be modified by applying a transformation matrix. The canvas axes themselves
1099 % may be adjusted using \cs{@@_backend_cm:nnnn}: note that this
1100 % is transparent to the drawing code so is not tracked.
1101 %
1102 % \begin{function}
1103 % {\draw_transform_matrix:nnnn, \draw_transform_matrix_absolute:nnnn}
1104 % \begin{syntax}
1105 % \cs{draw_transform_matrix:nnnn}
1106 % \Arg{a} \Arg{b} \Arg{c} \Arg{d}
1107 % \end{syntax}
1108 % Applies the transformation matrix $[ \meta{a} \meta{b} \meta{c} \meta{d}]$.
1109 % The basic applies the transformation in addition to those active; the
1110 % |absolute| version overwrites any active transformation.
1111 % This assignment is local.
1112 % \end{function}
1113 %
1114 % \begin{function}{\draw_transform_shift:n, \draw_transform_shift_absolute:n}
1115 % \begin{syntax}
1116 % \cs{draw_transform_shift:n} \Arg{vector}
1117 % \end{syntax}
1118 % Applies the transformation \meta{vector} to points.
1119 % The basic applies the vector in addition to those active; the
1120 % |absolute| version overwrites any active vector. Any active
1121 % transformation matrix is applied to the shifts each time they are adjusted.
1122 % This assignment is local.
1123 % \end{function}
1124 %
1125 % \begin{function}{\draw_transform_triangle:nnn}
1126 % \begin{syntax}
1127 % \cs{draw_transform_triangle:nnn}
1128 % \Arg{origin} \Arg{point1} \Arg{point2}
1129 % \end{syntax}
1130 % Applies a transformation such that the coordinates $(0, 0)$, $(1, 0)$
1131 % and $(0, 1)$ are given by the \meta{origin}, \meta{point1} and
1132 % \meta{point2}, respectively.
1133 % This assignment is local.
1134 % \end{function}
1135 %
1136 % \begin{function}{\draw_transform_rotate:n}
1137 % \begin{syntax}
1138 % \cs{draw_transform_rotate:n} \Arg{angle}
1139 % \end{syntax}
1140 % Applies a rotation by the \meta{angle}, measured anti-clockwise in degrees.
1141 % This rotation is \emph{additional} to any prevailing transformation.
1142 % This assignment is local.
1143 % \end{function}
1144 %
1145 % \begin{function}
1146 % {
1147 % \draw_transform_scale:n,
1148 % \draw_transform_xscale:n,
1149 % \draw_transform_yscale:n
1150 % }
1151 % \begin{syntax}
1152 % \cs{draw_transform_scale:n} \Arg{scale}
1153 % \end{syntax}
1154 % Applies the \meta{scale} in either $x$ or $y$ (or both).
1155 % This scale is \emph{added} to any prevailing transformation.
1156 % This assignment is local.
1157 % \end{function}
1158 %
1159 % \begin{function}
1160 % {
1161 % \draw_transform_xshift:n,
1162 % \draw_transform_yshift:n
1163 % }
1164 % \begin{syntax}
1165 % \cs{draw_transform_xshift:n} \Arg{xshift}
1166 % \end{syntax}
1167 % Applies an \meta{xshift} or \meta{yshift}, as appropriate. This shift is
1168 % \emph{added} to any prevailing one.
1169 % This assignment is local.
1170 % \end{function}
1171 %
1172 % \begin{function}
1173 % {
1174 % \draw_transform_xslant:n,
1175 % \draw_transform_yslant:n
1176 % }
1177 % \begin{syntax}
1178 % \cs{draw_transform_xslant:n} \Arg{slant}
1179 % \end{syntax}
1180 % Applies the \meta{slant} (a factor) in either $x$ or $y$.
1181 % This slant is \emph{added} to any prevailing transformation.
1182 % This assignment is local.
1183 % \end{function}
1184 %
1185 % \begin{function}
1186 % {\draw_transform_matrix_invert:, \draw_transform_shift_invert:}
1187 % \begin{syntax}
1188 % \cs{draw_transform_matrix_invert:}
1189 % \end{syntax}
1190 % Inverts the current transformation matrix or shift vector, as
1191 % appropriate.
1192 % This assignment is local.
1193 % \end{function}
1194 %
1195 % \begin{function}
1196 % {\draw_transform_matrix_reset:, \draw_transform_shift_reset:}
1197 % \begin{syntax}
1198 % \cs{draw_transform_matrix_reset:}
1199 % \end{syntax}
1200 % Resets the current transformation matrix or shift vector, as
1201 % appropriate.
1202 % This assignment is local.
1203 % \end{function}
1204 %
1205 % \subsection{Layers}
1206 %
1207 % Drawing layers may be used to alter the way in which elements are stacked
1208 % on top of one another. In particular, they are useful when the nature of
1209 % an element depends on another, but where it needs to be behind it's
1210 % \enquote{parent}. A classic example is a filled background: this needs to
1211 % know the size of the material it is behind.
1212 %
1213 % All drawings feature a layer called |main|. This layer should always be
1214 % present, and is the one which \enquote{non-layered} content is added to.
1215 %
1216 % Layers do not automatically set any color: to propagate the color active
1217 % at the point of definition, use \cs{color_ensure_current:}.
1218 %
1219 % \begin{function}{\draw_layer_begin:n, \draw_layer_end:}
1220 % \begin{syntax}
1221 % \cs{draw_layer_begin:n} \Arg{layer}
1222 % ...
1223 % \cs{draw_layer_end:}
1224 % \end{syntax}
1225 % Begin and end collection of material for the \meta{layer}, which should
1226 % previously have been created (and which cannot be |main|). Material
1227 % collected for the layer is available globally within the current drawing.
1228 % Layers are automatically created provided they are present in
1229 % \cs{l_draw_layers_clist}.
1230 % \end{function}
1231 %
1232 % \begin{variable}{\l_draw_layers_clist}
1233 % The list of active layers: should be given \emph{before}
1234 % \cs{draw_layer_begin:n} but may be adjusted after.
1235 % The |main| layer should always be included.
1236 % \end{variable}
1237 %
1238 % \end{documentation}
1239 %
1240 % \begin{implementation}
1241 %
1242 % \section{\pkg{l3draw} implementation}
1243 %
1244 % \begin{macrocode}
1245 %<*package>
1246 % \end{macrocode}
1247 %
1248 % \begin{macrocode}
1249 %<@@=draw>
1250 % \end{macrocode}
1251 %
1252 % \begin{macrocode}
1253 \ProvidesExplPackage{l3draw}{2026-05-26}{}
1254 {L3 Experimental core drawing support}
1255 % \end{macrocode}
1256 %
1257 % \subsection{Internal auxiliaries}
1258 %
1259 % \begin{variable}{\s_@@_mark,\s_@@_stop}
1260 % Internal scan marks.
1261 % \begin{macrocode}
1262 \scan_new:N \s_@@_mark
1263 \scan_new:N \s_@@_stop
1264 % \end{macrocode}
1265 % \end{variable}
1266 %
1267 % \begin{variable}{\q_@@_recursion_tail,\q_@@_recursion_stop}
1268 % Internal recursion quarks.
1269 % \begin{macrocode}
1270 \quark_new:N \q_@@_recursion_tail
1271 \quark_new:N \q_@@_recursion_stop
1272 % \end{macrocode}
1273 % \end{variable}
1274 %
1275 % \begin{macro}[EXP]{\@@_if_recursion_tail_stop_do:Nn}
1276 % Functions to query recursion quarks.
1277 % \begin{macrocode}
1278 \__kernel_quark_new_test:N \@@_if_recursion_tail_stop_do:Nn
1279 % \end{macrocode}
1280 % \end{macro}
1281 %
1282 % Everything else is in the sub-files!
1283 %
1284 % \begin{macrocode}
1285 %</package>
1286 % \end{macrocode}
1287 %
1288 % \end{implementation}
1289 %
1290 % \PrintIndex