summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex')
-rw-r--r--Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex321
1 files changed, 171 insertions, 150 deletions
diff --git a/Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex b/Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex
index 0322a679410..5872a71fdf3 100644
--- a/Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex
+++ b/Master/texmf-dist/tex/latex/spath3/tikzlibraryknots.code.tex
@@ -4,17 +4,17 @@
%%
%% The original source files were:
%%
-%% spath3.dtx (with options: `knots')
+%% spath3_code.dtx (with options: `knots')
%% ----------------------------------------------------------------
%% spath3 --- Functions for manipulating PGF soft paths
-%% E-mail: stacey@math.ntnu.no
+%% E-mail: loopspace@mathforge.org
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%%
%%
\RequirePackage{spath3}
-\usetikzlibrary{intersections}
+\usetikzlibrary{intersections,spath3}
\ExplSyntaxOn
@@ -22,8 +22,6 @@
\tl_new:N \l__knot_tmpb_tl
\tl_new:N \l__knot_tmpc_tl
\tl_new:N \l__knot_tmpd_tl
-\tl_new:N \l__knot_tmpe_tl
-\tl_new:N \l__knot_tmpf_tl
\tl_new:N \l__knot_tmpg_tl
\tl_new:N \l__knot_redraws_tl
\tl_new:N \l__knot_clip_width_tl
@@ -31,16 +29,21 @@
\tl_new:N \l__knot_node_tl
\tl_new:N \l__knot_aux_tl
\tl_new:N \l__knot_auxa_tl
+\tl_new:N \l__knot_prefix_tl
+
+\seq_new:N \l__knot_segments_seq
\int_new:N \l__knot_tmpa_int
\int_new:N \l__knot_strands_int
-\int_new:N \l__knot_intersections_int
-\int_new:N \l__knot_filaments_int
+\int_new:N \g__knot_intersections_int
+\int_new:N \g__knot_filaments_int
\int_new:N \l__knot_component_start_int
+\fp_new:N \l__knot_tmpa_fp
+\fp_new:N \l__knot_tmpb_fp
+
\dim_new:N \l__knot_tmpa_dim
\dim_new:N \l__knot_tmpb_dim
-\dim_new:N \l__knot_tmpc_dim
\dim_new:N \l__knot_tolerance_dim
\dim_new:N \l__knot_clip_bg_radius_dim
\dim_new:N \l__knot_clip_draw_radius_dim
@@ -56,10 +59,16 @@
\bool_new:N \l__knot_skip_bool
\bool_new:N \l__knot_save_bool
-\seq_new:N \l__knot_nodes_seq
+\seq_new:N \g__knot_nodes_seq
\bool_set_true:N \l__knot_ignore_ends_bool
\tikzset{
+ spath/prefix/knot/.style={
+ spath/set~ prefix=knot strand,
+ },
+ spath/suffix/knot/.style={
+ spath/set~ suffix={},
+ },
knot/.code={
\tl_if_eq:nnTF {#1} {none}
{
@@ -218,7 +227,7 @@
\int_incr:N \l__knot_strands_int
\tl_clear_new:c {l__knot_options_strand \int_use:N \l__knot_strands_int}
\tl_set:cn {l__knot_options_strand \int_use:N \l__knot_strands_int} {#1}
- \path[#1,save~ spath=knot strand \int_use:N \l__knot_strands_int]
+ \path[#1,spath/set~ name=knot,spath/save=\int_use:N \l__knot_strands_int]
}
\NewDocumentEnvironment{knot} { O{} }
{
@@ -232,7 +241,7 @@
\tikzset{knot~ diagram/.cd,every~ knot~ diagram/.try,#1}
\int_zero:N \l__knot_strands_int
\tl_clear:N \l__knot_redraws_tl
- \seq_gclear:N \l__knot_nodes_seq
+ \seq_gclear:N \g__knot_nodes_seq
}
\cs_new_protected_nopar:Npn \knot_render:
{
@@ -245,25 +254,23 @@
\bool_if:NTF \l__knot_self_intersections_bool
{
\knot_split_strands:
- \int_set_eq:NN \l__knot_tmpa_int \l__knot_filaments_int
+ \int_set_eq:NN \l__knot_tmpa_int \g__knot_filaments_int
\tl_set:Nn \l__knot_prefix_tl {filament}
}
{
\int_set_eq:NN \l__knot_tmpa_int \l__knot_strands_int
\tl_set:Nn \l__knot_prefix_tl {strand}
}
- \int_gzero:N \l__knot_intersections_int
- \bool_if:NTF \l__knot_draft_bool
+ \int_gzero:N \g__knot_intersections_int
+ \tl_clear:N \l__knot_node_tl
+ \bool_if:NT \l__knot_draft_bool
{
\tl_set:Nn \l__knot_node_tl {
\exp_not:N \node[coordinate,
- pin={[node~ contents={\int_use:N \l__knot_intersections_int},knot~ diagram/draft/crossing~ label, knot~ diagram/draft/crossing~ \int_use:N \l__knot_intersections_int \c_space_tl label/.try]
+ pin={[node~ contents={\int_use:N \g__knot_intersections_int},knot~ diagram/draft/crossing~ label, knot~ diagram/draft/crossing~ \int_use:N \g__knot_intersections_int \c_space_tl label/.try]
}]
}
}
- {
- \tl_set:Nn \l__knot_node_tl {\exp_not:N \node[coordinate]}
- }
\int_step_variable:nnnNn {1} {1} {\l__knot_tmpa_int - 1} \l__knot_tmpa_tl
{
\int_step_variable:nnnNn {\tl_use:N \l__knot_tmpa_tl + 1} {1} {\l__knot_tmpa_int} \l__knot_tmpb_tl
@@ -272,7 +279,7 @@
}
}
\tl_use:N \l__knot_redraws_tl
- \seq_use:Nn \l__knot_nodes_seq {}
+ \seq_use:Nn \g__knot_nodes_seq {}
}
\endpgfscope
}
@@ -280,11 +287,11 @@
{
\pgfscope
\group_begin:
- \tl_set:Nn \l_tmpa_tl {knot~ diagram/every~ strand/.try,}
- \tl_put_right:Nv \l_tmpa_tl {l__knot_options_strand #1}
- \tl_put_right:Nn \l_tmpa_tl {,knot~ diagram/only~ when~ rendering/.try,only~ when~ rendering/.try}
- \spath_bake_round:n {knot strand #1}
- \spath_tikz_path:Vn \l_tmpa_tl {knot strand #1}
+ \spath_bake_round:c {knot strand #1}
+ \tl_set:Nn \l__knot_tmpa_tl {knot~ diagram/every~ strand/.try,}
+ \tl_put_right:Nv \l__knot_tmpa_tl {l__knot_options_strand #1}
+ \tl_put_right:Nn \l__knot_tmpa_tl {,knot~ diagram/only~ when~ rendering/.try,only~ when~ rendering/.try}
+ \spath_tikz_path:Vv \l__knot_tmpa_tl {knot strand #1}
\group_end:
\endpgfscope
}
@@ -293,11 +300,11 @@
{
\bool_if:NT \l__knot_draft_bool
{
- \spath_get:nnN {knot strand #1} {final point} \l__knot_tmpb_tl
+ \spath_finalpoint:Nv \l__knot_tmpb_tl {knot strand #1}
\dim_set:Nn \l__knot_tmpa_dim {\tl_item:Nn \l__knot_tmpb_tl {1}}
\dim_set:Nn \l__knot_tmpb_dim {\tl_item:Nn \l__knot_tmpb_tl {2}}
\node[knot~ diagram/draft/strand~label] at (\l__knot_tmpa_dim,\l__knot_tmpb_dim) {#1};
- \spath_get:nnN {knot strand #1} {initial point} \l__knot_tmpb_tl
+ \spath_initialpoint:Nv \l__knot_tmpb_tl {knot strand #1}
\dim_set:Nn \l__knot_tmpa_dim {\tl_item:Nn \l__knot_tmpb_tl {1}}
\dim_set:Nn \l__knot_tmpb_dim {\tl_item:Nn \l__knot_tmpb_tl {2}}
\node[knot~ diagram/draft/strand~label] at (\l__knot_tmpa_dim,\l__knot_tmpb_dim) {#1};
@@ -309,84 +316,86 @@
}
{
\tl_clear:N \l__knot_tmpa_tl
- \spath_map_segment_function:nN {knot strand #1} \knot_split_self_intersects:NN
- \spath_put:nnV {knot strand #1} {path} \l__knot_tmpa_tl
+ \spath_segments_to_seq:Nv \l__knot_segments_seq {knot strand #1}
+ \seq_map_function:NN \l__knot_segments_seq \knot_split_self_intersects:N
+ \tl_set_eq:cN {knot strand #1} \l__knot_tmpa_tl
}
}
-\cs_new_protected_nopar:Npn \knot_split_self_intersects:NN #1#2
+\cs_new_protected_nopar:Npn \knot_split_self_intersects:N #1
{
- \tl_case:NnF #1
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_item:nn {#1} {4}}
+ \tl_case:NnF \l__knot_tmpc_tl
{
- \g__spath_curvetoa_tl
+ \c_spath_curvetoa_tl
{
- \fp_set:Nn \l_tmpa_fp
+ \fp_set:Nn \l__knot_tmpa_fp
{
- (\tl_item:Nn #2 {3} - 3 * \tl_item:Nn #2 {6} + 3 * \tl_item:Nn #2 {9} - \tl_item:Nn #2 {12})
+ (\tl_item:nn {#1} {3} - 3 * \tl_item:nn {#1} {6} + 3 * \tl_item:nn {#1} {9} - \tl_item:nn {#1} {12})
*
- (3 * \tl_item:Nn #2 {8} - 3 * \tl_item:Nn #2 {11})
+ (3 * \tl_item:nn {#1} {8} - 3 * \tl_item:nn {#1} {11})
-
- (\tl_item:Nn #2 {2} - 3 * \tl_item:Nn #2 {5} + 3 * \tl_item:Nn #2 {8} - \tl_item:Nn #2 {11})
+ (\tl_item:nn {#1} {2} - 3 * \tl_item:nn {#1} {5} + 3 * \tl_item:nn {#1} {8} - \tl_item:nn {#1} {11})
*
- (3 * \tl_item:Nn #2 {9} - 3 * \tl_item:Nn #2 {12})
+ (3 * \tl_item:nn {#1} {9} - 3 * \tl_item:nn {#1} {12})
}
- \fp_set:Nn \l_tmpb_fp
+ \fp_set:Nn \l__knot_tmpb_fp
{
- (\tl_item:Nn #2 {2} - 3 * \tl_item:Nn #2 {5} + 3 * \tl_item:Nn #2 {8} - \tl_item:Nn #2 {11})
+ (\tl_item:nn {#1} {2} - 3 * \tl_item:nn {#1} {5} + 3 * \tl_item:nn {#1} {8} - \tl_item:nn {#1} {11})
*
- (3 * \tl_item:Nn #2 {6} - 6 * \tl_item:Nn #2 {9} + 3 * \tl_item:Nn #2 {12})
+ (3 * \tl_item:nn {#1} {6} - 6 * \tl_item:nn {#1} {9} + 3 * \tl_item:nn {#1} {12})
-
- (\tl_item:Nn #2 {3} - 3 * \tl_item:Nn #2 {6} + 3 * \tl_item:Nn #2 {9} - \tl_item:Nn #2 {12})
+ (\tl_item:nn {#1} {3} - 3 * \tl_item:nn {#1} {6} + 3 * \tl_item:nn {#1} {9} - \tl_item:nn {#1} {12})
*
- (3 * \tl_item:Nn #2 {5} - 6 * \tl_item:Nn #2 {8} + 3 * \tl_item:Nn #2 {11})
+ (3 * \tl_item:nn {#1} {5} - 6 * \tl_item:nn {#1} {8} + 3 * \tl_item:nn {#1} {11})
}
\fp_compare:nTF
{
- \l_tmpb_fp != 0
+ \l__knot_tmpb_fp != 0
}
{
- \fp_set:Nn \l_tmpa_fp {.5 * \l_tmpa_fp / \l_tmpb_fp}
+ \fp_set:Nn \l__knot_tmpa_fp {.5 * \l__knot_tmpa_fp / \l__knot_tmpb_fp}
\fp_compare:nTF
{
- 0 < \l_tmpa_fp && \l_tmpa_fp < 1
+ 0 < \l__knot_tmpa_fp && \l__knot_tmpa_fp < 1
}
{
- \spath_split_curve:VVNN \l_tmpa_fp #2 \l_tmpa_tl \l_tmpb_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_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__knot_tmpa_tl \l_tmpa_tl
- \tl_put_right:NV \l__knot_tmpa_tl \l_tmpb_tl
+ \spath_split_curve:NNnV \l__knot_tmpc_tl \l__knot_tmpd_tl {#1} \l__knot_tmpa_fp
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpd_tl {\tl_tail:N \l__knot_tmpd_tl}
+ \tl_set:Nx \l__knot_tmpd_tl {\tl_tail:N \l__knot_tmpd_tl}
+ \tl_set:Nx \l__knot_tmpd_tl {\tl_tail:N \l__knot_tmpd_tl}
+ \tl_put_right:NV \l__knot_tmpa_tl \l__knot_tmpc_tl
+ \tl_put_right:NV \l__knot_tmpa_tl \l__knot_tmpd_tl
}
{
- \tl_set_eq: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_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl}
- \tl_put_right:NV \l__knot_tmpa_tl \l_tmpa_tl
+ \tl_set:Nn \l__knot_tmpc_tl {#1}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_put_right:NV \l__knot_tmpa_tl \l__knot_tmpc_tl
}
}
{
- \tl_set_eq: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_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl}
- \tl_put_right:NV \l__knot_tmpa_tl \l_tmpa_tl
+ \tl_set:Nn \l__knot_tmpc_tl {#1}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_put_right:NV \l__knot_tmpa_tl \l__knot_tmpc_tl
}
}
- \g__spath_lineto_tl
+ \c_spath_lineto_tl
{
- \tl_set_eq: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_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl}
- \tl_put_right:NV \l__knot_tmpa_tl \l_tmpa_tl
+ \tl_set:Nn \l__knot_tmpc_tl {#1}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_set:Nx \l__knot_tmpc_tl {\tl_tail:N \l__knot_tmpc_tl}
+ \tl_put_right:NV \l__knot_tmpa_tl \l__knot_tmpc_tl
}
}
{
- \tl_put_right:NV \l__knot_tmpa_tl #2
+ \tl_put_right:Nn \l__knot_tmpa_tl {#1}
}
}
\cs_new_protected_nopar:Npn \knot_intersections:nn #1#2
@@ -396,8 +405,8 @@
\tl_put_right:Nn \l__knot_tmpa_tl {#1}
\tl_set_eq:NN \l__knot_tmpb_tl \l__knot_prefix_tl
\tl_put_right:Nn \l__knot_tmpb_tl {#2}
- \spath_get:nnN {knot \tl_use:N \l__knot_tmpa_tl} {path} \l__knot_tmpc_tl
- \spath_get:nnN {knot \tl_use:N \l__knot_tmpb_tl} {path} \l__knot_tmpd_tl
+ \tl_set_eq:Nc \l__knot_tmpc_tl {knot \tl_use:N \l__knot_tmpa_tl}
+ \tl_set_eq:Nc \l__knot_tmpd_tl {knot \tl_use:N \l__knot_tmpb_tl}
\bool_if:nTF {
\l__knot_save_bool
@@ -411,10 +420,12 @@
\pgfintersectionofpaths{\pgfsetpath\l__knot_tmpc_tl}{\pgfsetpath\l__knot_tmpd_tl}
}
+
\int_compare:nT {\pgfintersectionsolutions > 0}
{
\int_step_function:nnnN {1} {1} {\pgfintersectionsolutions} \knot_do_intersection:n
}
+
\knot_save_intersections:VV \l__knot_tmpa_tl \l__knot_tmpb_tl
\group_end:
}
@@ -464,10 +475,10 @@
\bool_set_false:N \l__knot_skip_bool
\bool_if:NT \l__knot_self_intersections_bool
{
- \tl_set:Nn \l_tmpa_tl {knot previous}
- \tl_put_right:NV \l_tmpa_tl \l__knot_tmpa_tl
- \tl_set:Nv \l_tmpa_tl \l_tmpa_tl
- \tl_if_eq:NNT \l_tmpa_tl \l__knot_tmpb_tl
+ \tl_set:Nn \l__knot_tmpc_tl {knot previous}
+ \tl_put_right:NV \l__knot_tmpc_tl \l__knot_tmpa_tl
+ \tl_set:Nv \l__knot_tmpc_tl \l__knot_tmpc_tl
+ \tl_if_eq:NNT \l__knot_tmpc_tl \l__knot_tmpb_tl
{
\knot_test_endpoint:VnT \l__knot_tmpb_tl {final point}
{
@@ -475,10 +486,10 @@
}
}
- \tl_set:Nn \l_tmpa_tl {knot previous}
- \tl_put_right:NV \l_tmpa_tl \l__knot_tmpb_tl
- \tl_set:Nv \l_tmpa_tl \l_tmpa_tl
- \tl_if_eq:NNT \l_tmpa_tl \l__knot_tmpa_tl
+ \tl_set:Nn \l__knot_tmpc_tl {knot previous}
+ \tl_put_right:NV \l__knot_tmpc_tl \l__knot_tmpb_tl
+ \tl_set:Nv \l__knot_tmpc_tl \l__knot_tmpc_tl
+ \tl_if_eq:NNT \l__knot_tmpc_tl \l__knot_tmpa_tl
{
\knot_test_endpoint:VnT \l__knot_tmpa_tl {final point}
{
@@ -508,23 +519,23 @@
\bool_if:NF \l__knot_skip_bool
{
- \int_gincr:N \l__knot_intersections_int
+ \int_gincr:N \g__knot_intersections_int
\bool_if:nF
{
\tl_if_exist_p:c {l__knot_ignore_crossing_ \int_use:N
- \l__knot_intersections_int}
+ \g__knot_intersections_int}
&&
! \tl_if_empty_p:c {l__knot_ignore_crossing_ \int_use:N
- \l__knot_intersections_int}
+ \g__knot_intersections_int}
}
{
\bool_if:nTF
{
\tl_if_exist_p:c {l__knot_crossing_ \int_use:N
- \l__knot_intersections_int}
+ \g__knot_intersections_int}
&&
! \tl_if_empty_p:c {l__knot_crossing_ \int_use:N
- \l__knot_intersections_int}
+ \g__knot_intersections_int}
}
{
\tl_set_eq:NN \l__knot_tmpg_tl \l__knot_tmpb_tl
@@ -553,9 +564,10 @@
\l__knot_prepend_prev_bool || \l__knot_append_next_bool
}
{
- \spath_clone:nn {knot \tl_use:N \l__knot_tmpg_tl}
- {knot \tl_use:N \l__knot_prefix_tl -1}
+ \tl_clear_new:c {knot \tl_use:N \l__knot_prefix_tl -1}
+ \tl_set_eq:cc {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:N \l__knot_tmpg_tl}
+ \tl_clear_new:c {l__knot_options_ \tl_use:N \l__knot_prefix_tl -1}
\tl_set_eq:cc {l__knot_options_ \tl_use:N \l__knot_prefix_tl -1} {l__knot_options_ \tl_use:N \l__knot_tmpg_tl}
\bool_if:nT
@@ -567,7 +579,7 @@
!\tl_if_empty_p:c {knot previous \tl_use:N \l__knot_tmpg_tl}
}
{
- \spath_prepend_no_move:nn {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot previous \tl_use:N \l__knot_tmpg_tl}}
+ \spath_prepend_no_move:cv {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot previous \tl_use:N \l__knot_tmpg_tl}}
\bool_if:nT
{
\l__knot_splits_bool
@@ -579,10 +591,9 @@
{
\knot_test_endpoint:vnT {knot previous \tl_use:N \l__knot_tmpg_tl} {initial point}
{
- \spath_get:nnN {knot \tl_use:N \l__knot_prefix_tl -1} {path} \l_tmpa_tl
- \spath_prepend_no_move:nn {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot previous \tl_use:c {knot previous \tl_use:N \l__knot_tmpg_tl}}}
- \spath_get:nnN {knot \tl_use:N \l__knot_prefix_tl -1} {path} \l_tmpa_tl
+ \spath_prepend_no_move:cv {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot previous \tl_use:c {knot previous \tl_use:N \l__knot_tmpg_tl}}}
+ \tl_set_eq:Nc \l__knot_tmpa_tl {knot \tl_use:N \l__knot_prefix_tl -1}
}
}
}
@@ -595,7 +606,7 @@
!\tl_if_empty_p:c {knot previous \tl_use:N \l__knot_tmpg_tl}
}
{
- \spath_append_no_move:nn {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot next \tl_use:N \l__knot_tmpg_tl}}
+ \spath_append_no_move:cv {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot next \tl_use:N \l__knot_tmpg_tl}}
\bool_if:nT
{
\l__knot_splits_bool
@@ -608,7 +619,7 @@
{
\knot_test_endpoint:vnT {knot previous \tl_use:N \l__knot_tmpg_tl} {final point}
{
- \spath_append_no_move:nn {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot next \tl_use:c {knot next \tl_use:N \l__knot_tmpg_tl}}}
+ \spath_append_no_move:cv {knot \tl_use:N \l__knot_prefix_tl -1} {knot \tl_use:c {knot next \tl_use:c {knot next \tl_use:N \l__knot_tmpg_tl}}}
}
}
@@ -619,13 +630,16 @@
}
\pgfscope
\group_begin:
- \tikzset{knot~ diagram/every~ intersection/.try, every~ intersection/.try, knot~ diagram/intersection~ \int_use:N \l__knot_intersections_int/.try}
- \knot_draw_crossing:nVV {\tl_use:N \l__knot_tmpg_tl} \l__knot_tmpa_dim \l__knot_tmpb_dim
+ \tikzset{knot~ diagram/every~ intersection/.try, every~ intersection/.try, knot~ diagram/intersection~ \int_use:N \g__knot_intersections_int/.try}
+ \knot_draw_crossing:VVV \l__knot_tmpg_tl \l__knot_tmpa_dim \l__knot_tmpb_dim
+ \coordinate (\l__knot_name_tl \c_space_tl \int_use:N \g__knot_intersections_int) at (\dim_use:N \l__knot_tmpa_dim, \dim_use:N \l__knot_tmpb_dim);
\group_end:
\endpgfscope
}
- \seq_gpush:Nx \l__knot_nodes_seq { \l__knot_node_tl (\l__knot_name_tl \c_space_tl \int_use:N \l__knot_intersections_int) at (\dim_use:N \l__knot_tmpa_dim, \dim_use:N \l__knot_tmpb_dim) {};}
-
+ \tl_if_empty:NF \l__knot_node_tl
+ {
+ \seq_gpush:Nx \g__knot_nodes_seq { \l__knot_node_tl at (\dim_use:N \l__knot_tmpa_dim, \dim_use:N \l__knot_tmpb_dim) {};}
+ }
}
}
@@ -649,7 +663,7 @@
}
\prg_new_protected_conditional:Npnn \knot_test_endpoint:nn #1#2 {T,F,TF}
{
- \spath_get:nnN {knot #1} {#2} \l__knot_tmpd_tl
+ \use:c {spath_#2:Nv} \l__knot_tmpd_tl {knot #1}
\knot_test_endpoint:NTF \l__knot_tmpd_tl
{
\prg_return_true:
@@ -662,49 +676,49 @@
\cs_generate_variant:Nn \knot_test_endpoint:nnT {VnT,vnT}
\cs_generate_variant:Nn \knot_test_endpoint:nnF {VnF,vnF}
\cs_generate_variant:Nn \knot_test_endpoint:nnTF {VnTF,vnTF}
-\cs_new_nopar:Npn \knot_draw_crossing:nnn #1#2#3
+\cs_new_protected_nopar:Npn \knot_draw_crossing:nnn #1#2#3
{
\group_begin:
\pgfscope
\path[knot~ diagram/background~ clip] (#2, #3) circle[radius=\l__knot_clip_bg_radius_dim];
- \tl_set:Nn \l_tmpa_tl {knot~ diagram/every~ strand/.try,}
+ \tl_set:Nn \l__knot_tmpa_tl {knot~ diagram/every~ strand/.try,}
\tl_if_exist:cT {l__knot_options_ #1}
{
- \tl_put_right:Nv \l_tmpa_tl {l__knot_options_ #1}
+ \tl_put_right:Nv \l__knot_tmpa_tl {l__knot_options_ #1}
}
- \tl_put_right:Nn \l_tmpa_tl {,knotbg,line~ width= \tl_use:N \l__knot_clip_width_tl * \pgflinewidth}
- \spath_tikz_path:Vn \l_tmpa_tl {knot #1}
+ \tl_put_right:Nn \l__knot_tmpa_tl {,knotbg,line~ width= \tl_use:N \l__knot_clip_width_tl * \pgflinewidth}
+ \spath_tikz_path:Vv \l__knot_tmpa_tl {knot #1}
\endpgfscope
\pgfscope
\path[knot~ diagram/clip] (#2, #3) circle[radius=\l__knot_clip_draw_radius_dim];
- \tl_set:Nn \l_tmpa_tl {knot~ diagram/every~ strand/.try,}
+ \tl_set:Nn \l__knot_tmpa_tl {knot~ diagram/every~ strand/.try,}
\tl_if_exist:cT {l__knot_options_ #1}
{
- \tl_put_right:Nv \l_tmpa_tl {l__knot_options_ #1}
+ \tl_put_right:Nv \l__knot_tmpa_tl {l__knot_options_ #1}
}
- \tl_put_right:Nn \l_tmpa_tl {,knot~ diagram/only~ when~ rendering/.try,only~ when~ rendering/.try}
- \spath_tikz_path:Vn \l_tmpa_tl {knot #1}
+ \tl_put_right:Nn \l__knot_tmpa_tl {,knot~ diagram/only~ when~ rendering/.try,only~ when~ rendering/.try}
+ \spath_tikz_path:Vv \l__knot_tmpa_tl {knot #1}
\endpgfscope
\group_end:
}
-\cs_generate_variant:Nn \knot_draw_crossing:nnn {nVV}
+\cs_generate_variant:Nn \knot_draw_crossing:nnn {nVV, VVV}
-\cs_new_nopar:Npn \knot_draw_crossing:nn #1#2
+\cs_new_protected_nopar:Npn \knot_draw_crossing:nn #1#2
{
\tikz@scan@one@point\pgfutil@firstofone #2 \relax
\knot_draw_crossing:nVV {#1} \pgf@x \pgf@y
}
\cs_new_protected_nopar:Npn \knot_split_strands:
{
- \int_gzero:N \l__knot_filaments_int
+ \int_gzero:N \g__knot_filaments_int
\int_step_function:nnnN {1} {1} {\l__knot_strands_int} \knot_split_strand:n
- \int_step_function:nnnN {1} {1} {\l__knot_filaments_int} \knot_compute_nexts:n
+ \int_step_function:nnnN {1} {1} {\g__knot_filaments_int} \knot_compute_nexts:n
}
\cs_new_protected_nopar:Npn \knot_compute_nexts:n #1
{
@@ -713,66 +727,70 @@
}
\cs_new_protected_nopar:Npn \knot_split_strand:n #1
{
- \int_set_eq:NN \l__knot_component_start_int \l__knot_filaments_int
+ \int_set_eq:NN \l__knot_component_start_int \g__knot_filaments_int
\int_incr:N \l__knot_component_start_int
\tl_set_eq:Nc \l__knot_tmpa_tl {l__knot_options_strand #1}
- \spath_map_segment_function:nN {knot strand #1} \knot_save_filament:NN
+ \spath_segments_to_seq:Nv \l__knot_segments_seq {knot strand #1}
+ \seq_map_function:NN \l__knot_segments_seq \knot_save_filament:N
}
-\cs_new_protected_nopar:Npn \knot_save_filament:NN #1#2
+\cs_new_protected_nopar:Npn \knot_save_filament:N #1
{
- \tl_case:NnF #1
+ \tl_set:Nx \l__knot_tmpb_tl {\tl_item:nn {#1} {4}}
+ \tl_case:NnF \l__knot_tmpb_tl
{
- \g__spath_moveto_tl
+ \c_spath_moveto_tl
{
- \int_compare:nT {\l__knot_component_start_int < \l__knot_filaments_int}
+ \int_compare:nT {\l__knot_component_start_int < \g__knot_filaments_int}
{
- \int_set_eq:NN \l__knot_component_start_int \l__knot_filaments_int
+ \int_set_eq:NN \l__knot_component_start_int \g__knot_filaments_int
}
}
- \g__spath_lineto_tl
+ \c_spath_lineto_tl
{
- \int_gincr:N \l__knot_filaments_int
- \spath_clear_new:n {knot filament \int_use:N \l__knot_filaments_int}
- \spath_put:nnV {knot filament \int_use:N \l__knot_filaments_int} {path} #2
- \tl_set_eq:cN {l__knot_options_filament \int_use:N \l__knot_filaments_int} \l__knot_tmpa_tl
+ \int_gincr:N \g__knot_filaments_int
+ \tl_clear_new:c {knot filament \int_use:N \g__knot_filaments_int}
+ \tl_set:cn {knot filament \int_use:N \g__knot_filaments_int} {#1}
+
+ \tl_clear_new:c {l__knot_options_filament \int_use:N \g__knot_filaments_int}
+ \tl_set_eq:cN {l__knot_options_filament \int_use:N \g__knot_filaments_int} \l__knot_tmpa_tl
- \tl_clear_new:c {knot previous filament \int_use:N \l__knot_filaments_int}
- \int_compare:nF {\l__knot_component_start_int == \l__knot_filaments_int}
+ \tl_clear_new:c {knot previous filament \int_use:N \g__knot_filaments_int}
+ \int_compare:nF {\l__knot_component_start_int == \g__knot_filaments_int}
{
- \tl_set:cx {knot previous filament \int_use:N \l__knot_filaments_int} {filament \int_eval:n {\l__knot_filaments_int - 1}}
+ \tl_set:cx {knot previous filament \int_use:N \g__knot_filaments_int} {filament \int_eval:n {\g__knot_filaments_int - 1}}
}
}
- \g__spath_curvetoa_tl
+ \c_spath_curvetoa_tl
{
- \int_gincr:N \l__knot_filaments_int
- \spath_clear_new:n {knot filament \int_use:N \l__knot_filaments_int}
- \spath_put:nnV {knot filament \int_use:N \l__knot_filaments_int} {path} #2
- \tl_set_eq:cN {l__knot_options_filament \int_use:N \l__knot_filaments_int} \l__knot_tmpa_tl
+ \int_gincr:N \g__knot_filaments_int
+ \tl_clear_new:c {knot filament \int_use:N \g__knot_filaments_int}
+ \tl_set:cn {knot filament \int_use:N \g__knot_filaments_int} {#1}
+ \tl_clear_new:c {l__knot_options_filament \int_use:N \g__knot_filaments_int}
+ \tl_set_eq:cN {l__knot_options_filament \int_use:N \g__knot_filaments_int} \l__knot_tmpa_tl
- \tl_clear_new:c {knot previous filament \int_use:N \l__knot_filaments_int}
- \int_compare:nF {\l__knot_component_start_int == \l__knot_filaments_int}
+ \tl_clear_new:c {knot previous filament \int_use:N \g__knot_filaments_int}
+ \int_compare:nF {\l__knot_component_start_int == \g__knot_filaments_int}
{
- \tl_set:cx {knot previous filament \int_use:N \l__knot_filaments_int} {filament \int_eval:n {\l__knot_filaments_int - 1}}
+ \tl_set:cx {knot previous filament \int_use:N \g__knot_filaments_int} {filament \int_eval:n {\g__knot_filaments_int - 1}}
}
}
- \g__spath_closepath_tl
+ \c_spath_closepath_tl
{
- \tl_show:N #2
- \int_gincr:N \l__knot_filaments_int
- \spath_clear_new:n {knot filament \int_use:N \l__knot_filaments_int}
- \tl_clear:N \l_tmpa_tl
- \tl_put_right:Nx {\tl_item:Nn #2 {1}\tl_item:Nn #2 {2}\tl_item:Nn #2 {3}}
- \tl_put_right:NV \l_tmpa_tl \g__spath_lineto_tl
- \tl_put_right:Nx {\tl_item:Nn #2 {5}\tl_item:Nn #2 {6}}
- \tl_show:N \l_tmpa_tl
- \spath_put:nnV {knot filament \int_use:N \l__knot_filaments_int} {path} \l_tmpa_tl
- \tl_set_eq:cN {l__knot_options_filament \int_use:N \l__knot_filaments_int} \l__knot_tmpa_tl
- \tl_clear_new:c {knot previous filament \int_use:N \l__knot_filaments_int}
- \int_compare:nF {\l__knot_component_start_int == \l__knot_filaments_int}
+ \int_gincr:N \g__knot_filaments_int
+ \tl_clear_new:c {knot filament \int_use:N \g__knot_filaments_int}
+ \tl_clear:N \l__knot_tmpa_tl
+ \tl_put_right:Nx {\tl_item:nn {#1} {1}\tl_item:nn {#1} {2}\tl_item:nn {#1} {3}}
+ \tl_put_right:NV \l__knot_tmpa_tl \c_spath_lineto_tl
+ \tl_put_right:Nx {\tl_item:nn {#1} {5}\tl_item:nn {#1} {6}}
+
+ \tl_set:cV {knot filament \int_use:N \g__knot_filaments_int} \l__knot_tmpa_tl
+ \tl_set_eq:cN {l__knot_options_filament \int_use:N \g__knot_filaments_int} \l__knot_tmpa_tl
+ \tl_clear_new:c {knot previous filament \int_use:N \g__knot_filaments_int}
+ \int_compare:nF {\l__knot_component_start_int == \g__knot_filaments_int}
{
- \tl_set:cx {knot previous filament \int_use:N \l__knot_filaments_int} {filament \int_eval:n {\l__knot_filaments_int - 1}}
+ \tl_set:cx {knot previous filament \int_use:N \g__knot_filaments_int} {filament \int_eval:n {\g__knot_filaments_int - 1}}
}
- \tl_set:cx {knot previous filament \int_use:N \l__knot_component_start_int} {filament \int_use:N \l__knot_filaments_int}
+ \tl_set:cx {knot previous filament \int_use:N \l__knot_component_start_int} {filament \int_use:N \g__knot_filaments_int}
}
}
{
@@ -990,7 +1008,7 @@
}
}
%%
-%% Copyright (C) 2011-2019 by Andrew Stacey <stacey@math.ntnu.no>
+%% Copyright (C) 2011-2019 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
@@ -1005,13 +1023,16 @@
%% This work consists of the files spath3.dtx
%% calligraphy_doc.tex
%% knots_doc.tex
+%% spath3.tex
%% and the derived files spath3.ins,
%% spath3_code.pdf,
%% spath3.sty,
%% tikzlibrarycalligraphy.code.tex
%% tikzlibraryknots.code.tex
+%% tikzlibraryspath3.code.tex
%% calligraphy.pdf
%% knots.pdf
+%% spath3.pdf
%% README
%%
%%