summaryrefslogtreecommitdiff
path: root/graphics/pgf
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-10-27 03:01:07 +0000
committerNorbert Preining <norbert@preining.info>2022-10-27 03:01:07 +0000
commit876d640726265ada7e067f22dda368dd49ed9ad1 (patch)
tree8a7e5c35cb74a7fcf340169e19efcf89ffe06f68 /graphics/pgf
parentfac21618bdcd44d7ca47228c8b856488b12ee6a2 (diff)
CTAN sync 202210270300
Diffstat (limited to 'graphics/pgf')
-rw-r--r--graphics/pgf/contrib/braids/braids.pdfbin314455 -> 301271 bytes
-rw-r--r--graphics/pgf/contrib/braids/braids.tex55
-rw-r--r--graphics/pgf/contrib/braids/braids_code.dtx693
-rw-r--r--graphics/pgf/contrib/braids/braids_code.pdfbin410835 -> 456447 bytes
-rw-r--r--graphics/pgf/contrib/spath3/knots.pdfbin341621 -> 367400 bytes
-rw-r--r--graphics/pgf/contrib/spath3/knots.tex113
-rw-r--r--graphics/pgf/contrib/spath3/spath3.pdfbin388662 -> 441114 bytes
-rw-r--r--graphics/pgf/contrib/spath3/spath3.tex223
-rw-r--r--graphics/pgf/contrib/spath3/spath3_code.dtx5203
-rw-r--r--graphics/pgf/contrib/spath3/spath3_code.pdfbin571802 -> 833596 bytes
-rw-r--r--graphics/pgf/contrib/tikzmark/README1
-rw-r--r--graphics/pgf/contrib/tikzmark/tikzmark.dtx1592
-rw-r--r--graphics/pgf/contrib/tikzmark/tikzmark.pdfbin423477 -> 517587 bytes
13 files changed, 5936 insertions, 1944 deletions
diff --git a/graphics/pgf/contrib/braids/braids.pdf b/graphics/pgf/contrib/braids/braids.pdf
index 5241cd38ee..32712530b6 100644
--- a/graphics/pgf/contrib/braids/braids.pdf
+++ b/graphics/pgf/contrib/braids/braids.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/braids/braids.tex b/graphics/pgf/contrib/braids/braids.tex
index 7dab9f0873..fa99fd937b 100644
--- a/graphics/pgf/contrib/braids/braids.tex
+++ b/graphics/pgf/contrib/braids/braids.tex
@@ -10,7 +10,15 @@
\usepackage{listings}
\lstloadlanguages{[LaTeX]TeX}
-\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
+ \lstset{
+ gobble=2,
+ breakatwhitespace=true,
+ breaklines=true,
+ language=[LaTeX]TeX,
+ basicstyle=\small\ttfamily,
+ keepspaces=true,
+ columns=fullflexible
+}
\usepackage{fancyvrb}
@@ -21,7 +29,6 @@
\begin{center}
\setlength{\parindent}{0pt}
\fbox{\begin{minipage}{.9\linewidth}
- \lstset{breakatwhitespace=true,breaklines=true,language=TeX,basicstyle=\small}
\lstinputlisting[]{example.out}
\end{minipage}}
@@ -105,15 +112,27 @@ The usual syntax for this is as follows:
\DescribeMacro{braid-word}
The \Verb+braid-word+ is an expression in the braid group, such as \Verb+s_1 s_2^{-1} s_{3,5}+.
The generator labels are not significant.
-If the subscript is a single number, as in \Verb+s_2+, the crossing goes from that number over the next.
-If the subscript is two numbers, as in \Verb+s_{2,4}+, the crossing goes from the first over the second, with both the crossing strands passing over all of the intervening strands.
+
+The subscript determines how the strands cross, as follows:
+\begin{enumerate}
+\item If the subscript is a single number, as in \Verb+s_2+, the crossing goes from that number over the next.
+\item If the subscript is two or more numbers separated by a comma, as in \Verb+s_{2,4}+ or \Verb+s_{1,3,5}+, imagine holding the numbered strands and moving each to the position of the next with the last strand moving under the others to where the first stands.
+Any intermediate non-specified strand is behind all those involved in the crossing.
+\item If the subscript is hyphenated, as in \Verb+s_{1-5}+, this is equivalent to \Verb+s_{1,2,3,4,5}+.
+This can be used as part of a list, as in \Verb+s_{1-3,5}+.
+\end{enumerate}
+
+All of these crossings take place in the same amount of vertical space.
+Be advised that crossings involving a lot of strands can get quite squashed.
+
The exponent can be \Verb+1+, \Verb+{-1}+, or missing (in which case it defaults to \Verb+1+, note also that the exponent is read as a \TeX-token so \Verb+{1}+ is also legal).
-If the exponent is \(-1\) then the over and under strands swap.
+If the exponent is \(-1\) then the braid element represented by the crossing is inverted.
\begin{itemize}
\item \Verb+s_1+ is strand \(1\) over strand \(2\).
\item \Verb+s_1^{-1}+ is strand \(2\) over strand \(1\).
\item \Verb+s_{1,3}+ is strand \(1\) over strand \(3\), and both are over strand \(2\).
+\item \Verb+s_{1-3}+ is strand \(3\) under strand \(2\) and then under strand \(1\).
\end{itemize}
Certain other symbols are allowed in the \Verb+braid-word+ which control the rendering of the braid.
@@ -217,9 +236,13 @@ With a \Verb+name prefix+, the coordinate names look like the following:
The crossing number can also be either \Verb+s+ or \Verb+e+ for the start and end of the strand.
Note that \Verb+-1-0+ and \Verb+-1-s+ are slightly different in that \Verb+s+ includes the border height.
+In addition, if the braid is named then a rectangular node is defined that fits around the whole braid.
+This node is not actually rendered but its anchors can be used afterwards as if it had been.
+
\DescribeMacro{anchor}
The key \Verb+anchor+ (in the \Verb+braid+ name space) can be used to shift the braid so that a different part of it is at the specified location.
-It uses the same syntax as the coordinates, except without the \Verb+<name prefix>-+.
+If the argument contains a hyphen then it is assumed to refer to a point on a strand with the same interpretation as the coordinates (except without the \Verb+<name prefix>-+, of course).
+If the argument does not contain a hyphen then it is taken to be an anchor of a surrounding rectangular node (the node might not itself exist -- if the braid isn't named -- but that doesn't affect the positioning).
In the following example, the braid is shifted so that where the third strand starts the second level is at the position \Verb+(1,1)+
\begin{example}
@@ -282,6 +305,26 @@ Here are more detailed examples.
\end{example}
+\begin{example}
+\begin{center}
+\begin{tikzpicture}
+\pic[
+ braid/.cd,
+ number of strands=3,
+ ultra thick,
+ strand 1/.style={red},
+ strand 2/.style={green},
+ strand 3/.style={blue},
+ gap=0.1,
+% control factor=0,
+% nudge factor=0,
+ name prefix=braid,
+] {braid={a_{1-3} a_{1,3}}};
+\end{tikzpicture}
+\end{center}
+
+\end{example}
+
\newpage
\section{Original Package Usage (Depreciated)}
diff --git a/graphics/pgf/contrib/braids/braids_code.dtx b/graphics/pgf/contrib/braids/braids_code.dtx
index 51a4ee2c60..f1f59c29b0 100644
--- a/graphics/pgf/contrib/braids/braids_code.dtx
+++ b/graphics/pgf/contrib/braids/braids_code.dtx
@@ -35,7 +35,7 @@ See http://www.latex-project.org/lppl.txt
\endpreamble
\postamble
-Copyright (C) 2011-2019 by Andrew Stacey <loopspace@mathforge.org>
+Copyright (C) 2011-2022 by Andrew Stacey <loopspace@mathforge.org>
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
@@ -103,7 +103,7 @@ and the derived files README.txt,
%</driver>
% \fi
%
-% \CheckSum{1949}
+% \CheckSum{2352}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -125,6 +125,8 @@ and the derived files README.txt,
% \changes{1.0}{2011/05/03}{Converted to DTX file}
% \changes{1.1}{2011/05/03}{Extended syntax}
% \changes{2.0}{2019/03/20}{Converted TikZ library}
+% \changes{2.1}{2019/08/14}{Extended crossing capability}
+% \changes{2.2}{2022/10/26}{Advanced positioning}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
@@ -1181,7 +1183,7 @@ and the derived files README.txt,
% Life is so much easier with \LaTeX3.
% \begin{macrocode}
\ProvidesFile{tikzlibrarybraids.code.tex}[%
- 2019/03/20 v2.0 Tikz/PGF library for drawing braid diagrams%
+ 2022/10/26 v2.2 Tikz/PGF library for drawing braid diagrams%
]
\RequirePackage{expl3}
\ExplSyntaxOn
@@ -1207,11 +1209,19 @@ and the derived files README.txt,
\fp_new:N \l_@@_anchor_x_fp
\fp_new:N \l_@@_anchor_y_fp
\int_new:N \l_@@_tmpa_int
+\int_new:N \l_@@_tmpb_int
\int_new:N \l_@@_length_int
\int_new:N \l_@@_strands_int
\int_new:N \l_@@_crossing_int
+\int_new:N \l_@@_crossing_start_int
+\int_new:N \l_@@_crossing_end_int
+\int_new:N \l_@@_crossing_width_int
+\int_new:N \l_@@_crossing_long_int
+\int_new:N \l_@@_crossing_start_factor_int
+\int_new:N \l_@@_crossing_end_factor_int
\int_new:N \l_@@_anchor_level_int
\int_new:N \l_@@_floor_int
+\seq_new:N \l_@@_tmpa_seq
\seq_new:N \l_@@_word_seq
\seq_new:N \l_@@_crossing_seq
\seq_new:N \l_@@_anchor_seq
@@ -1235,22 +1245,19 @@ and the derived files README.txt,
\prop_new:N \l_@@_crossing_permutation_prop
\prop_new:N \l_@@_inverse_prop
\prop_new:N \l_@@_anchor_prop
+\cs_generate_variant:Nn \seq_set_split:Nnn {NVn}
% \end{macrocode}
% Our interface is through a TikZ pic.
% \begin{macrocode}
\tikzset{
braid/.pic={
- code={
- \@@_parse_word:n {#1}
- \@@_count:
- \@@_render:
- }
+ \@@_parse_word:n {#1}
+ \@@_count:
+ \@@_render:
},
floor/.pic={
- code={
- \path[pic~ actions, draw=none] (0,0) rectangle (1,1);
- \path[pic~ actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
- }
+ \path[pic~ actions, draw=none] (0,0) rectangle (1,1);
+ \path[pic~ actions, fill=none] (0,0) -- (1,0) (0,1) -- (1,1);
},
/tikz/braid/.search~ also={/tikz},
braid/.cd,
@@ -1431,15 +1438,35 @@ and the derived files README.txt,
% \begin{macrocode}
\cs_new_nopar:Npn \@@_parse_index:n #1
{
- \seq_set_from_clist:Nn \l_@@_crossing_seq {#1}
+ \seq_clear:N \l_@@_crossing_seq
+ \clist_map_inline:nn {#1}
+ {
+ \tl_if_in:nnTF {##1} {-}
+ {
+ \seq_set_split:Nnn \l_@@_tmpa_seq {-} {##1}
+ \int_compare:nTF {\seq_item:Nn \l_@@_tmpa_seq {1} < \seq_item:Nn \l_@@_tmpa_seq {2} }
+ {
+ \int_set:Nn \l_@@_tmpa_int {1}
+ }
+ {
+ \int_set:Nn \l_@@_tmpa_int {-1}
+ }
+ \int_step_inline:nnnn {\seq_item:Nn \l_@@_tmpa_seq {1}} {\l_@@_tmpa_int} {\seq_item:Nn \l_@@_tmpa_seq {2}}
+ {
+ \seq_put_right:Nn \l_@@_crossing_seq {####1}
+ }
+ }
+ {
+ \seq_put_right:Nn \l_@@_crossing_seq {##1}
+ }
+ }
\int_compare:nT {\seq_count:N \l_@@_crossing_seq == 1}
{
\seq_put_right:Nx \l_@@_crossing_seq {\int_eval:n {#1 + 1} }
}
- \bool_if:NT \l_@@_swap_crossing_bool
+ \bool_if:NF \l_@@_swap_crossing_bool
{
- \seq_pop_left:NN \l_@@_crossing_seq \l_@@_tmpa_tl
- \seq_put_right:NV \l_@@_crossing_seq \l_@@_tmpa_tl
+ \seq_reverse:N \l_@@_crossing_seq
}
}
% \end{macrocode}
@@ -1507,15 +1534,11 @@ and the derived files README.txt,
% \begin{macrocode}
\seq_if_empty:NF \l_@@_crossing_seq
{
- \int_set:Nn \l_@@_strands_int
+ \seq_map_inline:Nn \l_@@_crossing_seq
{
- \int_max:nn
+ \int_set:Nn \l_@@_strands_int
{
- \int_max:nn {\l_@@_strands_int}
- { \seq_item:Nn \l_@@_crossing_seq {1}}
- }
- {
- \seq_item:Nn \l_@@_crossing_seq {2}
+ \int_max:nn {\l_@@_strands_int} {####1}
}
}
}
@@ -1534,38 +1557,51 @@ and the derived files README.txt,
% Now we step through the braid word again and record the permutations so that we can calculate the overall permutation defined by the braid.
%
% We will also figure out our shift from the anchor, so first we need to get some information about the anchor.
+%
+% If the anchor specification has a hyphen then it is of the form strand-level, otherwise it is an anchor as if the whole braid were contained in a rectangular node.
% \begin{macrocode}
\tl_set:Nx \l_@@_tmpa_tl {\@@_value:n {anchor}}
- \seq_set_split:NnV \l_@@_anchor_seq {-} \l_@@_tmpa_tl
-
- \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
- \tl_if_eq:VnTF \l_@@_tmpa_tl {rev}
- {
- \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
- \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {3}}
- }
+ \tl_if_in:NnTF \l_@@_tmpa_tl {-}
{
- \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
- \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
- }
+ \seq_set_split:NnV \l_@@_anchor_seq {-} \l_@@_tmpa_tl
+
+ \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
+ \tl_if_eq:VnTF \l_@@_tmpa_tl {rev}
+ {
+ \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
+ \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {3}}
+ }
+ {
+ \tl_set:Nx \l_@@_anchor_strand_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
+ \tl_set:Nx \l_@@_anchor_level_tl {\seq_item:Nn \l_@@_anchor_seq {2}}
+ }
% \end{macrocode}
% The important information is as to the level at which the requested anchor resides.
% If it is at the end or start of a strand, we set the level to \(-1\) so that it never matches a level number.
% \begin{macrocode}
- \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
- {
- \int_set:Nn \l_@@_anchor_level_int {-1}
- }
- {
- \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+ \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
{
\int_set:Nn \l_@@_anchor_level_int {-1}
}
{
- \int_set:Nn \l_@@_anchor_level_int
- {\tl_use:N \l_@@_anchor_level_tl}
+ \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+ {
+ \int_set:Nn \l_@@_anchor_level_int {-1}
+ }
+ {
+ \int_set:Nn \l_@@_anchor_level_int
+ {\tl_use:N \l_@@_anchor_level_tl}
+ }
}
}
+ {
+% \end{macrocode}
+% There wasn't a hyphen in the anchor specification, so assume it's an anchor on a node surrounding the entire braid.
+% For now, set the anchor strand and level to \(-1\).
+% \begin{macrocode}
+ \int_set:Nn \l_@@_anchor_level_int {-1}
+ \tl_set:Nn \l_@@_anchor_strand_tl {-1}
+ }
\int_zero:N \l_@@_crossing_int
\int_incr:N \l_@@_crossing_int
@@ -1580,23 +1616,29 @@ and the derived files README.txt,
##1
\seq_if_empty:NF \l_@@_crossing_seq
{
- \prop_get:NxN \l_@@_permutation_prop
- {
- \seq_item:Nn \l_@@_crossing_seq {1}
- } \l_@@_tmpa_tl
- \prop_get:NxN \l_@@_permutation_prop
+ \int_step_inline:nnn {2} {\seq_count:N \l_@@_crossing_seq}
{
- \seq_item:Nn \l_@@_crossing_seq {2}
- } \l_@@_tmpb_tl
+ \int_set:Nn \l_@@_tmpa_int {####1}
+ \int_set:Nn \l_@@_tmpb_int {####1 - 1}
- \prop_put:NxV \l_@@_permutation_prop
- {
- \seq_item:Nn \l_@@_crossing_seq {2}
- } \l_@@_tmpa_tl
- \prop_put:NxV \l_@@_permutation_prop
- {
- \seq_item:Nn \l_@@_crossing_seq {1}
- } \l_@@_tmpb_tl
+ \prop_get:NxN \l_@@_permutation_prop
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ } \l_@@_tmpa_tl
+ \prop_get:NxN \l_@@_permutation_prop
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+ } \l_@@_tmpb_tl
+
+ \prop_put:NxV \l_@@_permutation_prop
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+ } \l_@@_tmpa_tl
+ \prop_put:NxV \l_@@_permutation_prop
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ } \l_@@_tmpb_tl
+ }
}
% \end{macrocode}
% See if the current level is what was requested by the anchor.
@@ -1629,24 +1671,30 @@ and the derived files README.txt,
}
% \end{macrocode}
% Now that we have the inverse, we can figure out our anchor.
-% First, see if we requested a strand by its position at the end of the braid.
+% If the strand was recorded as \(-1\), then we want to figure out the position from the braid as a whole so we don't bother with processing.
% \begin{macrocode}
- \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
- \tl_if_eq:VnT \l_@@_tmpa_tl {rev}
+ \tl_if_eq:VnF \l_@@_anchor_strand_tl {-1}
{
- \prop_get:NVN \l_@@_permutation_prop
- \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
- }
- \tl_if_eq:VnF \l_@@_anchor_level_tl {s}
- {
- \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+% \end{macrocode}
+% Now, see if we requested a strand by its position at the end of the braid.
+% \begin{macrocode}
+ \tl_set:Nx \l_@@_tmpa_tl {\seq_item:Nn \l_@@_anchor_seq {1}}
+ \tl_if_eq:VnT \l_@@_tmpa_tl {rev}
{
- \prop_get:NVN \l_@@_inverse_prop
+ \prop_get:NVN \l_@@_permutation_prop
\l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
}
+ \tl_if_eq:VnF \l_@@_anchor_level_tl {s}
{
- \prop_get:NVN \l_@@_anchor_prop
- \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
+ \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+ {
+ \prop_get:NVN \l_@@_inverse_prop
+ \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
+ }
+ {
+ \prop_get:NVN \l_@@_anchor_prop
+ \l_@@_anchor_strand_tl \l_@@_anchor_strand_tl
+ }
}
}
% \end{macrocode}
@@ -1684,28 +1732,91 @@ and the derived files README.txt,
\cs_new_nopar:Npn \@@_render:
{
% \end{macrocode}
-%
+% Start by figuring out our anchor.
% \begin{macrocode}
- \fp_set:Nn \l_@@_anchor_x_fp { - 1 * (\tl_use:N \l_@@_anchor_strand_tl - 1) * \@@_dim_value:n {width} }
-
- \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
+ \tl_if_eq:VnTF \l_@@_anchor_strand_tl {-1}
{
- \fp_set:Nn \l_@@_anchor_y_fp {0}
+% \end{macrocode}
+% The strand is \(-1\) then we're working with the braid as if a node.
+% We'll redefine this node later anyway.
+% \begin{macrocode}
+ \tl_set:cn {pgf@sh@ns@temporary braid node}{rectangle}
+ \tl_set:cx {pgf@sh@np@temporary braid node}{%
+ \exp_not:N\def
+ \exp_not:N\southwest
+ {
+ \exp_not:N\pgfqpoint
+ {0pt}
+ {0pt}
+ }
+ \exp_not:N\def
+ \exp_not:N\northeast
+ {
+ \exp_not:N\pgfqpoint
+ {
+ \fp_to_dim:n
+ {
+ (\l_@@_strands_int - 1)
+ *
+ abs(\@@_dim_value:n {width})
+ }
+ }
+ {
+ \fp_to_dim:n
+ {
+ \l_@@_length_int * abs(\@@_dim_value:n {height})
+ + 2 * \@@_dim_value:n {border~ height}
+ }
+ }
+ }
+ }%
+ \pgfgettransform\l_@@_tmpa_tl
+ \tl_set:cV {pgf@sh@nt@temporary braid node} \l_@@_tmpa_tl
+ \tl_set:cV {pgf@sh@pi@temporary braid node} \pgfpictureid
+ \pgfpointanchor{temporary braid node} {\@@_value:n {anchor}}
+% \end{macrocode}
+% Adjustments due to the possibility of negative widths/heights
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_anchor_x_fp {
+ - \dim_use:c {pgf@x}
+ - (1 - sign(\@@_dim_value:n {width})) / 2
+ * (\l_@@_strands_int - 1)
+ * \@@_dim_value:n {width}
+ }
+ \fp_set:Nn \l_@@_anchor_y_fp {
+ - \dim_use:c {pgf@y}
+ - (1 - sign(\@@_dim_value:n {height})) / 2
+ * (
+ \l_@@_length_int * abs(\@@_dim_value:n {height})
+ + 2 * \@@_dim_value:n {border~ height}
+ ) * sign(\@@_dim_value:n {height})
+ }
}
{
- \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+% \end{macrocode}
+% The strand is not \(-1\) so we're setting the anchor via strand and level numbers.
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_anchor_x_fp { - 1 * (\tl_use:N \l_@@_anchor_strand_tl - 1) * \@@_dim_value:n {width} }
+
+ \tl_if_eq:VnTF \l_@@_anchor_level_tl {s}
{
- \fp_set:Nn \l_@@_anchor_y_fp {
- -1 * \l_@@_length_int * \@@_dim_value:n {height}
- - sign(\@@_dim_value:n {height})
- * 2 * \@@_dim_value:n {border~ height}
- }
+ \fp_set:Nn \l_@@_anchor_y_fp {0}
}
{
- \fp_set:Nn \l_@@_anchor_y_fp {
- -1 * \l_@@_anchor_level_tl * \@@_dim_value:n {height}
- - sign(\@@_dim_value:n {height})
- * \@@_dim_value:n {border~ height}
+ \tl_if_eq:VnTF \l_@@_anchor_level_tl {e}
+ {
+ \fp_set:Nn \l_@@_anchor_y_fp {
+ -1 * \l_@@_length_int * \@@_dim_value:n {height}
+ - sign(\@@_dim_value:n {height})
+ * 2 * \@@_dim_value:n {border~ height}
+ }
+ }
+ {
+ \fp_set:Nn \l_@@_anchor_y_fp {
+ -1 * \l_@@_anchor_level_tl * \@@_dim_value:n {height}
+ - sign(\@@_dim_value:n {height})
+ * \@@_dim_value:n {border~ height}
+ }
}
}
}
@@ -1860,190 +1971,321 @@ and the derived files README.txt,
% \begin{macrocode}
\seq_if_empty:NF \l_@@_crossing_seq
{
+ \int_set:Nn \l_@@_crossing_long_int
+ {
+ % \seq_item:Nn \l_@@_crossing_seq {\seq_count:N \l_@@_crossing_seq}
+ \seq_item:Nn \l_@@_crossing_seq {1}
+ }
+ \int_set:Nn \l_@@_crossing_start_int
+ {
+ \int_min:nn
+ {
+ \seq_item:Nn \l_@@_crossing_seq {1}
+ }
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\seq_count:N \l_@@_crossing_seq}
+ }
+ }
+ \int_set:Nn \l_@@_crossing_end_int
+ {
+ \int_max:nn
+ {
+ \seq_item:Nn \l_@@_crossing_seq {1}
+ }
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\seq_count:N \l_@@_crossing_seq}
+ }
+
+ }
+ \int_set:Nn \l_@@_crossing_width_int
+ {
+ \l_@@_crossing_end_int
+ -
+ \l_@@_crossing_start_int
+ }
+% \end{macrocode}
+% Step through the crossing
+% \begin{macrocode}
+ \int_step_inline:nnn {2} {\seq_count:N \l_@@_crossing_seq}
+ {
+ \int_set:Nn \l_@@_tmpa_int {####1}
+ \int_set:Nn \l_@@_tmpb_int {####1 - 1}
% \end{macrocode}
% Keep track of the current permutation.
% \begin{macrocode}
\prop_get:NxN \l_@@_crossing_permutation_prop
- {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpa_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpa_tl
\prop_get:NxN \l_@@_crossing_permutation_prop
- {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpb_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpb_tl
\prop_put:NxV \l_@@_crossing_permutation_prop
- {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpa_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpa_tl
\prop_put:NxV \l_@@_crossing_permutation_prop
- {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpb_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpb_tl
% \end{macrocode}
% Now get the strands corresponding to the ones involved in the crossing.
% \begin{macrocode}
\prop_get:NxN \l_@@_strands_prop
- {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpa_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpa_tl
\prop_get:NxN \l_@@_strands_prop
- {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpb_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpb_tl
% \end{macrocode}
% The over-strand is easy as that's a single curve.
% \begin{macrocode}
+% \int_set:Nn \l_@@_crossing_start_factor_int {1}
+% \int_set:Nn \l_@@_crossing_end_factor_int {1}
+% \int_compare:nT {
+% \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+% =
+% \l_@@_crossing_long_int
+% }
+% {
+ \int_set:Nn \l_@@_crossing_start_factor_int {0}
+ \int_set:Nn \l_@@_crossing_end_factor_int {0}
+
+ \int_compare:nT {
+ ####1 = \seq_count:N \l_@@_crossing_seq
+ }
+ {
+ \int_set:Nn \l_@@_crossing_end_factor_int {1}
+ }
+ \int_compare:nT {
+ ####1 = 2
+ }
+ {
+ \int_set:Nn \l_@@_crossing_start_factor_int {1}
+ }
+% }
+
\tl_put_right:Nx \l_@@_tmpa_tl
{
\exp_not:N \@@_lineto:nn
{\fp_eval:n
{
- (\seq_item:Nn \l_@@_crossing_seq {1} - 1)
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int} - 1)
* \@@_dim_value:n {width}
}
}
- {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp } }
+ {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+ } }
\exp_not:N \@@_curveto:nnnnnn
{0}
- {\fp_eval:n { \l_@@_control_fp}}
+ {\fp_eval:n { \l_@@_control_fp
+% * \l_@@_crossing_start_factor_int
+ * 1/(\seq_count:N \l_@@_crossing_seq - 1)}}
{0}
- {\fp_eval:n {- \l_@@_control_fp}}
+ {\fp_eval:n {- \l_@@_control_fp
+% * \l_@@_crossing_end_factor_int
+ * 1/(\seq_count:N \l_@@_crossing_seq - 1)}}
{\fp_eval:n
{
- (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
* \@@_dim_value:n {width}
}
}
{\fp_eval:n
{
\l_@@_height_fp
- + \@@_dim_value:n {height}
- - \l_@@_nudge_fp
+ + \@@_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
}
}
}
% \end{macrocode}
% The under-strand is a bit more complicated as we need to break it in the middle.
% \begin{macrocode}
+% \int_set:Nn \l_@@_crossing_start_factor_int {1}
+% \int_set:Nn \l_@@_crossing_end_factor_int {1}
+% \int_compare:nT {
+% \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+% =
+% \l_@@_crossing_long_int
+% }
+% {
+ \int_set:Nn \l_@@_crossing_start_factor_int {0}
+ \int_set:Nn \l_@@_crossing_end_factor_int {0}
+
+ \int_compare:nT {
+ ####1 = \seq_count:N \l_@@_crossing_seq
+ }
+ {
+ \int_set:Nn \l_@@_crossing_end_factor_int {1}
+ }
+ \int_compare:nT {
+ ####1 = 2
+ }
+ {
+ \int_set:Nn \l_@@_crossing_start_factor_int {1}
+ }
+% }
+
\tl_put_right:Nx \l_@@_tmpb_tl
{
\exp_not:N \@@_lineto:nn
{\fp_eval:n
{
- (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
* \@@_dim_value:n {width}
}
}
- {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp } }
+ {\fp_eval:n { \l_@@_height_fp + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+
+ } }
\exp_not:N \@@_curveto:nnnnnn
{0}
{
\fp_eval:n {
- \l_@@_control_fp * (.5 - \@@_value:n {gap} )
+ \l_@@_control_fp * (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_start_factor_int
}
}
{
\fp_eval:n {
- - (.5 - \@@_value:n {gap} ) / 3 *
+ - (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
\@@_bezier_tangent:nnnnn
- {.5 - \@@_value:n {gap} }
+ {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
{0}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
}
}
{
\fp_eval:n {
- -(.5 - \@@_value:n {gap} ) / 3 *
+ -(.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
\@@_bezier_tangent:nnnnn
- {.5 - \@@_value:n {gap} }
+ {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
- {\l_@@_control_fp}
{
- \@@_dim_value:n {height}
- - 2* \l_@@_nudge_fp
- - \l_@@_control_fp
+ \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_start_factor_int
+ }
+ {
+ \@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+ - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_end_factor_int
+ }
+ {
+ \@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
}
- {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
}
}
{
\fp_eval:n {
- (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
* \@@_dim_value:n {width} +
\@@_bezier_point:nnnnn
- {.5 - \@@_value:n {gap} }
+ {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
{0}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
}
}
{
\fp_eval:n {
- \l_@@_height_fp + \l_@@_nudge_fp +
+ \l_@@_height_fp
+ + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+ +
\@@_bezier_point:nnnnn
- {.5 - \@@_value:n {gap} }
+ {.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
- {\l_@@_control_fp}
{
- \@@_dim_value:n {height}
- - 2* \l_@@_nudge_fp
- - \l_@@_control_fp
+ \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_start_factor_int
+ }
+ {
+ \@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+ - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_end_factor_int
+ }
+ {\@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
}
- {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
}
}
\exp_not:N \@@_moveto:nn
{
\fp_eval:n {
- (\seq_item:Nn \l_@@_crossing_seq {2} - 1)
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int} - 1)
* \@@_dim_value:n {width} +
\@@_bezier_point:nnnnn
- {.5 + \@@_value:n {gap} }
+ {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
{0}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
}
}
{
\fp_eval:n {
- \l_@@_height_fp + \l_@@_nudge_fp +
+ \l_@@_height_fp
+ + \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
+ +
\@@_bezier_point:nnnnn
- {.5 + \@@_value:n {gap} }
+ {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
- {\l_@@_control_fp}
{
- \@@_dim_value:n {height} - 2* \l_@@_nudge_fp
- - \l_@@_control_fp
+ \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_start_factor_int
+ }
+ {
+ \@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+ - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_end_factor_int
+ }
+ {\@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
}
- {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
}
}
@@ -2051,55 +2293,65 @@ and the derived files README.txt,
{
\fp_eval:n {
- (.5 - \@@_value:n {gap} ) / 3 *
+ (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
\@@_bezier_tangent:nnnnn
- {.5 + \@@_value:n {gap} }
+ {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
{0}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
{
- (\seq_item:Nn \l_@@_crossing_seq {1}
- - \seq_item:Nn \l_@@_crossing_seq {2})
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ - \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int})
* \@@_dim_value:n {width}
}
}
}
{
\fp_eval:n {
- (.5 - \@@_value:n {gap} ) / 3 *
+ (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) ) / 3 *
\@@_bezier_tangent:nnnnn
- {.5 + \@@_value:n {gap} }
+ {.5 + \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) }
{0}
- {\l_@@_control_fp}
{
- \@@_dim_value:n {height} - 2* \l_@@_nudge_fp
- - \l_@@_control_fp
+ \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_start_factor_int
+ }
+ {
+ \@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
+ - \l_@@_control_fp * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+% * \l_@@_crossing_end_factor_int
+ }
+ {\@@_dim_value:n {height} * 1/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_start_factor_int
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
}
- {\@@_dim_value:n {height} - 2* \l_@@_nudge_fp}
}
}
{0}
- { \fp_eval:n {
- -\l_@@_control_fp * (.5 - \@@_value:n {gap} )
- }
+ {\fp_eval:n {
+ - \l_@@_control_fp * (.5 - \@@_value:n {gap} * (\seq_count:N \l_@@_crossing_seq - 1) )
+% * \l_@@_crossing_end_factor_int
+ * 1/(\seq_count:N \l_@@_crossing_seq - 1)}
}
-
{\fp_eval:n
{
- (\seq_item:Nn \l_@@_crossing_seq {1} - 1)
+ (\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int} - 1)
* \@@_dim_value:n {width}
}
}
{\fp_eval:n
{
- \l_@@_height_fp + \@@_dim_value:n {height}
- - \l_@@_nudge_fp
+ \l_@@_height_fp
+ + \@@_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l_@@_crossing_seq - 1)
+ - \l_@@_nudge_fp * \l_@@_crossing_end_factor_int
}
}
@@ -2108,9 +2360,9 @@ and the derived files README.txt,
% Now put those new strands back in the prop.
% \begin{macrocode}
\prop_put:NxV \l_@@_strands_prop
- {\seq_item:Nn \l_@@_crossing_seq {2}} \l_@@_tmpa_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}} \l_@@_tmpa_tl
\prop_put:NxV \l_@@_strands_prop
- {\seq_item:Nn \l_@@_crossing_seq {1}} \l_@@_tmpb_tl
+ {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}} \l_@@_tmpb_tl
% \end{macrocode}
% If the strands are more than one apart, the intermediate strands need to be broken as well.
% \begin{macrocode}
@@ -2118,18 +2370,18 @@ and the derived files README.txt,
{
\int_max:nn
{
- \seq_item:Nn \l_@@_crossing_seq {1}
+ \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
}
{
- \seq_item:Nn \l_@@_crossing_seq {2}
+ \seq_item:Nn \l_@@_crossing_seq {####1}
}
-
\int_min:nn
{
- \seq_item:Nn \l_@@_crossing_seq {1}
+ \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
}
{
- \seq_item:Nn \l_@@_crossing_seq {2}
+ \seq_item:Nn \l_@@_crossing_seq {####1}
}
> 1
}
@@ -2138,49 +2390,78 @@ and the derived files README.txt,
{
\int_min:nn
{
- \seq_item:Nn \l_@@_crossing_seq {1}
+ \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
}
{
- \seq_item:Nn \l_@@_crossing_seq {2}
+ \seq_item:Nn \l_@@_crossing_seq {####1}
}
+ 1}
{1}
{
\int_max:nn
{
- \seq_item:Nn \l_@@_crossing_seq {1}
+ \seq_item:Nn \l_@@_crossing_seq {####1 - 1}
}
{
- \seq_item:Nn \l_@@_crossing_seq {2}
+ \seq_item:Nn \l_@@_crossing_seq {####1}
}
- 1
}
{
- \prop_get:NnN \l_@@_strands_prop {####1} \l_@@_tmpa_tl
+ \prop_get:NnN \l_@@_strands_prop {########1} \l_@@_tmpa_tl
\tl_put_right:Nx \l_@@_tmpa_tl
{
\exp_not:N \@@_lineto:nn
- {\fp_eval:n {(####1 - 1) * \@@_dim_value:n {width} }}
+ {\fp_eval:n {(########1 - 1) * \@@_dim_value:n {width} }}
{\fp_eval:n
{
\l_@@_height_fp + \l_@@_nudge_fp
- + .5 * \l_@@_control_fp
+ + .5 * \l_@@_control_fp / (\seq_count:N \l_@@_crossing_seq - 1)
+ + \@@_dim_value:n {height} * (####1 - 2)/(\seq_count:N \l_@@_crossing_seq - 1)
}
}
\exp_not:N \@@_moveto:nn
- {\fp_eval:n {(####1 - 1) * \@@_dim_value:n {width} }}
+ {\fp_eval:n {(########1 - 1) * \@@_dim_value:n {width} }}
{\fp_eval:n
{
- \l_@@_height_fp + \@@_dim_value:n {height}
- - \l_@@_nudge_fp - .5 * \l_@@_control_fp
+ \l_@@_height_fp
+ - \l_@@_nudge_fp - .5 * \l_@@_control_fp / (\seq_count:N \l_@@_crossing_seq - 1)
+ + \@@_dim_value:n {height} * (####1 - 1)/(\seq_count:N \l_@@_crossing_seq - 1)
}
}
}
- \prop_put:NnV \l_@@_strands_prop {####1} \l_@@_tmpa_tl
+ \prop_put:NnV \l_@@_strands_prop {########1} \l_@@_tmpa_tl
}
}
+% \end{macrocode}
+% Reset the current long
+% \begin{macrocode}
+ \int_compare:nTF
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}
+ =
+ \l_@@_crossing_long_int
+ }
+ {
+ \int_set:Nn \l_@@_crossing_long_int {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}}
+ }
+ {
+ \int_compare:nT
+ {
+ \seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpb_int}
+ =
+ \l_@@_crossing_long_int
+ }
+ {
+ \int_set:Nn \l_@@_crossing_long_int {\seq_item:Nn \l_@@_crossing_seq {\l_@@_tmpa_int}}
+ }
+
+ }
+% \end{macrocode}
+% \begin{macrocode}
+ }
}
% \end{macrocode}
% If we're to step the level, increase the height and add a load of coordinates.
@@ -2239,6 +2520,68 @@ and the derived files README.txt,
\prop_get:NnN \l_@@_strands_prop {##1} \l_@@_tmpa_tl
\tl_use:N \l_@@_tmpa_tl
}
+% \end{macrocode}
+% Finally, put a node around the whole braid if it's been named
+% \begin{macrocode}
+ \tl_if_empty:cF {tikz@fig@name}
+ {
+ \tl_gset:cn {pgf@sh@ns@ \tl_use:c{tikz@fig@name} }{rectangle}
+ \tl_gset:cx {pgf@sh@np@ \tl_use:c{tikz@fig@name} }{%
+ \exp_not:N\def
+ \exp_not:N\southwest
+ {
+ \exp_not:N\pgfqpoint
+ {
+ \fp_to_dim:n
+ {
+ min(0,
+ (\l_@@_strands_int - 1)
+ *
+ (\@@_dim_value:n {width})
+ )
+ }
+ }
+ {
+ \fp_to_dim:n
+ {
+ min(0,
+ \l_@@_length_int * (\@@_dim_value:n {height})
+ + 2 * sign(\@@_dim_value:n {height}) *
+ \@@_dim_value:n {border~ height}
+ )
+ }
+ }
+ }
+ \exp_not:N\def
+ \exp_not:N\northeast
+ {
+ \exp_not:N\pgfqpoint
+ {
+ \fp_to_dim:n
+ {
+ max(0,
+ (\l_@@_strands_int - 1)
+ *
+ (\@@_dim_value:n {width})
+ )
+ }
+ }
+ {
+ \fp_to_dim:n
+ {
+ max(0,
+ \l_@@_length_int * (\@@_dim_value:n {height})
+ + 2 * sign(\@@_dim_value:n {height}) *
+ \@@_dim_value:n {border~ height}
+ )
+ }
+ }
+ }
+ }%
+ \pgfgettransform\l_@@_tmpa_tl
+ \tl_gset:cV {pgf@sh@nt@ \tl_use:c{tikz@fig@name} } \l_@@_tmpa_tl
+ \tl_gset:cV {pgf@sh@pi@ \tl_use:c{tikz@fig@name} } \pgfpictureid
+ }
\end{scope}
}
% \end{macrocode}
@@ -2257,6 +2600,8 @@ and the derived files README.txt,
}
\cs_new_nopar:Npn \@@_curveto:nnnnnn #1#2#3#4#5#6
{
+% -- +(5 pt, 0) -- +(0 pt, 0pt)
+% -- +(#1 pt, #2 pt) -- (#5 pt + #3 pt, #6 pt + #4 pt) -- (#5 pt, #6 pt)
.. controls +(#1 pt, #2 pt) and +(#3 pt, #4 pt)
.. (#5 pt, #6 pt)
}
diff --git a/graphics/pgf/contrib/braids/braids_code.pdf b/graphics/pgf/contrib/braids/braids_code.pdf
index d60b9b6f39..e001392bde 100644
--- a/graphics/pgf/contrib/braids/braids_code.pdf
+++ b/graphics/pgf/contrib/braids/braids_code.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/spath3/knots.pdf b/graphics/pgf/contrib/spath3/knots.pdf
index 39067dee2e..9f4d6b0fa7 100644
--- a/graphics/pgf/contrib/spath3/knots.pdf
+++ b/graphics/pgf/contrib/spath3/knots.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/spath3/knots.tex b/graphics/pgf/contrib/spath3/knots.tex
index 7e0d885843..9236af6aa5 100644
--- a/graphics/pgf/contrib/spath3/knots.tex
+++ b/graphics/pgf/contrib/spath3/knots.tex
@@ -611,6 +611,119 @@ This can be combined with the facilities of this package but also has some featu
For braids themselves, there is the \Verb+braids+ package which allows input specification in the form of a word in the braid group.
+\section{Troubleshooting}
+
+The diagrams drawn by this package can involve quite complicated calculations and they don't always turn out as expected.
+There are plenty of \href{https://tex.stackexchange.com/search?q=knots}{questions on TeX-SX} about this package, but sifting through them can be tricky.
+Through answering some of them, I've developed a few strategies for figuring out what's going on.
+This section details some of what can go wrong and some of those strategies for finding out what's going on.
+
+\subsection{Small Diagrams}
+
+A common situation when the diagrams don't always work out is when the diagram is relatively small.
+The defaults in this library are set for a diagram of a few centimetres across.
+Some of the key properties are stored as dimensions which means that they don't naturally scale but have to be reset.
+In particular, the \Verb!end tolerance! and \Verb!clip radius! are dimensions with defaults \Verb!14pt! and \Verb!10pt! respectively.
+
+The \Verb!end tolerance! is used to weed out false intersections that occur when a strand is split into pieces.
+Therefore, if the \Verb!consider self intersections! key is not set then \Verb!end tolerance! is largely unneeded (though it is still used) so can safely be set to something very small.
+
+The effect of this can be seen in the following (where to make the issue evident, I've made \Verb!end tolerance! larger rather than make the diagram small).
+
+\begin{example}
+\begin{tikzpicture}
+\begin{knot}[
+ end tolerance=1.5cm
+ ]
+\strand[red] (0,0) to[out=0,in=180] ++(1,1);
+\strand[blue] (0,1) to[out=0,in=180] ++(1,-1);
+\end{knot}
+\begin{knot}
+\strand[red] (1.5,0) to[out=0,in=180] ++(1,1);
+\strand[blue] (1.5,1) to[out=0,in=180] ++(1,-1);
+\end{knot}
+\end{tikzpicture}
+\end{example}
+
+The \Verb!clip radius! determines how much of the diagram is redrawn near a crossing.
+If the crossings are very close together, the redraws can interfere with each other.
+
+\begin{example}
+\begin{tikzpicture}
+\begin{knot}[
+ clip radius=.6cm,
+ flip crossing=2
+ ]
+\strand[red] (0,0) to[out=0,in=180] ++(1,.6) to[out=0,in=180] ++(1,-.6);
+\strand[blue] (0,1) to[out=0,in=180] ++(1,-.6) to[out=0,in=180] ++(1,.6);
+\end{knot}
+\begin{knot}[flip crossing=2]
+\strand[red] (2.5,0) to[out=0,in=180] ++(1,.6) to[out=0,in=180] ++(1,-.6);
+\strand[blue] (2.5,1) to[out=0,in=180] ++(1,-.6) to[out=0,in=180] ++(1,.6);
+\end{knot}
+\end{tikzpicture}
+\end{example}
+
+\subsection{Strategies}
+
+\begin{itemize}
+\item \Verb+draft mode=crossings+
+
+This is useful to check that all the intersections are actually being found.
+Any that aren't might be due to \Verb!end tolerance! being too large.
+Or if \Verb!consider self intersections! is set to \Verb!no splits! then some self intersections might not be found.
+
+\item \Verb+background clip+ and \Verb+clip+ styles.
+
+When a crossing is redrawn, the over strand is clipped to a circle centred on the crossing.
+First a background path is drawn to ``wipe out'' the under strand and then the over strand is drawn.
+The clip circle for the background path is slightly smaller than the over path to avoid an issue whereby faint artefacts are visible (called \href{https://tex.stackexchange.com/q/188447/86}{crop circles} in one question on TeX-SX).
+Rather than use a \Verb!\clip! directly, I use \Verb!\path[background clip]! and \Verb!\path[clip]! which means that these styles can be modified to show the region that is being used.
+A useful style is:
+
+\begin{lstlisting}
+ background clip/.append style={
+ preaction={
+ fill=gray,
+ fill opacity=.5,
+ }
+ }
+\end{lstlisting}
+
+\begin{example}
+\begin{tikzpicture}
+\begin{knot}[
+ clip radius=.6cm,
+ flip crossing=2,
+ background clip/.append style={
+ preaction={
+ fill=gray,
+ fill opacity=.5,
+ }
+ }
+]
+\strand[red] (0,0) to[out=0,in=180] ++(1,.6) to[out=0,in=180] ++(1,-.6);
+\strand[blue] (0,1) to[out=0,in=180] ++(1,-.6) to[out=0,in=180] ++(1,.6);
+\end{knot}
+\begin{knot}[
+ flip crossing=2,
+ background clip/.append style={
+ preaction={
+ fill=gray,
+ fill opacity=.5,
+ }
+ }
+]
+\strand[red] (2.5,0) to[out=0,in=180] ++(1,.6) to[out=0,in=180] ++(1,-.6);
+\strand[blue] (2.5,1) to[out=0,in=180] ++(1,-.6) to[out=0,in=180] ++(1,.6);
+\end{knot}
+\end{tikzpicture}
+\end{example}
+
+
+\end{itemize}
+
+
\end{document}
% Local Variables:
% tex-output-type: "pdf18"
diff --git a/graphics/pgf/contrib/spath3/spath3.pdf b/graphics/pgf/contrib/spath3/spath3.pdf
index ebbefefa1a..9282e0adfe 100644
--- a/graphics/pgf/contrib/spath3/spath3.pdf
+++ b/graphics/pgf/contrib/spath3/spath3.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/spath3/spath3.tex b/graphics/pgf/contrib/spath3/spath3.tex
index 7621db4a28..c8e9d65af7 100644
--- a/graphics/pgf/contrib/spath3/spath3.tex
+++ b/graphics/pgf/contrib/spath3/spath3.tex
@@ -1,5 +1,5 @@
-%\RequirePackage{shellesc}
-%\immediate\write18{tex spath3_code.dtx}
+\RequirePackage{shellesc}
+\immediate\write18{tex spath3_code.dtx}
\documentclass{l3doc}
\usepackage{tikz}
\usetikzlibrary{
@@ -89,12 +89,62 @@ The best way is to open an issue at the code repository on github, at \href{http
\end{lstlisting}
The \texttt{spath3} TikZ library defines a set of keys that can be issued to muck about with soft paths.
-These are all defined in the \texttt{spath} family, so all the following keys should be prefixed by \texttt{spath/}, or the key \texttt{spath/.cd} needs to be used beforehand (but note that as yet I haven't implemented sending unknown keys back to the main \Verb+tikz+ directory).
+These are all defined in the |spath| family, so all the following keys should be prefixed by |spath/|, or the key |spath/.cd| needs to be used beforehand (but note that as yet I haven't implemented sending unknown keys back to the main |tikz| directory).
-The keys try to gracefully fail if the path doesn't exist or is empty.
+The keys try to gracefully fail if the path doesn't exist or is empty\footnote{A path that was defined inside a group will be empty if referred to outside that group rather than not existing.}.
The intention is that the document should still compile with a warning in the log file (and on the console output).
If this doesn't happen, please report it.
+\subsection{Path Names}
+
+Soft paths are stored in macros but are referred to via a name.
+The macro is constructed from the name, but there is scope for a prefix and suffix.
+By default, these are set up so to be compatible with the |intersections| library -- this package and that save their paths in the same underlying macro.
+Some packages that are built on top of this one (such as the |knot| and |penrose| packages) install their own prefixes and suffixes to avoid clashes.
+
+\begin{function}{
+ set prefix,
+ set suffix,
+ prefix,
+ suffix
+}
+\begin{syntax}
+|set prefix=|\marg{prefix}
+|set suffix=|\marg{suffix}
+|prefix=|\oarg{name}
+|suffix=|\oarg{name}
+|set name=|\oarg{name}
+\end{syntax}
+The first two keys set the prefix and suffix directly.
+The other keys allow for defining a label for a prefix and suffix for quick switching between different ones.
+The default (with key |default| or no key specified) is to match the |intersections| library.
+The |knots| library uses this to set a different prefix.
+\end{function}
+
+Using names rather than macros directly also makes it possible to link a soft path with a set of TikZ styles (this is particularly useful when splitting the path into components).
+
+\begin{variable}{current}
+\begin{syntax}
+|\path (0,0) -- (3,0) to[out=90, in=90] (1,0) [spath/adjust and close=current];|
+\end{syntax}
+
+There is a special path name, |current|, which refers to the current path being built.
+To be clear, the test for this name takes place before any prefix or suffix is applied so it depends only on what the user uses.
+
+When this name is encountered, the current path is copied into a macro and that path is used in the command.
+If the command is such that it is possible that the path is modified in some fashion then after the command is finished the old current path is replaced by the new one.
+There are several commands that take multiple paths and |current| can be used in place of any of the paths, but usually there is only one that is modified and so that is the only one that would be used to replace the old current path.
+
+It only makes sense to use it in a path-building context, and it refers to the path at the moment of invocation, so it doesn't do a lot in the main options on that path but it can be used in options later on in the process.
+
+Sometimes it isn't possible to put commands partway through a path (for example, if the path command is buried in another macro) so there is a key which can be used to delay things to the end of the construction:
+
+\begin{verbatim}
+at end path construction={code}
+\end{verbatim}
+%
+This invokes the |code| right after the path has finished being built.
+\end{variable}
\subsection{Saving and Using Soft Paths}
@@ -104,16 +154,14 @@ If this doesn't happen, please report it.
|save global=|\meta{name}
\end{syntax}
-Saves the current path with name \texttt{<name>}.
+Saves the current path with name \meta{name}.
This delays until the path is fully constructed so can be issued in the options to the main command.
Soft paths constructed this way are local to the group in which the path command is issued.
The |global| version saves the path globally which is useful when the original path is inside a scope or even another tikzpicture.
-The soft path is actually stored in a macro constructed from the name.
-There are a couple of reasons for using a \emph{name} rather than a macro directly.
-One is so that it is compatible with the \texttt{intersections} library -- by default both this package and that save their paths in the same underlying macro.
-The other is to provide a way to link a soft path with a set of TikZ styles (this is particularly useful when splitting the path into components).
+If wanting to save the border of a node then because there are extra levels of grouping, the global version of this key has to be used.
+
\end{function}
\begin{function}{clone, clone globally}
@@ -124,6 +172,22 @@ The other is to provide a way to link a soft path with a set of TikZ styles (thi
Clones one soft path into another.
In the second, the clone is global (the original need not be).
+
+By using |current| as the source name, the current soft path in its current state is copied.
+This can be used to get round the restriction whereby |save path| waits until the path is fully constructed before being saved.
+\end{function}
+
+\begin{function}{show, show current path}
+\begin{syntax}
+|show=|\meta{name}
+|show current path|
+\end{syntax}
+
+These keys display a path on the terminal and in the log file.
+They do a bit of sensible line formatting so that the paths are relatively easy to scan through.
+
+The key |show current path| delays the logging until the path is fully constructed.
+To get a view of what the path is at an intermediate stage of construction, use |show=current|.
\end{function}
\begin{function}{use}
@@ -145,20 +209,22 @@ The options is a comma separated list and can include:
\item |weld|, |no weld| determines whether to weld the inserted path to the current path.
Welding means that the |move to| at the start of the inserted path is removed.
Note that this doesn't \emph{move} the inserted path so this will usually modify the first segment of the inserted path, possibly in unexpected ways.
+The expected use is that when the |weld| key is used then the inserted path starts where the current path ends either because it already does or because the |move| key has also been invoked.
+But there's nothing \emph{stopping} anyone using this key in other circumstances.
\item |move|, |no move| determines whether the inserted path is translated so that it starts where the current path ends.
\item |transform=|\marg{transformations} applies the specified transformations to the inserted path.
-See the |transform| key in Section~\ref{sec:transform}
+See the |transform| key in Section~\ref{sec:transform}.
+\item |use current transformation| applies the current transformation to the inserted path.
+Note that because the keys are processed and then acted upon, this key is always applied \emph{before} the |transform| key.
\item Any other key is taken as the name of the path (so it doesn't have to be specified first) with the last one winning.
\end{itemize}
One thing should be noted about transformations.
By the time a soft path is built, all available transformations have been applied.
-This means that when re-inserting a soft path back into a high level command (such as |\draw|), the effect of existing transformations might produce some confusing effects.
-When restoring a path then the library tries to set up various internals of TikZ correctly, but there may be some things I've overlooked or not accounted for particularly with regard to existing transformations; if you spot anything working oddly then please report it to me.
-
-In particular, restoring a path should sets things right for positioning nodes along the path.
-Using the \Verb+pos=D+ key on a node positions that node at a particular point on the path.
+This means that when re-inserting a soft path back into a high level command (such as |\draw|), existing transformations should have no effect (other than those specified via the |transform| key).
+Where this gets a little tricky is with things like node placement -- using the \Verb+pos=D+ key on a node positions that node at a particular point on the path.
Exactly how the parameter is interpreted is the same as for the \Verb+spath+ coordinate system described in Section~\ref{sec:coordinates}.
+When restoring a path then the library tries to set up various internals of TikZ correctly, but there may be some things I've overlooked or not accounted for particularly with regard to existing transformations; if you spot anything working oddly then please report it to me.
\end{function}
\begin{function}{
@@ -183,6 +249,19 @@ The equivalences are:
\end{itemize}
\end{function}
+\begin{function}{join with}
+\begin{syntax}
+|join with=|\marg{path}\marg{path, options}
+\end{syntax}
+
+This joins the second path to the first, with applying the specified options.
+The options are the same as for the |use| key.
+The first path is modified, the second is not (the second path is copied before any modifications are applied).
+
+It is almost the case that |join with={current}{...}| is synonymous with |use={...}|.
+The difference is that |use={...}| applies an extra check to ensure that the resulting path is not empty.
+\end{function}
+
\begin{function}{to}
\begin{syntax}
|to=|\marg{name}
@@ -198,7 +277,7 @@ The path is transformed by rotation, translation, and uniform scaling so that it
\label{sec:transform}
The following keys all apply some sort of transformation to the soft path.
-They do not render the path, but simply adjust it.
+They do not render the path, but simply adjust it (but they can be used to modify the current path by invoking with the path name |current|).
The global versions apply their transformation globally, otherwise it is local to the current group (or scope).
\begin{function}{reverse, reverse global}
@@ -245,9 +324,6 @@ As with the \Verb+to+ path construction and the \Verb+splice+ method, this won't
\subsection{Intersection Routines}
To use these features you need to use the \texttt{intersections} library.
-Note that there is currently an issue with the intersections routine when trying to intersect two parallel (or near parallel) lines.
-One workaround is to replace one of the lines by a B\'ezier curve along the same path.
-The best such replacement is to put the control points at one third and two thirds between the start and end.
\begin{function}{
split at self intersections,
@@ -346,18 +422,27 @@ It applies the following styles (in this order):
\begin{function}{
insert gaps after components,
- insert gaps globally after components
+ insert gaps globally after components,
+ insert gaps after segments,
+ insert gaps globally after segments
}
\begin{syntax}
|insert gaps after components=|\marg{path}\marg{gap}\marg{components}
|insert gaps after components=|\marg{path}\marg{gap}
|insert gaps globally after components=|\marg{path}\marg{gap}\marg{components}
|insert gaps globally after components=|\marg{path}\marg{gap}
+|insert gaps after segments=|\marg{path}\marg{gap}\marg{segments}
+|insert gaps after segments=|\marg{path}\marg{gap}
+|insert gaps globally after segments=|\marg{path}\marg{gap}\marg{segments}
+|insert gaps globally after segments=|\marg{path}\marg{gap}
\end{syntax}
This inserts a gap between components of a path by shortening the end of the specified component and start of the next one.
The list of components is passed through a |\foreach| loop so that syntax like |2,4,...,16| can be used.
If the list of components is not given the gaps are inserted between all components.
+
+The \texttt{segments} versions work on the segments of the path rather than its components.
+A \emph{segment} is a minimal drawing piece, meaning a line or B\'ezier curve.
\end{function}
\begin{function}{
@@ -374,16 +459,20 @@ The list of components is processed by |\foreach|.
If the component is the first one then it is joined to the last component.
\end{function}
-\begin{function}{join components with, join components globally with, join components upright with, join components globally upright with}
+\begin{function}{join components with, join components globally with, join components upright with, join components globally upright with, join components with curve, join components globally with curve}
\begin{syntax}
|join components with=|\marg{path}\marg{splice path}
|join components with=|\marg{path}\marg{splice path}\marg{list}
|join components upright with=|\marg{path}\marg{splice path}
|join components upright with=|\marg{path}\marg{splice path}\marg{list}
+|join components with curve=|\marg{path}
+|join components with curve=|\marg{path}\marg{list}
|join components globally with=|\marg{path}\marg{splice path}
|join components globally with=|\marg{path}\marg{splice path}\marg{list}
|join components globally upright with=|\marg{path}\marg{splice path}
|join components globally upright with=|\marg{path}\marg{splice path}\marg{list}
+|join components globally with curve=|\marg{path}
+|join components globally with curve=|\marg{path}\marg{list}
\end{syntax}
This inserts the |splice path| in the gaps between components of |path| specified by a comma separated list.
@@ -396,6 +485,9 @@ This does \emph{not} close the resulting path, even if the last component is spe
Note that because there is an optional third argument to this key, the second argument must always be enclosed in braces unless it is a single token.
The |upright| versions do a little test to see if the gap is oriented upside-down and if so then they insert the reflection of the splice path.
+
+The |with curve| versions insert a single B\'ezier curve into the gap.
+The curve is chosen to match the tangents of the segments either side of the gap and uses John Hobby's construction of a B\'ezier curve from its tangent directions.
\end{function}
@@ -436,18 +528,36 @@ This removes the listed components of the path.
As with other list routines, the list is parsed via |foreach| first.
\end{function}
+\begin{function}{open, open globally}
+\begin{syntax}
+|open=|\marg{path}
+|open globally=|\marg{path}
+\end{syntax}
-\begin{function}{close, close globally, close with, close globally with}
+These open the path by removing all of the closing elements.
+If the closing elements add substantially to the path then they are replaced by a line segment.
+\end{function}
+
+
+\begin{function}{close, close globally, close with, close globally with, close with curve, close globally with curve, adjust and close, adjust and close globally}
\begin{syntax}
|close=|\marg{path}
|close globally=|\marg{path}
|close with=|\marg{path}\marg{splice path}
|close globally with=|\marg{path}\marg{splice path}
+|close with curve=|\marg{path}
+|close globally with curve=|\marg{path}
+|adjust and close=|\marg{path}
+|adjust and close globally=|\marg{path}
\end{syntax}
These all close the last component of the given path.
The first two will insert a line segment if the initial and final points of the component are not sufficiently close.
-The latter two allow you to specify another path to insert.
+The two |with| variants allow you to specify another path to insert between the end and start of the path.
+The two |with curve| variants insert a B\'ezier curve in the gap; the choice of curve depends on the tangents of the path segments being joined and uses John Hobby's B\'ezier curve construction (as used in the \texttt{hobby} TikZ library).
+The two |adjust| variants shift the end point of the path so that it is at the same place as the start of that component.
+If the last segment is a B\'ezier curve then the second control point is also shifted.
+(The intention with the |adjust| keys is where the start and end of the component are very close together so the adjustment creates a smaller visual effect than adding in a line -- see Example~\ref{ex:close}.)
\end{function}
\begin{function}{splice, splice global}
@@ -461,7 +571,7 @@ The middle path is transformed to fit (don't try this with a path whose starting
\end{function}
-\subsection{Shortening Paths}
+\subsection{Shortening and Splitting Paths}
\begin{function}{
shorten at end,
@@ -488,6 +598,42 @@ It uses the derivative at the end to work out how much to shorten by.
If wanting to shorten by a large amount it is better to shorten by a small amount a number of times.
\end{function}
+\begin{function}{
+ split at,
+ split globally at,
+ split at into,
+ split globally at into,
+ split at keep start,
+ split globally at keep start,
+ split at keep end,
+ split globally at keep end,
+ split at keep middle,
+ split globally at keep middle,
+}
+\begin{syntax}
+|split at=|\marg{path}\marg{parameter}
+|split globally at=|\marg{path}\marg{parameter}
+|split at into=|\marg{start path}\marg{end path}\marg{path}\marg{parameter}
+|split globally at into=|\marg{start path}\marg{end path}\marg{path}\marg{parameter}
+|split at keep start=|\marg{path}\marg{parameter}
+|split globally at keep start=|\marg{path}\marg{parameter}
+|split at keep end=|\marg{path}\marg{parameter}
+|split globally at keep end=|\marg{path}\marg{parameter}
+|split at keep middle=|\marg{path}\marg{parameter}\marg{parameter}
+|split globally at keep middle=|\marg{path}\marg{parameter}\marg{parameter}
+\end{syntax}
+
+These keys split a path at a point specified by a parameter.
+The interpretation of the parameter is described in Section~\ref{sec:coordinates}.
+
+The first two keys replace the path with the split path, so this introduces a break at the point specified by the parameter.
+The second two save the split path into a new path.
+
+The ones with \texttt{keep} in the name split a path and keep the designated piece (so throw away the rest).
+The ones that keep the middle need two parameters to specify the break points.
+
+\end{function}
+
\subsection{Exporting Paths}
There are two keys to export a path.
@@ -516,8 +662,8 @@ Saves the path to the file \texttt{path.svg} as an SVG document.
draft mode
}
\begin{syntax}
-|knot=|\meta{path}\meta{gap}\meta{components}
-|global knot=|\meta{path}\meta{gap}\meta{components}
+|knot=|\marg{path}\marg{gap}\marg{components}
+|global knot=|\marg{path}\marg{gap}\marg{components}
\end{syntax}
This style combines various of the above to make it simpler to draw knots and links.
@@ -679,6 +825,24 @@ The intention with the second key is that it is similar to what happens with the
\end{tikzpicture}
\end{example}
+\item Closing and adjusting paths.
+\label{ex:close}
+
+\begin{example}
+\begin{tikzpicture}
+\draw[line width=.2cm] (0,0) -- +(1,0) -- +(1,1) -- +(0,1) -- +(.01,.01);
+
+\draw[line width=.2cm] (2,0) -- +(1,0) -- +(1,1) -- +(0,1) -- +(.01,.01)
+-- cycle;
+
+\draw[line width=.2cm] (4,0) -- +(1,0) -- +(1,1) -- +(0,1) -- +(.01,.01)
+[spath/close=current];
+
+\draw[line width=.2cm] (6,0) -- +(1,0) -- +(1,1) -- +(0,1) -- +(.01,.01)
+[spath/adjust and close=current];
+\end{tikzpicture}
+\end{example}
+
\item Shortening.
\begin{example}
@@ -929,8 +1093,8 @@ sin ++(1.57,1);
}
% If used in the preamble, this needs surrounding in \AtBeginDocument
-%\AtBeginDocument{
-\tikz[overlay] \path[spath/save=arc] (0,0) arc[radius=1cm, start angle=180, delta angle=-180];
+%\AtBeginDocument{%
+\tikz[overlay] { \path[spath/save global=arc] (0,0) arc[radius=1cm, start angle=180, delta angle=-180]; }%
%}
\begin{tikzpicture}
\path[spath/save=over] (0,0) -| ++(1,1) -| ++(-1,1) -| ++(1,1) -| ++(-1,1);
@@ -941,5 +1105,8 @@ sin ++(1.57,1);
\end{tikzpicture}
\end{example}
+The command defining the arc does introduce a box which can introduce additional spacing.
+The syntax above, with the \% at the end of the lines, shouldn't add space but if for some reason it does then more sophisticated solutions to this are detailed at \href{https://tex.stackexchange.com/q/605800/86}{How to save or define a TikZ path for spath3 without introducing artifacts?}.
+
\end{enumerate}
\end{document}
diff --git a/graphics/pgf/contrib/spath3/spath3_code.dtx b/graphics/pgf/contrib/spath3/spath3_code.dtx
index afd132938c..031c0e7bd3 100644
--- a/graphics/pgf/contrib/spath3/spath3_code.dtx
+++ b/graphics/pgf/contrib/spath3/spath3_code.dtx
@@ -143,7 +143,7 @@ and the derived files spath3.ins,
%</driver>
% \fi
%
-% \CheckSum{8929}
+% \CheckSum{10189}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -169,6 +169,8 @@ and the derived files spath3.ins,
% \changes{2.0}{2021/01/19}{Refactored the code to remove the OO approach and make it functional, introduced the spath3 TikZ library to provide a user interface.}
% \changes{2.2}{2021/02/05}{Bugfixes and improvements, mainly with regard to the intersection and splitting routines.}
% \changes{2.4}{2021/02/21}{Rejigged how the routines for using paths were implemented, added some more routines for joining paths.}
+% \changes{2.6}{2021/11/23}{Modified core routines to cope with a "true rectangle" path; added routines for splitting at a parametrised point.}
+% \changes{2.7}{2022/08/24}{Bug fixes}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
@@ -257,7 +259,7 @@ and the derived files spath3.ins,
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\RequirePackage{pgf}
-\ProvidesExplPackage {spath3} {2021/02/21} {2.4} {Functions for
+\ProvidesExplPackage {spath3} {2022/08/24} {2.7} {Functions for
manipulating PGF soft paths}
\RequirePackage{xparse}
% \end{macrocode}
@@ -332,6 +334,9 @@ manipulating PGF soft paths}
\fp_new:N \l_@@_tmpa_fp
\fp_new:N \l_@@_tmpb_fp
\fp_new:N \l_@@_tmpc_fp
+\fp_new:N \l_@@_tmpd_fp
+\fp_new:N \l_@@_tmpe_fp
+\fp_new:N \l_@@_tmpf_fp
\int_new:N \l_@@_tmpa_int
\int_new:N \l_@@_tmpb_int
@@ -353,6 +358,23 @@ manipulating PGF soft paths}
\bool_new:N \l_@@_closed_bool
% \end{macrocode}
%
+% True rectangles are rare, but need special handling.
+% They are specified by two tokens, the first specifies the lower left corner which can be handled pretty much as other tokens but the second specifies the width and height meaning that it transforms differently.
+% So when encountering on, the coordinates of the lower left corner are useful to remember.
+%
+% \begin{macrocode}
+\dim_new:N \l_@@_rectx_dim
+\dim_new:N \l_@@_recty_dim
+
+\bool_new:N \l_@@_rect_bool
+% \end{macrocode}
+%
+% When restoring a path we need to know whether to update the stored moveto.
+%
+% \begin{macrocode}
+\bool_new:N \l_spath_movetorelevant_bool
+% \end{macrocode}
+%
% The intersection routine can't happen inside a group so we need two token lists to hold the paths that we'll intersect.
%
% \begin{macrocode}
@@ -369,6 +391,8 @@ manipulating PGF soft paths}
\tl_const:Nn \c_spath_curvetoa_tl {\pgfsyssoftpath@curvetosupportatoken}
\tl_const:Nn \c_spath_curvetob_tl {\pgfsyssoftpath@curvetosupportbtoken}
\tl_const:Nn \c_spath_closepath_tl {\pgfsyssoftpath@closepathtoken}
+\tl_const:Nn \c_spath_rectcorner_tl {\pgfsyssoftpath@rectcornertoken}
+\tl_const:Nn \c_spath_rectsize_tl {\pgfsyssoftpath@rectsizetoken}
% \end{macrocode}
%
% We will want to be able to use anonymous spaths internally, so we create a global counter that we can use to refer to them.
@@ -377,6 +401,27 @@ manipulating PGF soft paths}
\int_gzero:N \g_@@_anon_int
% \end{macrocode}
%
+% \begin{macro}[internal]{
+% \spath_anonymous:N,
+% \spath_ganonymous:N
+% }
+% Set the token list to the next anonymous name.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \spath_anonymous:N #1
+{
+ \tl_set:Nx #1 {anonymous_\int_use:N \g_@@_anon_int}
+ \int_gincr:N \g_@@_anon_int
+}
+\cs_new_protected_nopar:Npn \spath_ganonymous:N #1
+{
+ \tl_gset:Nx #1 {anonymous_\int_use:N \g_@@_anon_int}
+ \int_gincr:N \g_@@_anon_int
+}
+\cs_generate_variant:Nn \spath_anonymous:N {c}
+\cs_generate_variant:Nn \spath_ganonymous:N {c}
+% \end{macrocode}
+% \end{macro}
+%
% And some error messages
% \begin{macrocode}
\msg_new:nnn { spath3 } { unknown path construction }
@@ -482,6 +527,27 @@ manipulating PGF soft paths}
}
+ \c_spath_rectcorner_tl
+ {
+ \tl_set_eq:NN \l_@@_tmpb_tl \c_spath_rectcorner_tl
+
+ \tl_put_right:Nx \l_@@_tmpb_tl {{\tl_head:N \l_@@_tmpa_tl}}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_put_right:Nx \l_@@_tmpb_tl {{\tl_head:N \l_@@_tmpa_tl}}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_put_right:Nx \l_@@_tmpb_tl {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_put_right:Nx \l_@@_tmpb_tl {{\tl_head:N \l_@@_tmpa_tl}}
+ \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_put_right:Nx \l_@@_tmpb_tl {{\tl_head:N \l_@@_tmpa_tl}}
+ \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ }
+
\c_spath_closepath_tl
{
\tl_set_eq:NN \l_@@_tmpb_tl \c_spath_moveto_tl
@@ -559,9 +625,11 @@ manipulating PGF soft paths}
\group_begin:
\tl_set:Nn \l_@@_tmpa_tl {#1}
\seq_clear:N \l_@@_tmpa_seq
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
\tl_put_right:NV \l_@@_tmpa_tl \c_spath_moveto_tl
- \tl_set_eq:NN \l_@@_tmpb_tl \c_spath_moveto_tl
+
\bool_do_until:nn {
\tl_if_empty_p:N \l_@@_tmpa_tl
}
@@ -572,6 +640,11 @@ manipulating PGF soft paths}
\seq_put_right:NV \l_@@_tmpa_seq \l_@@_tmpb_tl
\tl_clear:N \l_@@_tmpb_tl
}
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \seq_put_right:NV \l_@@_tmpa_seq \l_@@_tmpb_tl
+ \tl_clear:N \l_@@_tmpb_tl
+ }
\tl_if_single:NTF \l_@@_tmpc_tl
{
\tl_put_right:NV \l_@@_tmpb_tl \l_@@_tmpc_tl
@@ -637,7 +710,7 @@ manipulating PGF soft paths}
% \spath_reallength:Nn,
% \spath_greallength:Nn
% }
-% The real length of a path is the number of triples that actually draw something (that is, the number of lines, curves, and closepaths).
+% The real length of a path is the number of triples that actually draw something (that is, the number of lines, curves, rectangles, and closepaths).
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_reallength:n #1
{
@@ -650,6 +723,7 @@ manipulating PGF soft paths}
\c_spath_lineto_tl {}
\c_spath_curveto_tl {}
\c_spath_closepath_tl {}
+ \c_spath_rectsize_tl {}
}
{
\int_incr:N \l_@@_tmpa_int
@@ -695,6 +769,10 @@ manipulating PGF soft paths}
{
\int_incr:N \l_@@_tmpa_int
}
+ \c_spath_rectcorner_tl
+ {
+ \int_incr:N \l_@@_tmpa_int
+ }
}
}
\int_gzero:N \g_@@_output_int
@@ -765,10 +843,35 @@ manipulating PGF soft paths}
\tl_set:Nn \l_@@_tmpa_tl {#1}
\tl_reverse:N \l_@@_tmpa_tl
\tl_clear:N \l_@@_tmpb_tl
- \tl_set:Nx \l_@@_tmpb_tl
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_item:Nn \l_@@_tmpa_tl {3}}
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_rectsize_tl
+ {
+ \tl_set:Nx \l_@@_tmpb_tl
+ {
+ {
+ \dim_eval:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {2}
+ +
+ \tl_item:Nn \l_@@_tmpa_tl {5}
+ }
+ }
+ {
+ \dim_eval:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ +
+ \tl_item:Nn \l_@@_tmpa_tl {4}
+ }
+ }
+ }
+ }
{
- { \tl_item:Nn \l_@@_tmpa_tl {2} }
- { \tl_item:Nn \l_@@_tmpa_tl {1} }
+ \tl_set:Nx \l_@@_tmpb_tl
+ {
+ { \tl_item:Nn \l_@@_tmpa_tl {2} }
+ { \tl_item:Nn \l_@@_tmpa_tl {1} }
+ }
}
\tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpb_tl
\group_end:
@@ -817,6 +920,16 @@ manipulating PGF soft paths}
{ \tl_item:Nn \l_@@_tmpa_tl {3} }
}
}
+
+ \c_spath_rectcorner_tl
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ { \tl_item:Nn \l_@@_tmpa_tl {2} }
+ { \tl_item:Nn \l_@@_tmpa_tl {3} }
+ }
+ }
+
}
\prg_replicate:nn {3}
{
@@ -844,119 +957,404 @@ manipulating PGF soft paths}
% \end{macro}
%
% \begin{macro}[internal]{
-% \spath_reverse:Nn,
-% \spath_greverse:Nn
+% \spath_initialtangent:Nn,
+% \spath_ginitialtangent:Nn
% }
-% This computes the reverse of the path.
+% The starting tangent of the path.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_reverse:n #1
+\cs_new_protected_nopar:Npn \@@_initialtangent:n #1
+{
+ \group_begin:
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_item:nn {#1} {4}}
+ \tl_if_eq:NNTF \l_@@_tmpb_tl \c_spath_curvetoa_tl
+ {
+ \fp_set:Nn \l_@@_tmpa_fp {3}
+ }
+ {
+ \fp_set:Nn \l_@@_tmpa_fp {1}
+ }
+ \tl_clear:N \l_@@_tmpa_tl
+ \tl_set:Nx \l_@@_tmpa_tl
+ {
+ {
+ \fp_to_dim:n {
+ \l_@@_tmpa_fp
+ *
+ (
+ \tl_item:nn {#1} {5}
+ -
+ \tl_item:nn {#1} {2}
+ )
+ }
+ }
+ {
+ \fp_to_dim:n {
+ \l_@@_tmpa_fp
+ *
+ (
+ \tl_item:nn {#1} {6}
+ -
+ \tl_item:nn {#1} {3}
+ )
+ }
+ }
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_initialtangent:Nn #1#2
+{
+ \@@_initialtangent:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_initialtangent:Nn {NV, cn, cV, Nv}
+\cs_new_protected_nopar:Npn \spath_ginitialtangent:Nn #1#2
+{
+ \@@_initialtangent:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_ginitialtangent:Nn {NV, cn, cV, Nv}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
+% \spath_finaltangent:Nn,
+% \spath_gfinaltangent:Nn,
+% }
+% The final tangent of the path.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_finaltangent:n #1
{
\group_begin:
\tl_set:Nn \l_@@_tmpa_tl {#1}
-
+ \tl_reverse:N \l_@@_tmpa_tl
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_item:nn {#1} {6}}
+ \tl_if_eq:NNTF \l_@@_tmpb_tl \c_spath_curveto_tl
+ {
+ \fp_set:Nn \l_@@_tmpa_fp {3}
+ }
+ {
+ \fp_set:Nn \l_@@_tmpa_fp {1}
+ }
\tl_clear:N \l_@@_tmpb_tl
- \tl_clear:N \l_@@_tmpd_tl
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
-
- \tl_put_left:Nx \l_@@_tmpd_tl
+ \tl_set:Nx \l_@@_tmpb_tl
{
- {\dim_use:N \l_@@_tmpa_dim}
- {\dim_use:N \l_@@_tmpb_dim}
+ {
+ \fp_to_dim:n {
+ \l_@@_tmpa_fp
+ *
+ (
+ \tl_item:Nn \l_@@_tmpa_tl {2}
+ -
+ \tl_item:Nn \l_@@_tmpa_tl {5}
+ )
+ }
+ }
+ {
+ \fp_to_dim:n {
+ \l_@@_tmpa_fp
+ *
+ (
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ -
+ \tl_item:Nn \l_@@_tmpa_tl {4}
+ )
+ }
+ }
}
-
- \bool_set_false:N \l_@@_closed_bool
-
- \bool_until_do:nn {
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpb_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_finaltangent:Nn #1#2
+{
+ \@@_finaltangent:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_finaltangent:Nn {NV, cn, cV, Nv}
+\cs_new_protected_nopar:Npn \spath_gfinaltangent:Nn #1#2
+{
+ \@@_finaltangent:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gfinaltangent:Nn {NV, cn, cV, Nv}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}[internal]{
+% \spath_finalmovetangent:Nn,
+% \spath_gfinalmovetangent:Nn
+% }
+% Get the last move on the path.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_finalmovetangent:n #1
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpc_tl { {0pt} {0pt} }
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \bool_do_until:nn
+ {
\tl_if_empty_p:N \l_@@_tmpa_tl
}
{
- \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
-
- \tl_case:NnTF \l_@@_tmpc_tl
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_head:N \l_@@_tmpa_tl}
+ \tl_case:Nn \l_@@_tmpb_tl
{
- \c_spath_moveto_tl {
-
- \bool_if:NT \l_@@_closed_bool
+ \c_spath_moveto_tl
+ {
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:Nn \l_@@_tmpa_tl {4} }
+ \tl_if_eq:NNTF \l_@@_tmpd_tl \c_spath_curveto_tl
+ {
+ \fp_set:Nn \l_@@_tmpa_fp {3}
+ }
+ {
+ \fp_set:Nn \l_@@_tmpa_fp {1}
+ }
+ \tl_set:Nx \l_@@_tmpc_tl
{
- \tl_put_right:NV \l_@@_tmpd_tl \c_spath_closepath_tl
- \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpd_tl}
- \tl_put_right:Nx \l_@@_tmpd_tl
{
- { \tl_head:N \l_@@_tmpd_tl }
- { \tl_head:N \l_@@_tmpe_tl }
+ \fp_to_dim:n
+ {
+ \l_@@_tmpa_fp
+ *
+ (
+ \tl_item:Nn \l_@@_tmpa_tl {5}
+ -
+ \tl_item:Nn \l_@@_tmpa_tl {2}
+ )
+ }
+ }
+ {
+ \fp_to_dim:n
+ {
+ \l_@@_tmpa_fp
+ *
+ (
+ \tl_item:Nn \l_@@_tmpa_tl {6}
+ -
+ \tl_item:Nn \l_@@_tmpa_tl {3}
+ )
+ }
}
}
- \bool_set_false:N \l_@@_closed_bool
- \tl_put_left:NV \l_@@_tmpd_tl \c_spath_moveto_tl
- \tl_put_left:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
- \tl_clear:N \l_@@_tmpd_tl
- }
- \c_spath_lineto_tl {
- \tl_put_left:NV \l_@@_tmpd_tl \c_spath_lineto_tl
- }
- \c_spath_curveto_tl {
- \tl_put_left:NV \l_@@_tmpd_tl \c_spath_curvetoa_tl
- }
- \c_spath_curvetoa_tl {
- \tl_put_left:NV \l_@@_tmpd_tl \c_spath_curveto_tl
- }
- \c_spath_curvetob_tl {
- \tl_put_left:NV \l_@@_tmpd_tl \c_spath_curvetob_tl
}
}
+ \prg_replicate:nn {3}
{
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpc_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_finalmovetangent:Nn #1#2
+{
+ \@@_finalmovetangent:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_finalmovetangent:Nn {NV, cn, cV}
+\cs_new_protected_nopar:Npn \spath_gfinalmovetangent:Nn #1#2
+{
+ \@@_finalmovetangent:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gfinalmovetangent:Nn {NV, cn, cV}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
+% \spath_reverse:Nn,
+% \spath_greverse:Nn
+% }
+% This computes the reverse of the path.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_reverse:n #1
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
- \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_clear:N \l_@@_tmpb_tl
+ \tl_clear:N \l_@@_tmpd_tl
+
+ \bool_set_false:N \l_@@_rect_bool
+
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
+ \bool_while_do:nn {
+ \tl_if_eq_p:NN \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ }
+ {
+ \tl_put_left:Nx \l_@@_tmpd_tl
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ {\tl_item:Nn \l_@@_tmpa_tl {2}}
+ {\tl_item:Nn \l_@@_tmpa_tl {3}}
+ \tl_item:Nn \l_@@_tmpa_tl {4}
+ {\tl_item:Nn \l_@@_tmpa_tl {5}}
+ {\tl_item:Nn \l_@@_tmpa_tl {6}}
+ }
+ \prg_replicate:nn {6}
+ {
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
+ \bool_set_true:N \l_@@_rect_bool
+ }
- \tl_put_left:Nx \l_@@_tmpd_tl
- {
- {\dim_use:N \l_@@_tmpa_dim}
- {\dim_use:N \l_@@_tmpb_dim}
- }
+ \tl_if_empty:NF \l_@@_tmpa_tl
+ {
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_put_left:Nx \l_@@_tmpd_tl
+ {
+ {\dim_use:N \l_@@_tmpa_dim}
+ {\dim_use:N \l_@@_tmpb_dim}
+ }
+
+ \bool_set_false:N \l_@@_closed_bool
+ \bool_until_do:nn {
+ \tl_if_empty_p:N \l_@@_tmpa_tl
}
{
- \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_closepath_tl
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
+ \bool_set_false:N \l_@@_rect_bool
+
+ \tl_case:NnTF \l_@@_tmpc_tl
{
- \bool_set_true:N \l_@@_closed_bool
+ \c_spath_moveto_tl {
+
+ \bool_if:NT \l_@@_closed_bool
+ {
+ \tl_put_right:NV \l_@@_tmpd_tl \c_spath_closepath_tl
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpd_tl}
+ \tl_put_right:Nx \l_@@_tmpd_tl
+ {
+ { \tl_head:N \l_@@_tmpd_tl }
+ { \tl_head:N \l_@@_tmpe_tl }
+ }
+ }
+ \bool_set_false:N \l_@@_closed_bool
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_moveto_tl
+ \tl_put_left:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
+ \tl_clear:N \l_@@_tmpd_tl
+ }
+ \c_spath_rectcorner_tl {
+
+ \bool_if:NT \l_@@_closed_bool
+ {
+ \tl_put_right:NV \l_@@_tmpd_tl \c_spath_closepath_tl
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpd_tl}
+ \tl_put_right:Nx \l_@@_tmpd_tl
+ {
+ { \tl_head:N \l_@@_tmpd_tl }
+ { \tl_head:N \l_@@_tmpe_tl }
+ }
+ }
+ \bool_set_false:N \l_@@_closed_bool
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_moveto_tl
+ \tl_put_left:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
+ \tl_clear:N \l_@@_tmpd_tl
+
+ \bool_while_do:nn {
+ \tl_if_eq_p:NN \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ }
+ {
+ \tl_put_left:Nx \l_@@_tmpb_tl
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ {\tl_item:Nn \l_@@_tmpa_tl {2}}
+ {\tl_item:Nn \l_@@_tmpa_tl {3}}
+ \tl_item:Nn \l_@@_tmpa_tl {4}
+ {\tl_item:Nn \l_@@_tmpa_tl {5}}
+ {\tl_item:Nn \l_@@_tmpa_tl {6}}
+ }
+ \prg_replicate:nn {6}
+ {
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
+ }
+ \bool_set_true:N \l_@@_rect_bool
+
+ }
+ \c_spath_lineto_tl {
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_lineto_tl
+ }
+ \c_spath_curveto_tl {
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_curvetoa_tl
+ }
+ \c_spath_curvetoa_tl {
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_curveto_tl
+ }
+ \c_spath_curvetob_tl {
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_curvetob_tl
+ }
}
{
- \msg_warning:nnx
- { spath3 }
- { unknown path construction }
- {\l_@@_tmpc_tl }
+ \tl_if_empty:NF \l_@@_tmpa_tl
+ {
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_put_left:Nx \l_@@_tmpd_tl
+ {
+ {\dim_use:N \l_@@_tmpa_dim}
+ {\dim_use:N \l_@@_tmpb_dim}
+ }
+ }
}
+ {
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_closepath_tl
+ {
+ \bool_set_true:N \l_@@_closed_bool
+ }
+ {
+ \msg_warning:nnx
+ { spath3 }
+ { unknown path construction }
+ { \l_@@_tmpc_tl }
+ }
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ }
+ }
+ \bool_if:NT \l_@@_closed_bool
+ {
+ \tl_put_right:NV \l_@@_tmpd_tl \c_spath_closepath_tl
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpd_tl}
+ \tl_put_right:Nx \l_@@_tmpd_tl
+ {
+ { \tl_head:N \l_@@_tmpd_tl }
+ { \tl_head:N \l_@@_tmpe_tl }
+ }
}
- }
- \bool_if:NT \l_@@_closed_bool
- {
- \tl_put_right:NV \l_@@_tmpd_tl \c_spath_closepath_tl
- \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpd_tl}
- \tl_put_right:Nx \l_@@_tmpd_tl
+ \bool_set_false:N \l_@@_closed_bool
+ \bool_if:NF \l_@@_rect_bool
{
- { \tl_head:N \l_@@_tmpd_tl }
- { \tl_head:N \l_@@_tmpe_tl }
+ \tl_put_left:NV \l_@@_tmpd_tl \c_spath_moveto_tl
}
}
-
- \bool_set_false:N \l_@@_closed_bool
- \tl_put_left:NV \l_@@_tmpd_tl \c_spath_moveto_tl
+
\tl_put_left:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
-
\tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpb_tl
\group_end:
}
@@ -997,14 +1395,21 @@ manipulating PGF soft paths}
{
\group_begin:
\tl_clear:N \l_@@_tmpa_tl
- \int_compare:nT
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_head:n {#1}}
+ \tl_if_eq:NNTF \l_@@_tmpb_tl \c_spath_rectcorner_tl
{
- \tl_count:n {#1} > 3
+ \tl_set_eq:NN \l_@@_tmpa_tl \c_spath_rectcorner_tl
}
{
- \tl_set:Nx \l_@@_tmpa_tl
+ \int_compare:nT
{
- \tl_item:Nn {#1} {4}
+ \tl_count:n {#1} > 3
+ }
+ {
+ \tl_set:Nx \l_@@_tmpa_tl
+ {
+ \tl_item:Nn {#1} {4}
+ }
}
}
\tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
@@ -1052,6 +1457,10 @@ manipulating PGF soft paths}
{
\tl_set_eq:NN \l_@@_tmpb_tl \c_spath_curveto_tl
}
+ \tl_if_eq:NNT \l_@@_tmpb_tl \c_spath_rectsize_tl
+ {
+ \tl_set_eq:NN \l_@@_tmpb_tl \c_spath_rectcorner_tl
+ }
}
\tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpb_tl
\group_end:
@@ -1083,22 +1492,60 @@ manipulating PGF soft paths}
{
\group_begin:
\tl_set:Nn \l_@@_tmpa_tl {#1}
+
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
\dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
\dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \dim_set_eq:NN \l_@@_rectx_dim \l_@@_tmpa_dim
+ \dim_set_eq:NN \l_@@_recty_dim \l_@@_tmpb_dim
+ }
\bool_until_do:nn {
\tl_if_empty_p:N \l_@@_tmpa_tl
}
{
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpa_dim
- {\dim_min:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpa_dim}}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpb_dim
- {\dim_min:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpb_dim}}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_rectsize_tl
+ {
+ \dim_set:Nn \l_@@_tmpa_dim
+ {\dim_min:nn
+ {\tl_head:N \l_@@_tmpa_tl + \l_@@_rectx_dim} {\l_@@_tmpa_dim}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \dim_set:Nn \l_@@_tmpb_dim
+ {\dim_min:nn
+ {\tl_head:N \l_@@_tmpa_tl + \l_@@_recty_dim} {\l_@@_tmpb_dim}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+ {
+ \dim_set:Nn \l_@@_tmpa_dim
+ {\dim_min:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpa_dim}}
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \dim_set:Nn \l_@@_rectx_dim {\tl_head:N \l_@@_tmpa_tl}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \dim_set:Nn \l_@@_tmpb_dim
+ {\dim_min:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpb_dim}}
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \dim_set:Nn \l_@@_recty_dim {\tl_head:N \l_@@_tmpa_tl}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+
}
\tl_clear:N \l_@@_tmpb_tl
\tl_put_right:Nx \l_@@_tmpb_tl
@@ -1136,25 +1583,63 @@ manipulating PGF soft paths}
{
\group_begin:
\tl_set:Nn \l_@@_tmpa_tl {#1}
+
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
\dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
\dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \dim_set_eq:NN \l_@@_rectx_dim \l_@@_tmpa_dim
+ \dim_set_eq:NN \l_@@_recty_dim \l_@@_tmpb_dim
+ }
\bool_until_do:nn {
\tl_if_empty_p:N \l_@@_tmpa_tl
}
{
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpa_dim
- {\dim_max:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpa_dim}}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpb_dim
- {\dim_max:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpb_dim}}
- \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_rectsize_tl
+ {
+ \dim_set:Nn \l_@@_tmpa_dim
+ {\dim_max:nn
+ {\tl_head:N \l_@@_tmpa_tl + \l_@@_rectx_dim} {\l_@@_tmpa_dim}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \dim_set:Nn \l_@@_tmpb_dim
+ {\dim_max:nn
+ {\tl_head:N \l_@@_tmpa_tl + \l_@@_recty_dim} {\l_@@_tmpb_dim}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+ {
+ \dim_set:Nn \l_@@_tmpa_dim
+ {\dim_max:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpa_dim}}
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \dim_set:Nn \l_@@_rectx_dim {\tl_head:N \l_@@_tmpa_tl}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+
+ \dim_set:Nn \l_@@_tmpb_dim
+ {\dim_max:nn {\tl_head:N \l_@@_tmpa_tl} {\l_@@_tmpb_dim}}
+ \tl_if_eq:NNT \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+ \dim_set:Nn \l_@@_recty_dim {\tl_head:N \l_@@_tmpa_tl}
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ }
+
}
\tl_clear:N \l_@@_tmpb_tl
- \tl_put_right:Nx \l_@@_tmpb_tl
+ \tl_set:Nx \l_@@_tmpb_tl
{
{\dim_use:N \l_@@_tmpa_dim}
{\dim_use:N \l_@@_tmpb_dim}
@@ -1194,7 +1679,7 @@ manipulating PGF soft paths}
\tl_clear:N \l_@@_tmpa_tl
\tl_put_right:Nn \l_@@_tmpa_tl {
\ExplSyntaxOn
- \tl_clear:N #1
+ \tl_clear_new:N #1
\tl_set:Nn #1 {#2}
\ExplSyntaxOff
}
@@ -1212,6 +1697,7 @@ manipulating PGF soft paths}
\spath_save_to_aux:NV #1#1
}
}
+\cs_generate_variant:Nn \spath_save_to_aux:N {c}
% \end{macrocode}
% \end{macro}
%
@@ -1241,13 +1727,27 @@ manipulating PGF soft paths}
\tl_if_empty_p:N \l_@@_tmpa_tl
}
{
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
+
\tl_put_right:Nx \l_@@_tmpb_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
-
- \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl + #2}
+
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_rectsize_tl
+ {
+ \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl}
+ }
+ {
+ \dim_set:Nn \l_@@_tmpa_dim {\tl_head:N \l_@@_tmpa_tl + #2}
+ }
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
- \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl + #3}
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_rectsize_tl
+ {
+ \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl}
+ }
+ {
+ \dim_set:Nn \l_@@_tmpb_dim {\tl_head:N \l_@@_tmpa_tl + #3}
+ }
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
\tl_put_right:Nx \l_@@_tmpb_tl
@@ -1470,17 +1970,29 @@ manipulating PGF soft paths}
\tl_if_empty_p:N \l_@@_tmpa_tl
}
{
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_head:N \l_@@_tmpa_tl}
+
\tl_put_right:Nx \l_@@_tmpb_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpd_tl {\tl_head:N \l_@@_tmpa_tl}
\tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
-
- \fp_set:Nn \l_@@_tmpa_fp
- {\l_@@_tmpc_tl * #2 + \l_@@_tmpd_tl * #4 + #6}
- \fp_set:Nn \l_@@_tmpb_fp
- {\l_@@_tmpc_tl * #3 + \l_@@_tmpd_tl * #5 + #7}
+
+ \tl_if_eq:NNTF \l_@@_tmpe_tl \c_spath_rectsize_tl
+ {
+ \fp_set:Nn \l_@@_tmpa_fp
+ {\l_@@_tmpc_tl * #2 + \l_@@_tmpd_tl * #4}
+ \fp_set:Nn \l_@@_tmpb_fp
+ {\l_@@_tmpc_tl * #3 + \l_@@_tmpd_tl * #5}
+ }
+ {
+ \fp_set:Nn \l_@@_tmpa_fp
+ {\l_@@_tmpc_tl * #2 + \l_@@_tmpd_tl * #4 + #6}
+ \fp_set:Nn \l_@@_tmpb_fp
+ {\l_@@_tmpc_tl * #3 + \l_@@_tmpd_tl * #5 + #7}
+ }
+
\tl_put_right:Nx \l_@@_tmpb_tl
{
{\fp_to_dim:N \l_@@_tmpa_fp}
@@ -1738,8 +2250,8 @@ manipulating PGF soft paths}
\cs_new_protected_nopar:Npn \@@_splice_between:nnn #1#2#3
{
\group_begin:
- \spath_finalpoint:NV \l_@@_tmpd_tl {#1}
- \spath_initialpoint:NV \l_@@_tmpe_tl {#3}
+ \spath_finalpoint:Nn \l_@@_tmpd_tl {#1}
+ \spath_initialpoint:Nn \l_@@_tmpe_tl {#3}
\spath_span:NnVV \l_@@_tmpb_tl {#2} \l_@@_tmpd_tl \l_@@_tmpe_tl
\spath_append_no_move:NnV \l_@@_tmpa_tl {#1} \l_@@_tmpb_tl
\spath_append_no_move:Nn \l_@@_tmpa_tl {#3}
@@ -1774,6 +2286,340 @@ manipulating PGF soft paths}
% \end{macro}
%
% \begin{macro}[internal]{
+% \spath_hobby_curve:Nnnnn
+% }
+% Construct the curve from Hobby's algorithm given the start, end, and tangent directions.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_hobby_curve:nnnn #1#2#3#4
+{
+ \group_begin:
+% \end{macrocode}
+% First tangent vector projected onto vector between endpoints
+%
+% Something a bit weird here as the components are opposite to how I thought they should be ...
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_tmpa_fp
+ {
+ (
+ (\tl_item:nn {#2} {1})
+ *
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
+ +
+ (\tl_item:nn {#2} {2})
+ *
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
+ )
+ /
+ sqrt
+ (
+ (
+ (\tl_item:nn {#2} {1})^2
+ +
+ (\tl_item:nn {#2} {2})^2
+ )
+ *
+ (
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
+ +
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
+ )
+ )
+ }
+ \fp_set:Nn \l_@@_tmpb_fp
+ {
+ (
+ -
+ (\tl_item:nn {#2} {1})
+ *
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
+ +
+ (\tl_item:nn {#2} {2})
+ *
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
+ )
+ /
+ sqrt
+ (
+ (
+ (\tl_item:nn {#2} {1})^2
+ +
+ (\tl_item:nn {#2} {2})^2
+ )
+ *
+ (
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
+ +
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
+ )
+ )
+ }
+% \end{macrocode}
+% Second tangent vector projected onto vector between endpoints
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_tmpc_fp
+ {
+ (
+ (\tl_item:nn {#3} {1})
+ *
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
+ +
+ (\tl_item:nn {#3} {2})
+ *
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
+ )
+ /
+ sqrt
+ (
+ (
+ (\tl_item:nn {#3} {1})^2
+ +
+ (\tl_item:nn {#3} {2})^2
+ )
+ *
+ (
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
+ +
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
+ )
+ )
+ }
+ \fp_set:Nn \l_@@_tmpd_fp
+ {
+ (
+ (\tl_item:nn {#3} {1})
+ *
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})
+ -
+ (\tl_item:nn {#3} {2})
+ *
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})
+ )
+ /
+ sqrt
+ (
+ (
+ (\tl_item:nn {#3} {1})^2
+ +
+ (\tl_item:nn {#3} {2})^2
+ )
+ *
+ (
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
+ +
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
+ )
+ )
+ }
+
+ \fp_set:Nn \l_@@_tmpe_fp
+ {
+ (
+ 2 + sqrt(2) *
+ (\l_@@_tmpb_fp - 1/16 * \l_@@_tmpd_fp)
+ *
+ (\l_@@_tmpd_fp - 1/16 * \l_@@_tmpb_fp)
+ *
+ (\l_@@_tmpa_fp - \l_@@_tmpc_fp)
+ )
+ /
+ (
+ 1
+ +
+ (1 - (3 - sqrt(5))/2)
+ *
+ \l_@@_tmpa_fp
+ +
+ (3 - sqrt(5))/2
+ *
+ \l_@@_tmpc_fp
+ )
+ *
+ sqrt
+ (
+ (
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
+ +
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
+ )
+ /
+ (
+ (\tl_item:nn {#2} {1})^2
+ +
+ (\tl_item:nn {#2} {2})^2
+ )
+ )
+ /3
+ }
+ \fp_set:Nn \l_@@_tmpf_fp
+ {
+ (
+ 2 - sqrt(2) *
+ (\l_@@_tmpb_fp - 1/16 * \l_@@_tmpd_fp)
+ *
+ (\l_@@_tmpd_fp - 1/16 * \l_@@_tmpb_fp)
+ *
+ (\l_@@_tmpa_fp - \l_@@_tmpc_fp)
+ )
+ /
+ (
+ 1
+ +
+ (1 - (3 - sqrt(5))/2)
+ *
+ \l_@@_tmpc_fp
+ +
+ (3 - sqrt(5))/2
+ *
+ \l_@@_tmpa_fp
+ )
+ *
+ sqrt
+ (
+ (
+ (\tl_item:nn {#4} {1} - \tl_item:nn {#1} {1})^2
+ +
+ (\tl_item:nn {#4} {2} - \tl_item:nn {#1} {2})^2
+ )
+ /
+ (
+ (\tl_item:nn {#3} {1})^2
+ +
+ (\tl_item:nn {#3} {2})^2
+ )
+ )
+ /3
+ }
+
+ \tl_set:Nx \l_@@_tmpa_tl
+ {
+ {
+ \fp_to_dim:n
+ {
+ \tl_item:nn {#1} {1}
+ +
+ \l_@@_tmpe_fp
+ *
+ (\tl_item:nn {#2} {1})
+ }
+ }
+ {
+ \fp_to_dim:n
+ {
+ \tl_item:nn {#1} {2}
+ +
+ \l_@@_tmpe_fp
+ *
+ (\tl_item:nn {#2} {2})
+ }
+ }
+ }
+ \tl_set:Nx \l_@@_tmpb_tl
+ {
+ {
+ \fp_to_dim:n
+ {
+ \tl_item:nn {#4} {1}
+ -
+ \l_@@_tmpf_fp
+ *
+ (\tl_item:nn {#3} {1})
+ }
+ }
+ {
+ \fp_to_dim:n
+ {
+ \tl_item:nn {#4} {2}
+ -
+ \l_@@_tmpf_fp
+ *
+ (\tl_item:nn {#3} {2})
+ }
+ }
+ }
+
+ \tl_clear:N \l_@@_tmpc_tl
+ \tl_set:NV \l_@@_tmpc_tl \c_spath_moveto_tl
+ \tl_put_right:Nn \l_@@_tmpc_tl {#1}
+ \tl_put_right:NV \l_@@_tmpc_tl \c_spath_curvetoa_tl
+ \tl_put_right:NV \l_@@_tmpc_tl \l_@@_tmpa_tl
+ \tl_put_right:NV \l_@@_tmpc_tl \c_spath_curvetob_tl
+ \tl_put_right:NV \l_@@_tmpc_tl \l_@@_tmpb_tl
+ \tl_put_right:NV \l_@@_tmpc_tl \c_spath_curveto_tl
+ \tl_put_right:Nn \l_@@_tmpc_tl {#4}
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpc_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_hobby_curve:Nnnnn #1#2#3#4#5
+{
+ \@@_hobby_curve:nnnn {#2}{#3}{#4}{#5}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_hobby_curve:Nnnnn {NVVVV}
+\cs_new_protected_nopar:Npn \spath_ghobby_curve:Nnnnn #1#2#3#4#5
+{
+ \@@_hobby_curve:nnnn {#2}{#3}{#4}{#5}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_ghobby_curve:Nnnnn {NVVVV}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}[internal]{
+% \spath_curve_between:Nnn,
+% \spath_curve_between:Nn,
+% \spath_gcurve_between:Nnn,
+% \spath_gcurve_between:Nn
+% }
+% This takes two paths and returns a single path formed by joining the two paths by a curve.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_curve_between:nn #1#2
+{
+ \group_begin:
+ \spath_finalpoint:Nn \l_@@_tmpa_tl {#1}
+ \spath_finaltangent:Nn \l_@@_tmpb_tl {#1}
+ \spath_initialpoint:Nn \l_@@_tmpc_tl {#2}
+ \spath_initialtangent:Nn \l_@@_tmpd_tl {#2}
+
+ \spath_hobby_curve:NVVVV \l_@@_tmpe_tl
+ \l_@@_tmpa_tl \l_@@_tmpb_tl \l_@@_tmpd_tl \l_@@_tmpc_tl
+
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \spath_append_no_move:NV \l_@@_tmpa_tl \l_@@_tmpe_tl
+ \spath_append_no_move:Nn \l_@@_tmpa_tl {#2}
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_curve_between:Nnn #1#2#3
+{
+ \@@_curve_between:nn {#2}{#3}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_curve_between:Nnn {NVn, NVV}
+\cs_new_protected_nopar:Npn \spath_curve_between:Nn #1#2
+{
+ \spath_curve_between:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_curve_between:Nn {NV, cn, cv}
+\cs_new_protected_nopar:Npn \spath_gcurve_between:Nnn #1#2#3
+{
+ \@@_curve_between:nn {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gcurve_between:Nnn {NVn, NVV}
+\cs_new_protected_nopar:Npn \spath_gcurve_between:Nn #1#2
+{
+ \spath_gcurve_between:NVnn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_gcurve_between:Nn {NV, cn, cv}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
% \spath_close_with:Nn,
% \spath_gclose_with:Nn
% }
@@ -1839,6 +2685,77 @@ manipulating PGF soft paths}
% \end{macro}
%
% \begin{macro}[internal]{
+% \spath_close_with_curve:N,
+% \spath_gclose_with_curve:N
+% }
+% Closes the path with a curve.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_close_with_curve:n #1
+{
+ \group_begin:
+ \spath_finalpoint:Nn \l_@@_tmpa_tl {#1}
+ \spath_finaltangent:Nn \l_@@_tmpb_tl {#1}
+ \spath_finalmovepoint:Nn \l_@@_tmpc_tl {#1}
+ \spath_finalmovetangent:Nn \l_@@_tmpd_tl {#1}
+ \dim_compare:nTF
+ {
+ \dim_abs:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ -
+ \tl_item:Nn \l_@@_tmpc_tl {1}
+ }
+ +
+ \dim_abs:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {2}
+ -
+ \tl_item:Nn \l_@@_tmpc_tl {2}
+ }
+ < 0.01pt
+ }
+ {
+ \@@_close:n {#1}
+ }
+ {
+
+ \spath_hobby_curve:NVVVV \l_@@_tmpe_tl
+ \l_@@_tmpa_tl \l_@@_tmpb_tl \l_@@_tmpd_tl \l_@@_tmpc_tl
+
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \spath_append_no_move:NV \l_@@_tmpa_tl \l_@@_tmpe_tl
+ \@@_close:V \l_@@_tmpa_tl
+ }
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_close_with_curve:Nn #1#2
+{
+ \@@_close_with_curve:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_close_with_curve:Nn {cn, cV, cv, NV}
+\cs_new_protected_nopar:Npn \spath_close_with_curve:N #1
+{
+ \spath_close_with_curve:NV #1#1
+}
+\cs_generate_variant:Nn \spath_close_with_curve:N {c}
+\cs_new_protected_nopar:Npn \spath_gclose_with_curve:Nn #1#2
+{
+ \@@_close_with_curve:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gclose_with_curve:Nn {cn, cV, cv, NV}
+\cs_new_protected_nopar:Npn \spath_gclose_with_curve:N #1
+{
+ \spath_gclose_with_curve:NV #1#1
+}
+\cs_generate_variant:Nn \spath_gclose_with_curve:N {c}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
% \spath_weld:Nnn,
% \spath_weld:Nn,
% \spath_gweld:Nnn,
@@ -1893,16 +2810,27 @@ manipulating PGF soft paths}
% \spath_gappend_no_move:Nn,
% }
% Append the path from the second \Verb+spath+ to the first, removing
-% the adjoining move.
+% the adjoining move if neither path has a rectangle either side of the join or if the first path isn't closed.
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_append_no_move:nn #1#2
{
\group_begin:
\tl_set:Nn \l_@@_tmpa_tl {#1}
\tl_set:Nn \l_@@_tmpb_tl {#2}
- \tl_set:Nx \l_@@_tmpb_tl {\tl_tail:N \l_@@_tmpb_tl}
- \tl_set:Nx \l_@@_tmpb_tl {\tl_tail:N \l_@@_tmpb_tl}
- \tl_set:Nx \l_@@_tmpb_tl {\tl_tail:N \l_@@_tmpb_tl}
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpb_tl}
+ \spath_finalaction:Nn \l_@@_tmpd_tl {#1}
+ \bool_if:nT {
+ ! \tl_if_eq_p:NN \l_@@_tmpd_tl \c_spath_closepath_tl
+ &&
+ ! \tl_if_eq_p:NN \l_@@_tmpd_tl \c_spath_rectcorner_tl
+ &&
+ \tl_if_eq_p:NN \l_@@_tmpc_tl \c_spath_moveto_tl
+ }
+ {
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_tail:N \l_@@_tmpb_tl}
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_tail:N \l_@@_tmpb_tl}
+ \tl_set:Nx \l_@@_tmpb_tl {\tl_tail:N \l_@@_tmpb_tl}
+ }
\tl_put_right:NV \l_@@_tmpa_tl \l_@@_tmpb_tl
\tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
@@ -2079,6 +3007,56 @@ manipulating PGF soft paths}
% \end{macro}
%
% \begin{macro}[internal]{
+% \spath_bake_shorten:Nn,
+% \spath_bake_shorten:N,
+% \spath_gbake_shorten:Nn,
+% \spath_gbake_shorten:N
+% }
+%
+% The shortening routine is applied quite late in the process of building a soft path so this ensures that it is done.
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_bake_shorten:n #1
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \pgfsyssoftpath@getcurrentpath\l_@@_tmpb_tl
+ \pgfsyssoftpath@setcurrentpath\l_@@_tmpa_tl
+ \pgf@prepare@end@of@path
+ \pgf@prepare@start@of@path
+ \pgfsyssoftpath@getcurrentpath\l_@@_tmpa_tl
+ \pgfsyssoftpath@setcurrentpath\l_@@_tmpb_tl
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_bake_shorten:Nn #1#2
+{
+ \@@_bake_shorten:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_bake_shorten:Nn {NV}
+\cs_new_protected_nopar:Npn \spath_bake_shorten:N #1
+{
+ \spath_bake_shorten:NV #1#1
+}
+\cs_generate_variant:Nn \spath_bake_shorten:N {c}
+\cs_new_protected_nopar:Npn \spath_gbake_shorten:Nn #1#2
+{
+ \@@_bake_shorten:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gbake_shorten:Nn {NV}
+\cs_new_protected_nopar:Npn \spath_gbake_shorten:N #1
+{
+ \spath_gbake_shorten:NV #1#1
+}
+\cs_generate_variant:Nn \spath_gbake_shorten:N {c}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
% \spath_close:Nn,
% \spath_close:N,
% \spath_gclose:Nn,
@@ -2124,6 +3102,91 @@ manipulating PGF soft paths}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[internal]{
+% \spath_adjust_close:Nn,
+% \spath_adjust_close:N,
+% \spath_adjust_gclose:Nn,
+% \spath_adjust_gclose:N
+% }
+% This closes a path and adjusts the end point to be where the final move point (so where the close points to) is.
+% The intention is that this should be used if the two points are visually the same point but mathematically different.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_adjust_close:n #1
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \spath_finalmovepoint:NV \l_@@_tmpb_tl \l_@@_tmpa_tl
+ \spath_finalpoint:NV \l_@@_tmpc_tl \l_@@_tmpa_tl
+ \tl_reverse:N \l_@@_tmpa_tl
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpd_tl {\tl_head:N \l_@@_tmpa_tl}
+ \tl_if_eq:NNT \l_@@_tmpd_tl \c_spath_curveto_tl
+ {
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_clear:N \l_@@_tmpe_tl
+ \tl_set:Nx \l_@@_tmpe_tl {
+ {
+ \dim_eval:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ -
+ \tl_item:Nn \l_@@_tmpc_tl {2}
+ +
+ \tl_item:Nn \l_@@_tmpb_tl {2}
+ }
+ }
+ {
+ \dim_eval:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {2}
+ -
+ \tl_item:Nn \l_@@_tmpc_tl {1}
+ +
+ \tl_item:Nn \l_@@_tmpb_tl {1}
+ }
+ }
+ }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl}
+ \tl_put_left:NV \l_@@_tmpa_tl \l_@@_tmpe_tl
+ \tl_put_left:NV \l_@@_tmpa_tl \l_@@_tmpd_tl
+ }
+ \tl_reverse:N \l_@@_tmpa_tl
+ \tl_put_right:NV \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \tl_put_right:NV \l_@@_tmpa_tl \c_spath_closepath_tl
+ \tl_put_right:NV \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_generate_variant:Nn \@@_adjust_close:n {V}
+\cs_new_protected_nopar:Npn \spath_adjust_close:Nn #1#2
+{
+ \@@_adjust_close:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_adjust_close:Nn {NV}
+\cs_new_protected_nopar:Npn \spath_adjust_close:N #1
+{
+ \spath_adjust_close:NV #1#1
+}
+\cs_generate_variant:Nn \spath_adjust_close:N {c}
+\cs_new_protected_nopar:Npn \spath_adjust_gclose:Nn #1#2
+{
+ \@@_adjust_close:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_adjust_gclose:Nn {NV}
+\cs_new_protected_nopar:Npn \spath_adjust_gclose:N #1
+{
+ \spath_adjust_gclose:NV #1#1
+}
+\cs_generate_variant:Nn \spath_adjust_gclose:N {c}
+% \end{macrocode}
+% \end{macro}
+%
%
% \begin{macro}[internal]{
% \spath_open:Nn,
@@ -2132,11 +3195,12 @@ manipulating PGF soft paths}
% \spath_gopen:N
% }
% Removes all close paths from the path, replacing them by \Verb+lineto+ if they move any distance.
+% Rectangles are replaced by lines with the start/end at the lower left corner.
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_open:n #1
{
\group_begin:
- \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \spath_replace_rectangles:Nn \l_@@_tmpa_tl {#1}
\tl_clear:N \l_@@_tmpb_tl
\bool_until_do:nn {
\tl_if_empty_p:N \l_@@_tmpa_tl
@@ -2210,6 +3274,7 @@ manipulating PGF soft paths}
\tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpb_tl
\group_end:
}
+\cs_generate_variant:Nn \@@_open:n {V}
\cs_new_protected_nopar:Npn \spath_open:Nn #1#2
{
\@@_open:n {#2}
@@ -2232,6 +3297,8 @@ manipulating PGF soft paths}
{
\spath_gopen:NV #1#1
}
+\cs_generate_variant:Nn \spath_open:N {c}
+\cs_generate_variant:Nn \spath_gopen:N {c}
% \end{macrocode}
% \end{macro}
%
@@ -2358,6 +3425,126 @@ manipulating PGF soft paths}
% \end{macro}
%
% \begin{macro}[internal]{
+% \spath_replace_rectangles:Nn,
+% \spath_replace_rectangles:Nn,
+% \spath_replace_rectangles:Nn,
+% \spath_replace_rectangles:Nn,
+% }
+% Replace any rectangle components by lines.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_replace_rectangles:n #1
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \tl_clear:N \l_@@_tmpb_tl
+
+ \bool_do_until:nn
+ {
+ \tl_if_empty_p:N \l_@@_tmpa_tl
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_head:N \l_@@_tmpa_tl }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl }
+ \tl_set:Nx \l_@@_tmpd_tl {\tl_head:N \l_@@_tmpa_tl }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl }
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_head:N \l_@@_tmpa_tl }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl }
+
+ \tl_if_eq:NNTF \l_@@_tmpc_tl \c_spath_rectcorner_tl
+ {
+
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl }
+ \dim_set:Nn \l_@@_tmpa_dim
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {1}
+ }
+ \dim_set:Nn \l_@@_tmpb_dim
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {2}
+ }
+
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl }
+ \tl_set:Nx \l_@@_tmpa_tl {\tl_tail:N \l_@@_tmpa_tl }
+
+ \tl_put_right:NV \l_@@_tmpb_tl \c_spath_moveto_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpe_tl
+
+ \tl_put_right:NV \l_@@_tmpb_tl \c_spath_lineto_tl
+ \tl_put_right:Nx \l_@@_tmpb_tl
+ {
+ {
+ \fp_to_dim:n { \l_@@_tmpd_tl + \l_@@_tmpa_dim }
+ }
+ }
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpe_tl
+
+ \tl_put_right:NV \l_@@_tmpb_tl \c_spath_lineto_tl
+ \tl_put_right:Nx \l_@@_tmpb_tl
+ {
+ {
+ \fp_to_dim:n { \l_@@_tmpd_tl + \l_@@_tmpa_dim }
+ }
+ }
+ \tl_put_right:Nx \l_@@_tmpb_tl
+ {
+ {
+ \fp_to_dim:n { \l_@@_tmpe_tl + \l_@@_tmpb_dim }
+ }
+ }
+
+ \tl_put_right:NV \l_@@_tmpb_tl \c_spath_lineto_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
+ \tl_put_right:Nx \l_@@_tmpb_tl
+ {
+ {
+ \fp_to_dim:n { \l_@@_tmpe_tl + \l_@@_tmpb_dim }
+ }
+ }
+
+ \tl_put_right:NV \l_@@_tmpb_tl \c_spath_closepath_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpe_tl
+
+ }
+ {
+ \tl_put_right:NV \l_@@_tmpb_tl \l_@@_tmpc_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpd_tl
+ \@@_tl_put_right_braced:NV \l_@@_tmpb_tl \l_@@_tmpe_tl
+ }
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpb_tl
+ \group_end:
+}
+\cs_generate_variant:Nn \@@_replace_rectangles:n {V}
+\cs_new_protected_nopar:Npn \spath_replace_rectangles:Nn #1#2
+{
+ \@@_replace_rectangles:n {#2}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_replace_rectangles:Nn {NV, cV, cv, Nv}
+\cs_new_protected_nopar:Npn \spath_replace_rectangles:N #1
+{
+ \spath_replace_rectangles:NV #1#1
+}
+\cs_generate_variant:Nn \spath_replace_rectangles:N {c}
+\cs_new_protected_nopar:Npn \spath_greplace_rectangles:Nn #1#2
+{
+ \@@_replace_rectangles:n {#2}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_greplace_rectangles:Nn {NV, cV, cv, Nv}
+\cs_new_protected_nopar:Npn \spath_greplace_rectangles:N #1
+{
+ \spath_greplace_rectangles:NV #1#1
+}
+\cs_generate_variant:Nn \spath_greplace_rectangles:N {c}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
% \spath_remove_empty_components:Nn,
% \spath_remove_empty_components:N,
% \spath_gremove_empty_components:Nn,
@@ -2688,9 +3875,11 @@ manipulating PGF soft paths}
}
{
\fp_set:Nn \l_@@_tmpa_fp {.5 * \l_@@_tmpa_fp / \l_@@_tmpb_fp}
- \fp_compare:nTF
+ \bool_if:nTF
{
- 0 < \l_@@_tmpa_fp && \l_@@_tmpa_fp < 1
+ \fp_compare_p:n {0 < \l_@@_tmpa_fp}
+ &&
+ \fp_compare_p:n {\l_@@_tmpa_fp < 1}
}
{
\@@_split_curve:nV {#1} \l_@@_tmpa_fp
@@ -2908,16 +4097,74 @@ manipulating PGF soft paths}
% \end{macrocode}
% \end{macro}
%
+%
+% \begin{macro}[internal]{
+% \spath_split_rectangle:Nnn,
+% \spath_gsplit_rectangle:Nnn
+% }
+% Cuts a rectangle at a point.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_split_rectangle:nn #1#2
+{
+ \group_begin:
+ \spath_open:Nn \l_@@_tmpa_tl {#1}
+ \fp_set:Nn \l_@@_tmpa_fp {4*(#2)}
+ \spath_split_at:NNVV
+ \l_@@_tmpa_tl \l_@@_tmpb_tl \l_@@_tmpa_tl \l_@@_tmpa_fp
+ \@@_append_no_move:VV \l_@@_tmpb_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \spath_split_rectangle:Nnn #1#2#3
+{
+ \@@_split_rectangle:nn {#2}{#3}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_rectangle:Nnn {NnV, NVn, NVV}
+\cs_new_protected_nopar:Npn \spath_gsplit_rectangle:Nnn #1#2#3
+{
+ \@@_split_rectangle:nn {#2}{#3}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_rectangle:Nnn {NnV, NVn, NVV}
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}[internal]{
% \spath_split_at:NNnn,
% \spath_split_at:Nnn,
% \spath_split_at:Nn,
% \spath_gsplit_at:NNnn
% \spath_gsplit_at:Nnn,
-% \spath_gsplit_at:Nn
+% \spath_gsplit_at:Nn,
+% \spath_split_at_keep_start:Nnn,
+% \spath_split_at_keep_start:Nn,
+% \spath_gsplit_at_keep_start:Nnn,
+% \spath_gsplit_at_keep_start:Nn,
+% \spath_split_at_keep_end:Nnn,
+% \spath_split_at_keep_end:Nn,
+% \spath_gsplit_at_keep_end:Nnn,
+% \spath_gsplit_at_keep_end:Nn,
+% \spath_split_at_normalised:NNnn,
+% \spath_split_at_normalised:Nnn,
+% \spath_split_at_normalised:Nn,
+% \spath_gsplit_at_normalised:NNnn
+% \spath_gsplit_at_normalised:Nnn,
+% \spath_gsplit_at_normalised:Nn,
+% \spath_split_at_normalised_keep_start:Nnn,
+% \spath_split_at_normalised_keep_start:Nn,
+% \spath_gsplit_at_normalised_keep_start:Nnn,
+% \spath_gsplit_at_normalised_keep_start:Nn,
+% \spath_split_at_normalised_keep_end:Nnn,
+% \spath_split_at_normalised_keep_end:Nn,
+% \spath_gsplit_at_normalised_keep_end:Nnn,
+% \spath_gsplit_at_normalised_keep_end:Nn,
% }
% Split a path according to the parameter generated by the intersection routine.
% The versions with two \texttt{N} arguments stores the two parts in two macros, the version with a single \texttt{N} joins them back into a single path (as separate components).
+% The \texttt{keep} versions throw away the other part of the curve.
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_split_at:nn #1#2
{
@@ -2948,11 +4195,28 @@ manipulating PGF soft paths}
\bool_set_true:N \l_@@_tmpa_bool
\tl_set:Nn \l_@@_tmpe_tl {#1}
- \tl_clear:N \l_@@_tmpc_tl
\dim_zero:N \l_@@_tmpa_dim
\dim_zero:N \l_@@_tmpb_dim
+ % Remember if the component is closed
+ \spath_finalaction:NV \l_@@_tmpa_tl \l_@@_tmpe_tl
+
+ \bool_set:Nn \l_@@_closed_bool
+ {
+ \tl_if_eq_p:NN \l_@@_tmpa_tl \c_spath_closepath_tl
+ ||
+ \tl_if_eq_p:NN \l_@@_tmpa_tl \c_spath_rectcorner_tl
+ }
+
+ % Open it
+ \spath_open:N \l_@@_tmpe_tl
+
+ \tl_clear:N \l_@@_tmpa_tl
+ \tl_clear:N \l_@@_tmpb_tl
+ \tl_clear:N \l_@@_tmpc_tl
+ \tl_clear:N \l_@@_tmpd_tl
+
\bool_until_do:nn {
\tl_if_empty_p:N \l_@@_tmpe_tl
||
@@ -2971,6 +4235,10 @@ manipulating PGF soft paths}
{
\int_incr:N \l_@@_tmpb_int
}
+ \c_spath_rectcorner_tl
+ {
+ \int_incr:N \l_@@_tmpb_int
+ }
}
\int_compare:nT { \l_@@_tmpb_int < \l_@@_tmpa_int }
{
@@ -3075,14 +4343,65 @@ manipulating PGF soft paths}
\tl_put_right:NV \l_@@_tmpc_tl \l_@@_tmpa_tl
\tl_put_right:NV \l_@@_tmpb_tl \l_@@_tmpe_tl
}
+
+ \c_spath_rectcorner_tl
+ {
+ \tl_clear:N \l_@@_tmpd_tl
+ \tl_put_right:NV \l_@@_tmpd_tl \l_@@_tmpf_tl
+
+ \tl_put_right:Nx \l_@@_tmpd_tl {{\tl_head:N \l_@@_tmpe_tl}}
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpe_tl}
+ \tl_put_right:Nx \l_@@_tmpd_tl {{\tl_head:N \l_@@_tmpe_tl}}
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpe_tl}
+
+ \tl_put_right:Nx \l_@@_tmpd_tl {\tl_head:N \l_@@_tmpe_tl}
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpe_tl}
+
+ \tl_put_right:Nx \l_@@_tmpd_tl {{\tl_head:N \l_@@_tmpe_tl}}
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpe_tl}
+ \tl_put_right:Nx \l_@@_tmpd_tl {{\tl_head:N \l_@@_tmpe_tl}}
+ \tl_set:Nx \l_@@_tmpe_tl {\tl_tail:N \l_@@_tmpe_tl}
+
+ \spath_split_rectangle:NVV
+ \l_@@_tmpa_tl
+ \l_@@_tmpd_tl
+ \l_@@_tmpa_fp
+
+ \tl_put_right:NV \l_@@_tmpc_tl \l_@@_tmpa_tl
+ \tl_put_right:NV \l_@@_tmpb_tl \l_@@_tmpe_tl
+ }
+
}
}
+ \bool_if:NT \l_@@_closed_bool
+ {
+ \prg_replicate:nn {3}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl {\tl_tail:N \l_@@_tmpc_tl}
+ }
+ \tl_put_right:NV \l_@@_tmpb_tl \l_@@_tmpc_tl
+ \tl_set_eq:NN \l_@@_tmpc_tl \l_@@_tmpb_tl
+ \tl_clear:N \l_@@_tmpb_tl
+ }
+
\tl_gclear:N \g_@@_output_tl
\@@_tl_gput_right_braced:NV \g_@@_output_tl \l_@@_tmpc_tl
\@@_tl_gput_right_braced:NV \g_@@_output_tl \l_@@_tmpb_tl
\group_end:
}
+\cs_generate_variant:Nn \@@_split_at:nn {nV, VV}
+\cs_new_protected_nopar:Npn \@@_split_at_normalised:nn #1#2
+{
+ \group_begin:
+ \spath_reallength:Nn \l_@@_tmpa_int {#1}
+
+ \tl_set:Nx \l_@@_tmpa_tl
+ {\fp_to_decimal:n {(#2) * (\l_@@_tmpa_int)}}
+ \@@_split_at:nV {#1} \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_generate_variant:Nn \@@_split_at_normalised:nn {nV}
\cs_new_protected_nopar:Npn \spath_split_at:NNnn #1#2#3#4
{
\@@_split_at:nn {#3}{#4}
@@ -3099,6 +4418,114 @@ manipulating PGF soft paths}
\tl_gclear:N \g_@@_output_tl
}
\cs_generate_variant:Nn \spath_gsplit_at:NNnn {NNVn, NNVV, NNnV}
+\cs_new_protected_nopar:Npn \spath_split_at_keep_start:Nnn #1#2#3
+{
+ \@@_split_at:nn {#2}{#3}
+ \tl_set:Nx #1 {\tl_item:Nn \g_@@_output_tl {1}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_at_keep_start:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_split_at_keep_start:Nn #1#2
+{
+ \spath_split_at_keep_start:NVn #1#1{#2}
+}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_keep_start:Nnn #1#2#3
+{
+ \@@_split_at:nn {#2}{#3}
+ \tl_gset:Nx #1 {\tl_item:Nn \g_@@_output_tl {1}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_at_keep_start:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_keep_start:Nn #1#2
+{
+ \spath_gsplit_at_keep_start:NVn #1#1{#2}
+}
+\cs_new_protected_nopar:Npn \spath_split_at_keep_end:Nnn #1#2#3
+{
+ \@@_split_at:nn {#2}{#3}
+ \tl_set:Nx #1 {\tl_item:Nn \g_@@_output_tl {2}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_at_keep_end:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_split_at_keep_end:Nn #1#2
+{
+ \spath_split_at_keep_end:NVn #1#1{#2}
+}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_keep_end:Nnn #1#2#3
+{
+ \@@_split_at:nn {#2}{#3}
+ \tl_gset:Nx #1 {\tl_item:Nn \g_@@_output_tl {2}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_at_keep_end:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_keep_end:Nn #1#2
+{
+ \spath_gsplit_at_keep_end:NVn #1#1{#2}
+}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised:NNnn #1#2#3#4
+{
+ \@@_split_at_normalised:nn {#3}{#4}
+ \tl_set:Nx #1 {\tl_item:Nn \g_@@_output_tl {1}}
+ \tl_set:Nx #2 {\tl_item:Nn \g_@@_output_tl {2}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_at_normalised:NNnn {NNVn, NNVV, NNnV, ccvn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised:NNnn #1#2#3#4
+{
+ \@@_split_at_normalised:nn {#3}{#4}
+ \tl_gset:Nx #1 {\tl_item:Nn \g_@@_output_tl {1}}
+ \tl_gset:Nx #2 {\tl_item:Nn \g_@@_output_tl {2}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised:NNnn {NNVn, NNVV, NNnV, ccvn}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_start:Nnn #1#2#3
+{
+ \@@_split_at_normalised:nn {#2}{#3}
+ \tl_set:Nx #1 {\tl_item:Nn \g_@@_output_tl {1}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_at_normalised_keep_start:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_start:Nn #1#2
+{
+ \spath_split_at_normalised_keep_start:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_split_at_normalised_keep_start:Nn {cn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_start:Nnn #1#2#3
+{
+ \@@_split_at_normalised:nn {#2}{#3}
+ \tl_gset:Nx #1 {\tl_item:Nn \g_@@_output_tl {1}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_start:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_start:Nn #1#2
+{
+ \spath_gsplit_at_normalised_keep_start:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_start:Nn {cn}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_end:Nnn #1#2#3
+{
+ \@@_split_at_normalised:nn {#2}{#3}
+ \tl_set:Nx #1 {\tl_item:Nn \g_@@_output_tl {2}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_at_normalised_keep_end:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised_keep_end:Nn #1#2
+{
+ \spath_split_at_normalised_keep_end:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_split_at_normalised_keep_end:Nn {cn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_end:Nnn #1#2#3
+{
+ \@@_split_at_normalised:nn {#2}{#3}
+ \tl_gset:Nx #1 {\tl_item:Nn \g_@@_output_tl {2}}
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_end:Nnn {NVn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised_keep_end:Nn #1#2
+{
+ \spath_gsplit_at_normalised_keep_end:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised_keep_end:Nn {cn}
% \end{macrocode}
%
%
@@ -3133,6 +4560,38 @@ manipulating PGF soft paths}
{
\spath_gsplit_at:NVn #1#1{#2}
}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised:Nnn #1#2#3
+{
+ \@@_split_at_normalised:nn {#2}{#3}
+ \tl_set:Nx #1
+ {
+ \tl_item:Nn \g_@@_output_tl {1}
+ \tl_item:Nn \g_@@_output_tl {2}
+ }
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_split_at_normalised:Nnn {NVn, NVV}
+\cs_new_protected_nopar:Npn \spath_split_at_normalised:Nn #1#2
+{
+ \spath_split_at_normalised:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_split_at_normalised:Nn {cn}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised:Nnn #1#2#3
+{
+ \@@_split_at_normalised:nn {#2}{#3}
+ \tl_gset:Nx #1
+ {
+ \tl_item:Nn \g_@@_output_tl {1}
+ \tl_item:Nn \g_@@_output_tl {2}
+ }
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised:Nnn {NVn, NVV}
+\cs_new_protected_nopar:Npn \spath_gsplit_at_normalised:Nn #1#2
+{
+ \spath_gsplit_at_normalised:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \spath_gsplit_at_normalised:Nn {cn}
% \end{macrocode}
% \end{macro}
%
@@ -3473,6 +4932,40 @@ manipulating PGF soft paths}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[internal]{
+% \spath_shorten_at_both_ends:Nnn,
+% \spath_shorten_at_both_ends:Nn,
+% \spath_gshorten_at_both_ends:Nnn,
+% \spath_gshorten_at_both_ends:Nn
+% }
+%
+% This macro shortens a path from the start by a dimension.
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \spath_shorten_at_both_ends:Nnn #1#2#3
+{
+ \spath_shorten_at_start:Nnn #1{#2}{#3}
+ \spath_shorten_at_end:Nnn #1{#2}{#3}
+}
+\cs_new_protected_nopar:Npn \spath_shorten_at_both_ends:Nn #1#2
+{
+ \spath_shorten_at_start:Nn #1{#2}
+ \spath_shorten_at_end:Nn #1{#2}
+}
+\cs_generate_variant:Nn \spath_shorten_at_both_ends:Nn {cn, cV, NV}
+\cs_new_protected_nopar:Npn \spath_gshorten_at_both_ends:Nnn #1#2#3
+{
+ \spath_gshorten_at_start:Nnn #1{#2}{#3}
+ \spath_gshorten_at_end:Nnn #1{#2}{#3}
+}
+\cs_new_protected_nopar:Npn \spath_gshorten_at_both_ends:Nn #1#2
+{
+ \spath_gshorten_at_start:Nn #1{#2}
+ \spath_gshorten_at_end:Nn #1{#2}
+}
+\cs_generate_variant:Nn \spath_gshorten_at_both_ends:Nn {cn, cV, NV}
+% \end{macrocode}
+% \end{macro}
%
% \subsection{Points on a Path}
%
@@ -3561,6 +5054,95 @@ manipulating PGF soft paths}
}
}
+ \c_spath_rectsize_tl
+ {
+ \fp_compare:nTF
+ {
+ \l_@@_tmpa_fp <= .25
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {2} )
+ +
+ 4 * \l_@@_tmpa_fp * ( \tl_item:Nn \l_@@_tmpa_tl {5} )
+ }
+ }
+ {\fp_to_dim:n {\tl_item:Nn \l_@@_tmpa_tl {3} } }
+ }
+ }
+ {
+ \fp_compare:nTF
+ {
+ \l_@@_tmpa_fp <= .5
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {2} )
+ +
+ ( \tl_item:Nn \l_@@_tmpa_tl {5} )
+ }
+ }
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {3} )
+ +
+ (4 * (\l_@@_tmpa_fp) - 1) * ( \tl_item:Nn \l_@@_tmpa_tl {6} )
+ }
+ }
+ }
+ }
+ {
+ \fp_compare:nTF
+ {
+ \l_@@_tmpa_fp <= .75
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {2} )
+ +
+ (3 - 4 * (\l_@@_tmpa_fp)) *( \tl_item:Nn \l_@@_tmpa_tl {5} )
+ }
+ }
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {3} )
+ +
+ ( \tl_item:Nn \l_@@_tmpa_tl {6} )
+ }
+ }
+ }
+
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {2} )
+ }
+ }
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {3} )
+ +
+ (4 - 4 *(\l_@@_tmpa_fp)) * ( \tl_item:Nn \l_@@_tmpa_tl {6} )
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
\c_spath_closepath_tl
{
\tl_set:Nx \l_@@_tmpc_tl
@@ -3717,6 +5299,71 @@ manipulating PGF soft paths}
}
}
+ \c_spath_rectsize_tl
+ {
+ \fp_compare:nTF
+ {
+ \l_@@_tmpa_fp <= .25
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {\fp_to_dim:n
+ {
+ \tl_item:Nn \l_@@_tmpa_tl {5}
+ }
+ }
+ {0pt}
+ }
+ }
+ {
+ \fp_compare:nTF
+ {
+ \l_@@_tmpa_fp <= .5
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {0pt}
+ {\fp_to_dim:n
+ {
+ ( \tl_item:Nn \l_@@_tmpa_tl {6} )
+ }
+ }
+ }
+ }
+ {
+ \fp_compare:nTF
+ {
+ \l_@@_tmpa_fp <= .75
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {\fp_to_dim:n
+ {
+ -( \tl_item:Nn \l_@@_tmpa_tl {5} )
+ }
+ }
+ {0pt}
+ }
+
+ }
+ {
+ \tl_set:Nx \l_@@_tmpc_tl
+ {
+ {0pt}
+ {\fp_to_dim:n
+ {
+ - ( \tl_item:Nn \l_@@_tmpa_tl {6} )
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
\c_spath_closepath_tl
{
\tl_set:Nx \l_@@_tmpc_tl
@@ -3898,19 +5545,21 @@ manipulating PGF soft paths}
\tl_set:Nn \l_@@_tmpb_tl {#1}
\tl_set:Nn \l_@@_tmpc_tl {#2}
- \spath_reallength:Nn \l_@@_tmpa_int {#1}
-
% Remember if the component is closed
\spath_finalaction:NV \l_@@_tmpa_tl \l_@@_tmpb_tl
-
+
\bool_set:Nn \l_@@_closed_bool
{
\tl_if_eq_p:NN \l_@@_tmpa_tl \c_spath_closepath_tl
+ ||
+ \tl_if_eq_p:NN \l_@@_tmpa_tl \c_spath_rectcorner_tl
}
-
+
% Open it
\spath_open:N \l_@@_tmpb_tl
+ \spath_reallength:NV \l_@@_tmpa_int \l_@@_tmpb_tl
+
% Sort intersections along the component
\pgfintersectionsortbyfirstpath
\spath_intersect:NN \l_@@_tmpb_tl \l_@@_tmpc_tl
@@ -3933,6 +5582,7 @@ manipulating PGF soft paths}
{
\bool_set_false:N \l_@@_closed_bool
}
+
\seq_get_right:NN \l_@@_tmpb_seq \l_@@_tmpa_tl
\fp_compare:nT
{
@@ -3941,7 +5591,6 @@ manipulating PGF soft paths}
{
\bool_set_false:N \l_@@_closed_bool
}
-
\tl_set:Nn \l_@@_tmpg_tl {-1}
@@ -3989,6 +5638,7 @@ manipulating PGF soft paths}
\tl_set_eq:NN \l_@@_tmpb_tl \l_@@_tmpe_tl
}
+
\bool_if:NT \l_@@_closed_bool
{
\spath_join_component:Nn \l_@@_tmpb_tl {1}
@@ -4847,6 +6497,7 @@ manipulating PGF soft paths}
{
\pgfsyssoftpath@getcurrentpath #1
}
+\cs_generate_variant:Nn \spath_get_current_path:N {c}
% \end{macrocode}
%
% \begin{macrocode}
@@ -4855,6 +6506,7 @@ manipulating PGF soft paths}
\pgfsyssoftpath@getcurrentpath #1
\tl_gset_eq:NN #1 #1
}
+\cs_generate_variant:Nn \spath_gget_current_path:N {c}
% \end{macrocode}
% \end{macro}
%
@@ -4912,10 +6564,13 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \spath_tikz_path:nn #1#2
{
- \path[#1] \pgfextra{
- \spath_set_current_path:n {#2}
- \tl_put_right:Nn \tikz@preactions {\def\tikz@actions@path{#2}}
- };
+ \tl_if_empty:nF {#2}
+ {
+ \path[#1] \pgfextra{
+ \spath_set_current_path:n {#2}
+ \tl_put_left:Nn \tikz@preactions {\def\tikz@actions@path{#2}}
+ };
+ }
}
\cs_generate_variant:Nn \spath_tikz_path:nn {Vn, VV, nv, Vv, nV}
% \end{macrocode}
@@ -4929,8 +6584,8 @@ manipulating PGF soft paths}
\spath_finalpoint:Nn \l_@@_tmpa_tl {#1}
\tl_set:Nx \l_@@_tmpa_tl
{
- \exp_not:c {pgf@x}=\tl_item:Nn \l_@@_tmpa_tl {1}
- \exp_not:c {pgf@y}=\tl_item:Nn \l_@@_tmpa_tl {2}
+ \exp_not:c {pgf@x}=\tl_item:Nn \l_@@_tmpa_tl {1} \relax
+ \exp_not:c {pgf@y}=\tl_item:Nn \l_@@_tmpa_tl {2} \relax
}
\use:c {pgf@process}{%
\tl_use:N \l_@@_tmpa_tl
@@ -4939,32 +6594,41 @@ manipulating PGF soft paths}
}
\tl_set:Nx \l_@@_tmpa_tl
{
- \exp_not:c {tikz@lastx}=\exp_not:c {pgf@x}
- \exp_not:c {tikz@lasty}=\exp_not:c {pgf@y}
- \exp_not:c {tikz@lastxsaved}=\exp_not:c {pgf@x}
- \exp_not:c {tikz@lastysaved}=\exp_not:c {pgf@y}
+ \exp_not:c {tikz@lastx}=\exp_not:c {pgf@x} \relax
+ \exp_not:c {tikz@lasty}=\exp_not:c {pgf@y} \relax
+ \exp_not:c {tikz@lastxsaved}=\exp_not:c {pgf@x} \relax
+ \exp_not:c {tikz@lastysaved}=\exp_not:c {pgf@y} \relax
}
\tl_use:N \l_@@_tmpa_tl
\spath_finalmovepoint:Nn \l_@@_tmpa_tl {#1}
- \ifpgfsyssoftpathmovetorelevant%
- \tl_gset_eq:cN {pgfsyssoftpath@lastmoveto} \l_@@_tmpa_tl
- \fi
+ \bool_if:NT \l_spath_movetorelevant_bool
+ {
+ \ifpgfsyssoftpathmovetorelevant%
+ \tl_gset_eq:cN {pgfsyssoftpath@lastmoveto} \l_@@_tmpa_tl
+ \fi
+ }
\tl_set:Nx \l_@@_tmpa_tl
{
- \exp_not:c {pgf@x}=\tl_item:Nn \l_@@_tmpa_tl {1}
- \exp_not:c {pgf@y}=\tl_item:Nn \l_@@_tmpa_tl {2}
+ \exp_not:c {pgf@x}=\tl_item:Nn \l_@@_tmpa_tl {1} \relax
+ \exp_not:c {pgf@y}=\tl_item:Nn \l_@@_tmpa_tl {2} \relax
}
\use:c {pgf@process}{%
\tl_use:N \l_@@_tmpa_tl
\pgftransforminvert
\use:c {pgf@pos@transform@glob}
}
- \tl_set:Nx \l_@@_tmpa_tl
+ \bool_if:NT \l_spath_movetorelevant_bool
{
- \exp_not:c {tikz@lastmovetox}=\exp_not:c {pgf@x}
- \exp_not:c {tikz@lastmovetoy}=\exp_not:c {pgf@y}
+ \dim_if_exist:cT {tikz@lastmovetox}
+ {
+ \tl_set:Nx \l_@@_tmpa_tl
+ {
+ \exp_not:c {tikz@lastmovetox}=\exp_not:c {pgf@x} \relax
+ \exp_not:c {tikz@lastmovetoy}=\exp_not:c {pgf@y} \relax
+ }
+ \tl_use:N \l_@@_tmpa_tl
+ }
}
- \tl_use:N \l_@@_tmpa_tl
\tl_clear_new:c {tikz@timer}
\tl_set:cn {tikz@timer}
{
@@ -5028,6 +6692,11 @@ manipulating PGF soft paths}
%<*tikzspath3>
% \fi
%
+% \begin{macrocode}
+%<@@=tikzspath>
+% \end{macrocode}
+%
+%
% This provides an interface to the soft path manipulation routines via a series of TikZ keys.
% They all live in the \texttt{spath} family.
%
@@ -5037,24 +6706,44 @@ manipulating PGF soft paths}
\RequirePackage{expl3}
\ExplSyntaxOn
+\tl_new:N \l_@@_tmpa_tl
+\tl_new:N \l_@@_tmpb_tl
+\tl_new:N \l_@@_tmpc_tl
+\tl_new:N \l_@@_tmpd_tl
+\tl_new:N \l_@@_tmpe_tl
+\tl_new:N \l_@@_tmpf_tl
+
+\int_new:N \l_@@_tmpa_int
+\seq_new:N \l_@@_tmpa_seq
+\seq_new:N \l_@@_tmpb_seq
+\seq_new:N \l_@@_tmpc_seq
+\seq_new:N \l_@@_tmpd_seq
+
\tl_new:N \l_@@_current_tl
\tl_new:N \l_@@_reverse_tl
\tl_new:N \l_@@_prefix_tl
\tl_new:N \l_@@_suffix_tl
\tl_new:N \g_@@_smuggle_tl
+\tl_new:N \g_@@_output_tl
+\tl_new:N \l_@@_check_tl
+\clist_new:N \g_@@_output_clist
\seq_new:N \g_@@_tmpa_seq
\seq_new:N \g_@@_tmpb_seq
+\seq_new:N \g_@@_output_seq
\bool_new:N \l_@@_draft_bool
% \end{macrocode}
%
% We surround all the keys with checks to ensure that the soft path under consideration does actually exist, but if it doesn't we should warn the user.
%
% \begin{macrocode}
-\msg_new:nnn { spath3 } { missing soft path } { Soft~ path~ #1~ doesn't~ exist }
-\msg_new:nnnn { spath3 } { empty soft path } { Soft~ path~ #1~ is~ empty}
+\msg_new:nnn { spath3 } { missing soft path }
+{ Soft~ path~ #1~ doesn't~ exist~ \msg_line_context:}
+\msg_new:nnnn { spath3 } { empty soft path }
+{ Soft~ path~ #1~ is~ empty~ \msg_line_context:}
{If~ it~ was~ defined~ inside~ a~ group,~ try~ using~ "save~ global". }
\msg_new:nnn { spath3 } { load intersections }
-{ You~ need~ to~ load~ the~ "intersections"~ library~ to~ work~ with~ intersections }
+{ You~ need~ to~ load~ the~ "intersections"~ library~
+ to~ work~ with~ intersections }
% \end{macrocode}
%
% When saving a soft path, by default we use a naming convention that is compatible with the intersections library so that paths saved here and paths saved by the \texttt{name path} facility of the intersections library are mutually exchangeable.
@@ -5065,9 +6754,14 @@ manipulating PGF soft paths}
% \end{macrocode}
%
% When a soft path is grabbed from TikZ we're usually deep in a group so I've adapted the code from the intersections library to dig the definition out of the group without making everything global.
-%
+%
+% Interestingly, the intersections library doesn't clear its naming code once it is used meaning that it keeps resetting the definition of a path back to its original one every time a path command is called.
+%
+% Also, when the hook is restored outside a scope then no check is made to ensure that the inner one was actually invoked.
+% This can cause issues when the syntax \Verb!\tikz .. ;! is used since the end of the path coincides with the end of the picture.
% \begin{macrocode}
\tl_new:N \g_@@_tikzfinish_tl
+\tl_new:N \l_@@_tikzfinish_outside_tl
\cs_new_protected_nopar:Npn \spath_at_end_of_path:
{
\tl_use:N \g_@@_tikzfinish_tl
@@ -5075,8 +6769,43 @@ manipulating PGF soft paths}
}
\tl_put_right:Nn \tikz@finish {\spath_at_end_of_path:}
+\tikzset{
+ every~ scope/.append~ style={
+ execute~ at~ begin~ scope={
+ \tl_set_eq:NN \l_@@_tikzfinish_outside_tl \g_@@_tikzfinish_tl
+ },
+ execute~ at~ end~ scope={
+ \tl_use:N \g_@@_tikzfinish_tl
+ \tl_gclear:N \g_@@_tikzfinish_tl
+ \tl_gset_eq:NN \g_@@_tikzfinish_tl \l_@@_tikzfinish_outside_tl
+ },
+ },
+}
+% \end{macrocode}
+%
+% This is for delaying something until the path is fully constructed (but no later), sometimes useful to be able to specify this in the path options rather than directly at the end of the path.
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_tikzpath_finish_tl
+
+\cs_new_protected_nopar:Npn \@@_at_end_of_path_construction:
+{
+ \tl_use:N \l_@@_tikzpath_finish_tl
+ \tl_clear:N \l_@@_tikzpath_finish_tl
+}
+
+\tl_put_left:Nn \tikz@finish {\@@_at_end_of_path_construction:}
+% \end{macrocode}
+%
+% Code for saving a path
+%
+% \begin{macrocode}
\cs_new_protected_nopar:Npn \spath_save_path:Nn #1#2
{
+ \tl_if_empty:NF \g_@@_tikzfinish_tl
+ {
+ \tl_use:N \g_@@_tikzfinish_tl
+ }
\tl_gput_right:Nn \g_@@_tikzfinish_tl
{
\tl_clear_new:N #1
@@ -5127,6 +6856,228 @@ manipulating PGF soft paths}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[internal]{
+% \@@_check_path:nnn
+% \@@_check_two_paths:nnnn
+% \@@_check_three_paths:nnnnn
+% }
+% Given a path name as the second argument, check if it exists and is not empty, and if so reinsert it after the first argument.
+% The third argument is code to be executed in case of a missing or empty path.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_check_path:nnn #1#2#3
+{
+ \tl_set:Nn \l_@@_check_tl {#3}
+ \tl_if_exist:cTF {\@@_path_name:n {#2}}
+ {
+ \tl_if_empty:cTF {\@@_path_name:n {#2}}
+ {
+ \msg_warning:nnn { spath3 } { empty soft path } { #2 }
+ }
+ {
+ \tl_set:Nn \l_@@_check_tl {
+ #1 {\@@_path_name:n {#2}}
+ }
+ }
+ }
+ {
+ \msg_warning:nnn { spath3 } { missing soft path } { #2 }
+ }
+ \tl_use:N \l_@@_check_tl
+}
+\cs_new_protected_nopar:Npn \@@_check_two_paths:nnnn #1#2#3#4
+{
+ \@@_check_path:nnn {
+ \@@_check_path:nnn {#1}{#2}{#4}
+ }{#3}{#4}
+}
+\cs_new_protected_nopar:Npn \@@_check_three_paths:nnnnn #1#2#3#4#5
+{
+ \@@_check_path:nnn {
+ \@@_check_path:nnn {
+ \@@_check_path:nnn {#1}{#2}{#5}
+ }{#3}{#5}
+ }{#4}{#5}
+}
+\cs_generate_variant:Nn \@@_check_path:nnn {nVn}
+\cs_generate_variant:Nn \@@_check_two_paths:nnnn {nnVn}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
+% \@@_maybe_current_path:nn
+% \@@_maybe_current_path_reuse:nnn
+% \@@_maybe_current_two_paths_reuse_both:nnnn
+% \@@_maybe_current_two_paths_reuse_first:nnnn
+% \@@_maybe_current_two_paths_reuse_second:nnnn
+% }
+% If the named path is ``current'' then get the current path and use that.
+% The second version puts the resulting path back as the current path.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_maybe_current_path:nn #1#2
+{
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#2}}
+ }
+ #1 {#2}
+}
+\cs_new_protected_nopar:Npn \@@_maybe_current_path_reuse:nnn #1#2#3
+{
+ \bool_set_true:N \l_spath_movetorelevant_bool
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#2}}
+ }
+ #1 {#2} #3
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \tl_if_empty:cF {\@@_path_name:n {#2}}
+ {
+ \spath_set_current_path:c {\@@_path_name:n {#2}}
+ \spath_set_tikz_data:v {\@@_path_name:n {#2}}
+ }
+ }
+}
+\cs_new_protected_nopar:Npn \@@_maybe_current_two_paths_reuse_both:nnnn #1#2#3#4
+{
+ \bool_set_true:N \l_spath_movetorelevant_bool
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#2}}
+ }
+ \tl_if_eq:nnT {#3} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#3}}
+ }
+ #1 {#2} {#3} #4
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \tl_if_empty:cF {\@@_path_name:n {#2}}
+ {
+ \spath_set_current_path:c {\@@_path_name:n {#2}}
+ \spath_set_tikz_data:v {\@@_path_name:n {#2}}
+ }
+ }
+ \tl_if_eq:nnT {#3} {current}
+ {
+ \tl_if_empty:cF {\@@_path_name:n {#3}}
+ {
+ \spath_set_current_path:c {\@@_path_name:n {#3}}
+ \spath_set_tikz_data:v {\@@_path_name:n {#3}}
+ }
+ }
+}
+\cs_new_protected_nopar:Npn \@@_maybe_current_two_paths_reuse_first:nnnn #1#2#3#4
+{
+ \bool_set_true:N \l_spath_movetorelevant_bool
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#2}}
+ }
+ \tl_if_eq:nnT {#3} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#3}}
+ }
+ #1 {#2} {#3} #4
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \tl_if_empty:cF {\@@_path_name:n {#2}}
+ {
+ \spath_set_current_path:c {\@@_path_name:n {#2}}
+ \spath_set_tikz_data:v {\@@_path_name:n {#2}}
+ }
+ }
+}
+\cs_new_protected_nopar:Npn \@@_maybe_current_two_paths_reuse_second:nnnn #1#2#3#4
+{
+ \bool_set_true:N \l_spath_movetorelevant_bool
+ \tl_if_eq:nnT {#2} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#2}}
+ }
+ \tl_if_eq:nnT {#3} {current}
+ {
+ \spath_get_current_path:c {\@@_path_name:n {#3}}
+ }
+ #1 {#2} {#3} #4
+ \tl_if_eq:nnT {#3} {current}
+ {
+ \tl_if_empty:cF {\@@_path_name:n {#3}}
+ {
+ \spath_set_current_path:c {\@@_path_name:n {#3}}
+ \spath_set_tikz_data:v {\@@_path_name:n {#3}}
+ }
+ }
+}
+\cs_generate_variant:Nn \@@_maybe_current_path:nn {nV}
+\cs_generate_variant:Nn \@@_maybe_current_path_reuse:nnn {nVn}
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{
+% \@@_seq_from_foreach:NNn
+% }
+%
+% Convert a PGF foreach list, as the third argument, to a sequence.
+% The second argument is the maximum number on the list.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_seq_from_foreach:Nnn #1#2#3
+{
+ \group_begin:
+ \seq_gclear:N \g_@@_output_seq
+
+ \tl_if_empty:nTF {#3}
+ {
+ \int_step_inline:nnnn {1}{1} {#2}
+ {
+ \seq_gput_right:Nn \g_@@_output_seq {##1}
+ }
+ }
+ {
+ \foreach \l_@@_tmpa_tl in {#3}
+ {
+ \int_compare:nTF { \l_@@_tmpa_tl > 0 }
+ {
+ \seq_gput_right:NV \g_@@_output_seq \l_@@_tmpa_tl
+ }
+ {
+ \seq_gput_right:Nx \g_@@_output_seq
+ {\int_eval:n {#2 - \l_@@_tmpa_tl}}
+ }
+ }
+ \seq_gsort:Nn \g_@@_output_seq
+ {
+ \int_compare:nNnTF {##1} < {##2}
+ { \sort_return_same: }
+ { \sort_return_swapped: }
+ }
+ }
+ \group_end:
+ \seq_set_eq:NN #1 \g_@@_output_seq
+ \seq_gclear:N \g_@@_output_seq
+}
+\cs_generate_variant:Nn \@@_seq_from_foreach:Nnn {NVV, NVn}
+%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
+% \@@_path_name:n
+% }
+% Wrap the argument in the prefix and suffix to generate the proper name.
+% \begin{macrocode}
+\cs_new:Npn \@@_path_name:n #1
+{
+ \tl_use:N \l_@@_prefix_tl
+ #1
+ \tl_use:N \l_@@_suffix_tl
+}
+\cs_generate_variant:Nn \@@_path_name:n {V}
+% \end{macrocode}
+% \end{macro}
+%
% When joining two paths we provide a set of options for how to process the second path.
%
% \begin{macrocode}
@@ -5134,6 +7085,7 @@ manipulating PGF soft paths}
\bool_new:N \l_@@_weld_bool
\bool_new:N \l_@@_move_bool
\bool_new:N \l_@@_global_bool
+\bool_new:N \l_@@_current_transformation_bool
\tl_new:N \l_@@_joinpath_tl
\tl_new:N \l_@@_transformation_tl
@@ -5176,6 +7128,10 @@ manipulating PGF soft paths}
\@@_set_bool:Nn \l_@@_global_bool {#1}
},
global/.default = true,
+ use~ current~ transformation/.code={
+ \@@_set_bool:Nn \l_@@_current_transformation_bool {#1}
+ },
+ use~ current~ transformation/.default = true,
transform/.store~in=\l_@@_transformation_tl,
.unknown/.code = {
\tl_set_eq:NN \l_@@_joinpath_tl \pgfkeyscurrentname
@@ -5191,6 +7147,766 @@ manipulating PGF soft paths}
\cs_set_eq:NN \getComponentOf \clist_item:Nn
% \end{macrocode}
%
+% \subsection{Helper Functions}
+%
+% \begin{macro}[internal]{
+% \@@_use_path:n
+% }
+% Use a path, possibly manipulating it first.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_use_path:n #1
+{
+ \tl_set:Nn \l_@@_joinpath_tl {#1}
+ \spath_get_current_path:N \l_@@_current_tl
+
+ \bool_if:NT \l_@@_reverse_bool
+ {
+ \spath_reverse:N \l_@@_joinpath_tl
+ }
+
+ \bool_if:NT \l_@@_current_transformation_bool
+ {
+ \pgfgettransform \l_@@_tmpa_tl
+ \spath_transform:NV
+ \l_@@_joinpath_tl
+ \l_@@_tmpa_tl
+ }
+
+ \tl_if_empty:NF \l_@@_transformation_tl
+ {
+ \group_begin:
+ \pgftransformreset
+ \@@_tikzset:V \l_@@_transformation_tl
+ \pgfgettransform \l_@@_tmpa_tl
+ \tl_gset:Nn \g_@@_smuggle_tl
+ {
+ \spath_transform:Nnnnnnn
+ \l_@@_joinpath_tl
+ }
+ \tl_gput_right:NV \g_@@_smuggle_tl \l_@@_tmpa_tl
+ \group_end:
+ \tl_use:N \g_@@_smuggle_tl
+ }
+
+ \bool_if:NT \l_@@_move_bool
+ {
+ \tl_if_empty:NTF \l_@@_current_tl
+ {
+ \tl_set:Nn \l_@@_tmpc_tl { {0pt} {0pt} }
+ }
+ {
+ \spath_finalpoint:NV
+ \l_@@_tmpc_tl
+ \l_@@_current_tl
+ }
+ \spath_translate_to:NV \l_@@_joinpath_tl \l_@@_tmpc_tl
+ }
+
+ \tl_if_empty:NTF \l_@@_current_tl
+ {
+ \tl_if_empty:NTF \l_@@_joinpath_tl
+ {
+ \tl_set_eq:NN \l_@@_current_tl \c_spath_moveto_tl
+ \tl_put_right:Nn \l_@@_current_tl {{0pt}{0pt}}
+ }
+ {
+ \tl_set_eq:NN \l_@@_current_tl \l_@@_joinpath_tl
+ }
+ }
+ {
+
+ \tl_clear:N \l_@@_tmpa_tl
+ \tl_set:Nn \l_@@_tmpa_tl {spath_}
+
+ \tl_put_right:Nn \l_@@_tmpa_tl {append}
+
+ \bool_if:NT \l_@@_weld_bool
+ {
+ \tl_put_right:Nn \l_@@_tmpa_tl {_no_move}
+ \spath_numberofcomponents:NV \l_@@_tmpa_int \l_@@_joinpath_tl
+ \int_compare:nT {\l_@@_tmpa_int == 1}
+ {
+ \bool_set_false:N \l_spath_movetorelevant_bool
+ }
+ }
+ \tl_put_right:Nn \l_@@_tmpa_tl {:NV}
+
+ \use:c {\tl_use:N \l_@@_tmpa_tl }
+ \l_@@_current_tl
+ \l_@@_joinpath_tl
+ }
+
+ \spath_set_current_path:N \l_@@_current_tl
+ \spath_set_tikz_data:V \l_@@_joinpath_tl
+}
+\cs_generate_variant:Nn \@@_use_path:n {V, v}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}[internal]{
+% \@@_join_with:nn
+% }
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_join_with:Nn #1#2
+{
+ \tl_set:Nn \l_@@_joinpath_tl {#2}
+
+ \bool_if:NT \l_@@_reverse_bool
+ {
+ \spath_reverse:N \l_@@_joinpath_tl
+ }
+
+ \tl_if_empty:NF \l_@@_transformation_tl
+ {
+ \group_begin:
+ \pgftransformreset
+ \@@_tikzset:V \l_@@_transformation_tl
+ \pgfgettransform \l_@@_tmpa_tl
+ \tl_gset:Nn \g_@@_smuggle_tl
+ {
+ \spath_transform:Nnnnnnn
+ \l_@@_joinpath_tl
+ }
+ \tl_gput_right:NV \g_@@_smuggle_tl \l_@@_tmpa_tl
+ \group_end:
+ \tl_use:N \g_@@_smuggle_tl
+ }
+
+ \bool_if:NT \l_@@_move_bool
+ {
+ \spath_finalpoint:NV
+ \l_@@_tmpc_tl
+ #1
+ \spath_translate_to:NV \l_@@_joinpath_tl \l_@@_tmpc_tl
+ }
+
+ \tl_clear:N \l_@@_tmpa_tl
+ \tl_set:Nn \l_@@_tmpa_tl {spath_}
+
+ \bool_if:NT \l_@@_global_bool
+ {
+ \tl_put_right:Nn \l_@@_tmpa_tl {g}
+ }
+
+ \tl_put_right:Nn \l_@@_tmpa_tl {append}
+
+ \bool_if:NT \l_@@_weld_bool
+ {
+ \tl_put_right:Nn \l_@@_tmpa_tl {_no_move}
+ }
+ \tl_put_right:Nn \l_@@_tmpa_tl {:NV}
+
+ \cs_if_exist:cF {\tl_use:N \l_@@_tmpa_tl}
+ {
+ \tl_show:N \l_@@_tmpa_tl
+ }
+
+ \use:c {\tl_use:N \l_@@_tmpa_tl } #1
+ \l_@@_joinpath_tl
+}
+\cs_generate_variant:Nn \@@_join_with:Nn {cv, cn}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_join_components_with:Nnn
+% \@@_join_components_upright_with:Nnn
+% }
+% Join the specified components of the first path by splicing in the second.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_join_components_with_aux:nnn #1#2#3
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpc_tl {#1}
+ \tl_if_empty:nT {#3}
+ {
+ \spath_spot_weld_components:N \l_@@_tmpc_tl
+ }
+
+ \spath_numberofcomponents:NV \l_@@_tmpa_int \l_@@_tmpc_tl
+ \@@_seq_from_foreach:NVn \l_@@_tmpb_seq \l_@@_tmpa_int {#3}
+
+ \spath_components_to_seq:NV \l_@@_tmpa_seq \l_@@_tmpc_tl
+
+ \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
+ \seq_pop_left:NN \l_@@_tmpb_seq \l_@@_tmpb_tl
+
+ \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ {
+ \int_compare:nTF
+ {
+ ##1 == \l_@@_tmpb_tl
+ }
+ {
+ \seq_pop_left:NNF \l_@@_tmpb_seq \l_@@_tmpb_tl
+ {
+ \tl_set:Nn \l_@@_tmpb_tl {-1}
+ }
+ \spath_splice_between:Nnn \l_@@_tmpa_tl {#2} {##2}
+ }
+ {
+ \tl_put_right:Nn \l_@@_tmpa_tl {##2}
+ }
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_join_components_with:Nnnn #1#2#3#4
+{
+ \@@_join_components_with_aux:nnn {#2}{#3}{#4}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_join_components_with:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_join_components_with:Nnn #1#2#3
+{
+ \@@_join_components_with:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_join_components_with:Nnn {cvV}
+\cs_new_protected_nopar:Npn \@@_gjoin_components_with:Nnnn #1#2#3#4
+{
+ \@@_join_components_with_aux:nnn {#2}{#3}{#4}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_gjoin_components_with:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_gjoin_components_with:Nnn #1#2#3
+{
+ \@@_gjoin_components_with:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_gjoin_components_with:Nnn {cvV}
+\cs_new_protected_nopar:Npn \@@_join_components_upright_with_aux:nnn #1#2#3
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpc_tl {#1}
+ \tl_if_empty:nT {#3}
+ {
+ \spath_spot_weld_components:N \l_@@_tmpc_tl
+ }
+
+ \spath_numberofcomponents:NV \l_@@_tmpa_int \l_@@_tmpc_tl
+ \@@_seq_from_foreach:NVn \l_@@_tmpb_seq \l_@@_tmpa_int {#3}
+
+ \spath_components_to_seq:NV \l_@@_tmpa_seq \l_@@_tmpc_tl
+
+ \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
+ \seq_pop_left:NN \l_@@_tmpb_seq \l_@@_tmpb_tl
+
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \spath_transform:NVnnnnnn \l_@@_tmpd_tl \l_@@_tmpc_tl {1}{0}{0}{-1}{0pt}{0pt}
+
+ \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ {
+ \int_compare:nTF
+ {
+ ##1 == \l_@@_tmpb_tl
+ }
+ {
+ \seq_pop_left:NNF \l_@@_tmpb_seq \l_@@_tmpb_tl
+ {
+ \tl_set:Nn \l_@@_tmpb_tl {-1}
+ }
+
+ \spath_finalpoint:NV \l_@@_tmpe_tl \l_@@_tmpa_tl
+ \spath_initialpoint:Nn \l_@@_tmpf_tl {##2}
+
+ \dim_compare:nTF
+ {
+ \tl_item:Nn \l_@@_tmpe_tl {1}
+ >
+ \tl_item:Nn \l_@@_tmpf_tl {1}
+ }
+ {
+ \spath_splice_between:NVn
+ \l_@@_tmpa_tl
+ \l_@@_tmpd_tl
+ {##2}
+ }
+ {
+ \spath_splice_between:NVn
+ \l_@@_tmpa_tl
+ \l_@@_tmpc_tl
+ {##2}
+ }
+ }
+ {
+ \tl_put_right:Nn \l_@@_tmpa_tl {##2}
+ }
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_join_components_upright_with:Nnnn #1#2#3#4
+{
+ \@@_join_components_upright_with_aux:nnn {#2}{#3}{#4}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_join_components_upright_with:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_join_components_upright_with:Nnn #1#2#3
+{
+ \@@_join_components_upright_with:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_join_components_upright_with:Nnn {cvV}
+\cs_new_protected_nopar:Npn \@@_gjoin_components_upright_with:Nnnn #1#2#3#4
+{
+ \@@_join_components_upright_with_aux:nnn {#2}{#3}{#4}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_gjoin_components_upright_with:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_gjoin_components_upright_with:Nnn #1#2#3
+{
+ \@@_gjoin_components_upright_with:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_gjoin_components_upright_with:Nnn {cvV}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{
+% \@@_get_components:Nn
+% }
+% Get the components of the named path to the token list.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_get_components_aux:n #1
+{
+ \clist_gclear_new:N \g_@@_output_clist
+ \spath_components_to_seq:Nn \l_@@_tmpa_seq {#1}
+
+ \seq_map_inline:Nn \l_@@_tmpa_seq
+ {
+ \spath_anonymous:N \l_@@_tmpa_tl
+ \tl_new:c {\@@_path_name:V \l_@@_tmpa_tl}
+ \tl_set:cn {\@@_path_name:V \l_@@_tmpa_tl} {##1}
+ \clist_gput_right:NV \g_@@_output_clist \l_@@_tmpa_tl
+ }
+}
+\cs_new_protected_nopar:Npn \@@_get_components:Nn #1#2
+{
+ \clist_clear_new:N #1
+ \@@_get_components_aux:n {#2}
+ \clist_set_eq:NN #1 \g_@@_output_clist
+ \clist_gclear:N \g_@@_output_clist
+}
+\cs_generate_variant:Nn \@@_get_components:Nn {NV, Nv}
+\cs_new_protected_nopar:Npn \@@_gget_components:Nn #1#2
+{
+ \clist_gclear_new:N #1
+ \@@_get_components_aux:n {#2}
+ \clist_gset_eq:NN #1 \g_@@_output_clist
+ \clist_gclear:N \g_@@_output_clist
+}
+\cs_generate_variant:Nn \@@_gget_components:Nn {NV, Nv}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{
+% \@@_render_components:n
+% }
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_render_components:nn #1#2
+{
+ \group_begin:
+ \spath_components_to_seq:Nn \l_@@_tmpa_seq {#2}
+ \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ {
+ \spath_tikz_path:nn
+ {
+ every~ spath~ component/.try,
+ spath ~component~ ##1/.try,
+ spath ~component/.try={##1},
+ every~ #1~ component/.try,
+ #1 ~component~ ##1/.try,
+ #1 ~component/.try={##1},
+ }
+ {
+ ##2
+ }
+ }
+ \group_end:
+}
+\cs_generate_variant:Nn \@@_render_components:nn {nv}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
+% \@@_insert_gaps_after_components:nn
+% }
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_insert_gaps_after_components_aux:nnn #1#2#3
+{
+ \group_begin:
+ \spath_numberofcomponents:Nn \l_@@_tmpa_int {#1}
+ \@@_seq_from_foreach:NVn \l_@@_tmpa_seq \l_@@_tmpa_int {#3}
+
+ \tl_if_empty:nT {#3}
+ {
+ \seq_pop_right:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
+ }
+
+ \seq_clear:N \l_@@_tmpb_seq
+ \seq_map_inline:Nn \l_@@_tmpa_seq {
+ \seq_put_right:Nx
+ \l_@@_tmpb_seq
+ {\int_eval:n
+ {
+ \int_mod:nn { ##1 }{ \l_@@_tmpa_int } + 1
+ }
+ }
+ }
+
+ \spath_components_to_seq:Nn \l_@@_tmpc_seq {#1}
+
+ \seq_clear:N \l_@@_tmpd_seq
+ \seq_map_indexed_inline:Nn \l_@@_tmpc_seq
+ {
+ \tl_set:Nn \l_@@_tmpa_tl {##2}
+ \seq_if_in:NnT \l_@@_tmpa_seq {##1}
+ {
+ \spath_shorten_at_end:Nn \l_@@_tmpa_tl {(#2)/2}
+ }
+ \seq_if_in:NnT \l_@@_tmpb_seq {##1}
+ {
+ \spath_shorten_at_start:Nn \l_@@_tmpa_tl {(#2)/2}
+ }
+ \seq_put_right:NV \l_@@_tmpd_seq \l_@@_tmpa_tl
+ }
+ \tl_gset:Nx \g_@@_output_tl {\seq_use:Nn \l_@@_tmpd_seq {} }
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_insert_gaps_after_components:Nnnn #1#2#3#4
+{
+ \@@_insert_gaps_after_components_aux:nnn {#2}{#3}{#4}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_insert_gaps_after_components:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_insert_gaps_after_components:Nnn #1#2#3
+{
+ \@@_insert_gaps_after_components:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_insert_gaps_after_components:Nnn {cnn, cVV}
+\cs_new_protected_nopar:Npn \@@_ginsert_gaps_after_components:Nnnn #1#2#3#4
+{
+ \@@_insert_gaps_after_components_aux:nnn {#2}{#3}{#4}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_ginsert_gaps_after_components:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_ginsert_gaps_after_components:Nnn #1#2#3
+{
+ \@@_ginsert_gaps_after_components:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_ginsert_gaps_after_components:Nnn {cnn, cVV}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_insert_gaps_after_segments:Nn
+% }
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_insert_gaps_after_segments_aux:nnn #1#2#3
+{
+ \group_begin:
+ \spath_reallength:Nn \l_@@_tmpa_int {#1}
+ \@@_seq_from_foreach:NVn \l_@@_tmpa_seq \l_@@_tmpa_int {#3}
+
+ \tl_if_empty:nT {#3}
+ {
+ \seq_pop_right:NN \l_@@_tmpb_seq \l_@@_tmpa_tl
+ }
+
+ \seq_clear:N \l_@@_tmpb_seq
+ \seq_map_inline:Nn \l_@@_tmpa_seq {
+ \seq_put_right:Nx
+ \l_@@_tmpb_seq
+ {\int_eval:n
+ {
+ \int_mod:nn { ##1 }{ \l_@@_tmpa_int } + 1
+ }
+ }
+ }
+
+ \spath_segments_to_seq:Nn \l_@@_tmpc_seq {#1}
+
+ \seq_clear:N \l_@@_tmpd_seq
+ \seq_map_indexed_inline:Nn \l_@@_tmpc_seq
+ {
+ \tl_set:Nn \l_@@_tmpa_tl {##2}
+ \seq_if_in:NnT \l_@@_tmpa_seq {##1}
+ {
+ \spath_shorten_at_end:Nn \l_@@_tmpa_tl {(#2)/2}
+ }
+ \seq_if_in:NnT \l_@@_tmpb_seq {##1}
+ {
+ \spath_shorten_at_start:Nn \l_@@_tmpa_tl {(#2)/2}
+ }
+ \seq_put_right:NV \l_@@_tmpd_seq \l_@@_tmpa_tl
+ }
+ \tl_gset:Nx \g_@@_output_tl {\seq_use:Nn \l_@@_tmpd_seq {} }
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_insert_gaps_after_segments:Nnnn #1#2#3#4
+{
+ \@@_insert_gaps_after_segments_aux:nnn {#2}{#3}{#4}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_insert_gaps_after_segments:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_insert_gaps_after_segments:Nnn #1#2#3
+{
+ \@@_insert_gaps_after_segments:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_insert_gaps_after_segments:Nnn {cnn, cVV}
+\cs_new_protected_nopar:Npn \@@_ginsert_gaps_after_segments:Nnnn #1#2#3#4
+{
+ \@@_insert_gaps_after_segments_aux:nnn {#2}{#3}{#4}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_ginsert_gaps_after_segments:Nnnn {NVnn}
+\cs_new_protected_nopar:Npn \@@_ginsert_gaps_after_segments:Nnn #1#2#3
+{
+ \@@_ginsert_gaps_after_segments:NVnn #1#1{#2}{#3}
+}
+\cs_generate_variant:Nn \@@_ginsert_gaps_after_segments:Nnn {cnn, cVV}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_join_components:Nn
+% }
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_join_components_aux:nn #1#2
+{
+ \group_begin:
+
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \spath_numberofcomponents:NV \l_@@_tmpa_int \l_@@_tmpa_tl
+ \@@_seq_from_foreach:NVn \l_@@_tmpa_seq \l_@@_tmpa_int {#2}
+
+ \seq_reverse:N \l_@@_tmpa_seq
+
+ \seq_map_inline:Nn \l_@@_tmpa_seq
+ {
+ \spath_join_component:Nn \l_@@_tmpa_tl {##1}
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_join_components:Nnn #1#2#3
+{
+ \@@_join_components_aux:nn {#2}{#3}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_join_components:Nnn {NVn}
+\cs_new_protected_nopar:Npn \@@_join_components:Nn #1#2
+{
+ \@@_join_components:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \@@_join_components:Nn {cn}
+\cs_new_protected_nopar:Npn \@@_gjoin_components:Nnn #1#2#3
+{
+ \@@_join_components_aux:nn {#2}{#3}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_gjoin_components:Nnn {NVn}
+\cs_new_protected_nopar:Npn \@@_gjoin_components:Nn #1#2
+{
+ \@@_gjoin_components:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \@@_gjoin_components:Nn {cn}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_join_components_with_bezier:Nn
+% }
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_join_components_with_bezier_aux:nn #1#2
+{
+ \group_begin:
+ \tl_set:Nn \l_@@_tmpc_tl {#1}
+ \tl_if_empty:nT {#2}
+ {
+ \spath_spot_weld_components:N \l_@@_tmpc_tl
+ }
+
+ \spath_numberofcomponents:NV \l_@@_tmpa_int \l_@@_tmpc_tl
+ \@@_seq_from_foreach:NVn \l_@@_tmpb_seq \l_@@_tmpa_int {#2}
+
+ \spath_components_to_seq:NV \l_@@_tmpa_seq \l_@@_tmpc_tl
+
+ \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
+ \seq_pop_left:NN \l_@@_tmpb_seq \l_@@_tmpb_tl
+
+ \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ {
+ \int_compare:nTF
+ {
+ ##1 == \l_@@_tmpb_tl
+ }
+ {
+ \seq_pop_left:NNF \l_@@_tmpb_seq \l_@@_tmpb_tl
+ {
+ \tl_set:Nn \l_@@_tmpb_tl {-1}
+ }
+ \spath_curve_between:Nn \l_@@_tmpa_tl {##2}
+ }
+ {
+ \tl_put_right:Nn \l_@@_tmpa_tl {##2}
+ }
+ }
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_join_components_with_bezier:Nnn #1#2#3
+{
+ \@@_join_components_with_bezier_aux:nn {#2}{#3}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_join_components_with_bezier:Nnn {NVn}
+\cs_new_protected_nopar:Npn \@@_join_components_with_bezier:Nn #1#2
+{
+ \@@_join_components_with_bezier:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \@@_join_components_with_bezier:Nn {cV}
+\cs_new_protected_nopar:Npn \@@_gjoin_components_with_bezier:Nnn #1#2#3
+{
+ \@@_join_components_with_bezier_aux:nn {#2}{#3}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_gjoin_components_with_bezier:Nnn {NVn}
+\cs_new_protected_nopar:Npn \@@_gjoin_components_with_bezier:Nn #1#2
+{
+ \@@_gjoin_components_with_bezier:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \@@_gjoin_components_with_bezier:Nn {cV}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{
+% \@@_remove_components:nn
+% }
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_remove_components_aux:nn #1#2
+{
+ \group_begin:
+
+ \spath_numberofcomponents:Nn \l_@@_tmpa_int {#1}
+ \@@_seq_from_foreach:NVn \l_@@_tmpa_seq \l_@@_tmpa_int {#2}
+
+ \spath_components_to_seq:Nn \l_@@_tmpb_seq {#1}
+
+ \seq_pop_left:NNF \l_@@_tmpa_seq \l_@@_tmpa_tl
+ {
+ \tl_clear:N \l_@@_tmpa_tl
+ }
+
+ \seq_clear:N \l_@@_tmpc_seq
+ \seq_map_indexed_inline:Nn \l_@@_tmpb_seq
+ {
+ \tl_set:Nn \l_@@_tmpb_tl {##1}
+ \tl_if_eq:NNTF \l_@@_tmpb_tl \l_@@_tmpa_tl
+ {
+ \seq_pop_left:NNF \l_@@_tmpa_seq \l_@@_tmpa_tl
+ {
+ \tl_clear:N \l_@@_tmpa_tl
+ }
+ }
+ {
+ \seq_put_right:Nn \l_@@_tmpc_seq {##2}
+ }
+ }
+
+ \tl_gset:Nx \g_@@_output_tl {\seq_use:Nn \l_@@_tmpc_seq {} }
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_remove_components:Nnn #1#2#3
+{
+ \@@_remove_components_aux:nn {#2}{#3}
+ \tl_set_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_remove_components:Nnn {NVn}
+\cs_new_protected_nopar:Npn \@@_remove_components:Nn #1#2
+{
+ \@@_remove_components:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \@@_remove_components:Nn {cn}
+\cs_new_protected_nopar:Npn \@@_gremove_components:Nnn #1#2#3
+{
+ \@@_remove_components_aux:nn {#2}{#3}
+ \tl_gset_eq:NN #1 \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_gremove_components:Nnn {NVn}
+\cs_new_protected_nopar:Npn \@@_gremove_components:Nn #1#2
+{
+ \@@_gremove_components:NVn #1#1{#2}
+}
+\cs_generate_variant:Nn \@@_gremove_components:Nn {cn}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}[internal]{
+% \@@_transform_to:nn,
+% \@@_transform_upright_to:nn
+% }
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_transform_to_aux:nn #1#2
+{
+ \group_begin:
+ \spath_reallength:Nn \l_@@_tmpa_int {#2}
+
+ \tl_set:Nx \l_@@_tmpb_tl
+ {\fp_to_decimal:n {(#1) * (\l_@@_tmpa_int)}}
+ \spath_transformation_at:NnV \l_@@_tmpc_tl {#2} \l_@@_tmpb_tl
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpc_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \@@_transform_to:nn #1#2
+{
+ \@@_transform_to_aux:nn {#1}{#2}
+ \exp_last_unbraced:NV \pgfsettransformentries \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_transform_to:nn {nv}
+\cs_new_protected_nopar:Npn \@@_transform_upright_to:nn #1#2
+{
+ \@@_transform_to_aux:nn {#1}{#2}
+ \fp_compare:nT { \tl_item:Nn \g_@@_output_tl {4} < 0}
+ {
+ \tl_gset:Nx \g_@@_output_tl
+ {
+ { \fp_eval:n { - (\tl_item:Nn \g_@@_output_tl {1})} }
+ { \fp_eval:n { - (\tl_item:Nn \g_@@_output_tl {2})} }
+ { \fp_eval:n { - (\tl_item:Nn \g_@@_output_tl {3})} }
+ { \fp_eval:n { - (\tl_item:Nn \g_@@_output_tl {4})} }
+ { \tl_item:Nn \g_@@_output_tl {5} }
+ { \tl_item:Nn \g_@@_output_tl {6} }
+ }
+ }
+ \exp_last_unbraced:NV \pgfsettransformentries \g_@@_output_tl
+ \tl_gclear:N \g_@@_output_tl
+}
+\cs_generate_variant:Nn \@@_transform_upright_to:nn {nv}
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \subsection{Keys}
% Now we define all of our keys.
%
% \begin{macrocode}
@@ -5224,6 +7940,14 @@ manipulating PGF soft paths}
},
% \end{macrocode}
%
+% Hook in to the end of the path construction
+%
+% \begin{macrocode}
+ at~ end~ path~ construction/.code={
+ \tl_put_right:Nn \l_@@_tikzpath_finish_tl {#1}
+ },
+% \end{macrocode}
+%
% Keys for saving and cloning a soft path.
%
% \begin{macrocode}
@@ -5231,8 +7955,8 @@ manipulating PGF soft paths}
\tikz@addmode{
\spath_get_current_path:N \l_@@_tmpa_tl
\spath_bake_round:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
- \spath_save_path:cV
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \spath_bake_shorten:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
+ \spath_save_path:cV {\@@_path_name:n {#1}}
\l_@@_tmpa_tl
}
},
@@ -5240,38 +7964,30 @@ manipulating PGF soft paths}
\tikz@addmode{
\spath_get_current_path:N \l_@@_tmpa_tl
\spath_bake_round:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
- \spath_gsave_path:cV
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \spath_bake_shorten:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
+ \spath_gsave_path:cV {\@@_path_name:n {#1}}
\l_@@_tmpa_tl
}
},
clone/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- {
- \tl_clear_new:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \tl_set_eq:cc
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path:nn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
+ \@@_check_path:nnn {
+ \tl_clear_new:c {\@@_path_name:n {#1}}
+ \tl_set_eq:cc {\@@_path_name:n {#1}}
+ }
}
+ {#2}{}
},
clone~ global/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- {
- \tl_gclear_new:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \tl_gset_eq:cc
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path:nn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
+ \@@_check_path:nnn {
+ \tl_gclear_new:c {\@@_path_name:n {#1}}
+ \tl_gset_eq:cc {\@@_path_name:n {#1}}
+ }
}
+ {#2}{}
},
% \end{macrocode}
%
@@ -5279,15 +7995,14 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
save~ to~ aux/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path:nn
{
- \spath_save_to_aux:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \@@_check_path:nnn {
+ \spath_save_to_aux:c
+ }
}
+ {#1}
+ {}
},
% \end{macrocode}
%
@@ -5295,15 +8010,14 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
export~ to~ svg/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_export_to_svg:nv {#1}
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path:nn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \@@_check_path:nnn {
+ \spath_export_to_svg:nv {#1}
+ }
}
+ {#1}
+ {}
},
% \end{macrocode}
%
@@ -5317,6 +8031,8 @@ manipulating PGF soft paths}
\bool_set_false:N \l_@@_reverse_bool
\bool_set_false:N \l_@@_weld_bool
\bool_set_false:N \l_@@_move_bool
+ \bool_set_false:N \l_@@_current_transformation_bool
+ \bool_set_true:N \l_spath_movetorelevant_bool
\tl_clear:N \l_@@_joinpath_tl
\tl_clear:N \l_@@_transformation_tl
\tikzset{
@@ -5324,103 +8040,11 @@ manipulating PGF soft paths}
#1
}
- \tl_if_exist:cTF
+ \@@_check_path:nVn
{
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_joinpath_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {
- \tl_if_empty:cT
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_joinpath_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {
- \msg_warning:nnn { spath3 } { empty soft path } { #1 }
- }
- \tl_set_eq:Nc \l_@@_joinpath_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_joinpath_tl
- \tl_use:N \l_@@_suffix_tl
- }
- \spath_get_current_path:N \l_@@_current_tl
-
- \bool_if:NT \l_@@_reverse_bool
- {
- \spath_reverse:N \l_@@_joinpath_tl
- }
-
- \tl_if_empty:NF \l_@@_transformation_tl
- {
- \group_begin:
- \pgftransformreset
- \@@_tikzset:V \l_@@_transformation_tl
- \pgfgettransform \l_@@_tmpa_tl
- \tl_gset:Nn \g_@@_smuggle_tl
- {
- \spath_transform:Nnnnnnn
- \l_@@_joinpath_tl
- }
- \tl_gput_right:NV \g_@@_smuggle_tl \l_@@_tmpa_tl
- \group_end:
- \tl_use:N \g_@@_smuggle_tl
- }
-
- \bool_if:NT \l_@@_move_bool
- {
- \tl_if_empty:NTF \l_@@_current_tl
- {
- \tl_set:Nn \l_@@_tmpc_tl { {0pt} {0pt} }
- }
- {
- \spath_finalpoint:NV
- \l_@@_tmpc_tl
- \l_@@_current_tl
- }
- \spath_translate_to:NV \l_@@_joinpath_tl \l_@@_tmpc_tl
- }
-
- \tl_if_empty:NTF \l_@@_current_tl
- {
- \tl_if_empty:NTF \l_@@_joinpath_tl
- {
- \tl_set_eq:NN \l_@@_current_tl \c_spath_moveto_tl
- \tl_put_right:Nn \l_@@_current_tl {{0pt}{0pt}}
- }
- {
- \tl_set_eq:NN \l_@@_current_tl \l_@@_joinpath_tl
- }
- }
- {
-
- \tl_clear:N \l_@@_tmpa_tl
- \tl_set:Nn \l_@@_tmpa_tl {spath_}
-
- \tl_put_right:Nn \l_@@_tmpa_tl {append}
-
- \bool_if:NT \l_@@_weld_bool
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {_no_move}
- }
- \tl_put_right:Nn \l_@@_tmpa_tl {:NV}
-
- \use:c {\tl_use:N \l_@@_tmpa_tl }
- \l_@@_current_tl
- \l_@@_joinpath_tl
- }
+ \@@_use_path:v
+ } \l_@@_joinpath_tl {}
- \spath_set_current_path:N \l_@@_current_tl
- \spath_set_tikz_data:V \l_@@_joinpath_tl
- }
- {
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- {\tl_use:N \l_@@_joinpath_tl }
- }
},
% \end{macrocode}
%
@@ -5453,23 +8077,10 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
show/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \tl_if_empty:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \msg_warning:nnn { spath3 } { empty soft path } { #1 }
- }
- {
- \iow_term:n {---~ soft~ path~ #1~ ---}
- \spath_show:v
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn {
+ \iow_term:n {---~ soft~ path~ #1~ ---}
+ \spath_show:v
+ } {#1} {}
},
% \end{macrocode}
%
@@ -5479,98 +8090,25 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
join~ with/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \bool_set_false:N \l_@@_reverse_bool
- \bool_set_false:N \l_@@_weld_bool
- \bool_set_false:N \l_@@_move_bool
- \bool_set_false:N \l_@@_global_bool
- \tl_clear:N \l_@@_joinpath_tl
- \tl_clear:N \l_@@_transformation_tl
- \tikzset{
- spath/join/.cd,
- #2
- }
-
- \tl_if_exist:cTF
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_joinpath_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {
- \tl_set_eq:Nc \l_@@_joinpath_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_joinpath_tl
- \tl_use:N \l_@@_suffix_tl
- }
-
- \bool_if:NT \l_@@_reverse_bool
- {
- \spath_reverse:N \l_@@_joinpath_tl
- }
-
- \tl_if_empty:NF \l_@@_transformation_tl
- {
- \group_begin:
- \pgftransformreset
- \@@_tikzset:V \l_@@_transformation_tl
- \pgfgettransform \l_@@_tmpa_tl
- \tl_gset:Nn \g_@@_smuggle_tl
- {
- \spath_transform:Nnnnnnn
- \l_@@_joinpath_tl
- }
- \tl_gput_right:NV \g_@@_smuggle_tl \l_@@_tmpa_tl
- \group_end:
- \tl_use:N \g_@@_smuggle_tl
- }
-
- \bool_if:NT \l_@@_move_bool
- {
- \spath_finalpoint:Nv
- \l_@@_tmpc_tl
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \spath_translate_to:NV \l_@@_joinpath_tl \l_@@_tmpc_tl
- }
-
- \tl_clear:N \l_@@_tmpa_tl
- \tl_set:Nn \l_@@_tmpa_tl {spath_}
-
- \bool_if:NT \l_@@_global_bool
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {g}
- }
-
- \tl_put_right:Nn \l_@@_tmpa_tl {append}
-
- \bool_if:NT \l_@@_weld_bool
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {_no_move}
- }
- \tl_put_right:Nn \l_@@_tmpa_tl {:cV}
+ \bool_set_false:N \l_@@_reverse_bool
+ \bool_set_false:N \l_@@_weld_bool
+ \bool_set_false:N \l_@@_move_bool
+ \bool_set_false:N \l_@@_global_bool
+ \bool_set_false:N \l_@@_current_transformation_bool
+ \tl_clear:N \l_@@_joinpath_tl
+ \tl_clear:N \l_@@_transformation_tl
+ \tikzset{
+ spath/join/.cd,
+ #2
+ }
- \cs_if_exist:cF {\tl_use:N \l_@@_tmpa_tl}
- {
- \tl_show:N \l_@@_tmpa_tl
- }
-
- \use:c {\tl_use:N \l_@@_tmpa_tl }
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_joinpath_tl
- }
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_two_paths:nnVn
{
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- {\tl_use:N \l_@@_joinpath_tl }
+ \@@_join_with:cv
}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { \l_@@_joinpath_tl {} }
},
% \end{macrocode}
%
@@ -5578,26 +8116,22 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
spot~ weld/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_spot_weld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_spot_weld_components:c
+ }
+ } {#1} { {} }
},
spot~ weld~ globally/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_spot_gweld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_spot_gweld_components:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
@@ -5605,26 +8139,22 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
reverse/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_reverse:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_reverse:c
+ }
+ } {#1} { {} }
},
reverse~ globally/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_reverse:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_greverse:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
@@ -5632,32 +8162,26 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
span/.code ~n~ args={3}{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \@@_process_tikz_point:Nn \l_@@_tmpa_tl {#2}
- \@@_process_tikz_point:Nn \l_@@_tmpb_tl {#3}
- \spath_span:cVV
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_tmpa_tl \l_@@_tmpb_tl
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \@@_process_tikz_point:Nn \l_@@_tmpa_tl {#2}
+ \@@_process_tikz_point:Nn \l_@@_tmpb_tl {#3}
+ \spath_span:cVV
+ }
+ } {#1} { {} \l_@@_tmpa_tl \l_@@_tmpb_tl }
},
span~ global/.code ~n~ args={3}{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \@@_process_tikz_point:Nn \l_@@_tmpa_tl {#2}
- \@@_process_tikz_point:Nn \l_@@_tmpb_tl {#3}
- \spath_gspan:cVV
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_tmpa_tl \l_@@_tmpb_tl
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \@@_process_tikz_point:Nn \l_@@_tmpa_tl {#2}
+ \@@_process_tikz_point:Nn \l_@@_tmpb_tl {#3}
+ \spath_span:cVV
+ }
+ } {#1} { {} \l_@@_tmpa_tl \l_@@_tmpb_tl }
},
% \end{macrocode}
%
@@ -5668,69 +8192,34 @@ manipulating PGF soft paths}
to~path={
[
spath/span={#1}{(\tikztostart)}{(\tikztotarget)},
- spath/append~no~move={#1},
+ spath/use={#1,weld},
]
\tikztonodes
}
},
% \end{macrocode}
%
+%
% Splice three paths together, transforming the middle one so that it exactly fits between the first and third.
%
% \begin{macrocode}
splice/.code ~n~ args={3}{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- {
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #3 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_splice_between:cvv
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #3 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #3 }
- }
- }
+ \@@_check_three_paths:nnnnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
+ \spath_splice_between:cvv
}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {#2} {#3} {} }
},
splice~ global/.code ~n~ args={3}{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- {
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #3 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_gsplice_between:cvv
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #3 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #3 }
- }
- }
+ \@@_check_three_paths:nnnnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
+ \spath_gsplice_between:cvv
}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {#2} {#3} {} }
},
% \end{macrocode}
%
@@ -5742,447 +8231,177 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
join~ components~ with/.code~2~args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \tl_if_head_is_group:nTF {#2}
{
- \tl_if_head_is_group:nTF {#2}
- {
- \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
- \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
- }
- {
- \tl_set:Nn \l_@@_tmpc_tl {#2}
- \tl_clear:N \l_@@_tmpd_tl
- }
- \tl_if_exist:cTF
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {
- \tl_if_empty:NT \l_@@_tmpd_tl
- {
- \spath_spot_weld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
-
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \seq_gclear:N \g_@@_tmpa_seq
-
- \tl_if_empty:NTF \l_@@_tmpd_tl
- {
- \int_step_inline:nnnn {1}{1} {\seq_count:N \l_@@_tmpa_seq}
- {
- \seq_gput_right:Nn \g_@@_tmpa_seq {##1}
- }
- }
- {
- \foreach \l_@@_tmpa_tl in \l_@@_tmpd_tl
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} < {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- }
-
- \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
- \seq_gpop_left:NN \g_@@_tmpa_seq \l_@@_tmpb_tl
-
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
- {
- \int_compare:nTF
- {
- ##1 == \l_@@_tmpb_tl
- }
- {
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpb_tl
- {
- \tl_set:Nn \l_@@_tmpb_tl {-1}
- }
- \spath_splice_between:Nvn \l_@@_tmpa_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {##2}
- }
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {##2}
- }
- }
- \tl_set_eq:cN
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_tmpa_tl
- }
- {
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- { \tl_use:N \l_@@_tmpc_tl }
- }
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
}
- },
- join~ components~ globally~ with/.code~2~args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+
+ \@@_maybe_current_path_reuse:nnn
{
- \tl_if_head_is_group:nTF {#2}
- {
- \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
- \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
- }
- {
- \tl_set:Nn \l_@@_tmpc_tl {#2}
- \tl_clear:N \l_@@_tmpd_tl
- }
- \tl_if_exist:cTF
+ \@@_check_two_paths:nnVn
{
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
+ \@@_join_components_with:cvV
}
- {
- \tl_if_empty:NT \l_@@_tmpd_tl
- {
- \spath_spot_weld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
-
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \seq_gclear:N \g_@@_tmpa_seq
-
- \tl_if_empty:NTF \l_@@_tmpd_tl
- {
- \int_step_inline:nnnn {1}{1} {\seq_count:N \l_@@_tmpa_seq}
- {
- \seq_gput_right:Nn \g_@@_tmpa_seq {##1}
- }
- }
- {
- \foreach \l_@@_tmpa_tl in \l_@@_tmpd_tl
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} < {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- }
-
- \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
- \seq_gpop_left:NN \g_@@_tmpa_seq \l_@@_tmpb_tl
+ } {#1} { \l_@@_tmpc_tl {} \l_@@_tmpd_tl }
+ },
+ join~ components~ globally~ with/.code~2~args={
+ \tl_if_head_is_group:nTF {#2}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
+ }
+ {
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
+ }
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
- {
- \int_compare:nTF
- {
- ##1 == \l_@@_tmpb_tl
- }
- {
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpb_tl
- {
- \tl_set:Nn \l_@@_tmpb_tl {-1}
- }
- \spath_splice_between:Nvn \l_@@_tmpa_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {##2}
- }
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {##2}
- }
- }
- \tl_gset_eq:cN
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_tmpa_tl
- }
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_two_paths:nnVn
{
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- { \tl_use:N \l_@@_tmpc_tl }
+ \@@_gjoin_components_with:cvV
}
+ } {#1} { \l_@@_tmpc_tl {} \l_@@_tmpd_tl }
+ },
+ join~ components~ upright~ with/.code~2~args={
+ \tl_if_head_is_group:nTF {#2}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
}
- },
- join~ components~ upright~ with/.code~2~args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+
+ \@@_maybe_current_path_reuse:nnn
{
- \tl_if_head_is_group:nTF {#2}
- {
- \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
- \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
- }
- {
- \tl_set:Nn \l_@@_tmpc_tl {#2}
- \tl_clear:N \l_@@_tmpd_tl
- }
- \tl_if_exist:cTF
+ \@@_check_two_paths:nnVn
{
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
+ \@@_join_components_upright_with:cvV
}
- {
- \tl_if_empty:NT \l_@@_tmpd_tl
- {
- \spath_spot_weld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
-
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \seq_gclear:N \g_@@_tmpa_seq
-
- \tl_if_empty:NTF \l_@@_tmpd_tl
- {
- \int_step_inline:nnnn {1}{1} {\seq_count:N \l_@@_tmpa_seq}
- {
- \seq_gput_right:Nn \g_@@_tmpa_seq {##1}
- }
- }
- {
- \foreach \l_@@_tmpa_tl in \l_@@_tmpd_tl
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} < {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- }
-
- \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
- \seq_gpop_left:NN \g_@@_tmpa_seq \l_@@_tmpb_tl
-
- \tl_set_eq:Nc \l_@@_tmpc_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
- }
- \spath_transform:NVnnnnnn \l_@@_tmpd_tl \l_@@_tmpc_tl {1}{0}{0}{-1}{0pt}{0pt}
-
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
- {
- \int_compare:nTF
- {
- ##1 == \l_@@_tmpb_tl
- }
- {
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpb_tl
- {
- \tl_set:Nn \l_@@_tmpb_tl {-1}
- }
- \spath_finalpoint:NV \l_@@_tmpe_tl \l_@@_tmpa_tl
- \spath_initialpoint:Nn \l_@@_tmpf_tl {##2}
+ } {#1} { \l_@@_tmpc_tl {} \l_@@_tmpd_tl }
+ },
+ join~ components~ globally~ upright~ with/.code~2~args={
+ \tl_if_head_is_group:nTF {#2}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
+ }
+ {
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
+ }
- \dim_compare:nTF
- {
- \tl_item:Nn \l_@@_tmpe_tl {1}
- >
- \tl_item:Nn \l_@@_tmpf_tl {1}
- }
- {
- \spath_splice_between:NVn
- \l_@@_tmpa_tl
- \l_@@_tmpd_tl
- {##2}
- }
- {
- \spath_splice_between:NVn
- \l_@@_tmpa_tl
- \l_@@_tmpc_tl
- {##2}
- }
- }
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {##2}
- }
- }
- \tl_set_eq:cN
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_tmpa_tl
- }
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_two_paths:nnVn
{
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- { \tl_use:N \l_@@_tmpc_tl }
+ \@@_gjoin_components_upright_with:cvV
}
+ } {#1} { \l_@@_tmpc_tl {} \l_@@_tmpd_tl }
+ },
+ join~ components~ with~ bezier/.code={
+ \tl_if_head_is_group:nTF {#1}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#1} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#1} {2} }
}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \tl_set:Nn \l_@@_tmpc_tl {#1}
+ \tl_clear:N \l_@@_tmpd_tl
}
- },
- join~ components~ globally~ upright~ with/.code~2~args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+
+ \@@_maybe_current_path_reuse:nVn
{
- \tl_if_head_is_group:nTF {#2}
+ \@@_check_path:nnn
{
- \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
- \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
+ \@@_join_components_with_bezier:cV
}
+ } \l_@@_tmpc_tl { {} \l_@@_tmpd_tl }
+ },
+ join~ components~ globally~ with~ bezier/.code~2~args={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \tl_set:Nn \l_@@_tmpc_tl {#2}
- \tl_clear:N \l_@@_tmpd_tl
+ \@@_gjoin_components_with_bezier:cn
}
- \tl_if_exist:cTF
+ } {#1} { {} {#2} }
+ },
+% \end{macrocode}
+%
+% Close a path.
+%
+% \begin{macrocode}
+ close/.code={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
+ \spath_close:c
}
+ } {#1} { {} }
+ },
+ close~ globally/.code={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \tl_if_empty:NT \l_@@_tmpd_tl
- {
- \spath_spot_weld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
-
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \seq_gclear:N \g_@@_tmpa_seq
-
- \tl_if_empty:NTF \l_@@_tmpd_tl
- {
- \int_step_inline:nnnn {1}{1} {\seq_count:N \l_@@_tmpa_seq}
- {
- \seq_gput_right:Nn \g_@@_tmpa_seq {##1}
- }
- }
- {
- \foreach \l_@@_tmpa_tl in \l_@@_tmpd_tl
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} < {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- }
-
- \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
- \seq_gpop_left:NN \g_@@_tmpa_seq \l_@@_tmpb_tl
-
- \tl_set_eq:Nc \l_@@_tmpc_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpc_tl
- \tl_use:N \l_@@_suffix_tl
- }
- \spath_transform:NVnnnnnn \l_@@_tmpd_tl \l_@@_tmpc_tl {1}{0}{0}{-1}{0pt}{0pt}
-
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
- {
- \int_compare:nTF
- {
- ##1 == \l_@@_tmpb_tl
- }
- {
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpb_tl
- {
- \tl_set:Nn \l_@@_tmpb_tl {-1}
- }
- \spath_finalpoint:NV \l_@@_tmpe_tl \l_@@_tmpa_tl
- \spath_initialpoint:Nn \l_@@_tmpf_tl {##2}
-
- \dim_compare:nTF
- {
- \tl_item:Nn \l_@@_tmpe_tl {1}
- >
- \tl_item:Nn \l_@@_tmpf_tl {1}
- }
- {
- \spath_splice_between:NVn
- \l_@@_tmpa_tl
- \l_@@_tmpd_tl
- {##2}
- }
- {
- \spath_splice_between:NVn
- \l_@@_tmpa_tl
- \l_@@_tmpc_tl
- {##2}
- }
- }
- {
- \tl_put_right:Nn \l_@@_tmpa_tl {##2}
- }
- }
- \tl_gset_eq:cN
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \l_@@_tmpa_tl
+ \spath_gclose:c
}
+ } {#1} { {} }
+ },
+% \end{macrocode}
+%
+% Open a path.
+%
+% \begin{macrocode}
+ open/.code={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- { \tl_use:N \l_@@_tmpc_tl }
+ \spath_open:c
}
- }
+ } {#1} { {} }
+ },
+ open~ globally/.code={
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gopen:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
-% Close a path.
+% Close a path, ensuring that the end point is exactly where it will close up to.
%
% \begin{macrocode}
- close/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_close:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ adjust~ and~ close/.code={
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_adjust_close:c
+ }
+ } {#1} { {} }
},
- close~ globally/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_gclose:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ adjust~ and~ close~ globally/.code={
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_adjust_gclose:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
@@ -6190,117 +8409,191 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
close~ with/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \@@_check_two_paths:nnnn
{
\spath_close_with:cv
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
- }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {#2} {} }
},
close~ globally~ with/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \@@_check_two_paths:nnnn
{
\spath_gclose_with:cv
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
}
+ } {#1} { {#2} {} }
+ },
+% \end{macrocode}
+%
+% Close a path with a curve.
+%
+% \begin{macrocode}
+ close~ with~ curve/.code={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
+ \spath_close_with_curve:c
}
- }
+ } {#1} { {} }
+ },
+ close~ globally~ with~ curve/.code={
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gclose_with_curve:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
-% These keys shorten the path.
+% These keys shorten the path by a dimension.
%
% \begin{macrocode}
shorten~ at~ end/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_shorten_at_end:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_shorten_at_end:cn
+ }
+ } {#1} { {} {#2} }
},
shorten~ at~ start/.code~ 2~ args ={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_shorten_at_start:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_shorten_at_start:cn
+ }
+ } {#1} { {} {#2} }
},
shorten~ at~ both~ ends/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_shorten_at_end:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- \spath_shorten_at_start:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_shorten_at_both_ends:cn
+ }
+ } {#1} { {} {#2} }
},
shorten~ globally~ at~ end/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_gshorten_at_end:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gshorten_at_end:cn
+ }
+ } {#1} { {} {#2} }
},
shorten~ globally~ at~ start/.code~ 2~ args ={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_gshorten_at_start:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gshorten_at_start:cn
+ }
+ } {#1} { {} {#2} }
},
shorten~ globally~ at~ both~ ends/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_shorten_at_end:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- \spath_shorten_at_start:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl} {#2}
- }
+ \@@_check_path:nnn
+ {
+ \spath_gshorten_at_both_ends:cn
+ }
+ } {#1} { {} {#2} }
+ },
+% \end{macrocode}
+%
+% These keys split a path at a parameter, the \texttt{keep} versions only keep one part of the resultant path.
+%
+% \begin{macrocode}
+ split~ at/.code~ 2~ args={
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_split_at_normalised:cn
+ }
+ } {#1} { {} {#2} }
+ },
+ split~ globally~ at/.code~ 2~ args={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_gsplit_at_normalised:cn
+ }
+ } {#1} { {} {#2} }
+ },
+ split~ at~ into/.code~ n~ args={4}{
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_split_at_normalised:ccvn {\@@_path_name:n {#1}}
+ {\@@_path_name:n {#2}}
+ }
+ } {#3} { {} {#4} }
+ },
+ split~ globally~ at~ into/.code~ n~ args={4}{
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_gsplit_at_normalised:ccvn {\@@_path_name:n {#1}}
+ {\@@_path_name:n {#2}}
+ }
+ } {#3} { {} {#4} }
+ },
+ split~ at~ keep~ start/.code~ 2~ args={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_split_at_normalised_keep_start:cn
+ }
+ } {#1} { {} {#2} }
+ },
+ split~ globally~ at~ keep~ start/.code~ 2~ args={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_gsplit_at_normalised_keep_start:cn
+ }
+ } {#1} { {} {#2} }
+ },
+ split~ at~ keep~ end/.code~ 2~ args={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_split_at_normalised_keep_end:cn
+ }
+ } {#1} { {} {#2} }
+ },
+ split~ globally~ at~ keep~ end/.code~ 2~ args={
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \spath_gsplit_at_normalised_keep_end:cn
+ }
+ } {#1} { {} {#2} }
+ },
+ split~ at~ keep~ middle/.style~ n~ args={3}{
+ /tikz/spath/split~ at~ keep~ start={#1}{#3},
+ /tikz/spath/split~ at~ keep~ end={#1}{(#2)/(#3)},
+ },
+ split~ globally~ at~ keep~ middle/.style~ n~ args={3}{
+ /tikz/spath/split~ globally~ at~ keep~ start={#1}{#3},
+ /tikz/spath/split~ globally~ at~ keep~ end={#1}{(#2)/(#3)},
},
% \end{macrocode}
%
@@ -6308,26 +8601,22 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
translate/.code~ n~ args={3}{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_translate:cnn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}{#2}{#3}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_translate:cnn
+ }
+ } {#1} { {} {#2}{#3} }
},
translate~ globally/.code~ n~ args={3}{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_gtranslate:cnn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}{#2}{#3}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gtranslate:cnn
+ }
+ } {#1} { {} {#2}{#3} }
},
% \end{macrocode}
%
@@ -6335,26 +8624,22 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
normalise/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_normalise:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_normalise:c
+ }
+ } {#1} { {} }
},
normalise~ globally/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_gnormalise:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gnormalise:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
@@ -6362,75 +8647,55 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
transform/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \group_begin:
+ \pgftransformreset
+ \tikzset{#2}
+ \pgfgettransform \l_@@_tmpa_tl
+ \tl_gset_eq:NN \g_@@_smuggle_tl \l_@@_tmpa_tl
+ \group_end:
+
+ \@@_maybe_current_path_reuse:nnn
{
- \group_begin:
- \pgftransformreset
- \tikzset{#2}
- \pgfgettransform \l_@@_tmpa_tl
- \tl_gset:Nn \g_@@_smuggle_tl
+ \@@_check_path:nnn
{
- \spath_transform:cnnnnnn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \spath_transform:cV
}
- \tl_gput_right:NV \g_@@_smuggle_tl \l_@@_tmpa_tl
- \group_end:
- \tl_use:N \g_@@_smuggle_tl
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {} \g_@@_smuggle_tl }
},
transform~globally/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \group_begin:
+ \pgftransformreset
+ \tikzset{#2}
+ \pgfgettransform \l_@@_tmpa_tl
+ \tl_gset_eq:NN \g_@@_smuggle_tl \l_@@_tmpa_tl
+ \group_end:
+
+ \@@_maybe_current_path_reuse:nnn
{
- \group_begin:
- \pgftransformreset
- \tikzset{#2}
- \pgfgettransform \l_@@_tmpa_tl
- \tl_gset:Nn \g_@@_smuggle_tl
+ \@@_check_path:nnn
{
- \spath_gtransform:cnnnnnn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \spath_gtransform:cV
}
- \tl_gput_right:NV \g_@@_smuggle_tl \l_@@_tmpa_tl
- \group_end:
- \tl_use:N \g_@@_smuggle_tl
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {} \g_@@_smuggle_tl }
},
% \end{macrocode}
%
% Splits first path where it intersects with the second.
%
% \begin{macrocode}
- split~ at~ intersections~ with/.code~ n~ args={2}{
+ split~ at~ intersections~ with/.code~ 2~ args={
\tl_if_exist:cTF
{
tikz@library@intersections@loaded
}
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_two_paths_reuse_first:nnnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \@@_check_two_paths:nnnn
{
- \spath_split_path_at_intersections:cv
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \spath_split_path_at_intersections:cv
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
- }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} {#2} { {} }
}
{
\msg_warning:nn { spath3 } { load intersections }
@@ -6442,23 +8707,13 @@ manipulating PGF soft paths}
tikz@library@intersections@loaded
}
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_two_paths_reuse_first:nnnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \@@_check_two_paths:nnnn
{
\spath_gsplit_path_at_intersections:cv
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
- }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} {#2} { {} }
}
{
\msg_warning:nn { spath3 } { load intersections }
@@ -6475,23 +8730,13 @@ manipulating PGF soft paths}
tikz@library@intersections@loaded
}
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_two_paths_reuse_both:nnnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \@@_check_two_paths:nnnn
{
\spath_split_at_intersections:cc
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
- }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} {#2} { {} }
}
{
\msg_warning:nn { spath3 } { load intersections }
@@ -6503,23 +8748,13 @@ manipulating PGF soft paths}
tikz@library@intersections@loaded
}
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_two_paths_reuse_both:nnnn
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
+ \@@_check_two_paths:nnnn
{
\spath_gsplit_at_intersections:cc
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\tl_use:N \l_@@_prefix_tl #2 \tl_use:N \l_@@_suffix_tl}
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #2 }
- }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} {#2} { {} }
}
{
\msg_warning:nn { spath3 } { load intersections }
@@ -6536,15 +8771,13 @@ manipulating PGF soft paths}
tikz@library@intersections@loaded
}
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_split_at_self_intersections:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_split_at_self_intersections:c
+ }
+ } {#1} { {} }
}
{
\msg_warning:nn { spath3 } { load intersections }
@@ -6556,15 +8789,13 @@ manipulating PGF soft paths}
tikz@library@intersections@loaded
}
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_gsplit_at_self_intersections:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gsplit_at_self_intersections:c
+ }
+ } {#1} { {} }
}
{
\msg_warning:nn { spath3 } { load intersections }
@@ -6576,64 +8807,24 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
get~ components~ of/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path:nn
{
- \clist_clear_new:N #2
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \seq_map_inline:Nn \l_@@_tmpa_seq
- {
- \tl_new:c
- {
- \tl_use:N \l_@@_prefix_tl
- anonymous_\int_use:N \g_@@_anon_int
- \tl_use:N \l_@@_suffix_tl
- }
- \tl_set:cn
- {
- \tl_use:N \l_@@_prefix_tl
- anonymous_\int_use:N \g_@@_anon_int
- \tl_use:N \l_@@_suffix_tl
- } {##1}
- \clist_put_right:Nx #2 {anonymous_\int_use:N \g_@@_anon_int}
- \int_gincr:N \g_@@_anon_int
+ \@@_check_path:nnn {
+ \@@_get_components:Nv #2
}
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ {#1}
+ {}
},
get~ components~ of~ globally/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path:nn
{
- \clist_gclear_new:N #2
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \seq_map_inline:Nn \l_@@_tmpa_seq
- {
- \tl_new:c
- {
- \tl_use:N \l_@@_prefix_tl
- anonymous_\int_use:N \g_@@_anon_int
- \tl_use:N \l_@@_suffix_tl
- }
- \tl_gset:cn
- {
- \tl_use:N \l_@@_prefix_tl
- anonymous_\int_use:N \g_@@_anon_int
- \tl_use:N \l_@@_suffix_tl
- } {##1}
- \clist_gput_right:Nx #2 {anonymous_\int_use:N \g_@@_anon_int}
- \int_gincr:N \g_@@_anon_int
+ \@@_check_path:nnn {
+ \@@_gget_components:Nv #2
}
}
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ {#1}
+ {}
},
% \end{macrocode}
%
@@ -6641,33 +8832,14 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
render~ components/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path:nn
{
- \group_begin:
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
- {
- \spath_tikz_path:nn
- {
- every~ spath~ component/.try,
- spath ~component~ ##1/.try,
- spath ~component/.try={##1},
- every~ #1~ component/.try,
- #1 ~component~ ##1/.try,
- #1 ~component/.try={##1},
- }
- {
- ##2
- }
+ \@@_check_path:nnn {
+ \@@_render_components:nv {#1}
}
- \group_end:
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
}
+ {#1}
+ {}
},
% \end{macrocode}
%
@@ -6676,148 +8848,86 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
insert~ gaps~ after~ components/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \tl_if_head_is_group:nTF {#2}
{
- \group_begin:
- \tl_if_head_is_group:nTF {#2}
- {
- \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
- \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
- }
- {
- \tl_set:Nn \l_@@_tmpc_tl {#2}
- \tl_clear:N \l_@@_tmpd_tl
- }
- \seq_gclear:N \g_@@_tmpa_seq
- \seq_gclear:N \g_@@_tmpb_seq
- \spath_numberofcomponents:Nv \l_@@_tmpa_int
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \tl_if_empty:NTF \l_@@_tmpd_tl
- {
- \int_step_inline:nnnn {1}{1} { \l_@@_tmpa_int - 1 }
- {
- \seq_gput_right:Nn \g_@@_tmpa_seq {##1}
- \seq_gput_right:Nx
- \g_@@_tmpb_seq
- {\int_eval:n {##1 + 1}}
- }
- }
- {
- \foreach \l_@@_tmpa_tl in \l_@@_tmpd_tl
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- \seq_gput_right:Nx
- \g_@@_tmpb_seq
- {\int_eval:n
- {
- \int_mod:nn { \l_@@_tmpa_tl }{ \l_@@_tmpa_int } + 1
- }
- }
- }
- }
-
- \seq_clear:N \l_@@_tmpb_seq
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
- {
- \tl_set:Nn \l_@@_tmpa_tl {##2}
- \seq_if_in:NnT \g_@@_tmpa_seq {##1}
- {
- \spath_shorten_at_end:Nn \l_@@_tmpa_tl {\l_@@_tmpc_tl/2}
- }
- \seq_if_in:NnT \g_@@_tmpb_seq {##1}
- {
- \spath_shorten_at_start:Nn \l_@@_tmpa_tl {\l_@@_tmpc_tl/2}
- }
- \seq_put_right:NV \l_@@_tmpb_seq \l_@@_tmpa_tl
- }
- \tl_gset:Nx \g_@@_output_tl {\seq_use:Nn \l_@@_tmpb_seq {} }
- \group_end:
- \tl_set_eq:cN
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \g_@@_output_tl
- \tl_gclear:N \g_@@_output_tl
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
}
- },
- insert~ gaps~ globally~ after~ components/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+
+ \@@_maybe_current_path_reuse:nnn
{
- \group_begin:
- \tl_if_head_is_group:nTF {#2}
- {
- \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
- \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
- }
+ \@@_check_path:nnn
{
- \tl_set:Nn \l_@@_tmpc_tl {#2}
- \tl_clear:N \l_@@_tmpd_tl
+ \@@_insert_gaps_after_components:cVV
}
- \seq_gclear:N \g_@@_tmpa_seq
- \seq_gclear:N \g_@@_tmpb_seq
- \spath_numberofcomponents:Nv \l_@@_tmpa_int
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ } {#1} { {} \l_@@_tmpc_tl \l_@@_tmpd_tl }
+ },
+ insert~ gaps~ globally~ after~ components/.code~ 2~ args={
+ \tl_if_head_is_group:nTF {#2}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
+ }
+ {
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
+ }
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
-
- \tl_if_empty:NTF \l_@@_tmpd_tl
- {
- \int_step_inline:nnnn {1}{1} { \l_@@_tmpa_int - 1 }
- {
- \seq_gput_right:Nn \g_@@_tmpa_seq {##1}
- \seq_gput_right:Nx
- \g_@@_tmpb_seq
- {\int_eval:n {##1 + 1}}
- }
- }
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \foreach \l_@@_tmpa_tl in \l_@@_tmpd_tl
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- \seq_gput_right:Nx
- \g_@@_tmpb_seq
- {\int_eval:n
- {
- \int_mod:nn { \l_@@_tmpa_tl }{ \l_@@_tmpa_int } + 1
- }
- }
- }
+ \@@_ginsert_gaps_after_components:cVV
}
+ } {#1} { {} \l_@@_tmpc_tl \l_@@_tmpd_tl }
+ },
+% \end{macrocode}
+%
+% This puts gaps between segments of a soft path.
+% The list of segments is passed through a \Verb+\foreach+ loop so can use the shortcut syntax from those loops.
+%
+% \begin{macrocode}
+ insert~ gaps~ after~ segments/.code~ 2~ args={
+ \tl_if_head_is_group:nTF {#2}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
+ }
+ {
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
+ }
- \seq_clear:N \l_@@_tmpb_seq
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
{
- \tl_set:Nn \l_@@_tmpa_tl {##2}
- \seq_if_in:NnT \g_@@_tmpa_seq {##1}
- {
- \spath_shorten_at_end:Nn \l_@@_tmpa_tl {\l_@@_tmpc_tl/2}
- }
- \seq_if_in:NnT \g_@@_tmpb_seq {##1}
- {
- \spath_shorten_at_start:Nn \l_@@_tmpa_tl {\l_@@_tmpc_tl/2}
- }
- \seq_put_right:NV \l_@@_tmpb_seq \l_@@_tmpa_tl
+ \@@_insert_gaps_after_segments:cVV
}
- \tl_gset:Nx \g_@@_output_tl {\seq_use:Nn \l_@@_tmpb_seq {} }
- \group_end:
- \tl_gset_eq:cN
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \g_@@_output_tl
- \tl_gclear:N \g_@@_output_tl
+ } {#1} { {} \l_@@_tmpc_tl \l_@@_tmpd_tl }
+ },
+ insert~ gaps~ globally~ after~ segments/.code~ 2~ args={
+ \tl_if_head_is_group:nTF {#2}
+ {
+ \tl_set:Nx \l_@@_tmpc_tl { \tl_item:nn {#2} {1} }
+ \tl_set:Nx \l_@@_tmpd_tl { \tl_item:nn {#2} {2} }
}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
+ \tl_set:Nn \l_@@_tmpc_tl {#2}
+ \tl_clear:N \l_@@_tmpd_tl
}
+
+ \@@_maybe_current_path_reuse:nnn
+ {
+ \@@_check_path:nnn
+ {
+ \@@_ginsert_gaps_after_segments:cVV
+ }
+ } {#1} { {} \l_@@_tmpc_tl \l_@@_tmpd_tl }
},
% \end{macrocode}
%
@@ -6825,54 +8935,22 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
join~ components/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \seq_gclear:N \g_@@_tmpa_seq
- \foreach \l_@@_tmpa_tl in {#2}
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} > {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- \seq_map_inline:Nn \g_@@_tmpa_seq
+ \@@_check_path:nnn
{
- \spath_join_component:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}{##1}
+ \@@_join_components:cn
}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {} {#2} }
},
join~ components~ globally/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \seq_gclear:N \g_@@_tmpa_seq
- \foreach \l_@@_tmpa_tl in {#2}
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} > {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- \seq_map_inline:Nn \g_@@_tmpa_seq
+ \@@_check_path:nnn
{
- \spath_gjoin_component:cn
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}{##1}
+ \@@_gjoin_components:cn
}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {} {#2} }
},
% \end{macrocode}
%
@@ -6880,26 +8958,22 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
remove~ empty~ components/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_remove_empty_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_remove_empty_components:c
+ }
+ } {#1} { {} }
},
remove~ empty~ components~ globally/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_gremove_empty_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_gremove_empty_components:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
@@ -6907,120 +8981,46 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
replace~ lines/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_replace_lines:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_replace_lines:c
+ }
+ } {#1} { {} }
},
replace~ lines~ globally/.code={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_greplace_lines:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_greplace_lines:c
+ }
+ } {#1} { {} }
},
% \end{macrocode}
%
%
-% Join the specified components together, joining each to its previous one.
+% Remove the specified components.
%
% \begin{macrocode}
remove~ components/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \seq_gclear:N \g_@@_tmpa_seq
- \foreach \l_@@_tmpa_tl in {#2}
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} < {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpa_tl
- {
- \tl_clear:N \l_@@_tmpa_tl
- }
- \seq_clear:N \l_@@_tmpb_seq
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ \@@_check_path:nnn
{
- \tl_set:Nn \l_@@_tmpb_tl {##1}
- \tl_if_eq:NNTF \l_@@_tmpb_tl \l_@@_tmpa_tl
- {
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpa_tl
- {
- \tl_clear:N \l_@@_tmpa_tl
- }
- }
- {
- \seq_put_right:Nn \l_@@_tmpb_seq {##2}
- }
+ \@@_remove_components:cn
}
- \tl_set:cx {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\seq_use:Nn \l_@@_tmpb_seq {} }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {} {#2} }
},
remove~ components~ globally/.code~ 2~ args={
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \seq_gclear:N \g_@@_tmpa_seq
- \foreach \l_@@_tmpa_tl in {#2}
- {
- \seq_gput_right:NV \g_@@_tmpa_seq \l_@@_tmpa_tl
- }
- \seq_gsort:Nn \g_@@_tmpa_seq
- {
- \int_compare:nNnTF {##1} < {##2}
- { \sort_return_same: }
- { \sort_return_swapped: }
- }
- \spath_components_to_seq:Nv
- \l_@@_tmpa_seq
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpa_tl
- {
- \tl_clear:N \l_@@_tmpa_tl
- }
- \seq_clear:N \l_@@_tmpb_seq
- \seq_map_indexed_inline:Nn \l_@@_tmpa_seq
+ \@@_check_path:nnn
{
- \tl_set:Nn \l_@@_tmpb_tl {##1}
- \tl_if_eq:NNTF \l_@@_tmpb_tl \l_@@_tmpa_tl
- {
- \seq_gpop_left:NNF \g_@@_tmpa_seq \l_@@_tmpa_tl
- {
- \tl_clear:N \l_@@_tmpa_tl
- }
- }
- {
- \seq_put_right:Nn \l_@@_tmpb_seq {##2}
- }
+ \@@_gremove_components:cn
}
- \tl_gset:cx {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {\seq_use:Nn \l_@@_tmpb_seq {} }
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ } {#1} { {} {#2} }
},
% \end{macrocode}
%
@@ -7037,29 +9037,25 @@ manipulating PGF soft paths}
maybe~ spot~ weld/.code={
\bool_if:NF \l_@@_draft_bool
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
+ \@@_maybe_current_path_reuse:nnn
{
- \spath_spot_weld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
- {
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_spot_weld_components:c
+ }
+ } {#1} { {} }
}
},
maybe~ spot~ weld~ globally/.code={
\bool_if:NF \l_@@_draft_bool
{
- \tl_if_exist:cTF
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- {
- \spath_spot_gweld_components:c
- {\tl_use:N \l_@@_prefix_tl #1 \tl_use:N \l_@@_suffix_tl}
- }
+ \@@_maybe_current_path_reuse:nnn
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- }
+ \@@_check_path:nnn
+ {
+ \spath_spot_gweld_components:c
+ }
+ } {#1} { {} }
}
},
% \end{macrocode}
@@ -7068,40 +9064,16 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
transform~ to/.code~ 2~ args={
- \group_begin:
- \tl_if_exist:cTF
+ \@@_maybe_current_path:nn
{
- \tl_use:N \l_@@_prefix_tl
- #1
- \tl_use:N \l_@@_suffix_tl
- }
- {
- \spath_reallength:Nv
- \l_@@_tmpa_int
- {
- \tl_use:N \l_@@_prefix_tl
- #1
- \tl_use:N \l_@@_suffix_tl
+ \@@_check_path:nnn {
+ \@@_transform_to:nv {#2}
}
-
- \tl_set:Nx \l_@@_tmpb_tl
- {\fp_to_decimal:n {(#2) * (\l_@@_tmpa_int)}}
- \spath_transformation_at:NvV \l_@@_tmpc_tl
- {
- \tl_use:N \l_@@_prefix_tl
- #1
- \tl_use:N \l_@@_suffix_tl
- }
- \l_@@_tmpb_tl
- \tl_gset_eq:NN \g_@@_smuggle_tl \l_@@_tmpc_tl
}
+ {#1}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- \tl_gset_eq:NN \g_@@_smuggle_tl { {1}{0}{0}{1}{0pt}{0pt} }
+ \pgfsettransformentries {1}{0}{0}{1}{0pt}{0pt}
}
- \group_end:
- \exp_last_unbraced:NV \pgfsettransformentries \g_@@_smuggle_tl
- \tl_gclear:N \g_@@_smuggle_tl
},
% \end{macrocode}
%
@@ -7109,52 +9081,16 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
upright~ transform~ to/.code~ 2~ args={
- \group_begin:
- \tl_if_exist:cTF
- {
- \tl_use:N \l_@@_prefix_tl
- #1
- \tl_use:N \l_@@_suffix_tl
- }
+ \@@_maybe_current_path:nn
{
- \spath_reallength:Nv
- \l_@@_tmpa_int
- {
- \tl_use:N \l_@@_prefix_tl
- #1
- \tl_use:N \l_@@_suffix_tl
- }
-
- \tl_set:Nx \l_@@_tmpb_tl
- {\fp_to_decimal:n {(#2) * (\l_@@_tmpa_int)}}
- \spath_transformation_at:NvV \l_@@_tmpc_tl
- {
- \tl_use:N \l_@@_prefix_tl
- #1
- \tl_use:N \l_@@_suffix_tl
+ \@@_check_path:nnn {
+ \@@_transform_upright_to:nv {#2}
}
- \l_@@_tmpb_tl
- \tl_gset_eq:NN \g_@@_smuggle_tl \l_@@_tmpc_tl
}
+ {#1}
{
- \msg_warning:nnn { spath3 } { missing soft path } { #1 }
- \tl_gset_eq:NN \g_@@_smuggle_tl { {1}{0}{0}{1}{0pt}{0pt} }
- }
- \fp_compare:nT { \tl_item:Nn \g_@@_smuggle_tl {4} < 0}
- {
- \tl_gset:Nx \g_@@_smuggle_tl
- {
- { \fp_eval:n { - (\tl_item:Nn \g_@@_smuggle_tl {1})} }
- { \fp_eval:n { - (\tl_item:Nn \g_@@_smuggle_tl {2})} }
- { \fp_eval:n { - (\tl_item:Nn \g_@@_smuggle_tl {3})} }
- { \fp_eval:n { - (\tl_item:Nn \g_@@_smuggle_tl {4})} }
- { \tl_item:Nn \g_@@_smuggle_tl {5} }
- { \tl_item:Nn \g_@@_smuggle_tl {6} }
- }
+ \pgfsettransformentries {1}{0}{0}{1}{0pt}{0pt}
}
- \group_end:
- \exp_last_unbraced:NV \pgfsettransformentries \g_@@_smuggle_tl
- \tl_gclear:N \g_@@_smuggle_tl
},
% \end{macrocode}
%
@@ -7162,25 +9098,70 @@ manipulating PGF soft paths}
%
% \begin{macrocode}
knot/.style~ n~ args={3}{
- spath/split~ at~ self~ intersections=#1,
- spath/remove~ empty~ components=#1,
- spath/insert~ gaps~ after~ components={#1}{#2}{#3},
- spath/maybe~ spot~ weld=#1,
- spath/render~ components=#1
+ /tikz/spath/split~ at~ self~ intersections=#1,
+ /tikz/spath/remove~ empty~ components=#1,
+ /tikz/spath/insert~ gaps~ after~ components={#1}{#2}{#3},
+ /tikz/spath/maybe~ spot~ weld=#1,
+ /tikz/spath/render~ components=#1
},
global~ knot/.style~ n~ args={3}{
- spath/split~ globally~ at~ self~ intersections=#1,
- spath/remove~ empty~ components~ globally=#1,
- spath/insert~ gaps~ globally ~after~ components={#1}{#2}{#3},
- spath/maybe~ spot~ weld~ globally=#1,
- spath/render~ components=#1
+ /tikz/spath/split~ globally~ at~ self~ intersections=#1,
+ /tikz/spath/remove~ empty~ components~ globally=#1,
+ /tikz/spath/insert~ gaps~ globally ~after~ components={#1}{#2}{#3},
+ /tikz/spath/maybe~ spot~ weld~ globally=#1,
+ /tikz/spath/render~ components=#1
},
+% \end{macrocode}
+%
+% For single argument commands which take a path as their argument, set the default to be \Verb+current+ so that they use the current path.
+%
+% \begin{macrocode}
+ show/.default=current,
+ spot~ weld/.default=current,
+ spot~ weld~ globally/.default=current,
+ reverse/.default=current,
+ reverse~ globally/.default=current,
+ close/.default=current,
+ close~ globally/.default=current,
+ open/.default=current,
+ open~ globally/.default=current,
+ adjust~ and~ close/.default=current,
+ adjust~ and~ close~ globally/.default=current,
+ close~ with~ curve/.default=current,
+ close~ globally~ with~ curve/.default=current,
+ remove~ empty~ components/.default=current,
+ remove~ empty~ components~ globally/.default=current,
+ replace~ lines/.default=current,
+ replace~ lines~ globally/.default=current,
+ maybe~ spot~ weld/.default=current,
+ maybe~ spot~ weld~ globally/.default=current,
}
% \end{macrocode}
%
% This defines a coordinate system that finds a position on a soft path.
%
% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_get_point_at:nn #1#2
+{
+ \group_begin:
+ \spath_reallength:Nn \l_@@_tmpa_int {#2}
+ \tl_set:Nx \l_@@_tmpb_tl
+ {\fp_to_decimal:n {(#1) * (\l_@@_tmpa_int)}}
+ \spath_point_at:NnV \l_@@_tmpc_tl {#2} \l_@@_tmpb_tl
+
+ \tl_clear:N \l_@@_tmpd_tl
+ \tl_put_right:Nn \l_@@_tmpd_tl {\pgf@x=}
+ \tl_put_right:Nx \l_@@_tmpd_tl {\tl_item:Nn \l_@@_tmpc_tl {1}}
+ \tl_put_right:Nn \l_@@_tmpd_tl {\relax}
+ \tl_put_right:Nn \l_@@_tmpd_tl {\pgf@y=}
+ \tl_put_right:Nx \l_@@_tmpd_tl {\tl_item:Nn \l_@@_tmpc_tl {2}}
+ \tl_put_right:Nn \l_@@_tmpd_tl {\relax}
+
+ \tl_gset_eq:NN \g_@@_output_tl \l_@@_tmpd_tl
+ \group_end:
+ }
+\cs_generate_variant:Nn \@@_get_point_at:nn {VV, Vn, Vv}
+
\tikzdeclarecoordinatesystem{spath}{%
\group_begin:
\tl_set:Nn \l_@@_tmpa_tl {#1}
@@ -7190,55 +9171,25 @@ manipulating PGF soft paths}
\seq_pop_right:NN \l_@@_tmpa_seq \l_@@_tmpb_tl
\tl_set:Nx \l_@@_tmpa_tl { \seq_use:Nn \l_@@_tmpa_seq {~} }
- \tl_if_exist:cTF
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpa_tl
- \tl_use:N \l_@@_suffix_tl
- }
- {
-
- \tl_set_eq:Nc
- \l_@@_tmpa_tl
- {
- \tl_use:N \l_@@_prefix_tl
- \tl_use:N \l_@@_tmpa_tl
- \tl_use:N \l_@@_suffix_tl
- }
-
- \tl_if_empty:NTF \l_@@_tmpa_tl
- {
- \tl_gset_eq:NN \g_@@_smuggle_tl \pgfpointorigin
- }
- {
- \spath_reallength:NV \l_@@_tmpa_int \l_@@_tmpa_tl
- \tl_set:Nx \l_@@_tmpb_tl
- {\fp_to_decimal:n {(\l_@@_tmpb_tl) * (\l_@@_tmpa_int)}}
- \spath_point_at:NVV \l_@@_tmpc_tl \l_@@_tmpa_tl \l_@@_tmpb_tl
- \tl_clear:N \l_@@_tmpd_tl
- \tl_put_right:Nn \l_@@_tmpd_tl {\pgf@x=}
- \tl_put_right:Nx \l_@@_tmpd_tl {\tl_item:Nn \l_@@_tmpc_tl {1}}
- \tl_put_right:Nn \l_@@_tmpd_tl {\relax}
- \tl_put_right:Nn \l_@@_tmpd_tl {\pgf@y=}
- \tl_put_right:Nx \l_@@_tmpd_tl {\tl_item:Nn \l_@@_tmpc_tl {2}}
- \tl_put_right:Nn \l_@@_tmpd_tl {\relax}
- \tl_gset_eq:NN \g_@@_smuggle_tl \l_@@_tmpd_tl
+ \@@_maybe_current_path:nV
+ {
+ \@@_check_path:nnn {
+ \@@_get_point_at:Vv \l_@@_tmpb_tl
}
}
+ \l_@@_tmpa_tl
{
- \msg_warning:nnx
- { spath3 }
- { missing soft path }
- { \tl_use:N \l_@@_tmpa_tl }
- \tl_gset_eq:NN \g_@@_smuggle_tl \pgfpointorigin
+ \tl_gset_eq:NN \g_@@_output_tl \pgfpointorigin
}
+
\group_end:
\use:c {pgf@process}{%
- \tl_use:N \g_@@_smuggle_tl
+ \tl_use:N \g_@@_output_tl
\pgftransforminvert
\use:c {pgf@pos@transform@glob}
}
+ \tl_gclear:N \g_@@_output_tl
}
\ExplSyntaxOff
@@ -8281,6 +10232,7 @@ manipulating PGF soft paths}
\bool_new:N \l_@@_append_next_bool
\bool_new:N \l_@@_skip_bool
\bool_new:N \l_@@_save_bool
+\bool_new:N \l_@@_debugging_bool
\seq_new:N \g_@@_nodes_seq
@@ -8417,6 +10369,14 @@ manipulating PGF soft paths}
\bool_set_true:N \l_@@_draft_bool
\bool_set_true:N \l_@@_super_draft_bool
},
+ debug/.is~ choice,
+ debug/true/.code={
+ \bool_set_true:N \l_@@_debugging_bool
+ },
+ debug/false/.code={
+ \bool_set_false:N \l_@@_debugging_bool
+ },
+ debug/.default=true,
draft/.is~ family,
draft,
crossing~ label/.style={
@@ -8440,10 +10400,26 @@ manipulating PGF soft paths}
}
% \end{macrocode}
%
+% \begin{macro}[internal]{\knot_debug:n}
+% Debugging
+% \begin{macrocode}
+\cs_new_nopar:Npn \knot_debug:n #1
+{
+ \bool_if:NT \l_@@_debugging_bool
+ {
+ \iow_term:n {===Knot~ debug: #1===}
+ }
+}
+
+\cs_generate_variant:Nn \knot_debug:n {x}
+% \end{macrocode}
+% \end{macro}
+%
% Wrapper around \Verb+\tikzset+ for applying keys from a token list, checking for if the given token list exists.
% \begin{macrocode}
\cs_new_nopar:Npn \knot_apply_style:N #1
{
+ \knot_debug:n {knot~ apply~ style}
\tl_if_exist:NT #1 {
\exp_args:NV \tikzset #1
}
@@ -8492,6 +10468,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_initialise:n #1
{
+ \knot_debug:n {knot~ initialise}
\tikzset{knot~ diagram/.cd,every~ knot~ diagram/.try,#1}
\int_zero:N \l_@@_strands_int
\tl_clear:N \l_@@_redraws_tl
@@ -8505,6 +10482,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_render:
{
+ \knot_debug:n {knot~ render}
% \end{macrocode}
% Start a scope and reset the transformation (since all transformations have already been taken into account when defining the strands).
% \begin{macrocode}
@@ -8591,6 +10569,8 @@ manipulating PGF soft paths}
% Close the scope
% \begin{macrocode}
\endpgfscope
+ \knot_debug:x {knot~rendered,
+ ~found~\int_use:N \g_@@_intersections_int \c_space_tl~intersections}
}
% \end{macrocode}
% \end{macro}
@@ -8600,6 +10580,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_draw_strand:n #1
{
+ \knot_debug:n {knot~ draw~ strand~ #1}
\pgfscope
\group_begin:
\spath_bake_round:c {knot strand #1}
@@ -8609,7 +10590,7 @@ manipulating PGF soft paths}
{
,
knot~ diagram/only~ when~ rendering/.try,
- only~ when~ rendering/.try
+ only~ when~ rendering/.try,
}
\spath_tikz_path:Vv \l_@@_tmpa_tl {knot strand #1}
\group_end:
@@ -8625,6 +10606,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_draw_labels:n #1
{
+ \knot_debug:n {knot~ draw~ labels}
\bool_if:NT \l_@@_draft_bool
{
\spath_finalpoint:Nv \l_@@_tmpb_tl {knot strand #1}
@@ -8665,6 +10647,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_split_self_intersects:N #1
{
+ \knot_debug:n {knot~ split~ self~ intersects}
\tl_set:Nx \l_@@_tmpc_tl {\tl_item:nn {#1} {4}}
\tl_case:NnF \l_@@_tmpc_tl
{
@@ -8702,9 +10685,11 @@ manipulating PGF soft paths}
}
{
\fp_set:Nn \l_@@_tmpa_fp {.5 * \l_@@_tmpa_fp / \l_@@_tmpb_fp}
- \fp_compare:nTF
+ \bool_if:nTF
{
- 0 < \l_@@_tmpa_fp && \l_@@_tmpa_fp < 1
+ \fp_compare_p:n {0 < \l_@@_tmpa_fp}
+ &&
+ \fp_compare_p:n {\l_@@_tmpa_fp < 1}
}
{
\spath_split_curve:NNnV
@@ -8758,6 +10743,8 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_intersections:nn #1#2
{
+ \knot_debug:x {knot~ intersections~ between~
+ \l_@@_prefix_tl \c_space_tl #1~ and~ #2}
\group_begin:
\tl_set_eq:NN \l_@@_tmpa_tl \l_@@_prefix_tl
\tl_put_right:Nn \l_@@_tmpa_tl {#1}
@@ -8789,6 +10776,7 @@ manipulating PGF soft paths}
}
+ \knot_debug:x {found~\pgfintersectionsolutions\c_space_tl~ intersections}
\int_compare:nT {\pgfintersectionsolutions > 0}
{
\int_step_function:nnnN
@@ -8808,6 +10796,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_save_intersections:nn #1#2
{
+ \knot_debug:n {knot~ save~ intersections}
\bool_if:NT \l_@@_save_bool
{
\tl_clear:N \l_@@_aux_tl
@@ -8861,12 +10850,15 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_do_intersection:n #1
{
+ \knot_debug:n {knot~ do~ intersection~ #1}
% \end{macrocode}
% Get the intersection coordinates.
% \begin{macrocode}
\pgfpointintersectionsolution{#1}
\dim_set:Nn \l_@@_tmpa_dim {\pgf@x}
\dim_set:Nn \l_@@_tmpb_dim {\pgf@y}
+ \knot_debug:x {intersection~at~
+ (\dim_use:N \l_@@_tmpa_dim,\dim_use:N \l_@@_tmpb_dim)}
% \end{macrocode}
% If we're dealing with filaments, we can get false positives from the end points.
% \begin{macrocode}
@@ -8925,8 +10917,9 @@ manipulating PGF soft paths}
% \begin{macrocode}
\bool_if:NF \l_@@_skip_bool
{
-
+
\int_gincr:N \g_@@_intersections_int
+ \knot_debug:x {Processing~intersection~\int_use:N \g_@@_intersections_int}
% \end{macrocode}
% This is the intersection test.
% If the intersection finder finds too many, it might be useful to ignore some.
@@ -9007,6 +11000,8 @@ manipulating PGF soft paths}
!\tl_if_empty_p:c {knot previous \tl_use:N \l_@@_tmpg_tl}
}
{
+ \knot_debug:x {Prepending~
+ \tl_use:c {knot previous \tl_use:N \l_@@_tmpg_tl}}
\spath_prepend_no_move:cv
{knot \tl_use:N \l_@@_prefix_tl -1}
{knot \tl_use:c {knot previous \tl_use:N \l_@@_tmpg_tl}}
@@ -9017,9 +11012,13 @@ manipulating PGF soft paths}
{
\l_@@_splits_bool
&&
- \tl_if_exist_p:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ \tl_if_exist_p:c {knot previous
+ \tl_use:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ }
&&
- !\tl_if_empty_p:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ !\tl_if_empty_p:c {knot previous
+ \tl_use:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ }
}
{
\knot_test_endpoint:NvnT
@@ -9027,6 +11026,11 @@ manipulating PGF soft paths}
{knot previous \tl_use:N \l_@@_tmpg_tl}
{initial point}
{
+ \knot_debug:x {Prepending~
+ \tl_use:c {knot previous
+ \tl_use:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ }
+ }
\spath_prepend_no_move:cv
{knot \tl_use:N \l_@@_prefix_tl -1}
{knot \tl_use:c
@@ -9034,10 +11038,12 @@ manipulating PGF soft paths}
{knot previous \tl_use:N \l_@@_tmpg_tl}
}
}
- \tl_set_eq:Nc \l_@@_tmpa_tl {knot \tl_use:N \l_@@_prefix_tl -1}
+ \tl_set_eq:Nc \l_@@_tmpa_tl
+ {knot \tl_use:N \l_@@_prefix_tl -1}
}
}
}
+
% \end{macrocode}
% Now the same for appending.
% \begin{macrocode}
@@ -9047,9 +11053,11 @@ manipulating PGF soft paths}
&&
\tl_if_exist_p:c {knot next \tl_use:N \l_@@_tmpg_tl}
&&
- !\tl_if_empty_p:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ !\tl_if_empty_p:c {knot next \tl_use:N \l_@@_tmpg_tl}
}
{
+ \knot_debug:x {Appending~
+ \tl_use:c {knot next \tl_use:N \l_@@_tmpg_tl}}
\spath_append_no_move:cv
{knot \tl_use:N \l_@@_prefix_tl -1}
{knot \tl_use:c {knot next \tl_use:N \l_@@_tmpg_tl}}
@@ -9057,17 +11065,25 @@ manipulating PGF soft paths}
{
\l_@@_splits_bool
&&
- \tl_if_exist_p:c {knot previous \tl_use:N
- \l_@@_tmpg_tl}
+ \tl_if_exist_p:c {knot next \tl_use:c { knot next \tl_use:N
+ \l_@@_tmpg_tl}}
&&
- !\tl_if_empty_p:c {knot previous \tl_use:N \l_@@_tmpg_tl}
+ !\tl_if_empty_p:c {knot next
+ \tl_use:c { knot next \tl_use:N \l_@@_tmpg_tl}
+ }
}
{
+ \knot_debug:x {Testing~ whether~ to~ append~
+ {knot next \tl_use:c { knot next \tl_use:N \l_@@_tmpg_tl}}
+ }
\knot_test_endpoint:NvnT
\l_@@_redraw_tolerance_dim
- {knot previous \tl_use:N \l_@@_tmpg_tl}
+ {knot next \tl_use:N \l_@@_tmpg_tl}
{final point}
{
+ \knot_debug:x {Appending~
+ {knot next \tl_use:c { knot next \tl_use:N \l_@@_tmpg_tl}}
+ }
\spath_append_no_move:cv
{knot \tl_use:N \l_@@_prefix_tl -1}
{knot \tl_use:c
@@ -9170,6 +11186,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_draw_crossing:nnn #1#2#3
{
+ \knot_debug:n {knot~ draw~ crossing}
\group_begin:
\pgfscope
\path[knot~ diagram/background~ clip] (#2, #3)
@@ -9224,6 +11241,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_split_strands:
{
+ \knot_debug:n {knot~ split~ strands}
\int_gzero:N \g_@@_filaments_int
\int_step_function:nnnN {1} {1} {\l_@@_strands_int} \knot_split_strand:n
\int_step_function:nnnN {1} {1} {\g_@@_filaments_int} \knot_compute_nexts:n
@@ -9237,6 +11255,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_compute_nexts:n #1
{
+ \knot_debug:n {knot~ compute~ nexts}
\tl_clear_new:c {knot next \tl_use:c {knot previous filament #1}}
\tl_set:cn {knot next \tl_use:c {knot previous filament #1}} {filament #1}
}
@@ -9248,6 +11267,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_split_strand:n #1
{
+ \knot_debug:n {knot~ split~ strand}
\int_set_eq:NN \l_@@_component_start_int \g_@@_filaments_int
\int_incr:N \l_@@_component_start_int
\tl_set_eq:Nc \l_@@_tmpa_tl {l_@@_options_strand #1}
@@ -9262,6 +11282,7 @@ manipulating PGF soft paths}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \knot_save_filament:N #1
{
+ \knot_debug:n {knot~ save~ filament}
\tl_set:Nx \l_@@_tmpb_tl {\tl_item:nn {#1} {4}}
\tl_case:NnF \l_@@_tmpb_tl
{
diff --git a/graphics/pgf/contrib/spath3/spath3_code.pdf b/graphics/pgf/contrib/spath3/spath3_code.pdf
index e61a569ddf..f773a0b534 100644
--- a/graphics/pgf/contrib/spath3/spath3_code.pdf
+++ b/graphics/pgf/contrib/spath3/spath3_code.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/tikzmark/README b/graphics/pgf/contrib/tikzmark/README
index ef4d2e566d..c8d36e0132 100644
--- a/graphics/pgf/contrib/tikzmark/README
+++ b/graphics/pgf/contrib/tikzmark/README
@@ -8,3 +8,4 @@ See http://www.latex-project.org/lppl.txt
The tikzmark package defines a command to "remember" a position
on a page for later (or earlier) use, primarily (but not
exclusively) with TikZ.
+
diff --git a/graphics/pgf/contrib/tikzmark/tikzmark.dtx b/graphics/pgf/contrib/tikzmark/tikzmark.dtx
index 88aec1a4ed..6169f8176f 100644
--- a/graphics/pgf/contrib/tikzmark/tikzmark.dtx
+++ b/graphics/pgf/contrib/tikzmark/tikzmark.dtx
@@ -53,6 +53,8 @@ and the derived files tikzmark.ins,
tikzmark.pdf,
tikzlibrarytikzmark.code.tex, and
tikzmarklibrarylistings.code.tex
+ tikzmarklibraryhighlighting.code.tex
+ tikzmarklibraryams.code.tex
\endpostamble
\usedir{tex/latex/tikzmark}
@@ -62,9 +64,12 @@ and the derived files tikzmark.ins,
\generate{
\file{tikzmarklibrarylistings.code.tex}{\from{\jobname.dtx}{listings}}
}
-%\generate{
-% \file{tikzmarklibraryhighlight.code.tex}{\from{\jobname.dtx}{highlight}}
-%}
+\generate{
+ \file{tikzmarklibraryhighlighting.code.tex}{\from{\jobname.dtx}{highlighting}}
+}
+\generate{
+ \file{tikzmarklibraryams.code.tex}{\from{\jobname.dtx}{ams}}
+}
%</install>
%<install>\endbatchfile
%<*internal>
@@ -91,8 +96,8 @@ and the derived files tikzmark.ins,
%\usepackage{morefloats}
\usepackage{listings}
\usepackage{tikz}
-\usetikzlibrary{fit,arrows,tikzmark,shadows,decorations.pathreplacing,calc}
-\usetikzmarklibrary{listings}
+\usetikzlibrary{fit,arrows.meta,tikzmark,shadows,decorations.pathreplacing,calc}
+\usetikzmarklibrary{ams,listings,highlighting}
%\usepackage[numbered]{hypdoc}
\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9}
@@ -206,7 +211,7 @@ and the derived files tikzmark.ins,
%</driver>
% \fi
%
-% \CheckSum{1178}
+% \CheckSum{1891}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -235,8 +240,16 @@ and the derived files tikzmark.ins,
% \changes{1.7}{2019/05/07}{Added conditions to test if a tikzmark is on a particular page}
% \changes{1.8}{2019/10/04}{Fixed some bugs with subnode and tikzmarknode inside maths}
% \changes{1.10}{2021/02/16}{Tikzmarknode is now prefix and suffix aware, and added a test to see if a picture id has been saved to the aux file for times when pictures are thrown away, eg in AMS's text command}
+% \changes{1.11}{2021/08/16}{Tikzmark inside a tikzpicture was not applying any surrounding transformation before saving the coordinates. Code for adjusting a pic's location based on an internal coordinate.}
+% \changes{1.12}{2021/08/24}{Experimental library for creating pseudo-nodes around AMSMath equation alignment boxes.}
+% \changes{1.14}{2022/01/28}{Reimplementing the highlighting code using LaTeX3 hooks.}
+% \changes{1.15}{2022/08/24}{Improvements to highlighting code}
%
% \DoNotIndex{\newcommand,\newenvironment}
+% \pdfstringdefDisableCommands{%
+% \def\\{}%
+% \def\url#1{<#1>}%
+% }
%
% \GetFileInfo{tikzlibrarytikzmark.code.tex}
% \providecommand*{\url}{\texttt}
@@ -382,6 +395,8 @@ and the derived files tikzmark.ins,
%
% This package defines the following commands and usable stuff.
%
+% \subsection{Core Commands}
+%
% \begin{enumerate}
% \item \Verb+\tikzmark+\oarg{drawing command}\marg{name}
%
@@ -459,7 +474,7 @@ and the derived files tikzmark.ins,
% In such a situation, when defining nodes then the last one ``wins'' in that each node remembers the id of the last processed picture.
% However, only the one that is actually used has its location remembered on the page (since the others don't have a position).
% This can lead to the situation whereby a node becomes disassociated from its picture and so using it for later reference fails.
-% This key tries to get around that situation by checking the \Verb+aux+ file to see if the current picture was actually typeset last time (by checking for the presence of the remembered location) and if it find that it wasn't, it quietly appends the string \Verb+discard-+ to each node name.
+% This key tries to get around that situation by checking the \Verb+aux+ file to see if the current picture was actually typeset last time (by checking for the presence of the remembered location) and if it finds that it wasn't, it quietly appends the string \Verb+discard-+ to each node name.
% The idea being that the version of the picture that is actually typeset will not have this happen and so its nodes ``survive''.
%
% \item \Verb+/tikz/maybe define node=#1+
@@ -504,7 +519,35 @@ and the derived files tikzmark.ins,
%
% This was inspired by the question \href{http://tex.stackexchange.com/q/302517/86}{using tikzmark subnode with overlays beamer} on TeX-SX.
%
-% \item \Verb+\subnode[options]{name}{content}+
+% \end{enumerate}
+%
+% \subsection{Pic and Scope Positioning}
+%
+% \Verb+scope anchor+, \Verb+pic anchor+, and \Verb+surround pic+.
+%
+% These keys can be used to enable advanced positioning of \Verb+scope+s and \Verb+pic+s.
+% The standard positioning of a \Verb+pic+ places its internal origin at the location specified on the \Verb!\pic! command.
+% This is more limited than what is available to a \Verb+node+ whereby any of the defined anchors can be placed at the given position.
+% The key \Verb+pic anchor+ allows a little more flexibility to \Verb+pic+ positioning by allowing a \Verb+pic anchor+ to be defined and used as the point to place at the given position.
+%
+% When invoking the \Verb!pic! the key \Verb!pic anchor={coordinate}! can be used to specify a point inside the \Verb!pic! to use as the anchor.
+% This point is evaluated inside the \Verb!pic! so if using a node then the node name should be specified as if inside the \Verb!pic!.
+%
+% The node positioning syntax, things like \Verb!below! and \Verb!below=5pt of!, sets the anchor of the following node.
+% Using \Verb!pic anchor! without a coordinate uses this anchor on the bounding box of the pic when positioning the pic.
+%
+% Internally, this works by adjusting the location of the \Verb!pic!'s surrounding scope.
+% So the code can equally be used on \Verb!scope!s.
+% For a \Verb!scope!, use the \Verb!scope anchor! version on the scope directly.
+% The keys \Verb!name! and \Verb!anchor! can be used on the scope as if on a \Verb!node! with the same effect on the positioning.
+%
+% The key \Verb!surround pic! saves the bounding box of the pic as if it were the boundary of a rectangular node, using the name of the pic as the name of the node.
+%
+% This was inspired by the questions \href{https://tex.stackexchange.com/q/185279/86}{Anchoring TiKZ pics} and \href{https://tex.stackexchange.com/q/567245/86}{Reposition Tikz Scope After Size Known}.
+%
+% \subsection{Subnodes}
+%
+% \Verb+\subnode[options]{name}{content}+
%
% This produces a pseudo-node named \Verb+name+ around the \Verb+content+.
% The design purpose of this is to create a ``subnode'' inside a TikZ node.
@@ -525,9 +568,12 @@ and the derived files tikzmark.ins,
% The simplest way to turn a pseudo-node into a more normal node is to use the \Verb+fit+ library.
% Using the above example, \Verb+\node[fit=(a),draw,inner sep=0pt] {};+ would draw a rectangle around the word \Verb+sub+ of exactly the same size as would appear had a normal node been created.
%
-% Using a sneaky trick with \Verb+\mathchoice+, \Verb+subnode+ works inside a math environment. The spacing either side might not be quite right as although it detects the math style it doesn't got beyond that.
+% Using a sneaky trick with \Verb+\mathchoice+, \Verb+subnode+ works inside a math environment.
+% The spacing either side might not be quite right as although it detects the math style it doesn't got beyond that.
%
-% \item \emph{Node saving}
+% Note that because of the way that this works, the outer \Verb!tikzpicture! must have the \Verb!remember picture! option set.
+%
+% \subsection{Node saving}
%
% The node saving system takes the information stored about a node and saves it for later use.
% That later use can be in the same document, in which case it should be saved just to the memory of the current TeX process, or it can be used earlier in the same document or another document altogether (in particular, if the nodes are defined in a \Verb+tikzpicture+ that has been externalised, this can be used to import the node information into the main file) in which cases the node data is saved to a file.
@@ -539,9 +585,18 @@ and the derived files tikzmark.ins,
% The keys for working with saving and restoring nodes are as follows.
%
% \begin{itemize}
-% \item \Verb+save node+
+% \item \Verb+save node+, \Verb+save node=<name>+
+%
+% This is the key that indicates a node to be saved.
+% The version with no argument is to be used directly in the keys for a node and it saves that node.
+% With an argument then it saves a node that has been declared somewhere in the current tikz picture (it may not always be convenient to issue the \Verb+save node+ key directly on the node itself).
+% Since the list is saved up to the end of the picture, this can be invoked before the node is defined.
%
-% This is the key to put on a node that is to be saved.
+% \item \Verb+\SaveNode[group name]{name}+
+%
+% This command is for outside a tikzpicture and saves the named node directly.
+% The optional argument is a group name for saving to a group.
+% If this is not specified then the node is saved to a file.
%
% \item \Verb+set node group=<name>+
%
@@ -579,21 +634,17 @@ and the derived files tikzmark.ins,
% If there is a transformation in place on the containing node, this key applies that transformation to all the nodes in the inner picture.
%
% \end{itemize}
-% \end{enumerate}
%
-% \section{Examples and Extras}
+% \section{Examples}
%
% The \Verb+\tikzmark+ command has been used in numerous answers on \href{http://tex.stackexchange.com}{TeX-SX}.
-% The plan is to gather some of these into extra libraries which can be loaded via \Verb+\usetikzmarklibrary+.
-%
-% At present, this is the code listings library (which works with the \Verb+listings+ package).
-% One that is in development (as it has featured much on the TeX-SX website) is highlighting, however this is not so straightforward to implement so is still under development.
%
% \subsection{Basic Examples}
%
% A simple example of the \Verb+\tikzmark+ macro is the following.
%
% \begin{example}
+% \tikzset{tikzmark prefix=ex1-}
% \[
% \tikzmark{a} e^{i \pi/2} = i
% \]
@@ -602,6 +653,7 @@ and the derived files tikzmark.ins,
% \end{example}
%
% \begin{example}
+% \tikzset{tikzmark prefix=ex2-}
% \begin{itemize}
% \item A first item,\tikzmark{b}
% \item A second item,\tikzmark{c}
@@ -613,6 +665,7 @@ and the derived files tikzmark.ins,
% \end{example}
%
% \begin{example}
+% \tikzset{tikzmark prefix=ex3-}
% \begin{tikzpicture}[remember picture]
% \node (a) at (0,0) {This has a \subnode{sub}{subnode} in it};
% \draw[->] (0,-1) to[bend right] (sub);
@@ -622,7 +675,7 @@ and the derived files tikzmark.ins,
% An example using \Verb+\tikzmark+ inside a \Verb+tikzpicture+
%
% \begin{example}
-% \tikzset{tikzmark prefix=ex3-}
+% \tikzset{tikzmark prefix=ex4-}
% \begin{tikzpicture}[remember picture,overlay]
% \draw[->,line width=1mm,cyan] (pic cs:a) to[bend left] (pic cs:b);
% \end{tikzpicture}
@@ -638,6 +691,7 @@ and the derived files tikzmark.ins,
% The \Verb+\tikmarknode+ puts a node around some text, which can be referred to later, and adds a \Verb+\tikzmark+ at its origin.
%
% \begin{example}
+% \tikzset{tikzmark prefix=ex5-}
% Putting a node around \tikzmarknode{txt}{some text} means we can connect text together, including in maths:
% \[
% \tikzmarknode{a}{\sum_{k=1}^n} k^{\tikzmarknode{b}{2}}
@@ -719,6 +773,13 @@ and the derived files tikzmark.ins,
% \fbox{\IfFileExists{tikzrefextnodes.pdf}{\includegraphics{tikzrefextnodes}}{}}
% \end{center}
%
+% \section{Additional Libraries}
+%
+% Some of the more ambitious uses of \Verb!\tikzmark! involve a fair bit of extra code and so are worth gathering in to extra libraries of their own.
+% These can be loaded via \Verb+\usetikzmarklibrary+.
+%
+% At present, there are three libraries: one for code listings which works with the \Verb+listings+ package, one for AMSMath equations, and one for highlighting.
+%
% \subsection{Code Listings}
%
% If the \Verb+listings+ package has been loaded then issuing
@@ -749,6 +810,7 @@ and the derived files tikzmark.ins,
% The following example shows this, where the red dots are the \Verb+start+, the blue are \Verb+end+, and the green are \Verb+first+.
%
% \begin{example}
+% \tikzset{tikzmark prefix=ex6-}
% \begin{tikzpicture}[remember picture]
% \foreach \k in {0,...,7} {
% \iftikzmark{line-code-\k-start}{\fill[red,overlay] (pic cs:line-code-\k-start) circle[radius=4pt];}{\message{No start for \k}}
@@ -788,7 +850,215 @@ and the derived files tikzmark.ins,
% \end{lstlisting}
% \end{example}
%
+% \subsection{AMS Equation Environments}
+%
+% \textbf{This is an experimental library.}
+%
+% If the \Verb+amsmath+ package has been loaded then issuing
+%
+% \Verb+\usetikzmarklibrary{ams}+
+%
+% \noindent loads some code that places pseudo-nodes around the boxes that are used in AMSMath's various equation alignment environments, such as \Verb!align! and \Verb!gather!.
+% These environments work by constructing boxes with each of the pieces of the equations that are then put together into the grid.
+% This library hooks in to the unboxing code, before the box is typeset then it measures it and stores that information in various macros as if it were a TikZ node.
+% The aim is that this doesn't disturb the placement, but as far as TikZ is concerned then there is a node there that can be referred to later.
+%
+% As it is experimental, even if this library is loaded then it isn't automatically switched on.
+% To do that, use either the \Verb!tikzmarkmath! environment or the \Verb!\tikzmarkmath! command.
+% Each has an optional argument which is a prefix for the node names (the default is \Verb!equation!).
+% The node names are then of the form \Verb!<prefix>-<number>!.
+% The numbering is held in a counter called \Verb!tikzmarkequation! and is reset when the command is invoked or the environment is started.
+% As usual, redefining \Verb!\thetikzmarkequation! changes the styling of the \Verb!<number>!.
+%
+% To disable the marking, either end the environment or use \Verb!\endtikzmarkmath!.
+% The ending command explicitly removes the hook rather than rely on \TeX\ groupings.
+% It also prints out the number of nodes created to the log file and terminal.
+% This can be useful with figuring out which nodes to use, since the box that this library hooks into is used many times.
+% For example, equation numbers are included with this.
%
+% The box is also used when assembling a \Verb!\sqrt[3]{4}! command, and as that uses \Verb!\mathchoice! then there are more boxes created than used.
+% So the count of number of nodes created can be more than are actually there.
+%
+% \begin{example}
+% \begin{tikzmarkmath}[pythagoras]
+%
+% \begin{gather}
+% a^2 = b^2 + c^2
+% \end{gather}
+%
+% \begin{gather}
+% a = \sqrt[2]{b^2 + c^2}
+% \end{gather}
+% \end{tikzmarkmath}
+%
+% \begin{tikzpicture}[remember picture, overlay]
+% \foreach \k in {1,2,3,7,8} {
+% \draw[red] (pic cs:pythagoras-\k) -- ++(135:1) node[draw,red,circle,font=\tiny,above left] {\k};
+% \node[draw,blue,fit=(pythagoras-\k),inner sep=0pt] {};
+% }
+% \end{tikzpicture}
+% % \end{example}
+%
+%
+% \subsection{Highlighting}
+%
+% I've returned to the highlighting library.
+% The \LaTeX3 hook mechanism makes a couple of things possible that were tricky before.
+%
+% The idea of the highlighting mechanism is to use two \Verb!\tikzmark!s to mark a start and end of a region to be highlighted.
+% The region is considered to be formed by lines of text, with the first mark at the baseline of the start and the second at the baseline of the end.
+%
+% The highlighting itself is done by inserting code in the shipout routine before the page itself is laid out.
+% So the highlighting is on a separate layer to the text itself, which can be either behind or in front of the text layer.
+% The hook mechanisem also makes it relatively simple to support page breaks between the start and end of highlighting.
+%
+% Since the highlighting is separate to the flow of the text, it doesn't make sense to use an environment to mark the start and end of the highlighting so instead there are two commands: \Verb!\StartHighlighting[options]! and \Verb!\StopHighlighting!, or a single command \Verb!\Highlight[options]{text}! that just highlights the \Verb!text!.
+% At the moment, nesting highlighting is not supported.
+%
+% The optional argument to \Verb!\StartHighlighting! (or \Verb!\Highlight!) consists of key-value pairs that control the behaviour of the highlighted region.
+% There are particular keys in the \Verb!/tikz/highlighter! family which control the size of the highlighted region.
+%
+% The keys are as follows:
+%
+% \begin{itemize}
+% \item \texttt{direction}
+% \item \texttt{layer}
+% \item \texttt{initial height}
+% \item \texttt{initial depth}
+% \item \texttt{initial offset}
+% \item \texttt{final height}
+% \item \texttt{final depth}
+% \item \texttt{final offset}
+% \item \texttt{left margin}
+% \item \texttt{right margin}
+% \item \texttt{height}
+% \item \texttt{depth}
+% \item \texttt{offset}
+% \item \texttt{margin}
+% \end{itemize}
+%
+% The highlighting code draws a region which can be styled with standard TikZ keys, more of which in a moment.
+% Although it is a single region, the \emph{intention} is to simulate using an actual highlighter.
+% The first key, \Verb!direction!, is used to draw the region as if the highlighter were used in a particular direction.
+% The options are \Verb!horizontal!, \Verb!vertical!, or \Verb!box!.
+% The default is \Verb!horizontal!.
+%
+% The second key, \Verb!layer!, determines whether the highlighter is rendered on the \Verb!background! or \Verb!foreground! layer.
+% Using the \Verb!background! layer puts the highlighting underneath the text, which will make the text easier to read.
+% The \Verb!foreground! option puts the highlighting over the text, which can be used to fade the text.
+% The default is \Verb!background!.
+%
+% The shape of the region depends on a few things, such as whether the highlighting starts and ends on the same line.
+%
+% \begin{tikzpicture}[>=Latex]
+% \fill (0,0) circle[radius=2pt];
+% \fill (4,0) circle[radius=2pt];
+% \draw (-1,-1) rectangle (5,1);
+% \draw[dashed] (0,0) -- (4,0);
+% \draw[<->] (0,0) -- +(-1,0);
+% \draw[<->] (0,0) -- +(0,1);
+% \draw[<->] (4,0) -- +(0,-1);
+% \draw[<->] (4,0) -- +(1,0);
+% \draw[<-] (-.5,0) to[out=90,in=-90] +(-1,1.5) node[above] {initial offset};
+% \draw[<-] (4.5,0) to[out=90,in=-90] +(1,1.5) node[above] {final offset};
+% \draw[<-] (0,.5) to[out=0,in=180] +(1,1.5) node[right] {initial height};
+% \draw[<-] (4,-.5) to[out=0,in=180] +(1,-1.5) node[right] {final depth};
+% \node[anchor=base] at (2,0) {Single line};
+% \end{tikzpicture}
+%
+% \begin{tikzpicture}[>=Latex]
+% \fill (0,0) circle[radius=2pt];
+% \draw (-1,-1) rectangle (4,1);
+% \draw[dashed] (0,0) -- (4,0);
+% \draw[<->] (0,0) -- +(-1,0);
+% \draw[<->] (0,0) -- +(0,1);
+% \draw[<->] (0,0) -- +(0,-1);
+% \draw[<-] (-.5,0) to[out=90,in=-90] +(-1,1.5) node[above] {initial offset};
+% \draw[<-] (0,.5) to[out=0,in=180] +(1,1.5) node[right] {initial height};
+% \draw[<-] (0,-.5) to[out=0,in=180] +(1,-1.5) node[right] {initial depth};
+% \node[anchor=base] at (2,0) {Split line};
+% \begin{scope}[yshift=-3cm,xshift=-5cm]
+% \fill (4,0) circle[radius=2pt];
+% \draw (0,-1) rectangle (5,1);
+% \draw[dashed] (0,0) -- (4,0);
+% \draw[<->] (4,0) -- +(1,0);
+% \draw[<->] (4,0) -- +(0,1);
+% \draw[<->] (4,0) -- +(0,-1);
+% \draw[<-] (4.5,0) to[out=90,in=180] +(2.5,0) node[right] {final offset};
+% \draw[<-] (4,.5) to[out=180,in=0] +(-1,1.5) node[left] {final height};
+% \draw[<-] (4,-.5) to[out=0,in=180] +(1.5,-1) node[right] {final depth};
+% \node[anchor=base] at (2,0) {Split line};
+% \end{scope}
+% \end{tikzpicture}
+%
+% \begin{tikzpicture}[>=Latex]
+% \fill (0,0) circle[radius=2pt];
+% \fill (4,0) circle[radius=2pt];
+% \fill (-4,-1) circle[radius=2pt];
+% \fill (4,-1) circle[radius=2pt];
+% \fill (-4,-2) circle[radius=2pt];
+% \fill (0,-2) circle[radius=2pt];
+% \draw (-1,0) -- (-1,1) -- (5,1) -- (5,-2) -- (1,-2) -- (1,-3) -- (-5,-3) -- (-5,0) -- cycle;
+% \draw[dashed] (0,0) -- (4,0);
+% \draw[dashed] (-4,-1) -- (4,-1);
+% \draw[dashed] (-4,-2) -- (0,-2);
+% \draw[<->] (0,0) -- +(-1,0);
+% \draw[<->] (0,0) -- +(0,1);
+% \draw[<->] (4,0) -- +(1,0);
+% \draw[<->] (0,-2) -- +(1,0);
+% \draw[<->] (0,-2) -- +(0,-1);
+% \draw[<->] (-4,-2) -- +(-1,0);
+% \draw[<-] (-.5,0) to[out=90,in=0] +(-1,.5) node[left] {initial offset};
+% \draw[<-] (0,.5) to[out=0,in=180] +(1,0) node[right] {initial height};
+% \draw[<-] (4.5,0) to[out=90,in=-90] +(1,1.5) node[above] {right margin};
+% \draw[<-] (.5,-2) to[out=-90,in=180] +(1,-.5) node[right] {final offset};
+% \draw[<-] (0,-2.5) to[out=180,in=0] +(-1,0) node[left] {final depth};
+% \draw[<-] (-4.5,-2) to[out=90,in=-90] +(-1,1.5) node[above] {left margin};
+% \node[anchor=base] at (0,-1) {Multiple lines};
+% \end{tikzpicture}
+%
+% The \texttt{vertical} regions and the \texttt{box} are defined similarly.
+% With the vertical regions then the meaning of the \Verb!height!, \Verb!depth!, and \Verb!offset! are rotated \(90^\circ\), and the vertial regions don't stretch to the page boundaries.
+% The \texttt{box} region is always a rectangle.
+%
+% Once the region is defined, it can be styled using options directly on the \Verb!StartHighlighting! or \Verb!\Highlight! command and by using the following styles:
+%
+% \begin{itemize}
+% \item \texttt{every highlight picture}
+% \item \texttt{every <direction> highlight picture}
+% \item \texttt{every <layer> highlight picture}
+% \item \texttt{every highlight path}
+% \item \texttt{every <direction> highlight path}
+% \item \texttt{every <layer> highlight path}
+% \item \texttt{highlight path}
+% \item \texttt{<direction> highlight path}
+% \item \texttt{<layer> highlight path}
+% \end{itemize}
+%
+% The \Verb!picture! keys are for the surrounding \Verb!tikzpicture!, while the \Verb!path! keys are for the path itself.
+%
+% Lastly, a word about scoping the options.
+% Since the code that actually renders the highlighting is processed when the page is shipped out, it may well be that the settings in force when the highlighting was defined have changed.
+% The keys that adjust the size of the region (in the \Verb!highlighter! family) are saved at the moment of invocation but keys such as the colour or whether to fill or draw the path are not.
+% Therefore, it is wise to use styles that persist to set the rendering styles.
+%
+% \begin{example}
+% The sun was shining on the sea, shining with all its might.
+% \StartHighlighting[fill=cyan!50]
+% And this was very odd because it was the middle of the night.
+% \StopHighlighting
+% The moon was up there sulkily because she thought the sun had no
+% business to be there after the day was done.
+% \StartHighlighting[fill=magenta!50]
+% ``It's very rude of him,'' she said, ``to come and spoil the fun.''
+% \StopHighlighting
+
+% \noindent The sun was shining on the sea, shining with all its might.
+% And this was very odd because it was the middle of the night.
+% \StartHighlighting[fill=yellow!50]
+% The moon was up there sulkily because she thought the sun had no business to be there after the day was done\StopHighlighting.
+% ``It's very rude of him,'' she said, ``to come and spoil the fun.''
+% \end{example}
%
% \section{Acknowledgements}
%
@@ -810,8 +1080,8 @@ and the derived files tikzmark.ins,
% The \Verb+save nodes+ code uses \LaTeX3.
% \begin{macrocode}
\ProvidesFile{tikzlibrarytikzmark.code.tex}[%
- 2021/02/16
- v1.10
+ 2022/08/24
+ v1.15
TikZ library for marking positions in a document]
\RequirePackage{expl3, l3keys2e, xparse}
% \end{macrocode}
@@ -959,6 +1229,79 @@ and the derived files tikzmark.ins,
% \begin{macrocode}
tikzmark prefix/.initial=,%
tikzmark suffix/.initial=,%
+ tikzmark clear ixes/.style={
+ tikzmark prefix={},
+ tikzmark suffix={}
+ },
+% \end{macrocode}
+% Tikzmarks can be used to adjust the position of a scope or pic so that an internally defined coordinate is used to locate the scope or pic.
+%
+% The key used to adjust the location is \Verb!scope anchor={coordinate}! for \Verb!scope!s and \Verb!pic anchor={coordinate}! for \Verb!pic!s, where \Verb!coordinate! is evaluated internally to the \Verb!scope! or \Verb!pic!, so can use node names.
+% \begin{macrocode}
+ scope anchor location/.initial={(0,0)},
+ scope anchor location/.default=@auto,
+ pic anchor/.style={
+ scope anchor location={#1},
+ next pic/.append style={
+ adjust scope position,
+ }
+ },
+ scope anchor/.style={
+ scope anchor location={#1},
+ adjust scope position,
+ },
+% \end{macrocode}
+% The code that does the adjustment is added to the \Verb!pic! on its enclosing scope using the \Verb!every pic! key.
+% \begin{macrocode}
+ adjust scope position/.code={%
+ \pgfutil@ifundefined{tikz@fig@name}%
+ {\let\tikz@fig@name=\pgfutil@empty}{}%
+ \tikz@resetexpandcount%
+ \tikz@fig@mustbenamed
+ \pgfkeysgetvalue{/tikz/scope anchor location}\tkzmk@anchor
+ \ifx\tkzmk@anchor\tikz@auto@text
+ \tikzset{local bounding box/.expanded=\tikz@fig@name}%
+ \def\tkzmk@anchor{(\tikz@fig@name.\tikz@anchor)}%
+ \fi
+ \tikz@scan@one@point
+ \pgfutil@firstofone(pic cs:\tikz@fig@name-origin)\relax
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \tikz@scan@one@point
+ \pgfutil@firstofone(pic cs:\tikz@fig@name-anchor)\relax
+ \advance\pgf@xa by -\pgf@x
+ \advance\pgf@ya by -\pgf@y
+ \tikzset{
+ shift={(\the\pgf@xa,\the\pgf@ya)},
+ execute at end scope={%
+ \tikzmark{\tikz@fig@name-origin}{(0,0)}%
+ \tikzmark{\tikz@fig@name-anchor}{\tkzmk@anchor}%
+ }
+ }
+ },
+% \end{macrocode}
+%
+% To install this code on a pic, we hook in to the pic's enclosing scope using the \Verb+every pic+ key.
+% To avoid this bubbling down to pics within pics, we clear it once it has been executed.
+% So any code that triggers this adjustment adds \Verb!adjust pic position! to the !next pic! style.
+% \begin{macrocode}
+ every pic/.append style={
+ next pic/.try,
+ next pic/.style={}
+ },
+% \end{macrocode}
+%
+% This code remembers the bounding box of a pic, saving it as if it were a node.
+% \begin{macrocode}
+ save pic bounding box/.code={
+ \tikz@fig@mustbenamed
+ \tikzset{local bounding box/.expanded=\tikz@fig@name}
+ },
+ surround pic/.style={
+ next pic/.append style={
+ save pic bounding box
+ }
+ },
}
% \end{macrocode}
%
@@ -987,11 +1330,25 @@ and the derived files tikzmark.ins,
% \end{macro}
%
% \begin{macro}{\tikzmarkalias}
-% Alias a tikzmark to another name (used in tikzmarknode)
-% \begin{macrocode}
+% Alias a tikzmark to another name (used in tikzmarknode).
+% The alias is saved to the aux-file so that it is available prior to the definition.
+% The private one doesn't use the prefix-suffix for greater internal flexibility.
+% The public one does.
+% \begin{macrocode}
+\def\@tikzmarkalias#1#2{%
+ \@ifundefined{save@pt@#2}{}{%
+ \pgf@node@gnamelet{save@pt@#1}{save@pt@#2}%
+ \pgf@node@gnamelet{save@pt@#1@offset}{save@pt@#2@offset}%
+ \protected@write\pgfutil@auxout{}{%
+ \string\savepointas%
+ {#1}{\csname save@pt@#2\endcsname}%
+ \expandafter\expandafter\expandafter
+ \@gobble\csname save@pt@#2@offset\endcsname
+ }%
+ }%
+}
\def\tikzmarkalias#1#2{%
- \pgf@node@gnamelet{save@pt@#1}{save@pt@#2}%
- \pgf@node@gnamelet{save@pt@#1@offset}{save@pt@#2@offset}%
+ \@tikzmarkalias{\tikzmark@pp@name{#1}}{\tikzmark@pp@name{#2}}%
}
% \end{macrocode}
% \end{macro}
@@ -1017,7 +1374,8 @@ and the derived files tikzmark.ins,
\tmk@labeldef#1,(0pt,0pt)\@nil
\fi
\@ifundefined{save@pt@\tmk@label}{%
- \tikz@scan@one@point\pgfutil@firstofone\tmk@def
+ \expandafter\tikz@scan@one@point
+ \expandafter\pgfutil@firstofone\tmk@def\relax
}{%
\pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}%
\save@orig@pic%
@@ -1076,7 +1434,9 @@ and the derived files tikzmark.ins,
% \begin{macrocode}
\def\tikzmark@inside#1#2{%
\tikzset{remember picture}%
+ \tikz@resetexpandcount%
\tikz@scan@one@point\pgfutil@firstofone#2\relax
+ \pgf@pos@transform{\pgf@x}{\pgf@y}%
\protected@write\pgfutil@auxout{}{%
\string\savepointas%
{\tikzmark@pp@name{#1}}{\pgfpictureid}{\the\pgf@x}{\the\pgf@y}}%
@@ -1103,18 +1463,22 @@ and the derived files tikzmark.ins,
% \begin{macro}{\pgfmark}
% \begin{macrocode}
\newcommand\pgfmark[1]{%
- \bgroup
- \global\advance\pgf@picture@serial@count by1\relax%
- \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}%
- \pgfsys@markposition{\pgfpictureid}%
- \edef\pgf@temp{%
- \noexpand\write\noexpand\pgfutil@auxout{%
- \string\savepicturepage{\pgfpictureid}{\noexpand\arabic{page}}}}%
- \pgf@temp
- \protected@write\pgfutil@auxout{}{%
- \string\savepointas{\tikzmark@pp@name{#1}}{\pgfpictureid}{0pt}{0pt}}%
- \egroup
- }
+ \bgroup
+ \global\advance\pgf@picture@serial@count by1\relax%
+ \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}%
+ \pgfsys@markposition{\pgfpictureid}%
+ \edef\pgf@temp{%
+ \noexpand\write\noexpand\pgfutil@auxout{%
+ \string\savepicturepage
+ {\pgfpictureid}{\noexpand\arabic{page}}%
+ }%
+ }%
+ \pgf@temp
+ \protected@write\pgfutil@auxout{}{%
+ \string\savepointas
+ {\tikzmark@pp@name{#1}}{\pgfpictureid}{0pt}{0pt}}%
+ \egroup
+}
% \end{macrocode}
% \end{macro}
%
@@ -1183,7 +1547,9 @@ and the derived files tikzmark.ins,
\@ifundefined{save@pt@\tikzmark@pp@name{#1}}{%
\tikzmark@false
}{%
- \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname}{%
+ \@ifundefined{save@pg@%
+ \csname save@pt@\tikzmark@pp@name{#1}\endcsname%
+ }{%
\tikzmark@false
}{%
\ifnum\csname save@pg@%
@@ -1206,7 +1572,9 @@ and the derived files tikzmark.ins,
\@ifundefined{save@pt@\tikzmark@pp@name{#1}}{%
\tikzmark@false
}{%
- \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname}{%
+ \@ifundefined{save@pg@%
+ \csname save@pt@\tikzmark@pp@name{#1}\endcsname%
+ }{%
\tikzmark@false
}{%
\ifnum\csname save@pg@%
@@ -1225,13 +1593,15 @@ and the derived files tikzmark.ins,
%
% \begin{macro}{\subnode}
% Note: much of this code was inevitably adapted from the node defining code in the TikZ/PGF sources.
+%
+% The \Verb!\pgfmark! applies the current tikzmark prefix/suffix.
+% The current node prefix/suffix is applied by using the \Verb!name=! key.
% \begin{macrocode}
\def\subnode@#1#2#3{%
\begingroup
\pgfmark{#2}%
\setbox\pgfnodeparttextbox=\hbox\bgroup #3\egroup
- \def\tikz@fig@name{#2}%
- \tikzset{every subnode/.try,#1}%
+ \tikzset{every subnode/.try,#1,name=#2}%
\pgfpointorigin
\tikz@scan@one@point\pgfutil@firstofone(pic cs:#2)\relax
\advance\pgf@x by .5\wd\pgfnodeparttextbox
@@ -1251,24 +1621,30 @@ and the derived files tikzmark.ins,
\pgf@x=-\pgf@x%
\pgf@y=-\pgf@y%
}%
- \expandafter\pgfsavepgf@process\csname pgf@sh@sa@\tikz@fig@name\endcsname{%
+ \expandafter\pgfsavepgf@process
+ \csname pgf@sh@sa@\tikz@fig@name\endcsname{%
\pgf@sh@reanchor{rectangle}{center}% FIXME : this is double work!
}%
% Save the saved points and the transformation matrix
\edef\pgf@node@name{\tikz@fig@name}%
\ifx\pgf@node@name\pgfutil@empty%
\else%
- \expandafter\xdef\csname pgf@sh@ns@\pgf@node@name\endcsname{rectangle}%
+ \expandafter\xdef
+ \csname pgf@sh@ns@\pgf@node@name\endcsname{rectangle}%
\edef\pgf@sh@@temp{%
- \noexpand\gdef\expandafter\noexpand\csname pgf@sh@np@\pgf@node@name\endcsname}%
+ \noexpand\gdef\expandafter
+ \noexpand\csname pgf@sh@np@\pgf@node@name\endcsname}%
\expandafter\pgf@sh@@temp\expandafter{%
\pgf@sh@savedpoints}%
\edef\pgf@sh@@temp{%
- \noexpand\gdef\expandafter\noexpand\csname pgf@sh@ma@\pgf@node@name\endcsname}% MW
+ \noexpand\gdef\expandafter
+ \noexpand\csname pgf@sh@ma@\pgf@node@name\endcsname}% MW
\expandafter\pgf@sh@@temp\expandafter{\pgf@sh@savedmacros}% MW
\pgfgettransform\pgf@temp
- \expandafter\xdef\csname pgf@sh@nt@\pgf@node@name\endcsname{\pgf@temp}%
- \expandafter\xdef\csname pgf@sh@pi@\pgf@node@name\endcsname{\pgfpictureid}%
+ \expandafter\xdef
+ \csname pgf@sh@nt@\pgf@node@name\endcsname{\pgf@temp}%
+ \expandafter\xdef
+ \csname pgf@sh@pi@\pgf@node@name\endcsname{\pgfpictureid}%
\fi%
}%
\egroup
@@ -1291,31 +1667,34 @@ and the derived files tikzmark.ins,
\def\tzmk@prfx{pgf@sys@pdf@mark@pos@pgfid}%
\edef\tzmk@pic{\tzmk@prfx\the\pgf@picture@serial@count}
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
- \edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-1\relax}%
+ \edef\tzmk@pic%
+ {\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-1\relax}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
-\edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-2\relax}%
+ \edef\tzmk@pic%
+ {\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-2\relax}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
-\edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-3\relax}%
+ \edef\tzmk@pic%
+ {\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-3\relax}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
- \pgfutil@ifundefined{pgf@sh@ns@#2}{%
- \pgfnodealias{#2}{#2-t}%
- \tikzmarkalias{#2}{#2-t}%
+ \pgfutil@ifundefined{pgf@sh@ns@\tikz@pp@name{#2}}{%
+ \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-t}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
}{}%
\else
- \pgfnodealias{#2}{#2-d}%
- \tikzmarkalias{#2}{#2-d}%
+ \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-d}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-d}}%
\fi
\else
- \pgfnodealias{#2}{#2-t}%
- \tikzmarkalias{#2}{#2-t}%
+ \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-t}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
\fi
\else
- \pgfnodealias{#2}{#2-s}%
- \tikzmarkalias{#2}{#2-s}%
+ \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-s}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-s}}%
\fi
\else
- \pgfnodealias{#2}{#2-ss}%
- \tikzmarkalias{#2}{#2-ss}%
+ \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-ss}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-ss}}%
\fi
\else
\subnode@{#1}{#2}{#3}%
@@ -1366,31 +1745,34 @@ and the derived files tikzmark.ins,
\def\tzmk@prfx{pgf@sys@pdf@mark@pos@pgfid}%
\edef\tzmk@pic{\tzmk@prfx\the\pgf@picture@serial@count}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
- \edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-1\relax}%
+ \edef\tzmk@pic%
+ {\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-1\relax}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
-\edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-2\relax}%
+ \edef\tzmk@pic%
+ {\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-2\relax}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
-\edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-3\relax}%
+ \edef\tzmk@pic%
+ {\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-3\relax}%
\expandafter\ifx\csname\tzmk@pic\endcsname\relax
\pgfutil@ifundefined{pgf@sh@ns@\tikz@pp@name{#2}}{%
\pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-t}}%
- \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
}{}%
\else
\pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-d}}%
- \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-d}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-d}}%
\fi
\else
\pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-t}}%
- \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
\fi
\else
\pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-s}}%
- \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-s}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-s}}%
\fi
\else
\pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-ss}}%
- \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-ss}}%
+ \@tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-ss}}%
\fi
\else
\tikzmarknode@{#1}{#2}{#3}%
@@ -1399,6 +1781,80 @@ and the derived files tikzmark.ins,
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\tikzmark@box}
+% This macro takes a name and a box.
+% It pretends that there is a tight-fitting rectangular PGF node around that box with the given name, and saves the required information so that that node can be used later on in a tikzpicture drawing.
+%
+% It does not actually build a node, and it doesn't create a TikZ drawing.
+% Rather, it measures the box and uses that information to define the various macros that store the information about the node.
+%
+% Apart from assigning a load of macros, it does also place a \Verb+\pgfmark+ just before the box.
+% This is needed to be able to locate the node on the page.
+%
+% The command is defined with an \Verb!@! because it is more likely to be used in other packages than by a user.
+% \begin{macrocode}
+\def\tikzmark@box#1#2{%
+ \begingroup
+ \pgfmark{#1}%
+ \let\pgfnodeparttextbox=#2%
+ \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}%
+ \def\tikz@fig@name{#1}%
+ \pgfpointorigin
+ \advance\pgf@x by .5\wd\pgfnodeparttextbox
+ \advance\pgf@y by .5\ht\pgfnodeparttextbox
+ \advance\pgf@y by -.5\dp\pgfnodeparttextbox
+ \pgftransformshift{}%
+ \setbox\@tempboxa=\hbox\bgroup
+ {%
+ \tikzset{
+ inner sep=0pt,
+ minimum size=0pt,
+ outer sep=0pt,
+ anchor=base
+ }%
+ \let\pgf@sh@savedmacros=\pgfutil@empty% MW
+ \let\pgf@sh@savedpoints=\pgfutil@empty
+ \def\pgf@sm@shape@name{rectangle}% CJ % TT added prefix!
+ \pgf@sh@s@rectangle
+ \pgf@sh@savedpoints
+ \pgf@sh@savedmacros% MW
+ \pgftransformshift{%
+ \pgf@sh@reanchor{rectangle}{center}%
+ \pgf@x=-\pgf@x
+ \pgf@y=-\pgf@y
+ }%
+ \expandafter\pgfsavepgf@process
+ \csname pgf@sh@sa@\tikz@fig@name\endcsname{%
+ \pgf@sh@reanchor{rectangle}{center}% FIXME : this is double work!
+ }%
+ % Save the saved points and the transformation matrix
+ \edef\pgf@node@name{\tikz@fig@name}%
+ \ifx\pgf@node@name\pgfutil@empty
+ \else
+ \expandafter\xdef
+ \csname pgf@sh@ns@\pgf@node@name\endcsname{rectangle}%
+ \edef\pgf@sh@@temp{%
+ \noexpand\gdef\expandafter
+ \noexpand\csname pgf@sh@np@\pgf@node@name\endcsname}%
+ \expandafter\pgf@sh@@temp\expandafter{%
+ \pgf@sh@savedpoints}%
+ \edef\pgf@sh@@temp{%
+ \noexpand\gdef\expandafter
+ \noexpand\csname pgf@sh@ma@\pgf@node@name\endcsname}% MW
+ \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@savedmacros}% MW
+ \pgfgettransform\pgf@temp
+ \expandafter\xdef
+ \csname pgf@sh@nt@\pgf@node@name\endcsname{\pgf@temp}%
+ \expandafter\xdef
+ \csname pgf@sh@pi@\pgf@node@name\endcsname{\pgfpictureid}%
+ \fi
+ }%
+ \egroup
+ \endgroup
+ \box#2%
+}
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\usetikzmarklibrary}
% \begin{macrocode}
@@ -1407,28 +1863,33 @@ and the derived files tikzmark.ins,
}%}
\def\use@tikzmarklibrary[#1]{\use@@tikzmarklibrary{#1}}
\def\use@@tikzmarklibrary#1{%
- \edef\pgf@list{#1}%
- \pgfutil@for\pgf@temp:=\pgf@list\do{%
- \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}%
+ \edef\pgf@list{#1}%
+ \pgfutil@for\pgf@temp:=\pgf@list\do{%
+ \expandafter\pgfkeys@spdef
+ \expandafter\pgf@temp\expandafter{\pgf@temp}%
\ifx\pgf@temp\pgfutil@empty
\else
- \expandafter\ifx\csname tikzmark@library@\pgf@temp @loaded\endcsname\relax%
+ \expandafter\ifx
+ \csname tikzmark@library@\pgf@temp @loaded\endcsname\relax%
\expandafter\global\expandafter\let%
- \csname tikzmark@library@\pgf@temp @loaded\endcsname=\pgfutil@empty%
- \expandafter\edef\csname tikzmark@library@#1@atcode\endcsname{\the\catcode`\@}
- \expandafter\edef\csname tikzmark@library@#1@barcode\endcsname{\the\catcode`\|}
+ \csname tikzmark@library@\pgf@temp @loaded\endcsname
+ =\pgfutil@empty%
+ \expandafter\edef
+ \csname tikzmark@library@#1@atcode\endcsname{\the\catcode`\@}
+ \expandafter\edef
+ \csname tikzmark@library@#1@barcode\endcsname{\the\catcode`\|}
\catcode`\@=11
\catcode`\|=12
\pgfutil@InputIfFileExists{tikzmarklibrary\pgf@temp.code.tex}{}{
- \PackageError{tikzmark}{I did not find the tikzmark extras library '\pgf@temp'.}{}
- }%
+ \PackageError{tikzmark}{
+ I did not find the tikzmark extras library '\pgf@temp'.}{}
+ }%
\catcode`\@=\csname tikzmark@library@#1@atcode\endcsname
\catcode`\|=\csname tikzmark@library@#1@barcode\endcsname
\fi%
\fi
}%
}
-
% \end{macrocode}
% \end{macro}
%
@@ -1436,8 +1897,17 @@ and the derived files tikzmark.ins,
%
% \begin{macrocode}
\ExplSyntaxOn
+\cs_new_protected:Nn \tikzmark_tl_put_right_braced:Nn
+ {
+ \tl_put_right:Nn #1 { { #2 } }
+ }
+\cs_generate_variant:Nn \tikzmark_tl_put_right_braced:Nn { NV, cV, cv, Nx, cx }
% \end{macrocode}
%
+% This is how we handle return values from functions
+% \begin{macrocode}
+\tl_new:N \g__sn_output_tl
+% \end{macrocode}
% We save our information in a ``property list'', which is L3's
% version of an associative array or dictionary. They keys will give
% the ability to store several groups of nodes and restore them at
@@ -1462,9 +1932,10 @@ and the derived files tikzmark.ins,
\tl_new:N \l__sn_group_tl
% \end{macrocode}
%
-% We store up the nodes in a list and save them at the end of a given tikzpicture.
+% We store up the nodes in a list and save them at the end of a given tikzpicture.
+% Has to be global as we're often in a group.
% \begin{macrocode}
-\clist_new:N \l__sn_nodes_clist
+\clist_new:N \g__sn_nodes_clist
% \end{macrocode}
%
% This boolean is for whether we save to a file or not.
@@ -1475,9 +1946,19 @@ and the derived files tikzmark.ins,
% This boolean is for whether we are in the preamble or not.
% \begin{macrocode}
\bool_new:N \g__sn_preamble_bool
-\bool_set_true:N \g__sn_preamble_bool
+\bool_gset_true:N \g__sn_preamble_bool
+% \end{macrocode}
+%
+% Key interface for setting some of the options
+% \begin{macrocode}
+\keys_define:nn {tikzmark / save nodes}
+{
+ file .bool_set:N = \l__sn_file_bool,
+ group .tl_set:N = \l__sn_group_tl,
+}
% \end{macrocode}
%
+%
% \begin{macrocode}
\msg_new:nnn {tikzmark} {no file} {File~ "#1"~ doesn't~ exist.}
\msg_new:nnn {tikzmark} {loading nodes} {Loading~ nodes~ from~ "#1".}
@@ -1547,43 +2028,40 @@ and the derived files tikzmark.ins,
%
% \begingroup
% \catcode`_=12
-% \begin{macro}{\save_nodes:Nn}
+% \begin{macro}{\process_node:Nn}
% This is the command that actually does the work. It constructs a
% token list which contains the code that will restore the node data
% when invoked. The two arguments are the token list to store this in
-% and a comma separated list of the node names to be saved.
+% and the node name to be saved.
% \begin{macrocode}
-\cs_new_nopar:Npn \save_nodes:Nn #1#2
+\cs_new_nopar:Npn \__sn_process_node:n #1
{
+ \group_begin:
% \end{macrocode}
-% Clear our token lists
+% Clear our token list
% \begin{macrocode}
\tl_clear:N \l__sn_tmpa_tl
% \end{macrocode}
% Set the centre of the picture
% \begin{macrocode}
- \tikz_scan_point:NNn \l__sn_x_dim \l__sn_y_dim {(current~ bounding~ box.center)}
+ \tikz_scan_point:NNn \l__sn_x_dim \l__sn_y_dim
+ {(current~ bounding~ box.center)}
\dim_set:Nn \l__sn_x_dim {-\l__sn_x_dim}
\dim_set:Nn \l__sn_y_dim {-\l__sn_y_dim}
\tl_set:Nx \l__sn_centre_tl {
{1}{0}{0}{1}{\dim_use:N \l__sn_x_dim}{\dim_use:N \l__sn_y_dim}
}
% \end{macrocode}
-% Iterate over the list of node names
-% \begin{macrocode}
- \clist_map_inline:nn {#2}
- {
-% \end{macrocode}
% Test to see if the node has been defined
% \begin{macrocode}
- \tl_if_exist:cT {pgf@sh@ns@##1}
- {
-% \end{macrocode}
+ \tl_if_exist:cT {pgf@sh@ns@#1}
+ {
+% \end{macrocode}
% The node information is stored in a series of macros of the form
% \Verb+\pgf@sh@XX@nodename+ where XX is one of the following.
% \begin{macrocode}
- \clist_map_inline:nn {ns,np,ma,pi}
- {
+ \clist_map_inline:nn {ns,np,ma,pi}
+ {
% \end{macrocode}
% Our token list will look like:
%
@@ -1594,36 +2072,36 @@ and the derived files tikzmark.ins,
%
% This part puts the \Verb+\tl_set:cn {pgf@sh@XX@nodename}+ in place
% \begin{macrocode}
- \tl_put_right:Nn \l__sn_tmpa_tl
- {
- \tl_gset:cn {pgf@sh@####1@ \tikz_set_node_name:n{##1} }
- }
-% \end{macrocode}
+ \tl_put_right:Nn \l__sn_tmpa_tl
+ {
+ \tl_gset:cn {pgf@sh@##1@ \tikz_set_node_name:n{#1} }
+ }
+% \end{macrocode}
% Now we put the current contents in place. We're doing this in
% an expansive context to get at the contents. The \Verb+\exp_not:v+
% part takes the current value of \Verb+\pgf@sh@XX@nodename+ and puts
% it in place, preventing further expansion.
% \begin{macrocode}
- \tl_if_exist:cTF {pgf@sh@####1@##1}
- {
- \tl_put_right:Nx \l__sn_tmpa_tl {
- {\exp_not:v {pgf@sh@####1@ \tikz_set_node_name:n {##1}}}
- }
- }
- {
- \tl_put_right:Nx \l__sn_tmpa_tl {{}}
+ \tl_if_exist:cTF {pgf@sh@##1@#1}
+ {
+ \tl_put_right:Nx \l__sn_tmpa_tl {
+ {\exp_not:v {pgf@sh@##1@ \tikz_set_node_name:n {#1}}}
}
}
- \tl_put_right:Nn \l__sn_tmpa_tl
{
- \tl_gset:cn {pgf@sh@nt@ \tikz_set_node_name:n{##1} }
+ \tl_put_right:Nx \l__sn_tmpa_tl {{}}
}
- \compose_transformations:NVv \l__sn_tmpb_tl \l__sn_centre_tl {pgf@sh@nt@##1}
- \tl_put_right:Nx \l__sn_tmpa_tl {{\exp_not:V \l__sn_tmpb_tl}}
- \tl_put_right:Nn \l__sn_tmpa_tl {
- \transform_node:Nn \l__sn_transformation_tl {
- \tikz_set_node_name:n{##1}
- }
+ }
+ \tl_put_right:Nn \l__sn_tmpa_tl
+ {
+ \tl_gset:cn {pgf@sh@nt@ \tikz_set_node_name:n{#1} }
+ }
+ \compose_transformations:NVv
+ \l__sn_tmpb_tl \l__sn_centre_tl {pgf@sh@nt@#1}
+ \tl_put_right:Nx \l__sn_tmpa_tl {{\exp_not:V \l__sn_tmpb_tl}}
+ \tl_put_right:Nn \l__sn_tmpa_tl {
+ \transform_node:Nn \l__sn_transformation_tl {
+ \tikz_set_node_name:n{#1}
}
}
}
@@ -1631,7 +2109,20 @@ and the derived files tikzmark.ins,
% Once we've assembled our token list, we store it in the given
% token list
% \begin{macrocode}
- \tl_set_eq:NN #1 \l__sn_tmpa_tl
+ \tl_gset_eq:NN \g__sn_output_tl \l__sn_tmpa_tl
+ \group_end:
+}
+\cs_new_protected_nopar:Npn \process_node:Nn #1#2
+{
+ \__sn_process_node:n {#2}
+ \tl_set_eq:NN #1 \g__sn_output_tl
+ \tl_gclear:N \g__sn_output_tl
+}
+\cs_new_protected_nopar:Npn \process_gnode:Nn #1#2
+{
+ \__sn_process_node:n {#2}
+ \tl_gset_eq:NN #1 \g__sn_output_tl
+ \tl_gclear:N \g__sn_output_tl
}
% \end{macrocode}
% \end{macro}
@@ -1641,7 +2132,12 @@ and the derived files tikzmark.ins,
% \begin{macrocode}
\cs_new_nopar:Npn \save_nodes_to_list:nn #1#2
{
- \save_nodes:Nn \l__sn_tmpa_tl {#2}
+ \tl_clear:N \l__sn_tmpa_tl
+ \clist_map_inline:nn {#2}
+ {
+ \process_node:Nn \l__sn_tmpb_tl {##1}
+ \tl_put_right:NV \l__sn_tmpa_tl \l__sn_tmpb_tl
+ }
\prop_gput:NnV \g__sn_prop {#1} \l__sn_tmpa_tl
}
% \end{macrocode}
@@ -1650,24 +2146,27 @@ and the derived files tikzmark.ins,
% \begin{macro}{\save_nodes_to_file:n}
% Save the nodes to a file
% \begin{macrocode}
+\cs_generate_variant:Nn \iow_now:Nn {NV}
\cs_new_nopar:Npn \save_nodes_to_file:n #1
{
- \save_nodes:Nn \l__sn_tmpa_tl {#1}
+ \sn_open_stream:
+ \clist_map_inline:nn {#1}
+ {
+ \process_node:Nn \l__sn_tmpa_tl {##1}
% \end{macrocode}
% Save the token list to the nodes file so that on reading it back in, we restore the node definitions
% \begin{macrocode}
- \sn_open_stream:
- \iow_now:Nx \g__sn_stream
- {
- \iow_newline:
- \exp_not:V \l__sn_tmpa_tl
- \iow_newline:
+ \iow_now:Nx \g__sn_stream
+ {
+ \iow_newline:
+ \exp_not:V \l__sn_tmpa_tl
+ }
}
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
-\cs_generate_variant:Nn \save_nodes_to_list:nn {VV}
+\cs_generate_variant:Nn \save_nodes_to_list:nn {VV, Vn}
\cs_generate_variant:Nn \save_nodes_to_file:n {V}
% \end{macrocode}
%
@@ -1702,6 +2201,7 @@ and the derived files tikzmark.ins,
\msg_warning:nnn {tikzmark} {no file} {#1}
}
}
+\cs_generate_variant:Nn \restore_nodes_from_file:n {x}
\AtBeginDocument{\bool_gset_false:N \g__sn_preamble_bool}
% \end{macrocode}
% \end{macro}
@@ -1781,7 +2281,8 @@ and the derived files tikzmark.ins,
% \end{macro}
%
% \begin{macrocode}
-\cs_generate_variant:Nn \compose_transformations:Nnn {cVv,NVv,NVn,NvV,NnV}
+\cs_generate_variant:Nn \compose_transformations:Nnn
+{cVv,NVv,NVn,NvV,NnV}
% \end{macrocode}
%
% \begin{macro}{\transform_node:Nn}
@@ -1800,8 +2301,12 @@ and the derived files tikzmark.ins,
\tl_set_eq:Nc \l__sn_transformation_tl {pgf@sh@nt@#1}
\tikz_scan_point:NNn \l__sn_x_dim \l__sn_y_dim {(#1.center)}
- \dim_set:Nn \l__sn_x_dim {\l__sn_x_dim - \tl_item:cn {pgf@sh@nt@#1}{5}}
- \dim_set:Nn \l__sn_y_dim {\l__sn_y_dim - \tl_item:cn {pgf@sh@nt@#1}{6}}
+ \dim_set:Nn \l__sn_x_dim {
+ \l__sn_x_dim - \tl_item:cn {pgf@sh@nt@#1}{5}
+ }
+ \dim_set:Nn \l__sn_y_dim {
+ \l__sn_y_dim - \tl_item:cn {pgf@sh@nt@#1}{6}
+ }
\compose_transformations:NnV \l__sn_transformation_tl {
{1}{0}{0}{1}{\dim_use:N \l__sn_x_dim}{\dim_use:N \l__sn_y_dim}
@@ -1849,16 +2354,23 @@ and the derived files tikzmark.ins,
}
},
% \end{macrocode}
-% Append current node to the list of nodes to be saved
+% Append current node or named node to the list of nodes to be saved
% \begin{macrocode}
save~ node/.code={
- \tikz_fig_must_be_named:
- \pgfkeysalso{append~ after~ command={
- \pgfextra{
- \clist_gput_right:Nv \l__sn_nodes_clist {tikz@last@fig@name}
+ \tl_if_eq:nnTF {#1} {\pgfkeysnovalue}
+ {
+ \tikz_fig_must_be_named:
+ \pgfkeysalso{
+ append~ after~ command={
+ \pgfextra{
+ \clist_gput_right:Nv \g__sn_nodes_clist {tikz@last@fig@name}
+ }
}
}
}
+ {
+ \clist_gput_right:Nn \g__sn_nodes_clist {#1}
+ }
},
% \end{macrocode}
% Restore nodes from file
@@ -1866,14 +2378,14 @@ and the derived files tikzmark.ins,
restore~ nodes~ from~ file/.code={
\bool_if:NTF \g__sn_preamble_bool
{
- \restore_nodes_from_file:n {#1}
+ \restore_nodes_from_file:x {#1}
}
{
\tikz_fig_must_be_named:
\pgfkeysalso{append~ after~ command={
\pgfextra{
\scope
- \split_argument:NNn \tikzset \restore_nodes_from_file:n {#1}
+ \split_argument:NNn \tikzset \restore_nodes_from_file:x {#1}
\endscope
}
}
@@ -1929,22 +2441,51 @@ and the derived files tikzmark.ins,
% \begin{macrocode}
\cs_new_nopar:Npn \maybe_save_nodes:
{
- \clist_if_empty:NF \l__sn_nodes_clist
+ \clist_if_empty:NF \g__sn_nodes_clist
{
\bool_if:NTF \l__sn_file_bool
{
- \save_nodes_to_file:V \l__sn_nodes_clist
+ \save_nodes_to_file:V \g__sn_nodes_clist
}
{
\tl_if_empty:NF \l__sn_group_tl
{
- \save_nodes_to_list:VV \l__sn_group_tl \l__sn_nodes_clist
+ \save_nodes_to_list:VV \l__sn_group_tl \g__sn_nodes_clist
}
}
- \clist_gclear:N \l__sn_nodes_clist
+ \clist_gclear:N \g__sn_nodes_clist
}
}
-% \end{macrocode}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SaveNode}
+% Command for saving a node outside a TikZ picture.
+% \begin{macrocode}
+\DeclareDocumentCommand \SaveNode { o m }
+{
+ \group_begin:
+ \IfNoValueF {#1}
+ {
+ \keys_set:nn {tikzmark / save nodes}
+ {
+ file=false,
+ group=#1
+ }
+ }
+ \bool_if:NTF \l__sn_file_bool
+ {
+ \save_nodes_to_file:n {#2}
+ }
+ {
+ \tl_if_empty:NF \l__sn_group_tl
+ {
+ \save_nodes_to_list:Vn \l__sn_group_tl {#2}
+ }
+ }
+ \group_end:
+}
+% \end{macrocode}
% \end{macro}
% \endgroup
% \begin{macrocode}
@@ -2039,14 +2580,775 @@ and the derived files tikzmark.ins,
%
% \begin{macrocode}
}{%
- \PackageError{tikzmark listings}{The listings package has not been loaded.}{}
+ \PackageError{tikzmark listings}%
+ {The listings package has not been loaded.}{}
}
% \end{macrocode}
% \iffalse
%</listings>
% \fi
%
+% \subsection{AMS Math}
+%
+% This tikzmark library defines a routine that puts a pseudo-node (using \Verb+\tikzmark@box+) around all the pieces used in constructing the various math environments that the AMS Math package provides, such as \Verb+gather+ and \Verb+align+.
+% All of these (and their labels) work by putting various pieces into a box and then typesetting that box in the cells of an \Verb+halign+.
+% By using \Verb+\tikzmark@box+, this can be infiltrated to put nodes around each of those boxes as it is placed.
+%
+% \iffalse
+%<*ams>
+% \fi
+% \begin{macrocode}
+\@ifpackageloaded{amsmath}{%
+% \end{macrocode}
+%
+% \begin{macro}{tikzmarkmath}
+%
+% Defines an environment in which any AMS mathematical aligned environments get nodes around each piece of their contents.
+%
+% Start by saving the original \Verb+\boxz@+ command.
+% \begin{macrocode}
+ \let\tikzmark@ams@boxz@=\boxz@
+% \end{macrocode}
+%
+% We'll need a counter to keep track of the nodes.
+% \begin{macrocode}
+ \newcounter{tikzmarkequation}
+% \end{macrocode}
+%
+% The nodes will be labelled \Verb!<name>-<number>!.
+% By default the name is \Verb!equation! but this can be customised.
+% \begin{macrocode}
+ \def\tikzmark@ams@name{equation}
+% \end{macrocode}
+%
+% This is the substitute command.
+% I don't know if the \Verb=\ifmeasuring@= actually does anything, but it's here just in case at the moment.
+% \begin{macrocode}
+ \def\tikzmark@boxz@{%
+ \ifmeasuring@
+ \tikzmark@ams@boxz@
+ \else
+ \stepcounter{tikzmarkequation}%
+ \tikzmark@box{\tikzmark@ams@name-\thetikzmarkequation}{\z@}%
+ \fi
+ }
+% \end{macrocode}
+%
+% This is the environment that sets the node name and swaps out the box code.
+% At the end of the environment we swap back the code so that the commands can be used as standalone \Verb+\tikzmarkmath+ and \Verb+\endtikzmarkmath+ in occasions when it isn't appropriate to use an environment (for example, if it crosses sections, or if it is wanted to turn on this feature for an entire document).
+% At the end of the environment, the number of nodes is written out to the terminal and log file to make it easier to keep track.
+% \begin{macrocode}
+ \newenvironment{tikzmarkmath}[1][equation]{%
+ \def\tikzmark@ams@name{#1}%
+ \setcounter{tikzmarkequation}{0}%
+ \let\boxz@=\tikzmark@boxz@
+ }{%
+ \let\boxz@=\tikzmark@ams@boxz@
+ \message{%
+ Tikzmark math environment
+ \tikzmark@ams@name\space had
+ \the\value{tikzmarkequation} nodes in it
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+}{%
+ \PackageError{tikzmark AMS}%
+ {The amsmath package has not been loaded.}%
+ {}
+}
+% \end{macrocode}
+% \iffalse
+%</ams>
+% \fi
+%
+% \iffalse
+%<*highlighting>
+% \fi
+%
+% \subsection{Highlighting}
+%
+% An early use of \Verb!\tikzmark! was to add highlighting to text by drawing over or under the text between two tikzmarks, for example the question \href{http://tex.stackexchange.com/q/46434/86}{How to "highlight" text/formulas with tikz?}.
+%
+% I was never totally happy with the overall mechanism, so didn't include it in the main tikzmark package.
+% Recently, I had occasion to revisit it and by using the new \LaTeX3 hook facility I got something that I was sufficiently happy with to add to the main package.
+%
+% The key idea is to hook into the \texttt{shipout/background} routine to insert the highlighting behind the text.
+% This allows us to draw the highlighting before the page is laid out and so is under the text.
+%
+% \LaTeX3 makes life just that little bit easier.
+% \begin{macrocode}
+\ExplSyntaxOn
+% \end{macrocode}
+%
+% Since the code that draws the highlighting will probably be very separate from the code that defines it, when storing the highlighting code then we want to expand the tikzmark full name.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \tikzmark_fix_name:Nn #1#2
+{
+ \tl_set:Nx #1 {\tikzmark@pp@name{#2}}
+}
+% \end{macrocode}
+%
+% \begin{macro}{\StartHighlighting,\EndHighlighting,\Highlight}
+% These are the user interfaces for highlighting a section.
+% The first command inserts the drawing code into the relevant hook and places a tikzmark at the current location.
+% The second command indicates when the highlighting should stop.
+% The third is a short cut for highlighting its argument.
+%
+% These are commands rather than an environment to allow it to span, for example, different parts of an aligned equation.
+% \begin{macrocode}
+\tl_new:N \g__tikzmark_highlighter_tl
+\tl_set:Nn \g__tikzmark_highlighter_tl {tikzmark~ highlighter~}
+\int_new:N \g__tikzmark_highlighter_int
+\tl_new:N \l__tikzmark_start_tl
+\tl_new:N \l__tikzmark_end_tl
+\tl_new:N \l__tikzmark_highlighter_name_tl
+\tl_new:N \l__tikzmark_tmpa_tl
+\tl_new:N \l__tikzmark_tmpb_tl
+\tl_new:N \l__tikzmark_tmpc_tl
+
+\cs_new_protected_nopar:Npn \tikzmark_bake_highlighter:N #1
+{
+ \tl_clear:N #1
+ \clist_map_inline:nn {direction,layer}
+ {
+ \tl_put_right:Nx #1 {
+ /tikz/highlighter/##1=\pgfkeysvalueof{/tikz/highlighter/##1},
+ }
+ }
+ \clist_map_inline:nn {
+ initial~ height,
+ initial~ depth,
+ initial~ offset,
+ final~ height,
+ final~ depth,
+ final~ offset,
+ left~ margin,
+ right~ margin,
+ top~ margin,
+ bottom~ margin,
+ }
+ {
+ \tl_put_right:Nx #1 {
+ /tikz/highlighter/##1=\dim_eval:n {\pgfkeysvalueof{/tikz/highlighter/##1}},
+ }
+ }
+}
+
+\cs_new_protected_nopar:Npn \tikzmark_start_highlighting:n #1
+{
+ \int_gincr:N \g__tikzmark_highlighter_int
+ \tl_set:Nx \l__tikzmark_highlighter_name_tl
+ {
+ \tl_use:N \g__tikzmark_highlighter_tl
+ \int_use:N \g__tikzmark_highlighter_int
+ }
+ \tl_set:Nn \l__tikzmark_tmpb_tl
+ {
+ every~ highlighter/.try,
+ }
+ \tikzmark_bake_highlighter:N \l__tikzmark_tmpc_tl
+ \tl_put_right:NV \l__tikzmark_tmpb_tl \l__tikzmark_tmpc_tl
+ \tl_put_right:Nn \l__tikzmark_tmpb_tl {#1}
+ \tikzmark_process_highlighting:VV
+ \l__tikzmark_tmpb_tl
+ \l__tikzmark_highlighter_name_tl
+ \tikzmark{highlight-start-\tl_use:N \l__tikzmark_highlighter_name_tl}
+}
+\cs_new_protected_nopar:Npn \tikzmark_end_highlighting:
+{
+ \tl_set:Nx \l__tikzmark_highlighter_name_tl
+ {
+ \tl_use:N \g__tikzmark_highlighter_tl
+ \int_use:N \g__tikzmark_highlighter_int
+ }
+ \tikzmark{highlight-end-\tl_use:N \l__tikzmark_highlighter_name_tl}
+}
+
+\NewDocumentCommand \StartHighlighting {O{}}
+{%
+ \tikzmark_start_highlighting:n {#1}
+}
+\NewDocumentCommand \StopHighlighting {}
+{%
+ \tikzmark_end_highlighting:
+}
+\NewDocumentCommand \Highlight {O{} m}
+{%
+ \tikzmark_start_highlighting:n {#1}
+ #2
+ \tikzmark_end_highlighting:
+}
+% \end{macrocode}
+% \end{macro}
%
+% The following code inserts the drawing command into the shipout hook.
+% \begin{macrocode}
+% \end{macrocode}
+% We need an ordinary colon, rather than a \LaTeX3 one
+% \begin{macrocode}
+\tl_const:Nx \c__tikzmark_colon_tl
+{
+ \char_generate:nn {`:} {12}
+}
+
+\cs_generate_variant:Nn \hook_gput_next_code:nn {nV}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \tikzmark_highlight_or_shunt:nnnn #1#2#3#4
+{
+% \end{macrocode}
+% First, test to check if the tikzmarks are actually defined yet,
+% if not then bail out.
+% \begin{macrocode}
+ \bool_lazy_all:nT
+ {
+ {\tl_if_exist_p:c {save@pt@\tikzmark@pp@name{#2}}}
+ {\tl_if_exist_p:c {save@pg@\tl_use:c{save@pt@\tikzmark@pp@name{#2}}}}
+ {\tl_if_exist_p:c {save@pt@\tikzmark@pp@name{#3}}}
+ {\tl_if_exist_p:c {save@pg@\tl_use:c{save@pt@\tikzmark@pp@name{#3}}}}
+ }
+ {
+% \end{macrocode}
+% Okay, so all the tikzmarks are defined. Now see if we're on the
+% right page. Is our start tikzmark in the future?
+% \begin{macrocode}
+ \int_compare:nTF
+ {
+ \tl_use:c {save@pg@\tl_use:c{save@pt@\tikzmark@pp@name{#2}}}
+ >
+ \the\value{page}
+ }
+ {
+% \end{macrocode}
+% It is, so we just punt our highlighting down the line
+% \begin{macrocode}
+ \hook_gput_next_code:nn {#1} {
+ \tikzmark_highlight_or_shunt:nnnn {#1}{#2}{#3}{#4}
+ }
+ }
+ {
+% \end{macrocode}
+% It isn't, so we have some highlighting to do.
+% We need to build our highlighting code.
+% \begin{macrocode}
+ \tl_set:Nn \l__tikzmark_tmpa_tl {#4}
+% \end{macrocode}
+% Is our starting tikzmark on \emph{this} page?
+% \begin{macrocode}
+ \int_compare:nTF
+ {
+ \tl_use:c {save@pg@\tl_use:c{save@pt@\tikzmark@pp@name{#2}}}
+ =
+ \the\value{page}
+ }
+ {
+% \end{macrocode}
+% It is, so we use the starting tikzmark as our first coordinate.
+% \begin{macrocode}
+ \tl_put_right:Nx \l__tikzmark_tmpa_tl
+ {
+ {
+ pic~ cs
+ \tl_use:N \c__tikzmark_colon_tl
+ #2
+ }
+ }
+ }
+ {
+% \end{macrocode}
+% It isn't, so we use the north west corner of the page
+% \begin{macrocode}
+ \tl_put_right:Nn \l__tikzmark_tmpa_tl
+ {
+ {
+ page.north~ west
+ }
+ }
+ }
+% \end{macrocode}
+% Is our ending tikzmark on \emph{this} page?
+% \begin{macrocode}
+ \int_compare:nTF
+ {
+ \tl_use:c {save@pg@\tl_use:c{save@pt@\tikzmark@pp@name{#3}}}
+ =
+ \the\value{page}
+ }
+ {
+% \end{macrocode}
+% It is, so we use the ending tikzmark as our second coordinate.
+% \begin{macrocode}
+ \tl_put_right:Nx \l__tikzmark_tmpa_tl
+ {
+ {
+ pic~ cs
+ \tl_use:N \c__tikzmark_colon_tl
+ #3
+ }
+ }
+ }
+ {
+% \end{macrocode}
+% It isn't, so we use the south east corner of the page, and
+% we have to shunt the code to the next page.
+% \begin{macrocode}
+ \tl_put_right:Nn \l__tikzmark_tmpa_tl
+ {
+ {
+ page.south~ east
+ }
+ }
+ \hook_gput_next_code:nn {#1} {
+ \tikzmark_highlight_or_shunt:nnnn {#1}{#2}{#3}{#4}
+ }
+ }
+% \end{macrocode}
+% We've built our highlighting code, now's time to execute it.
+% \begin{macrocode}
+ \tl_use:N \l__tikzmark_tmpa_tl
+ }
+ }
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \tikzmark_process_highlighting:nn #1#2
+{
+ \pgfkeys{/tikz/highlighter/configuration/.activate~ family}
+ \pgfkeysfiltered{/tikz/.cd,highlighter/direction,highlighter/layer,#1}
+
+ \tikzmark_fix_name:Nn \l__tikzmark_start_tl {highlight-start-#2}
+ \tikzmark_fix_name:Nn \l__tikzmark_end_tl {highlight-end-#2}
+ \tl_set:Nx \l__tikzmark_tmpa_tl {\pgfkeysvalueof{/tikz/highlighter/direction}}
+ \tl_clear:N \l__tikzmark_tmpb_tl
+ \tl_clear:N \l__tikzmark_tmpc_tl
+ \tl_if_eq:NnTF \l__tikzmark_tmpa_tl {vertical}
+ {
+ \tl_put_right:Nn \l__tikzmark_tmpb_tl
+ {
+ \vl@draw
+ }
+ }
+ {
+ \tl_if_eq:NnTF \l__tikzmark_tmpa_tl {box}
+ {
+ \tl_put_right:Nn \l__tikzmark_tmpb_tl
+ {
+ \box@draw
+ }
+ }
+ {
+ \tl_put_right:Nn \l__tikzmark_tmpb_tl
+ {
+ \hl@draw
+ }
+ }
+ }
+
+ \tl_put_right:Nn \l__tikzmark_tmpb_tl
+ {
+ {tikzmark~ clear~ ixes,#1}
+ }
+
+ \tl_set:Nx \l__tikzmark_tmpa_tl {\pgfkeysvalueof{/tikz/highlighter/layer}}
+ \tl_set:Nn \l__tikzmark_tmpc_tl
+ {
+ \tikzmark_highlight_or_shunt:nnnn
+ }
+ \tl_if_eq:NnTF \l__tikzmark_tmpa_tl {foreground}
+ {
+ \tl_put_right:Nn \l__tikzmark_tmpc_tl {{shipout/foreground}}
+ }
+ {
+ \tl_put_right:Nn \l__tikzmark_tmpc_tl {{shipout/background}}
+ }
+
+ \tikzmark_tl_put_right_braced:NV \l__tikzmark_tmpc_tl \l__tikzmark_start_tl
+ \tikzmark_tl_put_right_braced:NV \l__tikzmark_tmpc_tl \l__tikzmark_end_tl
+ \tikzmark_tl_put_right_braced:NV \l__tikzmark_tmpc_tl \l__tikzmark_tmpb_tl
+
+ \tl_if_eq:NnTF \l__tikzmark_tmpa_tl {foreground}
+ {
+ \hook_gput_next_code:nV {shipout/foreground} \l__tikzmark_tmpc_tl
+ }
+ {
+ \hook_gput_next_code:nV {shipout/background} \l__tikzmark_tmpc_tl
+ }
+}
+\cs_generate_variant:Nn \tikzmark_process_highlighting:nn {nV,VV}
+\ExplSyntaxOff
+% \end{macrocode}
+%
+% The command that draws the horizontal highligher or fader.
+% This fills a shape determined by two coordinates assumed to be (in effect) on the baseline of the start and end of the region to be highlighted.
+% \begin{macrocode}
+\def\hl@draw#1#2#3{%
+ \pgfkeys{/tikz/highlighter/configuration/.activate family}
+ \pgfkeysfiltered{/tikz/.cd,highlighter/direction,highlighter/layer,#1}
+ \begin{tikzpicture}[
+ remember picture,
+ overlay,
+ highlight picture action,
+ #1,
+ ]%
+%
+ \page@node
+%
+ \tikz@scan@one@point\pgfutil@firstofone(#2)\relax
+ \pgf@ya=\pgf@y
+ \tikz@scan@one@point\pgfutil@firstofone(#3)\relax
+ \pgf@yb=\pgf@y
+%
+ \ifdim\pgf@ya=\pgf@yb
+%
+ \path (#2)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/initial offset},
+ \pgfkeysvalueof{/tikz/highlighter/initial height})
+ coordinate (start);
+%
+ \path (#3)
+ ++(\pgfkeysvalueof{/tikz/highlighter/final offset},
+ -1*\pgfkeysvalueof{/tikz/highlighter/final depth})
+ coordinate (end);
+%
+ \path[
+ highlight action,
+ #1
+ ] (start) rectangle (end);
+%
+ \else
+%
+ \path (page.east)
+ ++(\pgfkeysvalueof{/tikz/highlighter/right margin},0pt)
+ coordinate (east);
+%
+ \path (page.west)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/left margin},0pt)
+ coordinate (west);
+%
+ \pgfmathsetlength\pgf@x{%
+ \pgfkeysvalueof{/tikz/highlighter/initial height}%
+ }%
+%
+ \advance\pgf@yb by \pgf@x\relax
+%
+ \pgfmathsetlength\pgf@x{%
+ -1*\pgfkeysvalueof{/tikz/highlighter/final depth}%
+ }%
+%
+ \advance\pgf@ya by \pgf@x\relax
+%
+ \ifdim\pgf@yb>\pgf@ya
+%
+ \path (#2)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/initial offset},
+ \pgfkeysvalueof{/tikz/highlighter/initial height})
+ coordinate (start);
+%
+ \path (#2)
+ ++(0pt,-1*\pgfkeysvalueof{/tikz/highlighter/final depth})
+ coordinate (end);
+%
+ \path[
+ highlight action,
+ #1
+ ] (start) rectangle (end -| east);
+%
+ \path (#3)
+ ++(0pt,\pgfkeysvalueof{/tikz/highlighter/initial height})
+ coordinate (start);
+%
+ \path (#3)
+ ++(\pgfkeysvalueof{/tikz/highlighter/final offset},
+ -1*\pgfkeysvalueof{/tikz/highlighter/final depth})
+ coordinate (end);
+%
+ \path[
+ highlight action,
+ #1
+ ] (start -| west) rectangle (end);
+%
+ \else
+%
+ \path (#2)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/initial offset},
+ \pgfkeysvalueof{/tikz/highlighter/initial height})
+ coordinate (tl);
+%
+ \path (#2)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/initial offset},
+ -1*\pgfkeysvalueof{/tikz/highlighter/initial depth})
+ coordinate (start);
+%
+ \path (#3)
+ ++(\pgfkeysvalueof{/tikz/highlighter/final offset},
+ -1*\pgfkeysvalueof{/tikz/highlighter/final depth})
+ coordinate (end);
+%
+ \path (#3)
+ ++(\pgfkeysvalueof{/tikz/highlighter/final offset},
+ \pgfkeysvalueof{/tikz/highlighter/final height})
+ coordinate (mr);
+%
+ \path[
+ highlight action,
+ #1
+ ] (start) -- (tl) -- (tl -| east) -- (mr -| east) -- (mr) --
+ (end) -- (end -| west) -- (start -| west) -- cycle;
+%
+ \fi
+ \fi
+ \end{tikzpicture}%
+}
+% \end{macrocode}
+%
+% This one draws a box.
+% \begin{macrocode}
+\def\box@draw#1#2#3{%
+ \pgfkeys{/tikz/highlighter/configuration/.activate family}
+ \pgfkeysfiltered{/tikz/.cd,highlighter/direction,highlighter/layer,#1}
+ \begin{tikzpicture}[
+ remember picture,
+ overlay,
+ highlight picture action,
+ #1,
+ ]%
+%
+ \tikz@scan@one@point\pgfutil@firstofone(#2)\relax
+ \pgf@xa=\pgf@x
+ \tikz@scan@one@point\pgfutil@firstofone(#3)\relax
+ \pgf@xb=\pgf@x
+%
+ \def\tkmk@high@bscale{1}%
+ \ifdim\pgf@xa>\pgf@xb
+ \def\tkmk@high@bscale{-1}%
+ \fi
+%
+ \path (#2)
+ ++({\tkmk@high@bscale*(-1)*\pgfkeysvalueof{/tikz/highlighter/initial offset}},
+ \pgfkeysvalueof{/tikz/highlighter/initial height})
+ coordinate (start);
+%
+ \path (#3)
+ ++(\tkmk@high@bscale*\pgfkeysvalueof{/tikz/highlighter/final offset},
+ -1*\pgfkeysvalueof{/tikz/highlighter/final depth})
+ coordinate (end);
+%
+ \path[
+ highlight action,
+ #1
+ ] (start) rectangle (end);
+ \end{tikzpicture}%
+}
+% \end{macrocode}
+%
+% In this one the region is defined vertically.
+% \begin{macrocode}
+\def\vl@draw#1#2#3{%
+ \pgfkeys{/tikz/highlighter/configuration/.activate family}
+ \pgfkeysfiltered{/tikz/.cd,highlighter/direction,highlighter/layer,#1}
+ \begin{tikzpicture}[
+ remember picture,
+ overlay,
+ highlight picture action,
+ #1,
+ ]%
+%
+ \tikz@scan@one@point\pgfutil@firstofone(#2)\relax
+ \pgf@ya=\pgf@y
+ \pgf@xa=\pgf@x
+ \tikz@scan@one@point\pgfutil@firstofone(#3)\relax
+ \pgf@yb=\pgf@y
+ \pgf@xb=\pgf@x
+%
+ \pgfmathsetlength\pgf@y{%
+ \pgfkeysvalueof{/tikz/highlighter/initial offset}%
+ }%
+ \advance\pgf@yb by \pgf@y
+ \pgfmathsetlength\pgf@y{%
+ -1*\pgfkeysvalueof{/tikz/highlighter/final offset}%
+ }%
+ \advance\pgf@ya by \pgf@y
+%
+ \ifdim\pgf@yb>\pgf@ya
+%
+ \ifdim\pgf@xa>\pgf@xb
+%
+ \path (#2)
+ ++(\pgfkeysvalueof{/tikz/highlighter/initial height},
+ \pgfkeysvalueof{/tikz/highlighter/initial offset})
+ coordinate (start);
+%
+ \path (#3)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/final depth},
+ -1*\pgfkeysvalueof{/tikz/highlighter/final offset})
+ coordinate (end);
+%
+ \else
+%
+ \path (#2)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/initial depth},
+ \pgfkeysvalueof{/tikz/highlighter/initial offset})
+ coordinate (start);
+%
+ \path (#3)
+ ++(\pgfkeysvalueof{/tikz/highlighter/final height},
+ -1*\pgfkeysvalueof{/tikz/highlighter/final offset})
+ coordinate (end);
+%
+ \fi
+%
+ \path[
+ highlight action,
+ #1
+ ] (start) rectangle (end);
+%
+ \else
+%
+ \path (#2)
+ ++(\pgfkeysvalueof{/tikz/highlighter/initial height},0)
+ coordinate (tr);
+%
+ \path (#2)
+ ++(0,\pgfkeysvalueof{/tikz/highlighter/initial offset})
+ coordinate (start);
+%
+ \path (#2)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/initial depth},0)
+ coordinate (tl);
+%
+ \path (#3)
+ ++(\pgfkeysvalueof{/tikz/highlighter/final height},0)
+ coordinate (br);
+%
+ \path (#3)
+ ++(0,-1*\pgfkeysvalueof{/tikz/highlighter/final offset})
+ coordinate (end);
+%
+ \path (#3)
+ ++(-1*\pgfkeysvalueof{/tikz/highlighter/final depth},0)
+ coordinate (bl);
+%
+ \tikz@scan@one@point\pgfutil@firstofone(#2)\relax
+ \pgf@xa=\pgf@x
+ \tikz@scan@one@point\pgfutil@firstofone(#3)\relax
+ \pgf@xb=\pgf@x
+%
+ \ifdim\pgf@xa<\pgf@xb
+%
+ \path[
+ highlight action,
+ #1
+ ] (tl) |- (start) -| (tr) -| (br) |- (end) -| (bl) -| cycle;
+%
+ \else
+%
+ \path[
+ highlight action,
+ #1
+ ] (tl) |- (start) -| (tr) |- (br) |- (end) -| (bl) |- cycle;
+%
+ \fi
+%
+ \fi
+ \end{tikzpicture}
+}
+% \end{macrocode}
+%
+% These set various options.
+% \begin{macrocode}
+\tikzset{%
+ /tikz/highlighter/.is family,
+ /tikz/highlighter/.unknown/.code={%
+ \let\tk@searchname=\pgfkeyscurrentname%
+ \pgfkeysalso{%
+ /tikz/\tk@searchname=#1
+ }
+ },
+ every highlight path/.style={
+ fill=yellow!50,
+ rounded corners,
+ },
+ every foreground highlight path/.style={
+ fill opacity=.5,
+ },
+ highlight picture action/.style={
+ every highlight picture/.try,
+ every \pgfkeysvalueof{/tikz/highlighter/direction} highlight picture/.try,
+ every \pgfkeysvalueof{/tikz/highlighter/layer} highlight picture/.try,
+ },
+ highlight action/.style={
+ every highlight path/.try,
+ every \pgfkeysvalueof{/tikz/highlighter/direction} highlight path/.try,
+ every \pgfkeysvalueof{/tikz/highlighter/layer} highlight path/.try,
+ highlight path/.try,
+ \pgfkeysvalueof{/tikz/highlighter/direction} highlight path/.try,
+ \pgfkeysvalueof{/tikz/highlighter/layer} highlight path/.try,
+ },
+ /tikz/highlighter/.cd,
+ direction/.initial=horizontal,
+ layer/.initial=background,
+ direction/.default=horizontal,
+ layer/.default=background,
+ initial height/.initial=\baselineskip,
+ initial depth/.initial=.5ex,
+ initial offset/.initial=.5\baselineskip,
+ final height/.initial=\baselineskip,
+ final depth/.initial=.5ex,
+ final offset/.initial=.5\baselineskip,
+ left margin/.initial=.5\baselineskip,
+ right margin/.initial=.5\baselineskip,
+ top margin/.initial=.5\baselineskip,
+ bottom margin/.initial=-.5\baselineskip,
+ height/.style={
+ initial height=#1,
+ final height=#1
+ },
+ depth/.style={
+ initial depth=#1,
+ final depth=#1
+ },
+ offset/.style={
+ initial offset=#1,
+ final offset=#1
+ },
+ margin/.style={
+ left margin=#1,
+ right margin=#1,
+ top margin=#1,
+ bottom margin=#1,
+ },
+ /tikz/highlighter/configuration/.is family,
+ /tikz/highlighter/direction/.belongs to family=/tikz/highlighter/configuration,
+ /tikz/highlighter/layer/.belongs to family=/tikz/highlighter/configuration,
+}
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\def\page@node{
+ \path (current page.north west)
+ ++(\hoffset + 1in + \oddsidemargin + \leftskip,
+ -\voffset - 1in - \topmargin - \headheight - \headsep)
+ node[
+ minimum width=\textwidth - \leftskip - \rightskip,
+ minimum height=\textheight,
+ anchor=north west,
+ line width=0mm,
+ inner sep=0pt,
+ outer sep=0pt,
+ ] (page) {};
+}
+% \end{macrocode}
+%
+%
+%
+% \iffalse
+%</highlighting>
+% \fi
%
% \Finale
\endinput
diff --git a/graphics/pgf/contrib/tikzmark/tikzmark.pdf b/graphics/pgf/contrib/tikzmark/tikzmark.pdf
index 62c1de9cca..385b47553d 100644
--- a/graphics/pgf/contrib/tikzmark/tikzmark.pdf
+++ b/graphics/pgf/contrib/tikzmark/tikzmark.pdf
Binary files differ