diff options
author | Karl Berry <karl@freefriends.org> | 2016-02-20 23:38:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-02-20 23:38:34 +0000 |
commit | a96566db41be14d9f7d6ac1b237c9625b8b405ea (patch) | |
tree | 8f1a0317f4620e24bdd9030a11b6c59ac2132a08 /Master/texmf-dist/tex/latex/spath3/spath3.sty | |
parent | e9f61ed7121f3980dee02d7bc39309bbb7fd3c4a (diff) |
spath3 (20feb16)
git-svn-id: svn://tug.org/texlive/trunk@39794 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/spath3/spath3.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/spath3/spath3.sty | 144 |
1 files changed, 120 insertions, 24 deletions
diff --git a/Master/texmf-dist/tex/latex/spath3/spath3.sty b/Master/texmf-dist/tex/latex/spath3/spath3.sty index a1f4b190fe8..876f5ca5841 100644 --- a/Master/texmf-dist/tex/latex/spath3/spath3.sty +++ b/Master/texmf-dist/tex/latex/spath3/spath3.sty @@ -15,7 +15,7 @@ \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} \RequirePackage{pgf} -\ProvidesExplPackage {spath3} {2013/04/09} {1.0} {Functions for +\ProvidesExplPackage {spath3} {2016/02/19} {1.1} {Functions for manipulating PGF soft paths} \RequirePackage{xparse} \tl_new:N \l__spath_tmpa_tl @@ -25,17 +25,21 @@ manipulating PGF soft paths} \tl_new:N \l__spath_smuggle_tl \dim_new:N \l__spath_tmpa_dim \dim_new:N \l__spath_tmpb_dim +\fp_new:N \l__spath_tmpa_fp +\fp_new:N \l__spath_tmpb_fp \int_new:N \l__spath_tmpa_int \tl_new:N \g__spath_moveto_tl \tl_new:N \g__spath_lineto_tl \tl_new:N \g__spath_curveto_tl \tl_new:N \g__spath_curvetoa_tl \tl_new:N \g__spath_curvetob_tl +\tl_new:N \g__spath_closepath_tl \tl_set:Nn \g__spath_moveto_tl {\pgfsyssoftpath@movetotoken} \tl_set:Nn \g__spath_lineto_tl {\pgfsyssoftpath@linetotoken} \tl_set:Nn \g__spath_curveto_tl {\pgfsyssoftpath@curvetotoken} \tl_set:Nn \g__spath_curvetoa_tl {\pgfsyssoftpath@curvetosupportatoken} \tl_set:Nn \g__spath_curvetob_tl {\pgfsyssoftpath@curvetosupportbtoken} +\tl_set:Nn \g__spath_closepath_tl {\pgfsyssoftpath@closepathtoken} \tl_new:N \g__spath_attributes \tl_new:N \g__spath_moveable_attributes \tl_new:N \g__spath_path_attributes @@ -88,7 +92,7 @@ manipulating PGF soft paths} } \cs_new_nopar:Npn \__spath_get:nn #1#2 { - \prop_get:cn {l__spath_#1} {#2} + \prop_item:cn {l__spath_#1} {#2} } \cs_new_nopar:Npn \__spath_get:nnN #1#2#3 { @@ -104,11 +108,15 @@ manipulating PGF soft paths} \prg_new_protected_conditional:Npnn \__spath_get:nnN #1#2#3 {T, F, TF} { \__prop_split:cnTF {l__spath_#1} {#2} - { \__prop_get_true:Nnnn #3 } + { + \tl_set:Nn #3 {##2} + \prg_return_true: + } { \prg_return_false: } } \cs_generate_variant:Nn \spath_put:nnn {nnV, nnx, nno} \cs_generate_variant:Nn \__spath_get:nn {Vn} +\cs_generate_variant:Nn \__spath_get:nnN {VnN} \prg_new_conditional:Npnn \spath_if_exist:n #1 {p,T,F,TF} { \prop_if_exist:cTF {l__spath_#1} @@ -133,9 +141,9 @@ manipulating PGF soft paths} } \cs_new_protected_nopar:Npn \spath_get_current_path:n #1 { - \pgfsyssoftpath@getcurrentpath\l__knot_tmpa_tl + \pgfsyssoftpath@getcurrentpath\l__spath_tmpa_tl \spath_clear_new:n {#1} - \spath_put:nnV {#1} {path} \l__knot_tmpa_tl + \spath_put:nnV {#1} {path} \l__spath_tmpa_tl } \cs_new_protected_nopar:Npn \spath_set_current_path:n #1 { @@ -186,7 +194,7 @@ manipulating PGF soft paths} } \__spath_get:nnN {#1} {#2} #3 } -\cs_generate_variant:Nn \spath_get:nnN {nnV} +\cs_generate_variant:Nn \spath_get:nnN {nnV,VnN,VnV} \cs_new_nopar:Npn \spath_generate_length:n #1 { \__spath_get:nnN {#1} {path} \l__spath_tmpa_tl @@ -250,6 +258,7 @@ manipulating PGF soft paths} } \spath_put:nnV {#1} {final point} \l__spath_tmpb_tl } +\cs_generate_variant:Nn \spath_generate_finalpoint:n {V} \cs_new_nopar:Npn \spath_generate_reversepath:n #1 { \__spath_get:nnN {#1} {path} \l__spath_tmpa_tl @@ -270,7 +279,7 @@ manipulating PGF soft paths} { \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl} \tl_set:Nn \l__spath_tmpd_tl {} - \tl_case:Nnn \l__spath_tmpc_tl + \tl_case:NnF \l__spath_tmpc_tl { \g__spath_moveto_tl {\tl_set_eq:NN \l__spath_tmpd_tl \g__spath_moveto_tl } \g__spath_lineto_tl {\tl_set_eq:NN \l__spath_tmpd_tl \g__spath_lineto_tl } @@ -448,7 +457,7 @@ manipulating PGF soft paths} \tl_set_eq:NN \l__spath_fa_tl \l__spath_tmpc_tl \int_incr:N \l__spath_l_int - \tl_case:Nnn \l__spath_tmpc_tl + \tl_case:NnF \l__spath_tmpc_tl { \g__spath_moveto_tl { \tl_set_eq:NN \l__spath_tmpd_tl \g__spath_moveto_tl @@ -592,14 +601,14 @@ manipulating PGF soft paths} { \__spath_get:nnN {#1} {##1} \l__spath_tmpa_tl - \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl * #2} + \fp_set:Nn \l__spath_tmpa_fp {\tl_head:N \l__spath_tmpa_tl * #2} \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} - \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl * #3} + \fp_set:Nn \l__spath_tmpb_fp {\tl_head:N \l__spath_tmpa_tl * #3} \tl_clear:N \l__spath_tmpb_tl \tl_put_right:Nx \l__spath_tmpb_tl { - {\dim_use:N \l__spath_tmpa_dim} - {\dim_use:N \l__spath_tmpb_dim} + {\fp_to_dim:N \l__spath_tmpa_fp} + {\fp_to_dim:N \l__spath_tmpb_fp} } \spath_put:nnV {#1} {##1} \l__spath_tmpb_tl } @@ -617,26 +626,91 @@ manipulating PGF soft paths} \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl} \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} - \dim_set:Nn \l__spath_tmpa_dim {\tl_head:N \l__spath_tmpa_tl * #2} + \fp_set:Nn \l__spath_tmpa_fp {\tl_head:N \l__spath_tmpa_tl * #2} \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} - \dim_set:Nn \l__spath_tmpb_dim {\tl_head:N \l__spath_tmpa_tl * #3} + \fp_set:Nn \l__spath_tmpb_fp {\tl_head:N \l__spath_tmpa_tl * #3} \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} \tl_put_right:Nx \l__spath_tmpb_tl { - {\dim_use:N \l__spath_tmpa_dim} - {\dim_use:N \l__spath_tmpb_dim} + {\fp_to_dim:N \l__spath_tmpa_fp} + {\fp_to_dim:N \l__spath_tmpb_fp} } } \spath_put:nnV {#1} {##1} \l__spath_tmpb_tl } } } +\cs_generate_variant:Nn \spath_scale:nnn {nxx} +\cs_new_nopar:Npn \spath_scale:nn #1#2 +{ + \spath_scale:nnn {#1} #2 +} + +\cs_generate_variant:Nn \spath_scale:nn {nV} +\cs_new_nopar:Npn \spath_transform:nnnnnnn #1#2#3#4#5#6#7 +{ + \tl_map_inline:Nn \g__spath_moveable_attributes + { + \spath_if_in:nnT {#1} {##1} + { + \__spath_get:nnN {#1} {##1} \l__spath_tmpa_tl + \tl_set:Nx \l__spath_tmpb_tl {\tl_tail:N \l__spath_tmpa_tl} + \tl_set:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpb_tl} + \tl_set:Nx \l__spath_tmpa_tl {\tl_head:N \l__spath_tmpa_tl} + \fp_set:Nn \l__spath_tmpa_fp {\l__spath_tmpa_tl * #2 + \l__spath_tmpb_tl * #3 + #6} + \fp_set:Nn \l__spath_tmpb_fp {\l__spath_tmpa_tl * #4 + \l__spath_tmpb_tl * #5 + #7} + \tl_clear:N \l__spath_tmpb_tl + \tl_put_right:Nx \l__spath_tmpb_tl + { + {\fp_to_dim:N \l__spath_tmpa_fp} + {\fp_to_dim:N \l__spath_tmpb_fp} + } + \spath_put:nnV {#1} {##1} \l__spath_tmpb_tl + } + } + \tl_map_inline:Nn \g__spath_path_attributes + { + \spath_if_in:nnT {#1} {##1} + { + \__spath_get:nnN {#1} {##1} \l__spath_tmpa_tl + \tl_clear:N \l__spath_tmpb_tl + \bool_until_do:nn { + \tl_if_empty_p:N \l__spath_tmpa_tl + } + { + \tl_put_right:Nx \l__spath_tmpb_tl {\tl_head:N \l__spath_tmpa_tl} + \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} + \tl_set:Nx \l_tmpa_tl {\tl_head:N \l__spath_tmpa_tl} + \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} + \tl_set:Nx \l_tmpb_tl {\tl_head:N \l__spath_tmpa_tl} + \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} + + \fp_set:Nn \l__spath_tmpa_fp {\l_tmpa_tl * #2 + \l_tmpb_tl * #3 + #6} + \fp_set:Nn \l__spath_tmpb_fp {\l_tmpa_tl * #4 + \l_tmpb_tl * #5 + #7} + \tl_put_right:Nx \l__spath_tmpb_tl + { + {\fp_to_dim:N \l__spath_tmpa_fp} + {\fp_to_dim:N \l__spath_tmpb_fp} + } + } + \spath_put:nnV {#1} {##1} \l__spath_tmpb_tl + } + } +} + +\cs_generate_variant:Nn \spath_transform:nnnnnnn {nxxxxxx} +\cs_new_nopar:Npn \spath_transform:nn #1#2 +{ + \spath_transform:nnnnnnn {#1} #2 +} + +\cs_generate_variant:Nn \spath_transform:nn {nV} \cs_new_nopar:Npn \spath_reverse:n #1 { \spath_if_in:nnF {#1} {reverse path} { - \cs_use:c {spath_generate_reverse path} + \use:c {spath_generate_reverse path:n} {#1} } \spath_swap:nnn {#1} {path} {reverse path} \spath_swap:nnn {#1} {initial point} {final point} @@ -647,10 +721,10 @@ manipulating PGF soft paths} \__spath_get:nnNF {#1} {#2} \l__spath_tmpa_tl {\tl_clear:N \l__spath_tmpa_tl} \__spath_get:nnNF {#1} {#3} \l__spath_tmpb_tl {\tl_clear:N \l__spath_tmpb_tl} \tl_if_empty:NTF \l__spath_tmpb_tl - {\spath_remove:nnV {#1} {#2}} + {\spath_remove:nn {#1} {#2}} {\spath_put:nnV {#1} {#2} \l__spath_tmpb_tl} \tl_if_empty:NTF \l__spath_tmpa_tl - {\spath_remove:nnV {#1} {#3}} + {\spath_remove:nn {#1} {#3}} {\spath_put:nnV {#1} {#3} \l__spath_tmpa_tl} } \cs_new_nopar:Npn \spath_weld:nn #1#2 @@ -1060,6 +1134,28 @@ manipulating PGF soft paths} } } } +\cs_new_nopar:Npn \spath_bake_round:n #1 +{ + \__spath_get:nnN {#1} {path} \l__spath_tmpa_tl + \pgf@@processround\l__spath_tmpa_tl\l__spath_tmpb_tl + \spath_put:nnV {#1} {path} \l__spath_tmpb_tl +} +\cs_new_nopar:Npn \spath_close_path:n #1 +{ + \spath_get:nnN {#1} {initial point} \l__spath_tmpb_tl + \__spath_get:nnN {#1} {path} \l__spath_tmpa_tl + \tl_put_right:NV \l__spath_tmpa_tl \g__spath_closepath_tl + \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl + \spath_put:nnV {#1} {path} \l__spath_tmpa_tl + \spath_if_in:nnT {#1} {reverse path} + { + \spath_get:nnN {#1} {final point} \l__spath_tmpb_tl + \__spath_get:nnN {#1} {reverse path} \l__spath_tmpa_tl + \tl_put_right:NV \l__spath_tmpa_tl \g__spath_closepath_tl + \tl_put_right:NV \l__spath_tmpa_tl \l__spath_tmpb_tl + \spath_put:nnV {#1} {reverse path} \l__spath_tmpa_tl + } +} \cs_new_nopar:Npn \spath_map_component:Nn #1#2 { \int_gincr:N \g__prg_map_int @@ -1119,7 +1215,7 @@ manipulating PGF soft paths} { \tl_set:Nx \l__spath_tmpc_tl {\tl_head:N \l__spath_tmpa_tl} \tl_set:Nx \l__spath_tmpa_tl {\tl_tail:N \l__spath_tmpa_tl} - \tl_case:Nnn \l__spath_tmpc_tl + \tl_case:NnF \l__spath_tmpc_tl { \g__spath_lineto_tl { @@ -1229,7 +1325,7 @@ manipulating PGF soft paths} \tl_set:Nn \l_tmpa_tl #3 \spath_get:nnV {#1} {#2} \l_tmpa_tl } -\NewDocumentCommand \SPathShow { m m } +\NewDocumentCommand \SPathShow { m } { \spath_show:n {#1} } @@ -1244,12 +1340,12 @@ manipulating PGF soft paths} } \NewDocumentCommand \SPathScale { m m m } { - \spath_translate:nnn {#1} {#2} {#3} + \spath_scale:nnn {#1} {#2} {#3} } \NewDocumentCommand \SPathScaleInto { m m m m } { \spath_clone:nn {#1} {#2} - \spath_translate:nnn {#2} {#3} {#4} + \spath_scale:nnn {#2} {#3} {#4} } \NewDocumentCommand \SPathWeld { m m } { @@ -1268,7 +1364,7 @@ manipulating PGF soft paths} }, restore~spath/.code={ \spath_set_current_path:n {#1} - }, + } } \cs_new_nopar:Npn \spath_split_curve:nnNN #1#2#3#4 { |