From 06fc981c5f271d3fc1cd1a020175590bcbf4e7f8 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 28 Feb 2022 21:04:10 +0000 Subject: tzplot (28feb22) (branch) git-svn-id: svn://tug.org/texlive/branches/branch2021.final@62289 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/tzplot/tzplot.sty | 6547 ++++++++++++++++++++----- 1 file changed, 5229 insertions(+), 1318 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/tzplot/tzplot.sty b/Master/texmf-dist/tex/latex/tzplot/tzplot.sty index c5a1413a142..7b574bdc25c 100644 --- a/Master/texmf-dist/tex/latex/tzplot/tzplot.sty +++ b/Master/texmf-dist/tex/latex/tzplot/tzplot.sty @@ -2,7 +2,7 @@ %% %% tzplot %% -%% (C) Copyright 2017-2021 In-Sung Cho +%% (C) Copyright 2017-2022 In-Sung Cho %% %% This work may be distributed and/or modified %% under the conditions of the LaTeX Project Public License, @@ -11,7 +11,7 @@ %% http://www.latex-project.org/lppl.txt. %% %% ------------------------------------------------- -\ProvidesPackage{tzplot-v1.0.1}[2021/03/20 v1.0.1 Plot Graphs with TikZ Abbreviations] +\ProvidesPackage{tzplot}[2022/02/28 v2.0 Plot Graphs with TikZ Abbreviations] % expl3,xparse: LPPL % tikz: LPPL and/or GNU GPL @@ -19,11 +19,35 @@ \RequirePackage{tikz} \usetikzlibrary{ -calc,backgrounds,positioning,intersections, -arrows,shapes,patterns, -plotmarks, % for \tzplot[mark] -decorations.pathreplacing, % for tzshowcontrols/show path construction, tzbrace +arrows, % (deprecated in tikz) +backgrounds, +calc, +decorations.pathreplacing, % for tzshowcontrols, tzbrace calligraphy, % for calligraphic brace (load after decorations.pathreplacing) +intersections, +patterns, +plotmarks, % for \tzplot[mark] +positioning, +shapes, +} + +%%(ADDED) +\usetikzlibrary{ +% for later use +%angles, % for \tzpicangle %% (Removed!!!) +arrows.meta, % (added) +bending, % (added with arrows.meta) +decorations.markings, % need for "decoration" +decorations.pathmorphing, % for \tzsnake +spy, % for \tzspy (later) +fpu, % for computation for \tzpicangle +%fit, +%quotes, +%through, +%shadings, +%shadows, +%scopes, +%graphs, } @@ -34,42 +58,40 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \pgfdeclarelayer{foreground} \pgfsetlayers{background,behind,main,above,foreground} -%% usage: \begin{pgfonlayer}{foreground} ... \end{pgfonlayer} +%% USAGE: \begin{pgfonlayer}{foreground} ... \end{pgfonlayer} %%%%% defaults -\def\tz@default@radius{1.2pt} % fixed -\def\tz@initial@radius{\tz@default@radius} % changeable -\NewDocumentCommand\settzdotradius{m}{\renewcommand\tz@initial@radius{#1}} -\newcommand\tzdotradius{\tz@initial@radius} -% circle dot (using radius) +%%%%% basic defaults + +%% circle dot (using radius) \def\tz@default@Cdot@radius{1.2pt} % fixed \def\tz@initial@Cdot@radius{\tz@default@Cdot@radius} % changeable \NewDocumentCommand\settzcdotradius{m}{\renewcommand\tz@initial@Cdot@radius{#1}} \newcommand\tzCdotradius{\tz@initial@Cdot@radius} -% node dot (using minimum size) +%% node dot (using minimum size: diameter) \def\tz@default@dot@size{2.4pt} % fixed \def\tz@initial@dot@size{\tz@default@dot@size} % changeable \NewDocumentCommand\settzdotsize{m}{\renewcommand\tz@initial@dot@size{#1}} \newcommand\tzdotsize{\tz@initial@dot@size} -% mark (using mark size, which is a radius) % tikz initial = 2pt +%% mark (using mark size: radius) % tikz initial = 2pt \def\tz@default@mark@size{2pt} % fixed \def\tz@initial@mark@size{\tz@default@mark@size} % changeable \NewDocumentCommand\settzmarksize{m}{\renewcommand\tz@initial@mark@size{#1}} \newcommand\tzmarksize{\tz@initial@mark@size} -% opacity +%% opacity \def\tz@default@fill@opacity{0.3} % fixed \def\tz@initial@fill@opacity{\tz@default@fill@opacity} % changeable \NewDocumentCommand\settzfillopacity{m}{\renewcommand\tz@initial@fill@opacity{#1}} \newcommand\tzfillopacity{\tz@initial@fill@opacity} -% fillcolor -\def\tz@default@fill@color{black!50} % fixed -\def\tz@initial@fill@color{\tz@default@fill@color} % changeable +%% fillcolor +\def\tz@default@fill@color{black!50} % fixed +\def\tz@initial@fill@color{\tz@default@fill@color} % changeable \NewDocumentCommand\settzfillcolor{mg} {% \renewcommand\tz@initial@fill@color{#1} @@ -77,19 +99,22 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \newcommand\tzfillcolor{\tz@initial@fill@color} -% link style +%% link style \def\tz@default@link@style{to} % fixed \def\tz@initial@link@style{\tz@default@link@style} % changeable \NewDocumentCommand\settzlinkstyle{m}{\renewcommand\tz@initial@link@style{#1}} \newcommand\tzlinkstyle{\tz@initial@link@style} -% path style -\def\tz@default@path@style{to} % fixed -\def\tz@initial@path@style{\tz@default@path@style} % changeable -\NewDocumentCommand\settzpathstyle{m}{\renewcommand\tz@initial@path@style{#1}} -\newcommand\tzpathstyle{\tz@initial@path@style} +\let\tzpathstyle\tzlinkstyle +\let\settzpathstyle\settzlinkstyle -% tangent epsilon +%%% path style +%\def\tz@default@path@style{to} % fixed +%\def\tz@initial@path@style{\tz@default@path@style} % changeable +%\NewDocumentCommand\settzpathstyle{m}{\renewcommand\tz@initial@path@style{#1}} +%\newcommand\tzpathstyle{\tz@initial@path@style} + +%% tangent epsilon \def\tz@default@tangent@epsilonL{.01} \def\tz@default@tangent@epsilonR{.01} @@ -104,28 +129,130 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \newcommand\tztangentepsilonL{\tz@initial@tangent@epsilonL} \newcommand\tztangentepsilonR{\tz@initial@tangent@epsilonR} + \let\tztangentatepsilonL\tztangentepsilonL \let\tztangentatepsilonR\tztangentepsilonR -% tzpath layer %% (NOT USED!!!) (to be considered later) -\def\tz@default@tzpath@layer{main} % fixed -\def\tz@initial@tzpath@layer{\tz@default@tzpath@layer} % changeable -\NewDocumentCommand\settzpathlayer{m}{\renewcommand\tz@initial@tzpath@layer{#1}} -\newcommand\tzpathlayer{\tz@initial@tzpath@layer} +%%(ADDED) +%% slope epsilon + +\def\tz@default@slope@epsilonL{.01} +\def\tz@default@slope@epsilonR{.01} +\def\tz@initial@slope@epsilonL{\tz@default@slope@epsilonL} +\def\tz@initial@slope@epsilonR{\tz@default@slope@epsilonL} +\NewDocumentCommand\settzslopeepsilon{mg} +{% + \renewcommand\tz@initial@slope@epsilonL{#1} + \IfNoValueTF {#2} + {\renewcommand\tz@initial@slope@epsilonR{#1}} + {\renewcommand\tz@initial@slope@epsilonR{#2}} +} +\newcommand\tzslopeepsilonL{\tz@initial@slope@epsilonL} +\newcommand\tzslopeepsilonR{\tz@initial@slope@epsilonR} + +\let\tzslopeatepsilonL\tzslopeepsilonL +\let\tzslopeatepsilonR\tzslopeepsilonR + + +%%%%% layers: defaults -% tangent layer +%% tzpath layer %% default: main +\def\tz@default@tzpath@layer{main} % fixed +\def\tz@initial@tzpath@layer{\tz@default@tzpath@layer} % changeable +\NewDocumentCommand\settzpathlayer{m} + {\renewcommand\tz@initial@tzpath@layer{#1}} +\newcommand\tzpathlayer{\tz@initial@tzpath@layer} +%% (there is No \tz-link-layer thing) + +%% tzfnArea layer %% default: main +\def\tz@default@tzfnArea@layer{behind} % fixed +\def\tz@initial@tzfnArea@layer{\tz@default@tzfnArea@layer} % changeable +\NewDocumentCommand\settzfnArealayer{m} + {\renewcommand\tz@initial@tzfnArea@layer{#1}} +\newcommand\tzfnArealayer{\tz@initial@tzfnArea@layer} + +%% tzfnarea layer %% default: main +\def\tz@default@tzfnarea@layer{behind} % fixed +\def\tz@initial@tzfnarea@layer{\tz@default@tzfnarea@layer} % changeable +\NewDocumentCommand\settzfnarealayer{m} + {\renewcommand\tz@initial@tzfnarea@layer{#1}} +\newcommand\tzfnarealayer{\tz@initial@tzfnarea@layer} + +%% tangent layer \def\tz@default@tangent@layer{behind} % fixed \def\tz@initial@tangent@layer{\tz@default@tangent@layer} % changeable -\NewDocumentCommand\settztangentlayer{m}{\renewcommand\tz@initial@tangent@layer{#1}} +\NewDocumentCommand\settztangentlayer{m} + {\renewcommand\tz@initial@tangent@layer{#1}} \newcommand\tztangentlayer{\tz@initial@tangent@layer} + \let\tztangentatlayer\tztangentlayer +\let\settztangentatlayer\settztangentlayer -% secant layer -\def\tz@default@secant@layer{behind} % fixed -\def\tz@initial@secant@layer{\tz@default@secant@layer} % changeable -\NewDocumentCommand\settzsecantlayer{m}{\renewcommand\tz@initial@secant@layer{#1}} +%% secant layer +\def\tz@default@secant@layer{behind} % fixed +\def\tz@initial@secant@layer{\tz@default@secant@layer} % changeable +\NewDocumentCommand\settzsecantlayer{m} + {\renewcommand\tz@initial@secant@layer{#1}} \newcommand\tzsecantlayer{\tz@initial@secant@layer} + \let\tzsecantatlayer\tzsecantlayer +\let\settzsecantatlayer\settzsecantlayer + +%%(ADDED) +%% slope layer +\def\tz@default@slope@layer{behind} % fixed +\def\tz@initial@slope@layer{\tz@default@slope@layer} % changeable +\NewDocumentCommand\settzslopelayer{m} + {\renewcommand\tz@initial@slope@layer{#1}} +\newcommand\tzslopelayer{\tz@initial@slope@layer} + +\let\tzslopeatlayer\tzslopelayer +\let\settzslopeatlayer\settzslopelayer + +%% angle layer +\def\tz@default@angle@layer{behind} % fixed +\def\tz@initial@angle@layer{\tz@default@angle@layer} % changeable +\NewDocumentCommand\settzanglelayer{m} + {\renewcommand\tz@initial@angle@layer{#1}} +\newcommand\tzanglelayer{\tz@initial@angle@layer} + +\let\tzanglemarklayer\tzanglelayer +\let\settzanglemarklayer\settzanglelayer + + +%%%%% line style, radius, size: defaults + +%% function area (fnA) line width +\def\tz@default@fnA@linestyle{very thin} % fixed +\def\tz@initial@fnA@linestyle{\tz@default@fnA@linestyle} % changeable +\NewDocumentCommand\settzfnarealinestyle{m} + {\renewcommand\tz@initial@fnA@linestyle{#1}} +\newcommand\tzfnALstyle{\tz@initial@fnA@linestyle} + +%% angle arc (AA) line style +\def\tz@default@AA@linestyle{very thin} % fixed +\def\tz@initial@AA@linestyle{\tz@default@AA@linestyle} % changeable +\NewDocumentCommand\settzAAlinestyle{m} + {\renewcommand\tz@initial@AA@linestyle{#1}} +\newcommand\tzAAlinestyle{\tz@initial@AA@linestyle} + +\let\tzRAlinestyle\tzAAlinestyle +\let\settzRAlinestyle\settzAAlinestyle + +%% angle arc (AA) radius +\def\tz@default@AA@radius{10pt} % fixed +\def\tz@initial@AA@radius{\tz@default@AA@radius} % changeable +\NewDocumentCommand\settzAAradius{m} + {\renewcommand\tz@initial@AA@radius{#1}} +\newcommand\tzAAradius{\tz@initial@AA@radius} + +%% right angle (RA) marc size +\def\tz@default@RA@size{5pt} % fixed +\xdef\tz@initial@RA@size{\tz@default@RA@size} % changeable +\NewDocumentCommand\settzRAsize{m} + {\renewcommand\tz@initial@RA@size{#1}} +\newcommand\tzRAsize{\tz@initial@RA@size} + %%%%% TikZ alias styles @@ -157,6 +284,13 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) tzdot options/.style={tzdot=\tzdotsize,#1} } +%%%%%%% tzshowdot +%%%%%\tikzset{ +%%%%% tzshowdot/.style= +%%%%% {draw,fill,solid,thin,circle,inner sep=0pt,minimum size=\tzdotsize,#1}, +%%%%%% tzshowdot/.default=circle +%%%%%} + %% tzmark \tikzset{ tzmark/.style= @@ -227,6 +361,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } + %===================================================== %%===================================================== %%===================================================== @@ -234,6 +369,42 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%===================================================== %%===================================================== +%%% error messages: + +%% semicolon versions +\msg_new:nnn { tzplot } { semicolon-error } + { You~may~have~forgotten~a~semicolon~here~or~above! } + +%% infinite slope error: LFn related macros +\msg_new:nnn { tzplot } { infinite~slope~error } + { Perhaps~you~are~trying~an~'infinite~slope'~here~or~above! } + + +%%%% string replacement +%%%%%% to use string replacement for label positions +\cs_new:Npn \extract_posopt:w [ #1 ] #2 \q_stop % ndh +{ + \tl_set:Nn \l_label_pos_str_tl { [ \exp_not:n { #1 } ] } % \exp_not needed!!! + + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #2 } } + + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_put_right:Nn \l_label_pos_str_tl {left} } + {r} { \tl_put_right:Nn \l_label_pos_str_tl {right} } + {a} { \tl_put_right:Nn \l_label_pos_str_tl {above} } + {b} { \tl_put_right:Nn \l_label_pos_str_tl {below} } + {c} { \tl_put_right:Nn \l_label_pos_str_tl {center} } + {al} { \tl_put_right:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_put_right:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_put_right:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_put_right:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_put_right:Nn \l_label_pos_str_tl { #2 } + } +} + %%%%% help lines \NewDocumentCommand\tzhelplines{ s O{} r() d() } @@ -309,6 +480,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%%% --- end of \tzgetxyval + + + + + %%%%% Dots %%% Node Dots %%% (basic: using minimum size) @@ -318,13 +494,44 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzdot_shift_coor_bool -\NewDocumentCommand\tzdot{ s O{} d<> r() +G{} O{} D(){\tz@initial@dot@size} } +%%% \tzdot (main) +\NewDocumentCommand\tzdot + { s O{} d<> r() +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzdot_cmd_tl - \IfValueT { #7 } + \tl_if_empty:nF { #7 } { \renewcommand\tzdotsize{ #7 } } +%%%%%% to use string replacement for label positions + \IfValueTF { #6 } + { + \tl_if_in:nnTF { #6 } { [ } + { \extract_posopt:w #6 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #6 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #6 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \IfValueTF { #3 } { \tl_set:Nn \l_tzdot_shift_coor_tl { #3 } @@ -339,11 +546,13 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \tl_put_right:Nx \l_tzdot_cmd_tl { - ( [ shift = { (\l_tzdot_shift_coor_tl) } ]#4 ) node + ( [ shift = { (\l_tzdot_shift_coor_tl) } ] #4 ) } } - { \tl_put_right:Nn \l_tzdot_cmd_tl { (#4) node } } + { \tl_put_right:Nn \l_tzdot_cmd_tl { (#4) } } + \tl_put_right:Nn \l_tzdot_cmd_tl { node } %% + \IfBooleanTF { #1 } { \tl_put_right:Nn \l_tzdot_cmd_tl @@ -355,7 +564,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tzdot_cmd_tl { - label = { \exp_not:n { #6 } \c_colon_str \exp_not:n { #5 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #5 } } , % pos_str } \tl_put_right:Nn \l_tzdot_cmd_tl { @@ -367,6 +576,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzdot + %%% multiple dots %%% coding CAUTION! : _tzdot_ changed to _tzdots_ @@ -377,6 +587,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_new:N \l_tzdots_cmd_tl \bool_new:N \l_tzdots_shift_coor_bool +%%% \tzdots (main) \NewDocumentCommand\tzdots{ s O{} d<> } { \tl_clear:N \l_tzdots_cmd_tl @@ -413,29 +624,60 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzdots_late_opt_fn } } { - \tzdots_stop_action +% \tzdots_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzdots_sub_fn { r() +G{} O{} } +\NewDocumentCommand\tzdots_sub_fn { r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #3 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \bool_if:NTF \l_tzdots_shift_coor_bool { \tl_put_right:Nx \l_tzdots_cmd_tl {% if shift - ( [ shift = { (\l_tzdots_shift_coor_tl) } ]#1 ) + ( [ shift = { (\l_tzdots_shift_coor_tl) } ] #1 ) } } { \tl_put_right:Nn \l_tzdots_cmd_tl { (#1) } } + \tl_put_right:Nn \l_tzdots_cmd_tl { node } %% + \tl_put_right:Nx \l_tzdots_cmd_tl { - node [ \l_tzdots_STYLE_fill_tl , minimum~size = \exp_not:n { \tzdotsize } , - label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } , % pos_str } \tl_put_right:No \l_tzdots_cmd_tl % expand `once' { @@ -476,12 +718,12 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \clist_new:N \l_tzCdot_opt_clist \bool_new:N \l_tzCdot_shift_coor_bool -\NewDocumentCommand\tzcdot{ s o d<> r() +G{} O{} d() } +%%% \tzcdot (main) +\NewDocumentCommand\tzcdot{ s o d<> r() +G{} >{\TrimSpaces}o d() } { \tl_clear:N \l_tzCdot_opt_tl % (needed) \tl_clear:N \l_tzCdot_cmd_tl - % default dot radius == arg specifier D<>{\tz@initial@radius} \renewcommand\tzCdotradius{\tz@initial@Cdot@radius} \IfValueT { #7 } @@ -512,8 +754,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \str_if_in:nnTF { ##1 } { tzcdot } { % (matched item) - \clist_pop:NN \l_tzCdot_opt_input_clist \l_tmpa_tl - \keys_set:nV { keytzCdot } \l_tmpa_tl % form: { tzcdot=\l_tmpa_tl } + \clist_pop:NN \l_tzCdot_opt_input_clist \l_label_pos_str_tl + \keys_set:nV { keytzCdot } \l_label_pos_str_tl % form: { tzcdot=\l_label_pos_str_tl } \exp_args:NNo \renewcommand\tzCdotradius { \key_tzCdot_radius_tl } \clist_map_break: % non-tested list remains @@ -554,11 +796,40 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { circle ( \tzCdotradius ) } +%%%%%% to use string replacement for label positions + \IfValueTF { #6 } + { + \tl_if_in:nnTF { #6 } { [ } + { \extract_posopt:w #6 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #6 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #6 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \tl_put_right:Nx \l_tzCdot_cmd_tl { node [ inner~sep = 0pt , - label = { \exp_not:n { #6 } \c_colon_str \exp_not:n { #5 } } + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #5 } } % pos_str ] {} } \exp_last_unbraced:No \draw \l_tzCdot_cmd_tl ; @@ -570,6 +841,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% multiple dots %%% coding CAUTION! : _tzCdot_ changes to _tzCdots + +%%% \tzcdots %%% *[] (){}[] (){}[] repeated (){}[] ; (radius) %%% repeat pattern: (coor){label}[angle] @@ -577,6 +850,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzCdots_size_call_bool \bool_new:N \l_tzCdots_shift_coor_bool +%%% \tzcdots (main) \NewDocumentCommand\tzcdots{ s o d<> } { \renewcommand\tzCdotradius{\tz@initial@Cdot@radius} @@ -609,8 +883,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \str_if_in:nnTF { ##1 } { tzcdot } { - \clist_pop:NN \l_tzCdots_opt_input_clist \l_tmpa_tl - \keys_set:nV { keytzCdot } \l_tmpa_tl + \clist_pop:NN \l_tzCdots_opt_input_clist \l_label_pos_str_tl + \keys_set:nV { keytzCdot } \l_label_pos_str_tl \exp_args:NNo \renewcommand\tzCdotradius { \key_tzCdot_radius_tl } \bool_set_true:N \l_tzCdots_size_call_bool \clist_map_break: @@ -643,12 +917,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzCdots_late_opt_fn } } { - \tzCdots_stop_action +% \tzCdots_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzCdots_sub_fn { r() +G{} O{} } +\NewDocumentCommand\tzCdots_sub_fn { r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #3 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \bool_if:NTF \l_tzCdots_shift_coor_bool {% if shift \tl_put_right:Nx \l_tzCdots_cmd_tl @@ -664,7 +967,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { node [ inner~sep = 0pt , - label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } % pos_str ] {} } \tzCdots_check_token:n @@ -761,7 +1064,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%%%% Coordinates %%% \tzcoor()(){label}[pos] -\NewDocumentCommand\tzcoor{ s O{} d<> r() r() +G{} O{} D(){\tz@initial@dot@size} } +\NewDocumentCommand\tzcoor{ s O{} d<> r() r() +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzcoor_cmd_tl @@ -791,9 +1094,37 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { [ inner~sep = 0pt , } +%%%%%% to use string replacement for label positions + \IfValueTF { #7 } + { + \tl_if_in:nnTF { #7 } { [ } + { \extract_posopt:w #7 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #7 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #7 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \tl_put_right:Nx \l_tzcoor_cmd_tl { - label = { \exp_not:n { #7 } \c_colon_str \exp_not:n { #6 } } + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #6 } } % pos_str } \tl_put_right:Nn \l_tzcoor_cmd_tl { @@ -812,6 +1143,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzcoors*[opt] ()(){}[] ()(){}[] repeated ()(){}[]; %% repeat pattern: (coor)(name){label}[pos] + +%%% \tzcoors (main) \NewDocumentCommand\tzcoors{ s O{} d<> } { \tl_clear:N \l_tzcoors_cmd_tl @@ -849,12 +1182,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzcoors_late_opt_fn } } { - \tzcoors_stop_action +% \tzcoors_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzcoors_sub_fn { r() r() +G{} O{} } +\NewDocumentCommand\tzcoors_sub_fn { r() r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #4 } + { + \tl_if_in:nnTF { #4 } { [ } + { \extract_posopt:w #4 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #4 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #4 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \bool_if:NTF \l_tmpa_bool { % collect only coor info @@ -884,7 +1246,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tzcoors_tzdot_cmd_tl { - label = { \exp_not:n { #4 } \c_colon_str \exp_not:n { #3 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #3 } } , % abb } \tl_put_right:No \l_tzcoors_tzdot_cmd_tl { @@ -903,7 +1265,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { (#1) coordinate } } \tl_put_right:Nx \l_tzcoors_cmd_tl - { [ label = { \exp_not:n { #4 } \c_colon_str \exp_not:n { #3 } } ] } + { [ label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #3 } } ] } % pos_str \tl_put_right:Nn \l_tzcoors_cmd_tl { (#2) } } @@ -931,6 +1293,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzcoors_quick_shift_coor_bool +%%% \tzcoorsquick (main) \NewDocumentCommand\tzcoorsquick { s O{} d<> } { \tl_clear:N \l_tzcoors_quick_cmd_tl @@ -968,25 +1331,70 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzcoorsquick_late_opt_fn } } { - \tzcoorsquick_stop_action +% \tzcoorsquick_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } % repetition *** -\NewDocumentCommand\tzcoorsquick_sub_fn { r() r() +g O{} } +\NewDocumentCommand\tzcoorsquick_sub_fn { r() r() +g >{\TrimSpaces}o } { \IfValueTF { #3 } - { \tl_set:Nx \l_tmpa_tl { \exp_not:n { #3 } } } - { \tl_set:Nn \l_tmpa_tl { #2 } } % automatic view - \tl_if_empty:nTF { #4 } + { \tl_set:Nx \l_label_pos_tl { \exp_not:n { #3 } } } + { \tl_set:Nn \l_label_pos_tl { #2 } } % automatic view + +%%%%%% to use string replacement for label positions + \IfValueTF { #4 } { + \tl_if_in:nnTF { #4 } { [ } + { \extract_posopt:w #4 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #4 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #4 } + } + } + \tl_set:Nx \l_tmpb_tl { \l_label_pos_str_tl } % pos_str + } + { + \tl_clear:N \l_label_pos_str_tl \bool_if:NTF \l_tmpa_bool { \tl_set:Nn \l_tmpb_tl { } } % texts with dots (tikz default: above) { \tl_set:Nn \l_tmpb_tl { center } } % only texts } - { - \tl_set:Nx \l_tmpb_tl { \exp_not:n { #4 } } - } +%%%%%%%%%% + +% \IfValueTF { #4 } +% { +% \tl_set:Nx \l_tmpb_tl { \l_label_pos_str_tl } % pos_str +% } +% { +% \bool_if:NTF \l_tmpa_bool +% { \tl_set:Nn \l_tmpb_tl { } } % texts with dots (tikz default: above) +% { \tl_set:Nn \l_tmpb_tl { center } } % only texts +% } + +% \tl_if_empty:nTF { #4 } +% { +% \bool_if:NTF \l_tmpa_bool +% { \tl_set:Nn \l_tmpb_tl { } } % texts with dots (tikz default: above) +% { \tl_set:Nn \l_tmpb_tl { center } } % only texts +% } +% { +% \tl_set:Nx \l_tmpb_tl { \exp_not:n { #4 } } +% } \bool_if:NTF \l_tmpa_bool { %% glancing labels with dots @@ -1018,7 +1426,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tzcoors_quick_tzdot_cmd_tl { - label = { \l_tmpb_tl \c_colon_str { \l_tmpa_tl } } , + label = { \l_tmpb_tl \c_colon_str { \l_label_pos_tl } } , } \tl_put_right:No \l_tzcoors_quick_tzdot_cmd_tl { @@ -1038,7 +1446,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { (#1) coordinate } } \tl_put_right:Nx \l_tzcoors_quick_cmd_tl - { [ label = { \l_tmpb_tl \c_colon_str { \l_tmpa_tl } } ] } + { [ label = { \l_tmpb_tl \c_colon_str { \l_label_pos_tl } } ] } \tl_put_right:Nn \l_tzcoors_quick_cmd_tl { (#2) } } @@ -1071,9 +1479,25 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzline +\bool_new:N \g_tzline_BEGIN_cmd_bool +\bool_new:N \g_tzline_END_cmd_bool \bool_new:N \l_tzline_shift_coor_bool -%%% \tzline +%% \tzlineAtBegin +\NewDocumentCommand\tzlineAtBegin{ m } +{ + \bool_gset_true:N \g_tzline_BEGIN_cmd_bool + \tl_gset:No \g_tzline_BEGIN_cmd_tl { #1 } +} + +%% \tzlineAtEnd +\NewDocumentCommand\tzlineAtEnd{ m } +{ + \bool_gset_true:N \g_tzline_END_cmd_bool + \tl_gset:No \g_tzline_END_cmd_tl { #1 } +} + +%%% \tzline (main) \NewDocumentCommand\tzline{ s t+ o d<> d"" } { \tl_clear:N \l_tzline_cmd_tl @@ -1167,6 +1591,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nn \l_tzline_cmd_tl { node [ #7 ] { #6 } } + % add at begin/end + \bool_if:NT \g_tzline_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzline_cmd_tl { \g_tzline_BEGIN_cmd_tl } } + \bool_if:NT \g_tzline_END_cmd_bool + { \tl_put_right:Nx \l_tzline_cmd_tl { \g_tzline_END_cmd_tl } } % final action \tl_put_left:No \l_tzline_cmd_tl @@ -1178,6 +1607,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { [ \l_tzline_namepath_tl , } \exp_last_unbraced:Nf \draw \l_tzline_cmd_tl #8 ; + + \bool_gset_false:N \g_tzline_BEGIN_cmd_bool + \bool_gset_false:N \g_tzline_END_cmd_bool +% \tl_clear:N \g_tzline_BEGIN_cmd_tl +% \tl_clear:N \g_tzline_END_cmd_tl } %%% --- end of \tzline @@ -1185,8 +1619,25 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzlines +\bool_new:N \g_tzlines_BEGIN_cmd_bool +\bool_new:N \g_tzlines_END_cmd_bool \bool_new:N \l_tzlines_shift_coor_bool +%% \tzlinesAtBegin +\NewDocumentCommand\tzlinesAtBegin{ m } +{ + \bool_gset_true:N \g_tzlines_BEGIN_cmd_bool + \tl_gset:No \g_tzlines_BEGIN_cmd_tl { #1 } +} + +%% \tzlinesAtEnd +\NewDocumentCommand\tzlinesAtEnd{ m } +{ + \bool_gset_true:N \g_tzlines_END_cmd_bool + \tl_gset:No \g_tzlines_END_cmd_tl { #1 } +} + +%%% \tzlines (main) %% do not use: inner sep=0pt \NewDocumentCommand\tzlines{ s t+ O{} d<> D""{} } { @@ -1234,7 +1685,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzlines_late_opt_fn } } { - \tzlines_stop_action +% \tzlines_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -1299,6 +1751,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \tl_put_right:No \l_tzlines_cmd_tl { \l_tzlines_STYLE_B_tl } \tl_clear:N \l_tzlines_STYLE_tl + % add at begin/end + \bool_if:NT \g_tzlines_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzlines_cmd_tl { \g_tzlines_BEGIN_cmd_tl } } + \bool_if:NT \g_tzlines_END_cmd_bool + { \tl_put_right:Nx \l_tzlines_cmd_tl { \g_tzlines_END_cmd_tl } } % gathering options \tl_put_left:No \l_tzlines_cmd_tl { @@ -1309,6 +1766,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) % final action \exp_last_unbraced:Nf \draw \l_tzlines_cmd_tl \l_tzlines_code_at_end_tl ; + + \bool_gset_false:N \g_tzlines_BEGIN_cmd_bool + \bool_gset_false:N \g_tzlines_END_cmd_bool +% \tl_clear:N \g_tzlines_BEGIN_cmd_tl +% \tl_clear:N \g_tzlines_END_cmd_tl } %%% --- end of \tzlines @@ -1318,6 +1780,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzpolygon_shift_coor_bool +%%% \tzpolygon (main) %% do not use: inner sep=0pt \NewDocumentCommand\tzpolygon{ s t+ O{} d<> D""{} } { @@ -1365,7 +1828,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzpolygon_late_opt_fn } } { - \tzpolygon_stop_action +% \tzpolygon_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -1456,39 +1920,37 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzpolygon +%%(ADDED) +%%%%% Linking points -%%% \tzpath -%% draw=none version of \tzlinks (mainly for filling area) +%%% \tzlink (general version of \tzline) -\bool_new:N \g_tzpath_BEGIN_cmd_bool -\bool_new:N \g_tzpath_END_cmd_bool -\bool_new:N \l_tzpath_shift_coor_bool +\bool_new:N \g_tzlink_BEGIN_cmd_bool +\bool_new:N \g_tzlink_END_cmd_bool +\bool_new:N \l_tzlink_shift_coor_bool -%% \tzpathAtBegin -\NewDocumentCommand\tzpathAtBegin{ m } +%% \tzlinkAtBegin +\NewDocumentCommand\tzlinkAtBegin{ m } { - \bool_gset_true:N \g_tzpath_BEGIN_cmd_bool - \tl_gset:No \g_tzpath_BEGIN_cmd_tl { #1 } + \bool_gset_true:N \g_tzlink_BEGIN_cmd_bool + \tl_gset:No \g_tzlink_BEGIN_cmd_tl { #1 } } -%% \tzpathAtEnd -\NewDocumentCommand\tzpathAtEnd{ m } +%% \tzlinkAtEnd +\NewDocumentCommand\tzlinkAtEnd{ m } { - \bool_gset_true:N \g_tzpath_END_cmd_bool - \tl_gset:No \g_tzpath_END_cmd_tl { #1 } + \bool_gset_true:N \g_tzlink_END_cmd_bool + \tl_gset:No \g_tzlink_END_cmd_tl { #1 } } -%%% \tzpath -%% do not use: inner sep=0pt -\NewDocumentCommand\tzpath{ s t+ G{\tz@initial@path@style} O{} d<> D""{} } +%%% \tzlink (main) +\NewDocumentCommand\tzlink{ s t+ G{\tz@initial@link@style} o d<> d"" } { - \tl_clear:N \l_tzpath_cmd_tl - \tl_clear:N \l_tzpath_STYLE_tl + \tl_clear:N \l_tzlink_cmd_tl - \IfValueT { #3 } - { \renewcommand\tzpathstyle{ #3 } } + \renewcommand\tzlinkstyle{ #3 } - \IfBooleanTF { #1 } % (*) or not + \IfBooleanTF { #1 } % (*) or not (NOT USED!) { \bool_set_true:N \l_tmpa_bool } { \bool_set_false:N \l_tmpa_bool } @@ -1498,295 +1960,149 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \IfValueTF { #5 } { - \tl_set:Nn \l_tzpath_shift_coor_tl { #5 } - \bool_set_true:N \l_tzpath_shift_coor_bool + \tl_set:Nn \l_tzlink_shift_coor_tl { #5 } + \bool_set_true:N \l_tzlink_shift_coor_bool } { - \tl_clear:N \l_tzpath_shift_coor_tl - \bool_set_false:N \l_tzpath_shift_coor_bool + \tl_clear:N \l_tzlink_shift_coor_tl + \bool_set_false:N \l_tzlink_shift_coor_bool } \IfValueTF { #4 } - { \tl_set:Nx \l_tzpath_opt_tl { #4 } } - { \tl_clear:N \l_tzpath_opt_tl } + { \tl_set:Nn \l_tzlink_opt_tl { #4 } } + { \tl_clear:N \l_tzlink_opt_tl } + \IfValueTF { #6 } - { \tl_set:Nn \l_tzpath_namepath_tl { name~path = #6 } } - { \tl_clear:N \l_tzpath_namepath_tl } + { \tl_set:Nn \l_tzlink_namepath_tl { name~path = #6 } } + { \tl_clear:N \l_tzlink_namepath_tl } - \int_zero:N \l_tmpa_int - \tzpath_check_token:n + \tzlink_check_token:n } -\cs_new:Npn \tzpath_check_token:n #1 +\cs_new:Npn \tzlink_check_token:n #1 { -% \token_if_eq_charcode:NNTF #1 ( -% { \tzpath_sub_fn #1 } -% { \tzpath_stop_action } - \str_case:nnF { #1 } - { - { ( } { \tzpath_sub_fn #1 } - { ; } { \tzpath_late_opt_fn } - } - { - \tzpath_stop_action - } + \str_if_eq:nnT { #1 } { ( } + { \tzlink_sub_fn ( } +% \tzlink_stop_action } -\NewDocumentCommand\tzpath_sub_fn{ r() O{} +G{} O{} d<> } +\NewDocumentCommand\tzlink_sub_fn{ r() O{} +G{} O{} d<> r() +G{} O{} D<>{} } { - \int_incr:N \l_tmpa_int - % (from the second round) put line STYLE before the next cmd-tl - \int_compare:nT { \l_tmpa_int > 1 } - { - \tl_put_right:No \l_tzpath_cmd_tl { \l_tzpath_STYLE_tl } - \tl_clear:N \l_tzpath_STYLE_tl - } - - % collect cmd-tl - \bool_if:NTF \l_tzpath_shift_coor_bool - {% shift-coor - \bool_if:NTF \l_tmpb_bool - {% if ++ - \int_compare:nTF { \l_tmpa_int > 1 } - { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift from 2nd - { - \tl_put_right:Nx \l_tzpath_cmd_tl - { ([ shift = { (\l_tzpath_shift_coor_tl) } ]#1) } % shift first - } - } - {% no ++ - \tl_put_right:Nx \l_tzpath_cmd_tl - { ([ shift = { (\l_tzpath_shift_coor_tl) } ]#1) } % shift all coors - } - } - { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift (normal) - - % (from the first round on) determine and save STYLE % determine connect line STYLE \tl_if_empty:nTF { #2 } - { \tl_set:Nn \l_tzpath_STYLE_A_tl { ~ \tzpathstyle ~ } } - { \tl_set:Nn \l_tzpath_STYLE_A_tl { #2 } } - % save node info (for later use, at the end) - \tl_if_empty:nTF { #3 } { - \tl_clear:N \l_tzpath_STYLE_B_tl + \tl_set:Nn \l_tzlink_STYLE_A_tl { ~ \tzlinkstyle ~ } } { - \tl_set:Nn \l_tzpath_STYLE_B_tl - { ~ node [ #4 ] { #3 } } + \tl_set:Nn \l_tzlink_STYLE_A_tl { ~ #2 ~ } } - \IfValueTF { #5 } % <+ or ++ or none> (NOT USED!) + \IfValueTF { #5 } { - \tl_set:Nn \l_tzpath_STYLE_C_tl { #5 } + \tl_set:Nn \l_tzlink_STYLE_C_tl { #5 } % + or ++ } { \bool_if:NTF \l_tmpb_bool - { \tl_set:Nn \l_tzpath_STYLE_C_tl { ++ } } - { \tl_set:Nn \l_tzpath_STYLE_C_tl { } } + { \tl_set:Nn \l_tzlink_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzlink_STYLE_C_tl { } } } - - \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_A_tl } - \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_B_tl } - \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_C_tl } - - \tzpath_check_token:n -} - -\NewDocumentCommand\tzpath_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } -{ - \renewcommand\tzfillopacity{ #1 } - \tl_set:Nn \l_tzpath_code_at_end_tl { #2 } - \tzpath_stop_action -} - -\NewDocumentCommand\tzpath_stop_action {} -{ - \tl_if_empty:NF \l_tzpath_STYLE_B_tl + % insert connect line STYLE + \bool_if:NTF \l_tzlink_shift_coor_bool { - \tl_put_right:No \l_tzpath_cmd_tl { \l_tzpath_STYLE_B_tl } + \tl_put_right:Nx \l_tzlink_cmd_tl + { ([ shift = { (\l_tzlink_shift_coor_tl) } ]#1) } } - \tl_clear:N \l_tzpath_STYLE_tl - %% add at begin/end - \bool_if:NT \g_tzpath_BEGIN_cmd_bool - { \tl_put_left:Nx \l_tzpath_cmd_tl { \g_tzpath_BEGIN_cmd_tl } } - \bool_if:NT \g_tzpath_END_cmd_bool - { \tl_put_right:Nx \l_tzpath_cmd_tl { \g_tzpath_END_cmd_tl } } - %% collect options - \tl_put_left:No \l_tzpath_cmd_tl - { \l_tzpath_opt_tl ] } % expand `once' needed - % * or not - \bool_if:NTF \l_tmpa_bool - { - \tl_put_left:Nx \l_tzpath_cmd_tl - { - [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , - text~opacity = 1 , - \l_tzpath_namepath_tl , - } - } - { - \tl_put_left:Nx \l_tzpath_cmd_tl - { [ \l_tzpath_namepath_tl , } - } - %% final action - \exp_last_unbraced:Nf - \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path - - \bool_gset_false:N \g_tzpath_BEGIN_cmd_bool - \bool_gset_false:N \g_tzpath_END_cmd_bool -} - -%%% --- end of \tzpath - - -%%% \tzto - -\bool_new:N \g_tzto_BEGIN_cmd_bool -\bool_new:N \g_tzto_END_cmd_bool -\bool_new:N \l_tzto_shift_coor_bool - -%% \tztoAtBegin -\NewDocumentCommand\tztoAtBegin{ m } -{ - \bool_gset_true:N \g_tzto_BEGIN_cmd_bool - \tl_gset:No \g_tzto_BEGIN_cmd_tl { #1 } -} - -%% \tztoAtEnd -\NewDocumentCommand\tztoAtEnd{ m } -{ - \bool_gset_true:N \g_tzto_END_cmd_bool - \tl_gset:No \g_tzto_END_cmd_tl { #1 } -} - -%%% \tzto (main) -\NewDocumentCommand\tzto{ s t+ o d<> d"" } -{ - \tl_clear:N \l_tzto_cmd_tl - - \IfBooleanTF { #1 } % (*) or not (NOT USED!) - { \bool_set_true:N \l_tmpa_bool } - { \bool_set_false:N \l_tmpa_bool } - - \IfBooleanTF { #2 } % (+) or not - { \bool_set_true:N \l_tmpb_bool } - { \bool_set_false:N \l_tmpb_bool } - - \IfValueTF { #4 } - { - \tl_set:Nn \l_tzto_shift_coor_tl { #4 } - \bool_set_true:N \l_tzto_shift_coor_bool - } - { - \tl_clear:N \l_tzto_shift_coor_tl - \bool_set_false:N \l_tzto_shift_coor_bool - } - - \IfValueTF { #3 } - { \tl_set:Nn \l_tzto_opt_tl { #3 } } - { \tl_clear:N \l_tzto_opt_tl } - - \IfValueTF { #5 } - { \tl_set:Nn \l_tzto_namepath_tl { name~path = #5 } } - { \tl_clear:N \l_tzto_namepath_tl } - - \tzto_check_token:n -} - -\cs_new:Npn \tzto_check_token:n #1 -{ - \str_if_eq:nnT { #1 } { ( } - { \tzto_sub_fn ( } -% \tzto_stop_action -} - -\NewDocumentCommand\tzto_sub_fn{ r() +G{} O{} r() +G{} O{} D<>{} } -{ - - \bool_if:NTF \l_tzto_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzto_cmd_tl - { ([ shift = { (\l_tzto_shift_coor_tl) } ]#1) } - } - { \tl_put_right:Nn \l_tzto_cmd_tl { (#1) } } - - \tl_put_right:Nn \l_tzto_cmd_tl - { to ~node [ above , #3 ] { #2 } } - + { \tl_put_right:Nn \l_tzlink_cmd_tl { (#1) } } + + \tl_put_right:No \l_tzlink_cmd_tl % once + { + \l_tzlink_STYLE_A_tl + } + \tl_put_right:Nn \l_tzlink_cmd_tl + { + ~ node [ above , #4 ] { #3 } % above + } + \tl_put_right:No \l_tzlink_cmd_tl % once + { + \l_tzlink_STYLE_C_tl + } \bool_if:NTF \l_tmpb_bool {% if ++ - \tl_put_right:Nn \l_tzto_cmd_tl { ++ (#4) } + \tl_put_right:Nn \l_tzlink_cmd_tl { (#6) } } {% no ++ - \bool_if:NTF \l_tzto_shift_coor_bool + \bool_if:NTF \l_tzlink_shift_coor_bool {% if shift - \tl_put_right:Nx \l_tzto_cmd_tl - { ([ shift = { (\l_tzto_shift_coor_tl) } ]#4) } + \tl_put_right:Nx \l_tzlink_cmd_tl + { ( [ shift = { (\l_tzlink_shift_coor_tl) } ] \exp_not:n { #6 } ) } } - { \tl_put_right:Nn \l_tzto_cmd_tl { (#4) } } + { \tl_put_right:Nn \l_tzlink_cmd_tl { (#6) } } } - - \tl_put_right:Nn \l_tzto_cmd_tl - { node [ #6 ] { #5 } } + \tl_put_right:Nn \l_tzlink_cmd_tl + { + node [ #8 ] { #7 } + } % add at begin/end - \bool_if:NT \g_tzto_BEGIN_cmd_bool - { \tl_put_left:Nx \l_tzto_cmd_tl { \g_tzto_BEGIN_cmd_tl } } - \bool_if:NT \g_tzto_END_cmd_bool - { \tl_put_right:Nx \l_tzto_cmd_tl { \g_tzto_END_cmd_tl } } + \bool_if:NT \g_tzlink_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzlink_cmd_tl { \g_tzlink_BEGIN_cmd_tl } } + \bool_if:NT \g_tzlink_END_cmd_bool + { \tl_put_right:Nx \l_tzlink_cmd_tl { \g_tzlink_END_cmd_tl } } % final action - \tl_put_left:No \l_tzto_cmd_tl + \tl_put_left:No \l_tzlink_cmd_tl { - \l_tzto_opt_tl ] % expand `once' needed + \l_tzlink_opt_tl ] % expand `once' needed } - \tl_put_left:Nx \l_tzto_cmd_tl - { [ \l_tzto_namepath_tl , } + \tl_put_left:Nx \l_tzlink_cmd_tl + { [ \l_tzlink_namepath_tl , } - \exp_last_unbraced:Nf \draw \l_tzto_cmd_tl #7 ; + \exp_last_unbraced:Nf \draw \l_tzlink_cmd_tl #9 ; - \bool_gset_false:N \g_tzto_BEGIN_cmd_bool - \bool_gset_false:N \g_tzto_END_cmd_bool -% \tl_clear:N \g_tzto_BEGIN_cmd_tl -% \tl_clear:N \g_tzto_END_cmd_tl + \bool_gset_false:N \g_tzlink_BEGIN_cmd_bool + \bool_gset_false:N \g_tzlink_END_cmd_bool +% \tl_clear:N \g_tzlink_BEGIN_cmd_tl +% \tl_clear:N \g_tzlink_END_cmd_tl } -%%% --- end of \tzto +%%% --- end of \tzlink -%%% \tztos (longer version of \tzto) -\bool_new:N \g_tztos_BEGIN_cmd_bool -\bool_new:N \g_tztos_END_cmd_bool -\bool_new:N \l_tztos_shift_coor_bool -%% \tztosAtBegin -\NewDocumentCommand\tztosAtBegin{ m } +%%%(ADDED) +%%% \tzlinks -- generalized version of \tzlines + +\bool_new:N \g_tzlinks_BEGIN_cmd_bool +\bool_new:N \g_tzlinks_END_cmd_bool +\bool_new:N \l_tzlinks_shift_coor_bool + +%% \tzlinksAtBegin +\NewDocumentCommand\tzlinksAtBegin{ m } { - \bool_gset_true:N \g_tztos_BEGIN_cmd_bool - \tl_gset:No \g_tztos_BEGIN_cmd_tl { #1 } + \bool_gset_true:N \g_tzlinks_BEGIN_cmd_bool + \tl_gset:No \g_tzlinks_BEGIN_cmd_tl { #1 } } -%% \tztosAtEnd -\NewDocumentCommand\tztosAtEnd{ m } +%% \tzlinksAtEnd +\NewDocumentCommand\tzlinksAtEnd{ m } { - \bool_gset_true:N \g_tztos_END_cmd_bool - \tl_gset:No \g_tztos_END_cmd_tl { #1 } + \bool_gset_true:N \g_tzlinks_END_cmd_bool + \tl_gset:No \g_tzlinks_END_cmd_tl { #1 } } -%%% \tztos (main) +%%% \tzlinks (main) %% do not use: inner sep=0pt -\NewDocumentCommand\tztos{ s t+ O{} d<> D""{} } +\NewDocumentCommand\tzlinks{ s t+ G{\tz@initial@link@style} O{} d<> D""{} } { - \tl_clear:N \l_tztos_cmd_tl - \tl_clear:N \l_tztos_STYLE_tl + \tl_clear:N \l_tzlinks_cmd_tl + \tl_clear:N \l_tzlinks_STYLE_tl -% \IfValueT { #3 } -% { \renewcommand\tztostyle{ #3 } } + \IfValueT { #3 } + { \renewcommand\tzlinkstyle{ #3 } } - \IfBooleanTF { #1 } % (*) or not (NOT USED!) + \IfBooleanTF { #1 } % (*) or not { \bool_set_true:N \l_tmpa_bool } { \bool_set_false:N \l_tmpa_bool } @@ -1794,1355 +2110,3750 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \bool_set_true:N \l_tmpb_bool } { \bool_set_false:N \l_tmpb_bool } - \IfValueTF { #4 } + \IfValueTF { #5 } { - \tl_set:Nn \l_tztos_shift_coor_tl { #4 } - \bool_set_true:N \l_tztos_shift_coor_bool + \tl_set:Nn \l_tzlinks_shift_coor_tl { #5 } + \bool_set_true:N \l_tzlinks_shift_coor_bool } { - \tl_clear:N \l_tztos_shift_coor_tl - \bool_set_false:N \l_tztos_shift_coor_bool + \tl_clear:N \l_tzlinks_shift_coor_tl + \bool_set_false:N \l_tzlinks_shift_coor_bool } - \IfValueTF { #3 } - { \tl_set:Nn \l_tztos_opt_tl { #3 } } - { \tl_clear:N \l_tztos_opt_tl } + \IfValueTF { #4 } + { \tl_set:Nx \l_tzlinks_opt_tl { #4 } } + { \tl_clear:N \l_tzlinks_opt_tl } - \IfValueTF { #5 } - { \tl_set:Nn \l_tztos_namepath_tl { name~path = #5 } } - { \tl_clear:N \l_tztos_namepath_tl } + \IfValueTF { #6 } + { \tl_set:Nn \l_tzlinks_namepath_tl { name~path = #6 } } + { \tl_clear:N \l_tzlinks_namepath_tl } \int_zero:N \l_tmpa_int - \tztos_check_token:n + \tzlinks_check_token:n } -\cs_new:Npn \tztos_check_token:n #1 +\cs_new:Npn \tzlinks_check_token:n #1 { % \token_if_eq_charcode:NNTF #1 ( -% { \tztos_sub_fn #1 } -% { \tztos_stop_action } +% { \tzlinks_sub_fn #1 } +% { \tzlinks_stop_action } \str_case:nnF { #1 } { - { ( } { \tztos_sub_fn #1 } - { ; } { \tztos_late_opt_fn } + { ( } { \tzlinks_sub_fn #1 } + { ; } { \tzlinks_late_opt_fn } } { - \tztos_stop_action +% \tzlinks_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -%% (coor)[to opt]{text}[node opt] -\NewDocumentCommand\tztos_sub_fn{ r() O{} +G{} O{} } +\NewDocumentCommand\tzlinks_sub_fn{ r() O{} +G{} O{} d<> } { \int_incr:N \l_tmpa_int % (from the second round) put line STYLE before the next cmd-tl \int_compare:nT { \l_tmpa_int > 1 } { - \tl_put_right:No \l_tztos_cmd_tl { \l_tztos_STYLE_tl } - \tl_clear:N \l_tztos_STYLE_tl + \tl_put_right:No \l_tzlinks_cmd_tl { \l_tzlinks_STYLE_tl } + \tl_clear:N \l_tzlinks_STYLE_tl } % collect cmd-tl - \bool_if:NTF \l_tztos_shift_coor_bool + \bool_if:NTF \l_tzlinks_shift_coor_bool {% shift-coor \bool_if:NTF \l_tmpb_bool {% if ++ \int_compare:nTF { \l_tmpa_int > 1 } - { \tl_put_right:Nn \l_tztos_cmd_tl { (#1) } } % no shift from 2nd + { \tl_put_right:Nn \l_tzlinks_cmd_tl { (#1) } } % no shift from 2nd { - \tl_put_right:Nx \l_tztos_cmd_tl - { ([ shift = { (\l_tztos_shift_coor_tl) } ]#1) } % shift first + \tl_put_right:Nx \l_tzlinks_cmd_tl + { ([ shift = { (\l_tzlinks_shift_coor_tl) } ]#1) } % shift first } } {% no ++ - \tl_put_right:Nx \l_tztos_cmd_tl - { ([ shift = { (\l_tztos_shift_coor_tl) } ]#1) } % shift all coors + \tl_put_right:Nx \l_tzlinks_cmd_tl + { ([ shift = { (\l_tzlinks_shift_coor_tl) } ]#1) } % shift all coors } } - { \tl_put_right:Nn \l_tztos_cmd_tl { (#1) } } % no shift (normal) + { \tl_put_right:Nn \l_tzlinks_cmd_tl { (#1) } } % no shift (normal) % (from the first round on) determine and save STYLE % determine connect line STYLE - \tl_set:Nn \l_tztos_STYLE_A_tl { ~ to [ #2 ] } + \tl_if_empty:nTF { #2 } + { \tl_set:Nn \l_tzlinks_STYLE_A_tl { ~ \tzlinkstyle ~ } } + { \tl_set:Nn \l_tzlinks_STYLE_A_tl { #2 } } % save node info (for later use, at the end) \tl_if_empty:nTF { #3 } { - \tl_clear:N \l_tztos_STYLE_B_tl + \tl_clear:N \l_tzlinks_STYLE_B_tl } { - \tl_set:Nn \l_tztos_STYLE_B_tl + \tl_set:Nn \l_tzlinks_STYLE_B_tl { ~ node [ #4 ] { #3 } } } - \bool_if:NTF \l_tmpb_bool - { \tl_set:Nn \l_tztos_STYLE_C_tl { ++ } } - { \tl_set:Nn \l_tztos_STYLE_C_tl { } } + \IfValueTF { #5 } % <+ or ++ or none> (NOT USED!) + { + \tl_set:Nn \l_tzlinks_STYLE_C_tl { #5 } + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzlinks_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzlinks_STYLE_C_tl { } } + } - \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_A_tl } - \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_B_tl } - \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_C_tl } + \tl_put_right:No \l_tzlinks_STYLE_tl { \l_tzlinks_STYLE_A_tl } + \tl_put_right:No \l_tzlinks_STYLE_tl { \l_tzlinks_STYLE_B_tl } + \tl_put_right:No \l_tzlinks_STYLE_tl { \l_tzlinks_STYLE_C_tl } - \tztos_check_token:n + \tzlinks_check_token:n } -\NewDocumentCommand\tztos_late_opt_fn { D<>{} } +\NewDocumentCommand\tzlinks_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } { - \tl_set:Nn \l_tztos_code_at_end_tl { #1 } - \tztos_stop_action + \renewcommand\tzfillopacity{ #1 } + \tl_set:Nn \l_tzlinks_code_at_end_tl { #2 } + \tzlinks_stop_action } -\NewDocumentCommand\tztos_stop_action {} +\NewDocumentCommand\tzlinks_stop_action {} { - \tl_if_empty:NF \l_tztos_STYLE_B_tl + \tl_if_empty:NF \l_tzlinks_STYLE_B_tl { - \tl_put_right:No \l_tztos_cmd_tl { \l_tztos_STYLE_B_tl } + \tl_put_right:No \l_tzlinks_cmd_tl { \l_tzlinks_STYLE_B_tl } } - \tl_clear:N \l_tztos_STYLE_tl - % add at begin/end - \bool_if:NT \g_tztos_BEGIN_cmd_bool - { \tl_put_left:Nx \l_tztos_cmd_tl { \g_tztos_BEGIN_cmd_tl } } - \bool_if:NT \g_tztos_END_cmd_bool - { \tl_put_right:Nx \l_tztos_cmd_tl { \g_tztos_END_cmd_tl } } - % fill or not - \tl_put_left:No \l_tztos_cmd_tl + \tl_clear:N \l_tzlinks_STYLE_tl + %% add at begin/end + \bool_if:NT \g_tzlinks_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzlinks_cmd_tl { \g_tzlinks_BEGIN_cmd_tl } } + \bool_if:NT \g_tzlinks_END_cmd_bool + { \tl_put_right:Nx \l_tzlinks_cmd_tl { \g_tzlinks_END_cmd_tl } } + %% collect options + \tl_put_left:No \l_tzlinks_cmd_tl + { \l_tzlinks_opt_tl ] } % expand `once' needed + % * or not + \bool_if:NTF \l_tmpa_bool { - \l_tztos_opt_tl ] % expand `once' needed for user convenience + \tl_put_left:Nx \l_tzlinks_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + \l_tzlinks_namepath_tl , + } } - \tl_put_left:Nx \l_tztos_cmd_tl - { [ \l_tztos_namepath_tl , } - % final action + { + \tl_put_left:Nx \l_tzlinks_cmd_tl + { [ \l_tzlinks_namepath_tl , } + } + %% final action +% \begin{pgfonlayer}{\tzlinklayer} % default tzlinklayer = main \exp_last_unbraced:Nf - \draw \l_tztos_cmd_tl \l_tztos_code_at_end_tl ; %% draw - - \bool_gset_false:N \g_tztos_BEGIN_cmd_bool - \bool_gset_false:N \g_tztos_END_cmd_bool -% \tl_clear:N \g_tztos_BEGIN_cmd_tl -% \tl_clear:N \g_tztos_END_cmd_tl + \draw \l_tzlinks_cmd_tl \l_tzlinks_code_at_end_tl ; %% draw (\tzlinks) +% \end{pgfonlayer} + + \bool_gset_false:N \g_tzlinks_BEGIN_cmd_bool + \bool_gset_false:N \g_tzlinks_END_cmd_bool } -%%% --- end of \tztos +%%% --- end of \tzlinks -%%%%% Figures: circles, frames, ellipses, triangles, etc. -%%% \tzcircle +%%% \tzpath +%% draw=none version of \tzlinks (mainly for filling area) -\NewDocumentCommand\tzcircle - { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } +\bool_new:N \g_tzfnArea_call_bool + +\bool_new:N \g_tzpath_BEGIN_cmd_bool +\bool_new:N \g_tzpath_END_cmd_bool +\bool_new:N \l_tzpath_shift_coor_bool + + +%% \tzpathAtBegin +\NewDocumentCommand\tzpathAtBegin{ m } { - \renewcommand\tzfillopacity{#7} - \IfBooleanTF { #1 } - { - \IfValueTF { #3 } + \bool_gset_true:N \g_tzpath_BEGIN_cmd_bool + \tl_gset:No \g_tzpath_BEGIN_cmd_tl { #1 } +} + +%% \tzpathAtEnd +\NewDocumentCommand\tzpathAtEnd{ m } +{ + \bool_gset_true:N \g_tzpath_END_cmd_bool + \tl_gset:No \g_tzpath_END_cmd_tl { #1 } +} + +%%% \tzpath (main) +%% do not use: inner sep=0pt +\NewDocumentCommand\tzpath{ s t+ G{\tz@initial@link@style} O{} d<> D""{} } +{ + \tl_clear:N \l_tzpath_cmd_tl + \tl_clear:N \l_tzpath_STYLE_tl + + \IfValueT { #3 } + { \renewcommand\tzpathstyle{ #3 } } + + \IfBooleanTF { #1 } % (*) or not + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzpath_shift_coor_tl { #5 } + \bool_set_true:N \l_tzpath_shift_coor_bool + } + { + \tl_clear:N \l_tzpath_shift_coor_tl + \bool_set_false:N \l_tzpath_shift_coor_bool + } + + \IfValueTF { #4 } + { \tl_set:Nx \l_tzpath_opt_tl { #4 } } + { \tl_clear:N \l_tzpath_opt_tl } + + \IfValueTF { #6 } + { \tl_set:Nn \l_tzpath_namepath_tl { name~path = #6 } } + { \tl_clear:N \l_tzpath_namepath_tl } + + \int_zero:N \l_tmpa_int + \tzpath_check_token:n +} + +\cs_new:Npn \tzpath_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzpath_sub_fn #1 } +% { \tzpath_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzpath_sub_fn #1 } + { ; } { \tzpath_late_opt_fn } + } + { +% \tzpath_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzpath_sub_fn{ r() O{} +G{} O{} d<> } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tzpath_cmd_tl { \l_tzpath_STYLE_tl } + \tl_clear:N \l_tzpath_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzpath_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzpath_cmd_tl + { ( [ shift = { (\l_tzpath_shift_coor_tl) } ] #1 ) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzpath_cmd_tl + { ( [ shift = { (\l_tzpath_shift_coor_tl) } ] #1 ) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_if_empty:nTF { #2 } + { \tl_set:Nn \l_tzpath_STYLE_A_tl { ~ \tzpathstyle ~ } } + { \tl_set:Nn \l_tzpath_STYLE_A_tl { #2 } } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tzpath_STYLE_B_tl + } + { + \tl_set:Nn \l_tzpath_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \IfValueTF { #5 } % <+ or ++ or none> (NOT USED!) + { + \tl_set:Nn \l_tzpath_STYLE_C_tl { #5 } + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzpath_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzpath_STYLE_C_tl { } } + } + + \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_A_tl } + \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_B_tl } + \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_C_tl } + + \tzpath_check_token:n +} + +% \tzpath fill opacity : 0.3 (default) % differ from \tzlinks +\NewDocumentCommand\tzpath_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{ #1 } + \tl_set:Nn \l_tzpath_code_at_end_tl { #2 } + \tzpath_stop_action +} + +\NewDocumentCommand\tzpath_stop_action {} +{ + \tl_if_empty:NF \l_tzpath_STYLE_B_tl + { + \tl_put_right:No \l_tzpath_cmd_tl { \l_tzpath_STYLE_B_tl } + } + \tl_clear:N \l_tzpath_STYLE_tl + %% add at begin/end + \bool_if:NT \g_tzpath_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzpath_cmd_tl { \g_tzpath_BEGIN_cmd_tl } } + \bool_if:NT \g_tzpath_END_cmd_bool + { \tl_put_right:Nx \l_tzpath_cmd_tl { \g_tzpath_END_cmd_tl } } + %% collect options + \tl_put_left:No \l_tzpath_cmd_tl + { \l_tzpath_opt_tl ] } % expand `once' needed + % * or not + \bool_if:NTF \l_tmpa_bool + { + \tl_put_left:Nx \l_tzpath_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + \l_tzpath_namepath_tl , + } + } + { + \tl_put_left:Nx \l_tzpath_cmd_tl + { [ \l_tzpath_namepath_tl , } + } + %% final action + \bool_if:NTF \g_tzfnArea_call_bool + { % (ADDED) for \tzfnArealayer + \begin{pgfonlayer}{\tzfnArealayer} % default tzpathlayer = main + \exp_last_unbraced:Nf + \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path (\tzpath) + \end{pgfonlayer} + } + { % for original \tzpath + \begin{pgfonlayer}{\tzpathlayer} % default tzpathlayer = main + \exp_last_unbraced:Nf + \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path (\tzpath) + \end{pgfonlayer} + } + \bool_gset_false:N \g_tzpath_BEGIN_cmd_bool + \bool_gset_false:N \g_tzpath_END_cmd_bool +} + +%%% --- end of \tzpath + + +%%% \tzto + +\bool_new:N \g_tzto_BEGIN_cmd_bool +\bool_new:N \g_tzto_END_cmd_bool +\bool_new:N \l_tzto_shift_coor_bool + +%% \tztoAtBegin +\NewDocumentCommand\tztoAtBegin{ m } +{ + \bool_gset_true:N \g_tzto_BEGIN_cmd_bool + \tl_gset:No \g_tzto_BEGIN_cmd_tl { #1 } +} + +%% \tztoAtEnd +\NewDocumentCommand\tztoAtEnd{ m } +{ + \bool_gset_true:N \g_tzto_END_cmd_bool + \tl_gset:No \g_tzto_END_cmd_tl { #1 } +} + +%%% \tzto (main) +\NewDocumentCommand\tzto{ s t+ o d<> d"" } +{ + \tl_clear:N \l_tzto_cmd_tl + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzto_shift_coor_tl { #4 } + \bool_set_true:N \l_tzto_shift_coor_bool + } + { + \tl_clear:N \l_tzto_shift_coor_tl + \bool_set_false:N \l_tzto_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzto_opt_tl { #3 } } + { \tl_clear:N \l_tzto_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzto_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tzto_namepath_tl } + + \tzto_check_token:n +} + +\cs_new:Npn \tzto_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzto_sub_fn ( } +% \tzto_stop_action +} + +\NewDocumentCommand\tzto_sub_fn{ r() +G{} O{} r() +G{} O{} D<>{} } +{ + + \bool_if:NTF \l_tzto_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzto_cmd_tl + { ([ shift = { (\l_tzto_shift_coor_tl) } ]#1) } + } + { \tl_put_right:Nn \l_tzto_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tzto_cmd_tl + { to ~node [ above , #3 ] { #2 } } + + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzto_cmd_tl { ++ (#4) } + } + {% no ++ + \bool_if:NTF \l_tzto_shift_coor_bool {% if shift - \draw [ fill = \tzfillcolor , fill~opacity = #7 , - text~opacity = 1 , - name~path = #4 , #2 ] ([shift={(#3)}]#5) circle (#6) - #8 ; + \tl_put_right:Nx \l_tzto_cmd_tl + { ([ shift = { (\l_tzto_shift_coor_tl) } ]#4) } + } + { \tl_put_right:Nn \l_tzto_cmd_tl { (#4) } } + } + + \tl_put_right:Nn \l_tzto_cmd_tl + { node [ #6 ] { #5 } } + + % add at begin/end + \bool_if:NT \g_tzto_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzto_cmd_tl { \g_tzto_BEGIN_cmd_tl } } + \bool_if:NT \g_tzto_END_cmd_bool + { \tl_put_right:Nx \l_tzto_cmd_tl { \g_tzto_END_cmd_tl } } + + % final action + \tl_put_left:No \l_tzto_cmd_tl + { + \l_tzto_opt_tl ] % expand `once' needed + } + + \tl_put_left:Nx \l_tzto_cmd_tl + { [ \l_tzto_namepath_tl , } + + \exp_last_unbraced:Nf \draw \l_tzto_cmd_tl #7 ; + + \bool_gset_false:N \g_tzto_BEGIN_cmd_bool + \bool_gset_false:N \g_tzto_END_cmd_bool +% \tl_clear:N \g_tzto_BEGIN_cmd_tl +% \tl_clear:N \g_tzto_END_cmd_tl +} + +%%% --- end of \tzto + + +%%% \tztos (longer version of \tzto) + +\bool_new:N \g_tztos_BEGIN_cmd_bool +\bool_new:N \g_tztos_END_cmd_bool +\bool_new:N \l_tztos_shift_coor_bool + +%% \tztosAtBegin +\NewDocumentCommand\tztosAtBegin{ m } +{ + \bool_gset_true:N \g_tztos_BEGIN_cmd_bool + \tl_gset:No \g_tztos_BEGIN_cmd_tl { #1 } +} + +%% \tztosAtEnd +\NewDocumentCommand\tztosAtEnd{ m } +{ + \bool_gset_true:N \g_tztos_END_cmd_bool + \tl_gset:No \g_tztos_END_cmd_tl { #1 } +} + +%%% \tztos (main) +%% do not use: inner sep=0pt +\NewDocumentCommand\tztos{ s t+ O{} d<> D""{} } +{ + \tl_clear:N \l_tztos_cmd_tl + \tl_clear:N \l_tztos_STYLE_tl + +% \IfValueT { #3 } +% { \renewcommand\tztostyle{ #3 } } + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tztos_shift_coor_tl { #4 } + \bool_set_true:N \l_tztos_shift_coor_bool + } + { + \tl_clear:N \l_tztos_shift_coor_tl + \bool_set_false:N \l_tztos_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tztos_opt_tl { #3 } } + { \tl_clear:N \l_tztos_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tztos_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tztos_namepath_tl } + + \int_zero:N \l_tmpa_int + \tztos_check_token:n +} + +\cs_new:Npn \tztos_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tztos_sub_fn #1 } +% { \tztos_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tztos_sub_fn #1 } + { ; } { \tztos_late_opt_fn } + } + { +% \tztos_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +%% (coor)[to opt]{text}[node opt] +\NewDocumentCommand\tztos_sub_fn{ r() O{} +G{} O{} } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tztos_cmd_tl { \l_tztos_STYLE_tl } + \tl_clear:N \l_tztos_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tztos_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tztos_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tztos_cmd_tl + { ([ shift = { (\l_tztos_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tztos_cmd_tl + { ([ shift = { (\l_tztos_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tztos_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_set:Nn \l_tztos_STYLE_A_tl { ~ to [ #2 ] } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tztos_STYLE_B_tl + } + { + \tl_set:Nn \l_tztos_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tztos_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tztos_STYLE_C_tl { } } + + \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_A_tl } + \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_B_tl } + \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_C_tl } + + \tztos_check_token:n +} + +\NewDocumentCommand\tztos_late_opt_fn { D<>{} } +{ + \tl_set:Nn \l_tztos_code_at_end_tl { #1 } + \tztos_stop_action +} + +\NewDocumentCommand\tztos_stop_action {} +{ + \tl_if_empty:NF \l_tztos_STYLE_B_tl + { + \tl_put_right:No \l_tztos_cmd_tl { \l_tztos_STYLE_B_tl } + } + \tl_clear:N \l_tztos_STYLE_tl + % add at begin/end + \bool_if:NT \g_tztos_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tztos_cmd_tl { \g_tztos_BEGIN_cmd_tl } } + \bool_if:NT \g_tztos_END_cmd_bool + { \tl_put_right:Nx \l_tztos_cmd_tl { \g_tztos_END_cmd_tl } } + % fill or not + \tl_put_left:No \l_tztos_cmd_tl + { + \l_tztos_opt_tl ] % expand `once' needed for user convenience + } + \tl_put_left:Nx \l_tztos_cmd_tl + { [ \l_tztos_namepath_tl , } + % final action + \exp_last_unbraced:Nf + \draw \l_tztos_cmd_tl \l_tztos_code_at_end_tl ; %% draw + + \bool_gset_false:N \g_tztos_BEGIN_cmd_bool + \bool_gset_false:N \g_tztos_END_cmd_bool +% \tl_clear:N \g_tztos_BEGIN_cmd_tl +% \tl_clear:N \g_tztos_END_cmd_tl +} + +%%% --- end of \tztos + + +%%(ADDED) +%%% \tzedge + +\bool_new:N \l_tzedge_shift_coor_bool + +%%% \tzedge (main) +\NewDocumentCommand\tzedge{ s t+ o d<> } +{ + \tl_clear:N \l_tzedge_cmd_tl + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzedge_shift_coor_tl { #4 } + \bool_set_true:N \l_tzedge_shift_coor_bool + } + { + \tl_clear:N \l_tzedge_shift_coor_tl + \bool_set_false:N \l_tzedge_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzedge_opt_tl { #3 } } + { \tl_clear:N \l_tzedge_opt_tl } + + \tzedge_check_token:n +} + +\cs_new:Npn \tzedge_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzedge_sub_fn ( } +% \tzedge_stop_action +} + +\NewDocumentCommand\tzedge_sub_fn{ r() +G{} O{} r() +G{} O{} D<>{} } +{ + \bool_if:NTF \l_tzedge_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzedge_cmd_tl + { ([ shift = { (\l_tzedge_shift_coor_tl) } ]#1) } + } + { \tl_put_right:Nn \l_tzedge_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tzedge_cmd_tl + { edge [ } + \tl_put_right:No \l_tzedge_cmd_tl + { \l_tzedge_opt_tl ] } % expand `once' needed + \tl_put_right:Nn \l_tzedge_cmd_tl + { node [ #3 ] { #2 } } + + + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzedge_cmd_tl { ++ (#4) ++ (#4) } + } + {% no ++ + \bool_if:NTF \l_tzedge_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzedge_cmd_tl + { + ([ shift = { (\l_tzedge_shift_coor_tl) } ]#4) + ([ shift = { (\l_tzedge_shift_coor_tl) } ]#4) + } + } + { \tl_put_right:Nn \l_tzedge_cmd_tl { (#4) (#4) } } + } + + \tl_if_empty:nF { #5 } + { + \tl_put_right:Nn \l_tzedge_cmd_tl + { node [ #6 ] { #5 } } + } + + % final action + \exp_last_unbraced:Nf \draw \l_tzedge_cmd_tl #7 ; +} + +%%% --- end of \tzedge + + +%%(ADDED) +%%% \tzedges -- generalized version of \tzlines + +\bool_new:N \l_tzedges_shift_coor_bool + +%%% \tzedges (main) +%% do not use: inner sep=0pt +\NewDocumentCommand\tzedges{ s t+ O{} d<> } +{ + \tl_clear:N \l_tzedges_cmd_tl + \tl_clear:N \l_tzedges_STYLE_tl + +% \IfValueT { #3 } +% { \renewcommand\tzedgestyle{ #3 } } + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzedges_shift_coor_tl { #4 } + \bool_set_true:N \l_tzedges_shift_coor_bool + } + { + \tl_clear:N \l_tzedges_shift_coor_tl + \bool_set_false:N \l_tzedges_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzedges_opt_tl { #3 } } + { \tl_clear:N \l_tzedges_opt_tl } + + \int_zero:N \l_tmpa_int + \tzedges_check_token:n +} + +\cs_new:Npn \tzedges_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzedges_sub_fn #1 } +% { \tzedges_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzedges_sub_fn #1 } +% { ; } { \tzedges_late_opt_fn } + { ; } { \tzedges_stop_action } + } + { +% \tzedges_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzedges_sub_fn{ r() O{} +G{} O{} } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tzedges_cmd_tl { \l_tzedges_STYLE_tl } + \tl_clear:N \l_tzedges_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzedges_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzedges_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzedges_cmd_tl + { ([ shift = { (\l_tzedges_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzedges_cmd_tl + { ([ shift = { (\l_tzedges_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzedges_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_set:Nn \l_tzedges_STYLE_A_tl { edge [ #2 ] } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tzedges_STYLE_B_tl + } + { + \tl_set:Nn \l_tzedges_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzedges_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzedges_STYLE_C_tl { } } + + \tl_put_right:No \l_tzedges_STYLE_tl { \l_tzedges_STYLE_A_tl } + \tl_put_right:No \l_tzedges_STYLE_tl { \l_tzedges_STYLE_B_tl } + \tl_put_right:No \l_tzedges_STYLE_tl { \l_tzedges_STYLE_C_tl } + + \tzedges_check_token:n +} + +%\NewDocumentCommand\tzedges_late_opt_fn { D<>{} } +%{ +% \tl_set:Nn \l_tzedges_code_at_end_tl { #1 } +% \tzedges_stop_action +%} + +\NewDocumentCommand\tzedges_stop_action { D<>{} } +{ + % #1 works with the first coordinate + % because [edge] and [node] does not change the current point + \tl_if_empty:NF \l_tzedges_STYLE_B_tl + { + \tl_put_right:No \l_tzedges_cmd_tl { \l_tzedges_STYLE_B_tl } + } + \tl_clear:N \l_tzedges_STYLE_tl + + \tl_put_left:No \l_tzedges_cmd_tl + { [ \l_tzedges_opt_tl ] } % expand `once' needed + + % final action + \exp_last_unbraced:Nf + \draw \l_tzedges_cmd_tl #1 ; %% draw +} + +%%% --- end of \tzedges + + +%%%%% Figures: circles, frames, ellipses, triangles, etc. + +%%% \tzcircle + +\NewDocumentCommand\tzcircle + { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#7} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #4 , #2 ] ([shift={(#3)}]#5) circle (#6) + #8 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #4 , #2 ] (#5) circle (#6) + #8 ; + } + } + { + \IfValueTF { #3 } + { \draw [ name~path = #4 , #2 ] ([shift={(#3)}]#5) circle (#6) #8 ; } + { \draw [ name~path = #4 , #2 ] (#5) circle (#6) #8 ; } + } +} + +%%% \tzring + +\NewDocumentCommand\tzring + { s O{} d<> r() r() d() d() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + ([shift={(#3)}]#4) circle (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) circle (#7) } + #9 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + (#4) circle (#5) + \IfValueT { #6 } { (#6) circle (#7) } + #9 ; + } + } + { + \IfValueTF { #3 } + { + \draw [ even~odd~rule , #2 ] + ([shift={(#3)}]#4) circle (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) circle (#7) } + #9 ; + } + { + \draw [ even~odd~rule , #2 ] + (#4) circle (#5) + \IfValueT { #6 } { (#6) circle (#7) } + #9 ; + } + } +} + +%%% --- end of \tzring + +\let\tzcirclering\tzring + + +%%% \tzellipse + +\NewDocumentCommand\tzellipse + { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#7} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #4 , #2 ] + ([shift={(#3)}]#5) ellipse (#6) + #8 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #4 , #2 ] + (#5) ellipse (#6) + #8 ; + } + } + { + \IfValueTF { #3 } + { \draw [ name~path = #4 , #2 ] ([shift={(#3)}]#5) ellipse (#6) #8 ; } + { \draw [ name~path = #4 , #2 ] (#5) ellipse (#6) #8 ; } + } +} + +%%% --- end of \tzellipse + +\let\tzoval\tzellipse + + +%%% \tzellipsering + +\NewDocumentCommand\tzellipsering + { s O{} d<> r() r() d() d() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + ([shift={(#3)}]#4) ellipse (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) ellipse (#7) } + #9 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + (#4) ellipse (#5) + \IfValueT { #6 } { (#6) ellipse (#7) } + #9 ; + } + } + { + \IfValueTF { #3 } + { + \draw [ even~odd~rule , #2 ] + ([shift={(#3)}]#4) ellipse (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) ellipse (#7) } + #9 ; + } + { + \draw [ even~odd~rule , #2 ] + (#4) ellipse (#5) + \IfValueT { #6 } { (#6) ellipse (#7) } + #9 ; + } + } +} + +%%% --- end of \tzellipsering + +\let\tzovalring\tzellipsering + + +%%% \tzframe + +\NewDocumentCommand\tzframe + { s t+ O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfBooleanTF { #2 } + { + \IfValueTF { #4 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ++ (#7) + #9 ; + } + {% no shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + (#6) rectangle ++ (#7) + #9 ; + } + } + { + \IfValueTF { #4 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ([shift={(#4)}]#7) + #9 ; + } + {% no shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + (#6) rectangle (#7) + #9 ; + } + } + } + { + \IfBooleanTF { #2 } + { + \IfValueTF { #4 } + {% if shift + \draw [ name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ++ (#7) + #9 ; + } + {% no shift + \draw [ name~path = #5 , #3 ] (#6) rectangle ++ (#7) #9 ; + } + } + { + \IfValueTF { #4 } + {% if shift + \draw [ name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ([shift={(#4)}]#7) + #9 ; + } + {% no shift + \draw [ name~path = #5 , #3 ] (#6) rectangle (#7) #9 ; + } + } + } +} +%%% --- end of \tzframe + +\let\tzrectangle\tzframe +\let\tzbox\tzframe + + + +%%% \tzrectanglering + +\NewDocumentCommand\tzrectanglering + { s O{} d<> r() r() d() d() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + ([shift={(#3)}]#4) rectangle ([shift={(#3)}]#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) rectangle ([shift={(#3)}]#7) } + #9 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + (#4) rectangle (#5) + \IfValueT { #6 } { (#6) rectangle (#7) } + #9 ; + } + } + { + \IfValueTF { #3 } + { + \draw [ even~odd~rule , #2 ] + ([shift={(#3)}]#4) rectangle ([shift={(#3)}]#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) rectangle ([shift={(#3)}]#7) } + #9 ; + } + { + \draw [ even~odd~rule , #2 ] + (#4) rectangle (#5) + \IfValueT { #6 } { (#6) rectangle (#7) } + #9 ; + } + } +} + +%%% --- end of \tzrectanglering + +\let\tzframering\tzrectanglering +\let\tzboxring\tzrectanglering + + + +%%%%%%%(ADDED) -- to be removed +%%%%%%%% \tzdiamond +%%%%% +%%%%%\NewDocumentCommand\tzdiamond +%%%%% { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} } +%%%%%{ +%%%%% \renewcommand\tzfillopacity{#7} +%%%%% \IfBooleanTF { #1 } +%%%%% { +%%%%% \IfValueTF { #3 } +%%%%% {% if shift +%%%%% \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , +%%%%% text~opacity = 1 , #2 ] +%%%%% ([shift={(#3)}]$ (#5) + (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (#6-|0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift (normal) +%%%%% \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , +%%%%% text~opacity = 1 , #2 ] +%%%%% ($ (#5) + (#6|-0,0) $) +%%%%% -- ($ (#5) + (#6-|0,0) $) +%%%%% -- ($ (#5) - (#6|-0,0) $) +%%%%% -- ($ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%% { +%%%%% \IfValueTF { #3 } +%%%%% {% if shift +%%%%% \draw [ #2 ] +%%%%% ([shift={(#3)}]$ (#5) + (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (#6-|0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift (normal) +%%%%% \draw [ #2 ] +%%%%% ($ (#5) + (#6|-0,0) $) +%%%%% -- ($ (#5) + (#6-|0,0) $) +%%%%% -- ($ (#5) - (#6|-0,0) $) +%%%%% -- ($ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%%} +%%%%% +%%%%% +%%%%%%%(ADDED) -- to be removed +%%%%%%%% \tztriangle +%%%%% +%%%%%\NewDocumentCommand\tztriangle +%%%%% { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} } +%%%%%{ +%%%%% \renewcommand\tzfillopacity{#7} +%%%%% \IfBooleanTF { #1 } +%%%%% { +%%%%% \IfValueTF { #3 } +%%%%% {% if shift +%%%%% \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , +%%%%% text~opacity = 1 , name~path = #4 , #2 ] +%%%%% ([shift={(#3)}]$ (#5) + .5*(#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (0,0|-#6) $) +%%%%% -- ([shift={(#3)}]$ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift +%%%%% \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , +%%%%% text~opacity = 1 , name~path = #4 , #2 ] +%%%%% ($ (#5) + .5*(#6|-0,0) $) +%%%%% -- ($ (#5) + (0,0|-#6) $) +%%%%% -- ($ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%% { +%%%%% \IfValueTF { #3 } +%%%%% {% if shift +%%%%% \draw [ name~path = #4 , #2 ] +%%%%% ([shift={(#3)}]$ (#5) + .5*(#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (0,0|-#6) $) +%%%%% -- ([shift={(#3)}]$ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift +%%%%% \draw [ name~path = #4 , #2 ] +%%%%% ($ (#5) + .5*(#6|-0,0) $) +%%%%% -- ($ (#5) + (0,0|-#6) $) +%%%%% -- ($ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%%} + + +%%% \tzparabola + +\bool_new:N \g_tzparabola_BEGIN_cmd_bool +\bool_new:N \g_tzparabola_END_cmd_bool +\bool_new:N \l_tzparabola_shift_coor_bool + +%% \tzparabolaAtBegin +\NewDocumentCommand\tzparabolaAtBegin{ m } +{ + \bool_gset_true:N \g_tzparabola_BEGIN_cmd_bool + \tl_gset:No \g_tzparabola_BEGIN_cmd_tl { #1 } +} + +%% \tzparabolaAtEnd +\NewDocumentCommand\tzparabolaAtEnd{ m } +{ + \bool_gset_true:N \g_tzparabola_END_cmd_bool + \tl_gset:No \g_tzparabola_END_cmd_tl { #1 } +} + +%% \tzparabola (main) +\NewDocumentCommand\tzparabola +{ s t+ O{} d<> D""{} } +{ + \tl_clear:N \l_tzparabola_cmd_tl + + \IfBooleanTF { #1 } % NOT USED!!! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzparabola_pathname_tl { name~path = #5 } } + { \tl_clear:N \l_tzparabola_pathname_tl } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzparabola_shift_coor_tl { #4 } + \bool_set_true:N \l_tzparabola_shift_coor_bool + } + { + \tl_clear:N \l_tzparabola_shift_coor_tl + \bool_set_false:N \l_tzparabola_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzparabola_opt_tl { #3 } } + { \tl_clear:N \l_tzparabola_opt_tl } + + \tzparabola_check_token:n +} + +\cs_new:Npn \tzparabola_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzparabola_sub_fn ( } +% \tzparabola_stop_action +} + +\NewDocumentCommand\tzparabola_sub_fn + { r() r() d() +G{} O{} G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#6} %% NOT USED! (to be removed) + + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { ([shift = { (\l_tzparabola_shift_coor_tl) } ]#1) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { (#1) } + } + + \IfNoValueTF { #3 } + {%% 2 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { parabola ([shift = { (\l_tzparabola_shift_coor_tl) } ]$(#1)+(#2)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { parabola ($(#1)+(#2)$) } + } + } + {% no + (absolute coor) + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { parabola ([shift = { (\l_tzparabola_shift_coor_tl) } ]#2) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { parabola (#2) } + } + } + } + {%% 3 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \tl_put_right:Nn \l_tzparabola_cmd_tl + { parabola~bend + (#2) } + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { ([shift = { (\l_tzparabola_shift_coor_tl) } ]$(#1)+(#3)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { ($(#1)+(#3)$) } + } + } + {% no + (absolute coor) + \bool_if:NTF \l_tzparabola_shift_coor_bool + { + \tl_put_right:Nx \l_tzparabola_cmd_tl + { + parabola~bend + ([shift = { (\l_tzparabola_shift_coor_tl) } ]#2) + } + } + { + \tl_put_right:Nn \l_tzparabola_cmd_tl + { parabola~bend (#2) } + } + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { ([shift = { (\l_tzparabola_shift_coor_tl) } ]#3) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { (#3) } + } + } + } + + \tl_put_right:Nn \l_tzparabola_cmd_tl + { node [ #5 ] { #4 } } + % add at begin/end + \bool_if:NT \g_tzparabola_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzparabola_cmd_tl { \g_tzparabola_BEGIN_cmd_tl } } + \bool_if:NT \g_tzparabola_END_cmd_bool + { \tl_put_right:Nx \l_tzparabola_cmd_tl { \g_tzparabola_END_cmd_tl } } + + % final action + \tl_put_left:No \l_tzparabola_cmd_tl + { \l_tzparabola_opt_tl ] } % expand `once' + \tl_put_left:Nx \l_tzparabola_cmd_tl + { [ \l_tzparabola_pathname_tl , } + + \exp_last_unbraced:Nf + \draw \l_tzparabola_cmd_tl #7 ; + + \bool_gset_false:N \g_tzparabola_BEGIN_cmd_bool + \bool_gset_false:N \g_tzparabola_END_cmd_bool +% \tl_clear:N \g_tzparabola_BEGIN_cmd_tl +% \tl_clear:N \g_tzparabola_END_cmd_tl +} + +%%% -- end of \tzparabola + + +%%% \tzbezier + +\bool_new:N \g_tzbezier_BEGIN_cmd_bool +\bool_new:N \g_tzbezier_END_cmd_bool +\bool_new:N \l_tzbezier_shift_coor_bool + +%% \tzbezierAtBegin +\NewDocumentCommand\tzbezierAtBegin{ m } +{ + \bool_gset_true:N \g_tzbezier_BEGIN_cmd_bool + \tl_gset:No \g_tzbezier_BEGIN_cmd_tl { #1 } +} + +%% \tzbezierAtEnd +\NewDocumentCommand\tzbezierAtEnd{ m } +{ + \bool_gset_true:N \g_tzbezier_END_cmd_bool + \tl_gset:No \g_tzbezier_END_cmd_tl { #1 } +} + +%% \tzbezier (main) +\NewDocumentCommand\tzbezier{ s t+ O{} d<> D""{tzplot~path} } +{ + \tl_clear:N \l_tzbezier_cmd_tl + + \IfBooleanTF { #1 } %% NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_true:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzbezier_pathname_tl { name~path = #5 } } + { \tl_clear:N \l_tzbezier_pathname_tl } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzbezier_shift_coor_tl { #4 } + \bool_set_true:N \l_tzbezier_shift_coor_bool + } + { + \tl_clear:N \l_tzbezier_shift_coor_tl + \bool_set_false:N \l_tzbezier_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzbezier_opt_tl { #3 } } + { \tl_clear:N \l_tzbezier_opt_tl } + + \tzbezier_check_token:n +} + +\cs_new:Npn \tzbezier_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzbezier_sub_fn ( } +% \tzbezier_stop_action +} + +\NewDocumentCommand\tzbezier_sub_fn{ r() r() r() d() +G{} O{} D<>{} } +{ + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { ([shift = { (\l_tzbezier_shift_coor_tl) } ]#1) .. controls } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { (#1) .. controls } + } + + \IfNoValueTF { #4 } + {%% 3 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \tl_put_right:Nn \l_tzbezier_cmd_tl { + (#2) } + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]$(#1)+(#3)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. ($(#1)+(#3)$) } + } + } + {% no + (absolute coor) + % control coor + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#2) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { (#2) } + } + %% end coor + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]#3) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. (#3) } + } + } + } + {%% 4 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \tl_put_right:Nn \l_tzbezier_cmd_tl { + (#2) and + (#3) } + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]$(#1)+(#4)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. ($(#1)+(#4)$) } + } + } + {% no + (absolute coor) + %% control coors + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { + ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#2) + and + ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#3) + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { (#2) and (#3) } + } + %% end coor + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]#4) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. (#4) } + } + } + } + + \tl_put_right:Nn \l_tzbezier_cmd_tl + { node [ #6 ] { #5 } } + % add at begin/end + \bool_if:NT \g_tzbezier_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzbezier_cmd_tl { \g_tzbezier_BEGIN_cmd_tl } } + \bool_if:NT \g_tzbezier_END_cmd_bool + { \tl_put_right:Nx \l_tzbezier_cmd_tl { \g_tzbezier_END_cmd_tl } } + + % final action + \tl_put_left:No \l_tzbezier_cmd_tl { \l_tzbezier_opt_tl ] } + \tl_put_left:Nx \l_tzbezier_cmd_tl + { [ \l_tzbezier_pathname_tl , } + + \exp_last_unbraced:Nf \draw \l_tzbezier_cmd_tl #7 ; + + \bool_gset_false:N \g_tzbezier_BEGIN_cmd_bool + \bool_gset_false:N \g_tzbezier_END_cmd_bool +% \tl_clear:N \g_tzbezier_BEGIN_cmd_tl +% \tl_clear:N \g_tzbezier_END_cmd_tl +} + +%%% -- end of \tzbezier + + +%%% \tzarc (main) + +\use:x{ + \NewDocumentCommand \exp_not:N \tzarc + { s t' O{} d<> D""{} r() + >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + } +} +{ + \IfBooleanTF { #1 } {}{} % NOT USED! + + \tl_clear:N \l_tzarc_cmd_tl + + \tzarc_args_process #7 + \fp_set:Nn \l_tmpa_fp { \tzarcAngleA } + \fp_set:Nn \l_tmpb_fp { \tzarcAngleB } + + \tl_put_right:Nn \l_tzarc_cmd_tl + { [ name~path = #5 , #3 ] } + \IfValueTF { #4 } + {% if shift + \tl_put_right:Nn \l_tzarc_cmd_tl + { ([shift={(#4)}]#6) ++ (\tzarcAngleA \c_colon_str \tzarcRadius) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzarc_cmd_tl + { (#6) ++ (\tzarcAngleA \c_colon_str \tzarcRadius) } + } + + \tl_put_right:Nx \l_tzarc_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzarcAngleA + \c_colon_str + \IfBooleanTF { #2 } + {\tzarcAngleB - 360} + {\tzarcAngleB} + \c_colon_str + \tzarcRadius ) + } + { + arc ( \IfBooleanTF { #2 } + {\tzarcAngleA - 360} + {\tzarcAngleA} + \c_colon_str + \tzarcAngleB + \c_colon_str + \tzarcRadius ) + } } - {% no shift (normal) - \draw [ fill = \tzfillcolor , fill~opacity = #7 , - text~opacity = 1 , - name~path = #4 , #2 ] (#5) circle (#6) - #8 ; + + \tzarc_sub_fn:n +} + +\NewDocumentCommand\tzarc_args_process{ m m m } +{ + \def\tzarcAngleA{#1} + \def\tzarcAngleB{#2} + \def\tzarcRadius{#3} +} + +\cs_new:Npn \tzarc_sub_fn:n +{ + \tzarc_final_actions +} + +\NewDocumentCommand\tzarc_final_actions{ +G{} O{} D<>{} } +{ + \tl_put_right:Nn \l_tzarc_cmd_tl + { node [ #2 ] { #1 } #3 } + + \exp_last_unbraced:Nf \draw \l_tzarc_cmd_tl ; +} + +%%% --- end of \tzarc + + +%%% \tzarcfrom (main) +%% (works like tikz original) + +\use:x{ + \NewDocumentCommand \exp_not:N \tzarcfrom + { s t' O{} d<> D""{} r() + >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + } +} +{ + \IfBooleanTF { #1 } {}{} % NOT USED! + + \tl_clear:N \l_tzarcfrom_cmd_tl + + \tzarcfrom_args_process #7 + \fp_set:Nn \l_tmpa_fp { \tzarcfromAngleA } + \fp_set:Nn \l_tmpb_fp { \tzarcfromAngleB } + + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { [ name~path = #5 , #3 ] } + + \IfValueTF { #4 } + {% if shift + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { ([shift={(#4)}]#6) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { (#6) } % ++ (\tzarcfromAngleA \c_colon_str \tzarcfromRadius) + } + + \tl_put_right:No \l_tzarcfrom_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzarcfromAngleA + \c_colon_str + \IfBooleanTF {#2} + {\tzarcfromAngleB - 360} + {\tzarcfromAngleB} + \c_colon_str + \tzarcfromRadius ) + } + { + arc ( \IfBooleanTF {#2} + {\tzarcfromAngleA - 360} + {\tzarcfromAngleA} + \c_colon_str + \tzarcfromAngleB + \c_colon_str + \tzarcfromRadius ) + } + } + + \tzarcfrom_sub_fn:n + +} + +\NewDocumentCommand\tzarcfrom_args_process{ m m m } +{ + \def\tzarcfromAngleA{#1} + \def\tzarcfromAngleB{#2} + \def\tzarcfromRadius{#3} +} + +\cs_new:Npn \tzarcfrom_sub_fn:n +{ + \tzarcfrom_final_actions +} + +\NewDocumentCommand\tzarcfrom_final_actions{ +G{} O{} D<>{} } +{ + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { node [ #2 ] { #1 } #3 } + \exp_last_unbraced:Nf \draw \l_tzarcfrom_cmd_tl ; +} + +%%% --- end of \tzarcfrom + + +%%% \tzarcsfrom (main) +%% (works like tikz original) + +\tl_new:N \l_tzarcsfrom_code_at_end_tl + +\NewDocumentCommand\tzarcsfrom { s t' O{} d<> D""{} r() } +{ + \IfBooleanTF { #1 } {}{} % NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \tl_clear:N \l_tzarcsfrom_cmd_tl + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { [ name~path = #5 , #3 ] } + + \IfValueTF { #4 } + {% if shift + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { ([shift={(#4)}]#6) } + } + {% no shift + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { (#6) } % ++ (\tzarcsfromAngleA \c_colon_str \tzarcsfromRadius) + } + + \tzarcsfrom_check_token:n +} + +\cs_new:Npn \tzarcsfrom_check_token:n #1 +{ + \str_case:nnF { #1 } + { + { ( } { \tzarcsfrom_sub_fn #1 } + { ; } { \tzarcsfrom_late_opt_fn } + } + { +% \tzarcsfrom_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + + +\use:x{ + \NewDocumentCommand \exp_not:N \tzarcsfrom_sub_fn + { >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() +G{} O{} + } +} +{ + \tzarcsfrom_args_process #1 + \fp_set:Nn \l_tmpa_fp { \tzarcsfromAngleA } + \fp_set:Nn \l_tmpb_fp { \tzarcsfromAngleB } + + \tl_put_right:Nx \l_tzarcsfrom_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzarcsfromAngleA + \c_colon_str + \bool_if:NTF \l_tmpb_bool + {\tzarcsfromAngleB - 360} + {\tzarcsfromAngleB} + \c_colon_str + \tzarcsfromRadius ) + } + { + arc ( \bool_if:NTF \l_tmpb_bool + {\tzarcsfromAngleA - 360} + {\tzarcsfromAngleA} + \c_colon_str + \tzarcsfromAngleB + \c_colon_str + \tzarcsfromRadius ) + } } + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { node [ #3 ] { #2 } } + + \tzarcsfrom_check_token:n +} + +\NewDocumentCommand\tzarcsfrom_late_opt_fn { D<>{} } +{ + \tl_set:Nn \l_tzarcsfrom_code_at_end_tl { #1 } + \tzarcsfrom_stop_action +} + +\NewDocumentCommand\tzarcsfrom_stop_action {} +{ + \tl_put_right:No \l_tzarcsfrom_cmd_tl + { \l_tzarcsfrom_code_at_end_tl } + \exp_last_unbraced:Nf \draw \l_tzarcsfrom_cmd_tl ; +} + +\NewDocumentCommand\tzarcsfrom_args_process{ m m m } +{ + \def\tzarcsfromAngleA{#1} + \def\tzarcsfromAngleB{#2} + \def\tzarcsfromRadius{#3} +} + +%%% --- end of \tzarcsfrom + + +%%% \tzwedge (main) + +\use:x{ + \NewDocumentCommand \exp_not:N \tzwedge + { s t' O{} d<> D""{} r() + >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + } +} +{ + \tl_clear:N \l_tzwedge_cmd_tl + + \tzwedge_args_process #7 + \fp_set:Nn \l_tmpa_fp { \tzwedgeAngleA } + \fp_set:Nn \l_tmpb_fp { \tzwedgeAngleB } + + \IfBooleanTF { #1 } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { + [ fill=\tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , + name~path = #5 , #3 ] + } } { - \IfValueTF { #3 } - { \draw [ #2 ] ([shift={(#3)}]#5) circle (#6) #8 ; } - { \draw [ #2 ] (#5) circle (#6) #8 ; } + \tl_put_right:Nn \l_tzwedge_cmd_tl + { [ name~path = #5 , #3 ] } + } + + \IfValueTF { #4 } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { ([shift={(#4)}]#6) -- ++ (\tzwedgeAngleA \c_colon_str \tzwedgeRadius) } + } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { (#6) -- ++ (\tzwedgeAngleA \c_colon_str \tzwedgeRadius) } } + + \tl_put_right:No \l_tzwedge_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzwedgeAngleA + \c_colon_str + \IfBooleanTF {#2} + {\tzwedgeAngleB - 360} + {\tzwedgeAngleB} + \c_colon_str + \tzwedgeRadius ) + } + { + arc ( \IfBooleanTF {#2} + {\tzwedgeAngleA - 360} + {\tzwedgeAngleA} + \c_colon_str + \tzwedgeAngleB + \c_colon_str + \tzwedgeRadius ) + } + } + + \tzwedge_sub_fn:n } -%%% \tzellipse +\cs_new:Npn \tzwedge_sub_fn:n +{ + \tzwedge_final_actions +} -\NewDocumentCommand\tzellipse - { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } +\NewDocumentCommand\tzwedge_final_actions{ +G{} O{} G{.3} } { - \renewcommand\tzfillopacity{#7} + \tl_if_empty:nTF { #3 } + { \renewcommand\tzfillopacity{\tz@initial@fill@opacity} } + { \renewcommand\tzfillopacity{#3} } + + \tl_put_right:Nn \l_tzwedge_cmd_tl + { + node [ midway , #2 ] { #1 } + } + + \exp_last_unbraced:Nf \draw \l_tzwedge_cmd_tl -- cycle ; +} + +\NewDocumentCommand\tzwedge_args_process{ m m m } +{ + \def\tzwedgeAngleA{#1} + \def\tzwedgeAngleB{#2} + \def\tzwedgeRadius{#3} +} + +%%% --- end of \tzwedge + + +%%%%% Angles + + +%%% \tzp + +\NewDocumentCommand\tzpointangle{ r() r() m } +{ + \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}% + {\pgfpointanchor{#2}{center}} + \edef#3{\pgfmathresult} +% \tl_set:cx { #3 } { \pgfmathresult } +} + + + +%%% \tzanglemark (main) + +\NewDocumentCommand\tzanglemark{ s t' o } +{ + \tl_clear:N \l_tzanglemark_cmd_tl + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzanglemark_opt_tl { #3 } } + { \tl_clear:N \l_tzanglemark_opt_tl } + + \tzanglemark_check_token:n +} + +\cs_new:Npn \tzanglemark_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzanglemark_sub_fn ( } +} + +\NewDocumentCommand\tzanglemark_sub_fn + { r() r() r() +G{} O{} + D(){\tz@initial@AA@radius} G{\tz@initial@fill@opacity} + } + +{ + \renewcommand\tzfillopacity{#7} + \renewcommand\tzAAradius{#6} + + \path (#1) coordinate (tzAng-A) + (#2) coordinate (tzAng-B) + (#3) coordinate (tzAng-C); + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-A}{center}} + \edef\tzangleONE{\pgfmathresult} + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-C}{center}} + \edef\tzangleTWO{\pgfmathresult} + + \fp_set:Nn \l_tmpa_fp { \tzangleONE } + \fp_set:Nn \l_tmpb_fp { \tzangleTWO } + + \bool_if:NTF \l_tmpb_bool { - \IfValueTF { #3 } - {% if shift - \draw [ fill = \tzfillcolor , fill~opacity = #7 , - text~opacity = 1 , - name~path = #4 , #2 ] ([shift={(#3)}]#5) ellipse (#6) - #8 ; + \edef\tzangleresult{\fp_eval:n { 360 - abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + { + \edef\tzangleresult{\fp_eval:n { abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + +% % test +% \node (0,0) [align=left,right] {\tzangleresult \\ \halfangle}; + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:No \l_tzanglemark_cmd_tl + { + [ \tzAAlinestyle , draw = none , fill = \tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , } - {% no shift (normal) - \draw [ fill = \tzfillcolor , fill~opacity = #7 , - text~opacity = 1 , - name~path = #4 , #2 ] (#5) ellipse (#6) - #8 ; + } + { + \tl_put_right:No \l_tzanglemark_cmd_tl + { + [ \tzAAlinestyle , } } + + \tl_put_right:No \l_tzanglemark_cmd_tl + { \l_tzanglemark_opt_tl ] } + + \bool_if:NTF \l_tmpa_bool { - \IfValueTF { #3 } - { \draw [ name~path = #4 , #2 ] ([shift={(#3)}]#5) ellipse (#6) #8 ; } - { \draw [ name~path = #4 , #2 ] (#5) ellipse (#6) #8 ; } + \tl_put_right:Nx \l_tzanglemark_cmd_tl + { (#2) -- ++ (\tzangleONE \c_colon_str #6) } + } + { + \tl_put_right:Nx \l_tzanglemark_cmd_tl + { (#2) ++ (\tzangleONE \c_colon_str #6) } } -} -%%% --- end of \tzellipse + \tl_put_right:Nx \l_tzanglemark_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzangleONE + \c_colon_str + \bool_if:NTF \l_tmpb_bool + { \tzangleTWO - 360 } + { \tzangleTWO } + \c_colon_str + \tzAAradius ) node (tzAAmid) [midway] {} + } + { + arc ( \bool_if:NTF \l_tmpb_bool + { \tzangleONE -360 } + { \tzangleONE } + \c_colon_str + \tzangleTWO + \c_colon_str + \tzAAradius ) node (tzAAmid) [midway] {} + } + } + + \begin{pgfonlayer}{\tzanglelayer} + \bool_if:NTF \l_tmpa_bool + { + \exp_last_unbraced:Nf + \draw \l_tzanglemark_cmd_tl -- cycle ; %% -- cycle + } + { + \exp_last_unbraced:Nf + \draw \l_tzanglemark_cmd_tl ; + } + \end{pgfonlayer} + + \path (#2) -- (tzAAmid.center) node [ pos = 1.5, #5 ] { #4 } ; +} -\let\tzoval\tzellipse +%%% --- end of \tzanglemark -%%% \tzframe +%%% \tzanglefill (obsolete: to be removed) -\NewDocumentCommand\tzframe - { s t+ O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } +\NewDocumentCommand\tzanglefill{ s t' o } { - \renewcommand\tzfillopacity{#8} + \tl_clear:N \l_tzanglefill_cmd_tl + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzanglefill_opt_tl { #3 } } + { \tl_clear:N \l_tzanglefill_opt_tl } + + \tzanglefill_check_token:n +} + +\cs_new:Npn \tzanglefill_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzanglefill_sub_fn ( } +} + +\NewDocumentCommand\tzanglefill_sub_fn + { r() r() r() +G{} O{} D(){10pt} G{\tz@initial@fill@opacity} } + +{ + \renewcommand\tzfillopacity{#7} + + \path (#1) coordinate (tzAng-A) + (#2) coordinate (tzAng-B) + (#3) coordinate (tzAng-C); + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-A}{center}} + \edef\tzangleONE{\pgfmathresult} + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-C}{center}} + \edef\tzangleTWO{\pgfmathresult} + + \fp_set:Nn \l_tmpa_fp { \tzangleONE } + \fp_set:Nn \l_tmpb_fp { \tzangleTWO } + + \bool_if:NTF \l_tmpb_bool { - \IfBooleanTF { #2 } - { - \IfValueTF { #4 } - {% if shift - \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , - text~opacity = 1 , - name~path = #5 , #3 ] - ([shift={(#4)}]#6) rectangle ++ (#7) - #9 ; - } - {% no shift - \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , - text~opacity = 1 , - name~path = #5 , #3 ] - (#6) rectangle ++ (#7) - #9 ; - } - } - { - \IfValueTF { #4 } - {% if shift - \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , - text~opacity = 1 , - name~path = #5 , #3 ] - ([shift={(#4)}]#6) rectangle ([shift={(#4)}]#7) - #9 ; - } - {% no shift - \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , - text~opacity = 1 , - name~path = #5 , #3 ] - (#6) rectangle (#7) - #9 ; - } - } + \edef\tzangleresult{\fp_eval:n { 360 - abs(\l_tmpb_fp - \l_tmpa_fp) } } } { - \IfBooleanTF { #2 } + \edef\tzangleresult{\fp_eval:n { abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + +% % test +% \node (0,0) [align=left,right] {\tzangleresult}; + + \bool_if:NTF \l_tmpa_bool %%% (* NOT USED!) + { + \tl_put_right:No \l_tzanglefill_cmd_tl { - \IfValueTF { #4 } - {% if shift - \draw [ name~path = #5 , #3 ] - ([shift={(#4)}]#6) rectangle ++ (#7) - #9 ; - } - {% no shift - \draw [ name~path = #5 , #3 ] (#6) rectangle ++ (#7) #9 ; - } + [ \tzAAlinestyle , fill = \tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , } + } + { + \tl_put_right:No \l_tzanglefill_cmd_tl { - \IfValueTF { #4 } - {% if shift - \draw [ name~path = #5 , #3 ] - ([shift={(#4)}]#6) rectangle ([shift={(#4)}]#7) - #9 ; - } - {% no shift - \draw [ name~path = #5 , #3 ] (#6) rectangle (#7) #9 ; - } + [ \tzAAlinestyle , fill = \tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , + } + } + + \tl_put_right:No \l_tzanglefill_cmd_tl + { \l_tzanglefill_opt_tl ] } + + \tl_put_right:Nx \l_tzanglefill_cmd_tl + { (#2) -- ++ (\tzangleONE \c_colon_str #6) } + + \tl_put_right:Nx \l_tzanglefill_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzangleONE + \c_colon_str + \bool_if:NTF \l_tmpb_bool + { \tzangleTWO - 360 } + { \tzangleTWO } + \c_colon_str + #6 ) node (tzAAmid) [midway] {} + } + { + arc ( \bool_if:NTF \l_tmpb_bool + { \tzangleONE -360 } + { \tzangleONE } + \c_colon_str + \tzangleTWO + \c_colon_str + #6 ) node (tzAAmid) [midway] {} } } + + \begin{pgfonlayer}{\tzanglelayer} + \exp_last_unbraced:Nf + \path \l_tzanglefill_cmd_tl -- cycle ; %% -- cycle + \end{pgfonlayer} + \path (#2) -- (tzAAmid.center) node [ pos = 1.5, #5 ] { #4 } ; } -%%% --- end of \tzframe -\let\tzrectangle\tzframe +%%% --- end of \tzanglefill -%%% \tzparabola -\bool_new:N \l_tzparabola_shift_coor_bool -\NewDocumentCommand\tzparabola -{ s t+ O{} d<> D""{} } +%%%(ADDED) +%%% \tzrightanglemark (main) + +\NewDocumentCommand\tzrightanglemark{ s t' o } { - \tl_clear:N \l_tzparabola_cmd_tl - - \IfBooleanTF { #1 } % NOT USED!!! + \tl_clear:N \l_tzrightanglemark_cmd_tl + \tl_clear:N \l_tzrightanglemark_fill_cmd_tl + + \IfBooleanTF { #1 } { \bool_set_true:N \l_tmpa_bool } { \bool_set_false:N \l_tmpa_bool } - - \IfBooleanTF { #2 } + + \IfBooleanTF { #2 } % NOT USED (just to avoid frequent coding error) { \bool_set_true:N \l_tmpb_bool } { \bool_set_false:N \l_tmpb_bool } - \IfValueTF { #5 } - { \tl_set:Nn \l_tzparabola_pathname_tl { name~path = #5 } } - { \tl_clear:N \l_tzparabola_pathname_tl } - - \IfValueTF { #4 } - { - \tl_set:Nn \l_tzparabola_shift_coor_tl { #4 } - \bool_set_true:N \l_tzparabola_shift_coor_bool - } - { - \tl_clear:N \l_tzparabola_shift_coor_tl - \bool_set_false:N \l_tzparabola_shift_coor_bool - } - \IfValueTF { #3 } - { \tl_set:Nn \l_tzparabola_opt_tl { #3 } } - { \tl_clear:N \l_tzparabola_opt_tl } - - \tzparabola_check_token:n + { \tl_set:Nn \l_tzrightanglemark_opt_tl { #3 } } + { \tl_clear:N \l_tzrightanglemark_opt_tl } + + \tzrightanglemark_check_token:n } -\cs_new:Npn \tzparabola_check_token:n #1 +\cs_new:Npn \tzrightanglemark_check_token:n #1 { \str_if_eq:nnT { #1 } { ( } - { \tzparabola_sub_fn ( } -% \tzparabola_stop_action + { \tzrightanglemark_sub_fn ( } } -\NewDocumentCommand\tzparabola_sub_fn - { r() r() d() +G{} O{} G{\tz@initial@fill@opacity} D<>{} } -{ - \renewcommand\tzfillopacity{#6} %% NOT USED! (to be removed) +\NewDocumentCommand\tzrightanglemark_sub_fn + { r() r() r() +G{} O{} D(){\tz@initial@RA@size} G{\tz@initial@fill@opacity} } - \bool_if:NTF \l_tzparabola_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzparabola_cmd_tl - { ([shift = { (\l_tzparabola_shift_coor_tl) } ]#1) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzparabola_cmd_tl { (#1) } - } +{ + \renewcommand\tzfillopacity{#7} + \renewcommand\tzRAsize{#6} - \IfNoValueTF { #3 } - {%% 2 coors - \bool_if:NTF \l_tmpb_bool - {% if + (relative coor) - \bool_if:NTF \l_tzparabola_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzparabola_cmd_tl - { parabola ([shift = { (\l_tzparabola_shift_coor_tl) } ]$(#1)+(#2)$) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzparabola_cmd_tl { parabola ($(#1)+(#2)$) } - } - } - {% no + (absolute coor) - \bool_if:NTF \l_tzparabola_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzparabola_cmd_tl - { parabola ([shift = { (\l_tzparabola_shift_coor_tl) } ]#2) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzparabola_cmd_tl { parabola (#2) } - } + \coordinate (tzRAOne) at ($(#2)!\tzRAsize!(#1)$) ; + \coordinate (tzRAThree) at ($(#2)!\tzRAsize!(#3)$) ; + \coordinate (tzRAvertex) at ($(tzRAThree) + (tzRAOne) - (#2)$) ; + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:No \l_tzrightanglemark_cmd_tl + { + [ \tzAAlinestyle , draw = none , + fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , } } - {%% 3 coors - \bool_if:NTF \l_tmpb_bool - {% if + (relative coor) - \tl_put_right:Nn \l_tzparabola_cmd_tl - { parabola~bend + (#2) } - \bool_if:NTF \l_tzparabola_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzparabola_cmd_tl - { ([shift = { (\l_tzparabola_shift_coor_tl) } ]$(#1)+(#3)$) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzparabola_cmd_tl { ($(#1)+(#3)$) } - } - } - {% no + (absolute coor) - \bool_if:NTF \l_tzparabola_shift_coor_bool - { - \tl_put_right:Nx \l_tzparabola_cmd_tl - { - parabola~bend - ([shift = { (\l_tzparabola_shift_coor_tl) } ]#2) - } - } - { - \tl_put_right:Nn \l_tzparabola_cmd_tl - { parabola~bend (#2) } - } - \bool_if:NTF \l_tzparabola_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzparabola_cmd_tl - { ([shift = { (\l_tzparabola_shift_coor_tl) } ]#3) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzparabola_cmd_tl { (#3) } - } + { + \tl_put_right:No \l_tzrightanglemark_cmd_tl + { + [ \tzAAlinestyle , } } - - \tl_put_left:No \l_tzparabola_cmd_tl - { \l_tzparabola_opt_tl ] } % expand `once' - \tl_put_left:Nx \l_tzparabola_cmd_tl - { [ \l_tzparabola_pathname_tl , } - % final action - \exp_last_unbraced:Nf - \draw \l_tzparabola_cmd_tl node [ #5 ] { #4 } #7 ; -} + + \tl_put_right:No \l_tzrightanglemark_cmd_tl + { \l_tzrightanglemark_opt_tl ] } -%%% -- end of \tzparabola + \begin{pgfonlayer}{\tzanglelayer} + \bool_if:NTF \l_tmpa_bool + { + \exp_last_unbraced:Nf + \draw \l_tzrightanglemark_cmd_tl + (#2) -- (tzRAOne) -- (tzRAvertex) -- (tzRAThree) -- cycle ; + } + { + \exp_last_unbraced:Nf + \draw \l_tzrightanglemark_cmd_tl + (tzRAOne) -- (tzRAvertex) -- (tzRAThree) ; + } + \end{pgfonlayer} + \path (#2) -- (tzRAvertex) node [ pos = 2 , #5 ] { #4 } ; +} +%%% --- end of \tzrightanglemark -%%% \tzbezier -\bool_new:N \l_tzbezier_shift_coor_bool +%%% \tzrightanglefill (obsolete: to be removed) -\NewDocumentCommand\tzbezier{ s t+ O{} d<> D""{tzplot~path} } +\NewDocumentCommand\tzrightanglefill{ s t' o } { - \tl_clear:N \l_tzbezier_cmd_tl - - \IfBooleanTF { #1 } %% NOT USED! - { \bool_set_true:N \l_tmpa_bool } + \tl_clear:N \l_tzrightanglefill_cmd_tl + + \IfBooleanTF { #1 } { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } \IfBooleanTF { #2 } { \bool_set_true:N \l_tmpb_bool } { \bool_set_false:N \l_tmpb_bool } - - \IfValueTF { #5 } - { \tl_set:Nn \l_tzbezier_pathname_tl { name~path = #5 } } - { \tl_clear:N \l_tzbezier_pathname_tl } - \IfValueTF { #4 } - { - \tl_set:Nn \l_tzbezier_shift_coor_tl { #4 } - \bool_set_true:N \l_tzbezier_shift_coor_bool - } - { - \tl_clear:N \l_tzbezier_shift_coor_tl - \bool_set_false:N \l_tzbezier_shift_coor_bool - } - \IfValueTF { #3 } - { \tl_set:Nn \l_tzbezier_opt_tl { #3 } } - { \tl_clear:N \l_tzbezier_opt_tl } - - \tzbezier_check_token:n + { \tl_set:Nn \l_tzrightanglefill_opt_tl { #3 } } + { \tl_clear:N \l_tzrightanglefill_opt_tl } + + \tzrightanglefill_check_token:n } -\cs_new:Npn \tzbezier_check_token:n #1 +\cs_new:Npn \tzrightanglefill_check_token:n #1 { \str_if_eq:nnT { #1 } { ( } - { \tzbezier_sub_fn ( } -% \tzbezier_stop_action + { \tzrightanglefill_sub_fn ( } } -\NewDocumentCommand\tzbezier_sub_fn{ r() r() r() d() +G{} O{} D<>{} } +\NewDocumentCommand\tzrightanglefill_sub_fn + { r() r() r() +G{} O{} D(){5pt} G{\tz@initial@fill@opacity} } + { - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { ([shift = { (\l_tzbezier_shift_coor_tl) } ]#1) .. controls } + \renewcommand\tzfillopacity{#7} + + \coordinate (tzRAOne) at ($(#2)!#6!(#1)$) ; + \coordinate (tzRAThree) at ($(#2)!#6!(#3)$) ; + \coordinate (tzRAvertex) at ($(tzRAThree) + (tzRAOne) - (#2)$) ; + + \tl_put_right:Nn \l_tzrightanglefill_cmd_tl + { + [ very~thin , } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { (#1) .. controls } + + \tl_put_right:Nn \l_tzrightanglefill_cmd_tl + { + fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , } + + \tl_put_right:No \l_tzrightanglefill_cmd_tl + { \l_tzrightanglefill_opt_tl ] } - \IfNoValueTF { #4 } - {%% 3 coors - \bool_if:NTF \l_tmpb_bool - {% if + (relative coor) - \tl_put_right:Nn \l_tzbezier_cmd_tl { + (#2) } - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]$(#1)+(#3)$) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { .. ($(#1)+(#3)$) } - } - } - {% no + (absolute coor) - % control coor - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#2) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { (#2) } - } - %% end coor - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]#3) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { .. (#3) } - } - } + \begin{pgfonlayer}{\tzanglelayer} + \exp_last_unbraced:Nf + \fill \l_tzrightanglefill_cmd_tl + (#2) -- (tzRAOne) -- (tzRAvertex) -- (tzRAThree) -- cycle ; + \end{pgfonlayer} + \path (#2) -- (tzRAvertex) node [ pos = 2 , #5 ] { #4 } ; +} + +%%% --- end of \tzrightanglefill + + + +%%%(ADDED) +%%% \tzpicangle (to be removed) +\NewDocumentCommand\tzpicangle + { t' O{} O{} r() r() r() G{} O{1.5} D(){10pt} } +{ + \IfBooleanTF #1 + { + \begin{pgfonlayer}{background} + \path [ #3 ] (#4) coordinate (tzangleA) -- + (#5) coordinate (tzangleB) -- + (#6) coordinate (tzangleC) + pic [ draw , "#7" , angle~radius=#9 , angle~eccentricity = #8 , #2 ] + { angle = tzangleC -- tzangleB -- tzangleA } ; + % C to A (counter clockwise) + \end{pgfonlayer} } - {%% 4 coors - \bool_if:NTF \l_tmpb_bool - {% if + (relative coor) - \tl_put_right:Nn \l_tzbezier_cmd_tl { + (#2) and + (#3) } - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]$(#1)+(#4)$) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { .. ($(#1)+(#4)$) } - } - } - {% no + (absolute coor) - %% control coors - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { - ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#2) - and - ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#3) - } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { (#2) and (#3) } - } - %% end coor - \bool_if:NTF \l_tzbezier_shift_coor_bool - {% if shift - \tl_put_right:Nx \l_tzbezier_cmd_tl - { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]#4) } - } - {% no shift (normal) - \tl_put_right:Nn \l_tzbezier_cmd_tl { .. (#4) } - } - } + { + \begin{pgfonlayer}{background} + \path [ #3 ] (#4) coordinate (tzangleA) -- + (#5) coordinate (tzangleB) -- + (#6) coordinate (tzangleC) + pic [ draw , "#7" , angle~radius=#9 , angle~eccentricity = #8 , #2 ] + { angle = tzangleA -- tzangleB -- tzangleC } ; + % A to C (clockwise) + \end{pgfonlayer} } - - \tl_put_left:No \l_tzbezier_cmd_tl { \l_tzbezier_opt_tl ] } - \tl_put_left:Nx \l_tzbezier_cmd_tl - { [ \l_tzbezier_pathname_tl , } - % final action - \exp_last_unbraced:Nf \draw \l_tzbezier_cmd_tl node [ #6 ] { #5 } #7 ; } -%%% -- end of \tzbezier +%%% --- end of \tzpicangle -%%% \tzarc -\use:x{ - \NewDocumentCommand \exp_not:N \tzarc - { s t' O{} d<> D""{} r() - >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() - } +%%%%% plot coordinates (of TikZ) + + +%%% \tzplot + +\bool_new:N \l_tzplot_shift_coor_bool +\bool_new:N \g_tzplot_BEGIN_cmd_bool +\bool_new:N \g_tzplot_END_cmd_bool + +%% \tzplotAtBegin +\NewDocumentCommand\tzplotAtBegin{ m } +{ + \bool_gset_true:N \g_tzplot_BEGIN_cmd_bool + \tl_gset:No \g_tzplot_BEGIN_cmd_tl { #1 } } + +%% \tzplotAtEnd +\NewDocumentCommand\tzplotAtEnd{ m } { - \IfBooleanTF { #1 } {}{} % NOT USED! + \bool_gset_true:N \g_tzplot_END_cmd_bool + \tl_gset:No \g_tzplot_END_cmd_tl { #1 } +} - \tl_clear:N \l_tzarc_cmd_tl +%%% \tzplot (main) +\NewDocumentCommand\tzplot{ s O{} G{0} O{} d<> D""{} } +{ + \tl_clear:N \l_tzplot_opt_tl % [opt] + \tl_clear:N \l_tzplot_TEMP_opt_tl % for path only: [opt,mark=none] + \tl_clear:N \l_tzplot_plot_coordinates_tl % plot coordinates + \tl_clear:N \l_tzplot_coors_tl % {(coor-1)(coor-2)...(coor-n)} + \tl_clear:N \l_tzplot_code_at_end_tl % + \tl_clear:N \l_tzplot_nodes_tl - \tzarc_args_process #7 - \fp_set:Nn \l_tmpa_fp { \tzarcAngleA } - \fp_set:Nn \l_tmpb_fp { \tzarcAngleB } - - \tl_put_right:Nn \l_tzarc_cmd_tl - { [ name~path = #5 , #3 ] } - \IfValueTF { #4 } - {% if shift - \tl_put_right:Nn \l_tzarc_cmd_tl - { ([shift={(#4)}]#6) ++ (\tzarcAngleA \c_colon_str \tzarcRadius) } + \renewcommand\tzmarksize{\tz@initial@mark@size} + + \tl_put_right:Nn \l_tzplot_opt_tl + { + [ + name~path = #6 , + tension = #3 , + smooth , + tzmark = \tzmarksize , } - {% no shift (normal) - \tl_put_right:Nn \l_tzarc_cmd_tl - { (#6) ++ (\tzarcAngleA \c_colon_str \tzarcRadius) } + + %% closing options + % if AtBegin_true, USE mark=none (for path only) + \bool_if:NT \g_tzplot_BEGIN_cmd_bool + { + \tl_set_eq:NN \l_tzplot_TEMP_opt_tl \l_tzplot_opt_tl + \tl_put_right:Nn \l_tzplot_TEMP_opt_tl { mark = none ] } + } + % (normal) + \IfBooleanTF { #1 } + { + \tl_put_right:Nn \l_tzplot_opt_tl + { mark = * , draw = none , #2 ] } + } + { + \tl_put_right:Nn \l_tzplot_opt_tl + { #2 ] } + } + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzplot_shift_coor_tl { #5 } + \bool_set_true:N \l_tzplot_shift_coor_bool + } + { + \tl_clear:N \l_tzplot_shift_coor_tl + \bool_set_false:N \l_tzplot_shift_coor_bool } - \tl_put_right:Nx \l_tzarc_cmd_tl - { - \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + \tl_put_right:Nn \l_tzplot_plot_coordinates_tl + { plot [ #4 ] coordinates } + \tzplot_check_token:n +} + +\cs_new:Npn \tzplot_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzplot_sub_fn #1 } +% { \tzplot_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzplot_sub_fn #1 } + { ; } { \tzplot_late_opt_fn } + } + { +% \tzplot_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzplot_sub_fn{ r() +G{} >{\TrimSpaces}o } +{ +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } { - arc ( \tzarcAngleA - \c_colon_str - \IfBooleanTF {#2} - {\tzarcAngleB - 360} - {\tzarcAngleB} - \c_colon_str - \tzarcRadius ) + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } } { - arc ( \IfBooleanTF {#2} - {\tzarcAngleA - 360} - {\tzarcAngleA} - \c_colon_str - \tzarcAngleB - \c_colon_str - \tzarcRadius ) + \tl_set:Nn \l_label_pos_str_tl { #3 } } } - - \tzarc_sub_fn:n -} - -\NewDocumentCommand\tzarc_args_process{ m m m } -{ - \def\tzarcAngleA{#1} - \def\tzarcAngleB{#2} - \def\tzarcRadius{#3} + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + % collect coordinates only + \bool_if:NTF \l_tzplot_shift_coor_bool + { + \tl_put_right:Nx \l_tzplot_coors_tl + { ( [ shift = { (\l_tzplot_shift_coor_tl) } ] \exp_not:n { #1 } ) } + } + { + \tl_put_right:Nn \l_tzplot_coors_tl { (#1) } + } + % collect nodes information + \bool_if:NTF \l_tzplot_shift_coor_bool + { + \tl_put_right:Nx \l_tzplot_nodes_tl + { ( [ shift = { (\l_tzplot_shift_coor_tl) } ] \exp_not:n { #1 } ) } + } + { + \tl_put_right:Nn \l_tzplot_nodes_tl { (#1) } + } + \tl_put_right:Nx \l_tzplot_nodes_tl + { + node + [ label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } % pos_str + ] {} + } + \tzplot_check_token:n } -\cs_new:Npn \tzarc_sub_fn:n +\NewDocumentCommand\tzplot_late_opt_fn { d() D<>{} } { - \tzarc_final_actions + \IfValueTF { #1 } + { \edef\tztmpMarkSize { #1 } } + { \edef\tztmpMarkSize { \tz@initial@mark@size } } + \tl_put_right:Nn \l_tzplot_code_at_end_tl { #2 } + \tzplot_stop_action } -\NewDocumentCommand\tzarc_final_actions{ +G{} O{} D<>{} } +\NewDocumentCommand\tzplot_stop_action {} { - \tl_put_right:Nn \l_tzarc_cmd_tl - { node [ #2 ] { #1 } #3 } + \renewcommand\tzmarksize{ \tztmpMarkSize } + %% final action cases: + \bool_if:NTF \g_tzplot_BEGIN_cmd_bool + { %% if AtBegin_true + % define (tzCPSS) by path (WITH \l_tzplot_TEMP_opt_tl ) + \exp_last_unbraced:Nf + \path + \l_tzplot_TEMP_opt_tl + \l_tzplot_plot_coordinates_tl + { \l_tzplot_coors_tl } + ; + \path (current~subpath~start) coordinate (tzCSPS) ; + % all together (important) + \tl_put_right:No \l_tmpa_tl { \g_tzplot_BEGIN_cmd_tl } + \tl_put_right:Nn \l_tmpa_tl { (tzCSPS) -- } + \tl_put_right:No \l_tmpa_tl { \l_tzplot_plot_coordinates_tl } % important + \bool_if:NTF \g_tzplot_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplot_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplot_coors_tl } + \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl + \l_tzplot_nodes_tl + ; + } + { %% if AtEnd_false + % plot AtBegin and (coors) + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplot_coors_tl } +% \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl + \l_tzplot_nodes_tl + ; - \exp_last_unbraced:Nf \draw \l_tzarc_cmd_tl ; + } + } + { %% if AtBegin_false + \bool_if:NTF \g_tzplot_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplot_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl + \l_tzplot_plot_coordinates_tl + { \l_tzplot_coors_tl } + \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl + \l_tzplot_nodes_tl + ; + } + { %% if AtEnd_false + % normal + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl % [opt] + \l_tzplot_plot_coordinates_tl % plot coordinates + { \l_tzplot_coors_tl } % { (coor-1)(coor-2)...(coor-n) } +% \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl % + \l_tzplot_nodes_tl % (coor-i) node [opt] {text}, all i + ; + } + } + + \bool_gset_false:N \g_tzplot_BEGIN_cmd_bool + \bool_gset_false:N \g_tzplot_END_cmd_bool } -%%% --- end of \tzarc +%%% --- end of \tzplot +%%% \tzplotcurve -%%% \tzarcfrom % (works like tikz original) +\bool_new:N \l_tzplotcurve_shift_coor_bool +\bool_new:N \g_tzplotcurve_BEGIN_cmd_bool +\bool_new:N \g_tzplotcurve_END_cmd_bool -\use:x{ - \NewDocumentCommand \exp_not:N \tzarcfrom - { s t' O{} d<> D""{} r() - >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() - } +%% \tzplotcurveAtBegin +\NewDocumentCommand\tzplotcurveAtBegin{ m } +{ + \bool_gset_true:N \g_tzplotcurve_BEGIN_cmd_bool + \tl_gset:No \g_tzplotcurve_BEGIN_cmd_tl { #1 } } + +%% \tzplotcurveAtEnd +\NewDocumentCommand\tzplotcurveAtEnd{ m } { - \IfBooleanTF { #1 } {}{} % NOT USED! + \bool_gset_true:N \g_tzplotcurve_END_cmd_bool + \tl_gset:No \g_tzplotcurve_END_cmd_tl { #1 } +} - \tl_clear:N \l_tzarcfrom_cmd_tl - \tzarcfrom_args_process #7 - \fp_set:Nn \l_tmpa_fp { \tzarcfromAngleA } - \fp_set:Nn \l_tmpb_fp { \tzarcfromAngleB } +%%% \tzplotcurve (main) +\NewDocumentCommand\tzplotcurve{ s O{} G{1} O{} d<> D""{} } +{ + \tl_clear:N \l_tzplotcurve_opt_tl % [opt] + \tl_clear:N \l_tzplotcurve_TEMP_opt_tl % for path only: [opt,mark=none] + \tl_clear:N \l_tzplotcurve_plot_coordinates_tl % plot coordinates + \tl_clear:N \l_tzplotcurve_coors_tl % {(coor-1)(coor-2)...(coor-n)} + \tl_clear:N \l_tzplotcurve_code_at_end_tl % + \tl_clear:N \l_tzplotcurve_nodes_tl - \tl_put_right:Nn \l_tzarcfrom_cmd_tl - { [ name~path = #5 , #3 ] } + \renewcommand\tzmarksize{\tz@initial@mark@size} - \IfValueTF { #4 } - {% if shift - \tl_put_right:Nn \l_tzarcfrom_cmd_tl - { ([shift={(#4)}]#6) } + \tl_put_right:Nn \l_tzplotcurve_opt_tl + { + [ name~path = #6 , + tension = #3 , + smooth , + tzmark = \tzmarksize , } - {% no shift (normal) - \tl_put_right:Nn \l_tzarcfrom_cmd_tl - { (#6) } % ++ (\tzarcfromAngleA \c_colon_str \tzarcfromRadius) + + %% closing options + % if AtBegin_true, USE mark=none (for path only) + \bool_if:NT \g_tzplotcurve_BEGIN_cmd_bool + { + \tl_set_eq:NN \l_tzplotcurve_TEMP_opt_tl \l_tzplotcurve_opt_tl + \tl_put_right:Nn \l_tzplotcurve_TEMP_opt_tl { mark = none ] } + } + % (normal) + \IfBooleanTF { #1 } + { + \tl_put_right:Nn \l_tzplotcurve_opt_tl { mark = * , #2 ] } + } + { + \tl_put_right:Nn \l_tzplotcurve_opt_tl { #2 ] } + } + + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzplotcurve_shift_coor_tl { #5 } + \bool_set_true:N \l_tzplotcurve_shift_coor_bool + } + { + \tl_clear:N \l_tzplotcurve_shift_coor_tl + \bool_set_false:N \l_tzplotcurve_shift_coor_bool } - \tl_put_right:No \l_tzarcfrom_cmd_tl - { - \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + \tl_put_right:Nn \l_tzplotcurve_plot_coordinates_tl + { plot [ #4 ] coordinates } + \tzplotcurve_check_token:n +} + +\cs_new:Npn \tzplotcurve_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzplotcurve_sub_fn #1 } +% { \tzplotcurve_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzplotcurve_sub_fn #1 } + { ; } { \tzplotcurve_late_opt_fn } + } + { +% \tzplotcurve_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzplotcurve_sub_fn{ r() +G{} >{\TrimSpaces}o } +{ +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } { - arc ( \tzarcfromAngleA - \c_colon_str - \IfBooleanTF {#2} - {\tzarcfromAngleB - 360} - {\tzarcfromAngleB} - \c_colon_str - \tzarcfromRadius ) + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } } { - arc ( \IfBooleanTF {#2} - {\tzarcfromAngleA - 360} - {\tzarcfromAngleA} - \c_colon_str - \tzarcfromAngleB - \c_colon_str - \tzarcfromRadius ) + \tl_set:Nn \l_label_pos_str_tl { #3 } } } - - \tzarcfrom_sub_fn:n - + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + % collect coordinates only + \bool_if:NTF \l_tzplotcurve_shift_coor_bool + { + \tl_put_right:Nx \l_tzplotcurve_coors_tl + { ( [ shift = { (\l_tzplotcurve_shift_coor_tl) } ] \exp_not:n { #1 } ) } + } + { + \tl_put_right:Nn \l_tzplotcurve_coors_tl { (#1) } + } + % collect nodes information + \bool_if:NTF \l_tzplotcurve_shift_coor_bool + { + \tl_put_right:Nx \l_tzplotcurve_nodes_tl + { ( [ shift = { (\l_tzplotcurve_shift_coor_tl) } ] \exp_not:n { #1 } ) } + } + { + \tl_put_right:Nn \l_tzplotcurve_nodes_tl { (#1) } + } + \tl_put_right:Nx \l_tzplotcurve_nodes_tl + { node + [ label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } % pos_str + ] {} + } + \tzplotcurve_check_token:n } -\NewDocumentCommand\tzarcfrom_args_process{ m m m } +\NewDocumentCommand\tzplotcurve_late_opt_fn { d() D<>{} } { - \def\tzarcfromAngleA{#1} - \def\tzarcfromAngleB{#2} - \def\tzarcfromRadius{#3} + \IfValueTF { #1 } + { \edef\tztmpMarkSize { #1 } } + { \edef\tztmpMarkSize { \tz@initial@mark@size } } + \tl_put_right:Nn \l_tzplotcurve_code_at_end_tl { #2 } + \tzplotcurve_stop_action } -\cs_new:Npn \tzarcfrom_sub_fn:n +\NewDocumentCommand\tzplotcurve_stop_action {} { - \tzarcfrom_final_actions + \renewcommand\tzmarksize{ \tztmpMarkSize } + %% final action cases: + \bool_if:NTF \g_tzplotcurve_BEGIN_cmd_bool + { %% if AtBegin_true + % define (tzCPSS) by path (WITH \l_tzplotcurve_TEMP_opt_tl ) + \exp_last_unbraced:Nf + \path + \l_tzplotcurve_TEMP_opt_tl + \l_tzplotcurve_plot_coordinates_tl + { \l_tzplotcurve_coors_tl } + ; + \path (current~subpath~start) coordinate (tzCSPS) ; + % all together (important) + \tl_put_right:No \l_tmpa_tl { \g_tzplotcurve_BEGIN_cmd_tl } + \tl_put_right:Nn \l_tmpa_tl { (tzCSPS) -- } + \tl_put_right:No \l_tmpa_tl { \l_tzplotcurve_plot_coordinates_tl } % important + \bool_if:NTF \g_tzplotcurve_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplotcurve_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplotcurve_coors_tl } + \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl + \l_tzplotcurve_nodes_tl + ; + } + { %% if AtEnd_false + % plot AtBegin and (coors) + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplotcurve_coors_tl } +% \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl + \l_tzplotcurve_nodes_tl + ; + + } + } + { %% if AtBegin_false + \bool_if:NTF \g_tzplotcurve_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplotcurve_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl + \l_tzplotcurve_plot_coordinates_tl + { \l_tzplotcurve_coors_tl } + \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl + \l_tzplotcurve_nodes_tl + ; + } + { %% if AtEnd_false + % normal + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl % [opt] + \l_tzplotcurve_plot_coordinates_tl % plot coordinates + { \l_tzplotcurve_coors_tl } % { (coor-1)(coor-2)...(coor-n) } +% \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl % + \l_tzplotcurve_nodes_tl % (coor-i) node [opt] {text}, all i + ; + } + } + + \bool_gset_false:N \g_tzplotcurve_BEGIN_cmd_bool + \bool_gset_false:N \g_tzplotcurve_END_cmd_bool } -\NewDocumentCommand\tzarcfrom_final_actions{ +G{} O{} D<>{} } +%%% --- end of \tzplotcurve + + +%%(ADDED) +%%% \tzplotfile +\NewDocumentCommand\tzplotfile{ O{} m O{} } { - \tl_put_right:Nn \l_tzarcfrom_cmd_tl - { node [ #2 ] { #1 } #3 } - \exp_last_unbraced:Nf \draw \l_tzarcfrom_cmd_tl ; + \draw [ #1 ] plot [ smooth , #3 ] file { #2 } ; } -%%% --- end of \tzarcfrom - +%%% --- end of \tzplotfile -%%% \tzarcsfrom % (works like tikz original) -\tl_new:N \l_tzarcsfrom_code_at_end_tl +%%%%% Plot functions -\NewDocumentCommand\tzarcsfrom { s t' O{} d<> D""{} r() } +%%% \tzdeffn +\NewDocumentCommand\tzdeffn{ m m } { - \IfBooleanTF { #1 } {}{} % NOT USED! - { \bool_set_true:N \l_tmpa_bool } - { \bool_set_false:N \l_tmpa_bool } + \tl_set:cn { #1 } { #2 } +} +%% USAGE: \tzdeffn{Fx}{2*\x+1} - \IfBooleanTF { #2 } - { \bool_set_true:N \l_tmpb_bool } - { \bool_set_false:N \l_tmpb_bool } +%%% \tzdeffnofy +\NewDocumentCommand\tzdeffnofy{ m m } +{ + \tl_set:cn { #1 } { #2 } +} +%% just a reminder of using \y instead of \x +%% USAGE: \tzdeffn'{Gy}{2*\y+1} - \tl_clear:N \l_tzarcsfrom_cmd_tl - \tl_put_right:Nn \l_tzarcsfrom_cmd_tl - { [ name~path = #5 , #3 ] } - \IfValueTF { #4 } - {% if shift - \tl_put_right:Nn \l_tzarcsfrom_cmd_tl - { ([shift={(#4)}]#6) } +%%% \tzdefLFn +\NewDocumentCommand\tzdefLFn{ m r() d() G{1} } +{ + \IfNoValueTF { #3 } + { + \tzgetxyval(#2){\tzdefLFnXvalS}{\tzdefLFnYvalS} + \def#1{#4*(\x-\tzdefLFnXvalS)+\tzdefLFnYvalS} } - {% no shift - \tl_put_right:Nn \l_tzarcsfrom_cmd_tl - { (#6) } % ++ (\tzarcsfromAngleA \c_colon_str \tzarcsfromRadius) + { + \tzgetxyval(#2){\tzdefLFnXval}{\tzdefLFnYval} + \tzgetxyval(#3){\tzdefLFnXXval}{\tzdefLFnYYval} + \fp_compare:nT { \tzdefLFnXXval - \tzdefLFnXval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzdefLFnSlope{% + (\tzdefLFnYYval-\tzdefLFnYval)/(\tzdefLFnXXval-\tzdefLFnXval) + } + \def#1{\tzdefLFnSlope*(\x-\tzdefLFnXval)+\tzdefLFnYval} } - - \tzarcsfrom_check_token:n } -\cs_new:Npn \tzarcsfrom_check_token:n #1 -{ - \str_case:nnF { #1 } +%%% \tzdefLFnofy +\NewDocumentCommand\tzdefLFnofy{ m r() d() G{1} } +{ % linear function of \y + \IfNoValueTF { #3 } { - { ( } { \tzarcsfrom_sub_fn #1 } - { ; } { \tzarcsfrom_late_opt_fn } + \tzgetxyval(#2){\tzdefLFnofyXvalS}{\tzdefLFnofyYvalS} + \def#1{#4*(\y-\tzdefLFnofyYvalS)+\tzdefLFnofyXvalS} } { - \tzarcsfrom_stop_action + \tzgetxyval(#2){\tzdefLFnofyXval}{\tzdefLFnofyYval} + \tzgetxyval(#3){\tzdefLFnofyXXval}{\tzdefLFnofyYYval} + \fp_compare:nT { \tzdefLFnofyYYval - \tzdefLFnofyYval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzdefLFnofySlope{% + (\tzdefLFnofyXXval-\tzdefLFnofyXval)/(\tzdefLFnofyYYval-\tzdefLFnofyYval) + } + \def#1{\tzdefLFnofySlope*(\y-\tzdefLFnofyYval)+\tzdefLFnofyXval} } } -\use:x{ - \NewDocumentCommand \exp_not:N \tzarcsfrom_sub_fn - { >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() +G{} O{} - } -} -{ - \tzarcsfrom_args_process #1 - \fp_set:Nn \l_tmpa_fp { \tzarcsfromAngleA } - \fp_set:Nn \l_tmpb_fp { \tzarcsfromAngleB } - \tl_put_right:Nx \l_tzarcsfrom_cmd_tl - { - \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } - { - arc ( \tzarcsfromAngleA - \c_colon_str - \bool_if:NTF \l_tmpb_bool - {\tzarcsfromAngleB - 360} - {\tzarcsfromAngleB} - \c_colon_str - \tzarcsfromRadius ) - } - { - arc ( \bool_if:NTF \l_tmpb_bool - {\tzarcsfromAngleA - 360} - {\tzarcsfromAngleA} - \c_colon_str - \tzarcsfromAngleB - \c_colon_str - \tzarcsfromRadius ) - } - } - \tl_put_right:Nn \l_tzarcsfrom_cmd_tl - { node [ #3 ] { #2 } } +%%% \tzLFn -- plot Linear Function (LF) - \tzarcsfrom_check_token:n -} +\bool_new:N \g_tzLFn_BEGIN_cmd_bool +\bool_new:N \g_tzLFn_END_cmd_bool -\NewDocumentCommand\tzarcsfrom_late_opt_fn { D<>{} } +%% \tzLFnAtBegin +\NewDocumentCommand\tzLFnAtBegin{ m } { - \tl_set:Nn \l_tzarcsfrom_code_at_end_tl { #1 } - \tzarcsfrom_stop_action + \bool_gset_true:N \g_tzLFn_BEGIN_cmd_bool + \tl_gset:No \g_tzLFn_BEGIN_cmd_tl { #1 } } -\NewDocumentCommand\tzarcsfrom_stop_action {} +%% \tzLFnAtEnd +\NewDocumentCommand\tzLFnAtEnd{ m } { - \tl_put_right:No \l_tzarcsfrom_cmd_tl - { \l_tzarcsfrom_code_at_end_tl } - \exp_last_unbraced:Nf \draw \l_tzarcsfrom_cmd_tl ; + \bool_gset_true:N \g_tzLFn_END_cmd_bool + \tl_gset:No \g_tzLFn_END_cmd_tl { #1 } } -\NewDocumentCommand\tzarcsfrom_args_process{ m m m } -{ - \def\tzarcsfromAngleA{#1} - \def\tzarcsfromAngleB{#2} - \def\tzarcsfromRadius{#3} -} +%%% \tzLFn (main) +%% \tzLFn : variable = \x (default) -%%% --- end of \tzarcsfrom +\NewDocumentCommand \tzLFn { t' o D<>{0,0} d"" } +{ + \tl_clear:N \l_tzLFn_opt_tl + \tl_clear:N \l_tzLFn_path_tl + \tl_clear:N \l_tzLFn_TEMP_cmd_tl + \tl_clear:N \l_tzLFn_cmd_tl + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzLFn_shift_tl + { shift = { (#3) } } + } + { \tl_clear:N \l_tzLFn_shift_tl } + \IfValueTF { #2 } + { \tl_set:Nn \l_tzLFn_user_opt_tl { #2 } } + { \tl_clear:N \l_tzLFn_user_opt_tl } + + \IfValueTF { #4 } + { \tl_set:Nn \l_tzLFn_namepath_tl { name~path = #4 } } + { \tl_clear:N \l_tzLFn_namepath_tl } + + \tzLFn_check_token:n +} -%%% \tzwedge +\cs_new:Npn \tzLFn_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzLFn_sub_fn ( } +} \use:x{ - \NewDocumentCommand \exp_not:N \tzwedge - { s t' O{} d<> D""{} r() - >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + \NewDocumentCommand \exp_not:N \tzLFn_sub_fn + { r() d() G{1} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] + G{} O{} D<>{} } } { - \tl_clear:N \l_tzwedge_cmd_tl - - \tzwedge_args_process #7 - \fp_set:Nn \l_tmpa_fp { \tzwedgeAngleA } - \fp_set:Nn \l_tmpb_fp { \tzwedgeAngleB } + \tzLFn_domain_process #4 + + \tl_put_right:Nx \l_tzLFn_opt_tl + { + [ +% samples = 201 , + \l_tzLFn_namepath_tl , + domain = \tzLFnFromVal \c_colon_str \tzLFnToVal , %%% [here?] +% variable = \exp_not:n { \x } , + \l_tzLFn_shift_tl , + } + \tl_put_right:No \l_tzLFn_opt_tl + { + \l_tzLFn_user_opt_tl + ] + } - \IfBooleanTF { #1 } + % define LF: (X,Y)(XX,YY){slope num: dY/dX} + \IfNoValueTF { #2 } { - \tl_put_right:Nn \l_tzwedge_cmd_tl - { - [ fill=\tzfillcolor , - fill~opacity = \tzfillopacity , text~opacity = 1 , - name~path = #5 , #3 ] - } + \tzgetxyval(#1){\tzLFnXvalS}{\tzLFnYvalS} + \def\tzLFnDEF{#3*(\x-\tzLFnXvalS)+\tzLFnYvalS} } { - \tl_put_right:Nn \l_tzwedge_cmd_tl - { [ name~path = #5 , #3 ] } + \tzgetxyval(#1){\tzLFnXval}{\tzLFnYval} + \tzgetxyval(#2){\tzLFnXXval}{\tzLFnYYval} + \fp_compare:nT { \tzLFnXXval - \tzLFnXval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzLFSlope{(\tzLFnYYval-\tzLFnYval)/(\tzLFnXXval-\tzLFnXval)} + \def\tzLFnDEF{\tzLFSlope*(\x-\tzLFnXval)+\tzLFnYval} } - \IfValueTF { #4 } + \bool_if:NTF \l_tmpa_bool { - \tl_put_right:Nn \l_tzwedge_cmd_tl - { ([shift={(#4)}]#6) -- ++ (\tzwedgeAngleA \c_colon_str \tzwedgeRadius) } + \tl_put_right:Nn \l_tzLFn_path_tl + { plot ( { \tzLFnDEF } , \x ) } % \x should not be expanded } { - \tl_put_right:Nn \l_tzwedge_cmd_tl - { (#6) -- ++ (\tzwedgeAngleA \c_colon_str \tzwedgeRadius) } + \tl_put_right:Nn \l_tzLFn_path_tl + { plot ( \x , { \tzLFnDEF } ) } % \x should not be expanded } - - \tl_put_right:No \l_tzwedge_cmd_tl + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzLFn_BEGIN_cmd_bool { - \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } - { - arc ( \tzwedgeAngleA - \c_colon_str - \IfBooleanTF {#2} - {\tzwedgeAngleB - 360} - {\tzwedgeAngleB} - \c_colon_str - \tzwedgeRadius ) - } - { - arc ( \IfBooleanTF {#2} - {\tzwedgeAngleA - 360} - {\tzwedgeAngleA} - \c_colon_str - \tzwedgeAngleB - \c_colon_str - \tzwedgeRadius ) - } + \tl_put_right:No \l_tzLFn_TEMP_cmd_tl { \l_tzLFn_opt_tl } + \tl_put_right:No \l_tzLFn_TEMP_cmd_tl { \l_tzLFn_path_tl } + \exp_last_unbraced:Nf \path \l_tzLFn_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_opt_tl } + \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzLFn_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_path_tl } } + { + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_opt_tl } + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_path_tl } + } + \bool_if:NT \g_tzLFn_END_cmd_bool + { + \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzLFn_cmd_tl + { node [ #6 ] { #5 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzLFn_cmd_tl #7 ; - \tzwedge_sub_fn:n + \bool_gset_false:N \g_tzLFn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzLFn_END_cmd_bool } -\cs_new:Npn \tzwedge_sub_fn:n +\NewDocumentCommand\tzLFn_domain_process{ m m } { - \tzwedge_final_actions + \def\tzLFnFromVal{#1} + \def\tzLFnToVal{#2} } -\NewDocumentCommand\tzwedge_final_actions{ +G{} O{} G{.3} } -{ - \tl_if_empty:nTF { #3 } - { \renewcommand\tzfillopacity{\tz@initial@fill@opacity} } - { \renewcommand\tzfillopacity{#3} } +%%% --- end of \tzLFn - \tl_put_right:Nn \l_tzwedge_cmd_tl - { - node [ midway , #2 ] { #1 } - } - \exp_last_unbraced:Nf \draw \l_tzwedge_cmd_tl -- cycle ; -} -\NewDocumentCommand\tzwedge_args_process{ m m m } -{ - \def\tzwedgeAngleA{#1} - \def\tzwedgeAngleB{#2} - \def\tzwedgeRadius{#3} -} +%%% \tzLFnofy +%% variable = \y -%%% --- end of \tzwedge +\bool_new:N \g_tzLFnofy_BEGIN_cmd_bool +\bool_new:N \g_tzLFnofy_END_cmd_bool +%% \tzLFnofyAtBegin +\NewDocumentCommand\tzLFnofyAtBegin{ m } +{ + \bool_gset_true:N \g_tzLFnofy_BEGIN_cmd_bool + \tl_gset:No \g_tzLFnofy_BEGIN_cmd_tl { #1 } +} -%%%%% plot of Tikz +%% \tzLFnofyAtEnd +\NewDocumentCommand\tzLFnofyAtEnd{ m } +{ + \bool_gset_true:N \g_tzLFnofy_END_cmd_bool + \tl_gset:No \g_tzLFnofy_END_cmd_tl { #1 } +} -%%% \tzplot +%%% \tzLFnofy (main) +%% \tzLFnofy : variable = \y +\NewDocumentCommand \tzLFnofy { t' o D<>{0,0} d"" } +{ + \tl_clear:N \l_tzLFnofy_opt_tl + \tl_clear:N \l_tzLFnofy_path_tl + \tl_clear:N \l_tzLFnofy_TEMP_cmd_tl + \tl_clear:N \l_tzLFnofy_cmd_tl -\bool_new:N \l_tzplot_shift_coor_bool + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } -\NewDocumentCommand\tzplot{ s O{} G{0} O{} d<> D""{} } -{ - \tl_clear:N \l_tzplot_opt_cmd_tl - \tl_clear:N \l_tzplot_cmd_tl - \tl_clear:N \l_tzplot_nodes_cmd_tl - \tl_clear:N \l_tzplot_coors_cmd_tl - \tl_clear:N \l_tzplot_code_at_end_tl - - \renewcommand\tzmarksize{\tz@initial@mark@size} - - \tl_put_right:Nn \l_tzplot_opt_cmd_tl + \IfValueTF { #3 } { - [ - name~path = #6 , - tension = #3 , - smooth , - tzmark = \tzmarksize , + \tl_set:Nn \l_tzLFnofy_shift_tl + { shift = { (#3) } } } + { \tl_clear:N \l_tzLFnofy_shift_tl } - \IfBooleanT { #1 } - { - \tl_put_right:Nn \l_tzplot_opt_cmd_tl - { mark = * , draw = none , } - } + \IfValueTF { #2 } + { \tl_set:Nn \l_tzLFnofy_user_opt_tl { #2 } } + { \tl_clear:N \l_tzLFnofy_user_opt_tl } - \IfValueTF { #5 } - { - \tl_set:Nn \l_tzplot_shift_coor_tl { #5 } - \bool_set_true:N \l_tzplot_shift_coor_bool - } - { - \tl_clear:N \l_tzplot_shift_coor_tl - \bool_set_false:N \l_tzplot_shift_coor_bool - } + \IfValueTF { #4 } + { \tl_set:Nn \l_tzLFnofy_namepath_tl { name~path = #4 } } + { \tl_clear:N \l_tzLFnofy_namepath_tl } - \tl_put_right:Nn \l_tzplot_opt_cmd_tl - { - #2 - ] - plot [ #4 ] coordinates - } - \tzplot_check_token:n + \tzLFnofy_check_token:n } -\cs_new:Npn \tzplot_check_token:n #1 +\cs_new:Npn \tzLFnofy_check_token:n #1 { -% \token_if_eq_charcode:NNTF #1 ( -% { \tzplot_sub_fn #1 } -% { \tzplot_stop_action } - \str_case:nnF { #1 } - { - { ( } { \tzplot_sub_fn #1 } - { ; } { \tzplot_late_opt_fn } - } - { - \tzplot_stop_action - } + \str_if_eq:nnT { #1 } { ( } + { \tzLFnofy_sub_fn ( } } -\NewDocumentCommand\tzplot_sub_fn{ r() +G{} O{} } -{ - % collect coordinates only - \bool_if:NTF \l_tzplot_shift_coor_bool - { - \tl_put_right:Nx \l_tzplot_coors_cmd_tl - { ([shift = { (\l_tzplot_shift_coor_tl) } ]#1) } +\use:x{ + \NewDocumentCommand \exp_not:N \tzLFnofy_sub_fn + { r() d() G{1} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] + G{} O{} D<>{} } +} +{ + \tzLFnofy_domain_process #4 + + \tl_put_right:Nx \l_tzLFnofy_opt_tl + { + [ +% samples = 201 , + \l_tzLFnofy_namepath_tl , + domain = \tzLFnofyFromVal \c_colon_str \tzLFnofyToVal , %%% [here?] + variable = \exp_not:n { \y } , + \l_tzLFnofy_shift_tl , + } + \tl_put_right:No \l_tzLFnofy_opt_tl + { + \l_tzLFnofy_user_opt_tl + ] + } + + % define LFofy: (X,Y)(XX,YY){slope num: dX/dY} + \IfNoValueTF { #2 } { - \tl_put_right:Nn \l_tzplot_coors_cmd_tl { (#1) } + \tzgetxyval(#1){\tzLFnofyXvalS}{\tzLFnofyYvalS} + \def\tzLFnofyDEF{#3*(\y-\tzLFnofyYvalS)+\tzLFnofyXvalS} } - % collect nodes information - \bool_if:NTF \l_tzplot_shift_coor_bool { - \tl_put_right:Nx \l_tzplot_nodes_cmd_tl - { ([shift = { (\l_tzplot_shift_coor_tl) } ]#1) } + \tzgetxyval(#1){\tzLFnofyXval}{\tzLFnofyYval} + \tzgetxyval(#2){\tzLFnofyXXval}{\tzLFnofyYYval} + \fp_compare:nT { \tzLFnofyYYval - \tzLFnofyYval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzLFofySlope + { + (\tzLFnofyXXval-\tzLFnofyXval)/(\tzLFnofyYYval-\tzLFnofyYval) + } + \def\tzLFnofyDEF{\tzLFofySlope*(\y-\tzLFnofyYval)+\tzLFnofyXval} } + + \bool_if:NTF \l_tmpa_bool { - \tl_put_right:Nn \l_tzplot_nodes_cmd_tl { (#1) } + \tl_put_right:Nn \l_tzLFnofy_path_tl + { plot ( \y , { \tzLFnofyDEF } ) } % \y should not be expanded } - \tl_put_right:Nx \l_tzplot_nodes_cmd_tl { - node - [ label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } - ] {} + \tl_put_right:Nn \l_tzLFnofy_path_tl + { plot ( { \tzLFnofyDEF } , \y ) } % \y should not be expanded } - \tzplot_check_token:n -} + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzLFnofy_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzLFnofy_TEMP_cmd_tl { \l_tzLFnofy_opt_tl } + \tl_put_right:No \l_tzLFnofy_TEMP_cmd_tl { \l_tzLFnofy_path_tl } + \exp_last_unbraced:Nf \path \l_tzLFnofy_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_opt_tl } + \tl_put_right:No \l_tzLFnofy_cmd_tl { \g_tzLFnofy_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzLFnofy_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_path_tl } + } + { + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_opt_tl } + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_path_tl } + } + \bool_if:NT \g_tzLFnofy_END_cmd_bool + { + \tl_put_right:No \l_tzLFnofy_cmd_tl { \g_tzLFnofy_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzLFnofy_cmd_tl + { node [ #6 ] { #5 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzLFnofy_cmd_tl #7 ; -\NewDocumentCommand\tzplot_late_opt_fn { d() D<>{} } -{ - \IfValueTF { #1 } - { \edef\tztmpMarkSize { #1 } } - { \edef\tztmpMarkSize { \tz@initial@mark@size } } - \tl_put_right:Nn \l_tzplot_code_at_end_tl { #2 } - \tzplot_stop_action + \bool_gset_false:N \g_tzLFnofy_BEGIN_cmd_bool + \bool_gset_false:N \g_tzLFnofy_END_cmd_bool } -\NewDocumentCommand\tzplot_stop_action {} +\NewDocumentCommand\tzLFnofy_domain_process{ m m } { - \renewcommand\tzmarksize{ \tztmpMarkSize } - % final action - \exp_last_unbraced:Nf - \draw - \l_tzplot_opt_cmd_tl % [opt] plot coordinates - { \l_tzplot_coors_cmd_tl } % { (coor-1)(coor-2)...(coor-n) } - \l_tzplot_code_at_end_tl % should precede _nodes_cmd_tl - \l_tzplot_nodes_cmd_tl % (coor-i) node [opt] {text}, for all i - ; + \def\tzLFnofyFromVal{#1} + \def\tzLFnofyToVal{#2} } -%%% --- end of \tzplot +%%% --- end of \tzLFnofy -%%% \tzplotcurve +%%% \tzfn +%%(variable=\x -- default) -\bool_new:N \l_tzplotcurve_shift_coor_bool +\bool_new:N \g_tzfn_BEGIN_cmd_bool +\bool_new:N \g_tzfn_END_cmd_bool -\NewDocumentCommand\tzplotcurve{ s O{} G{1} O{} d<> D""{} } +%% \tzfnAtBegin +\NewDocumentCommand\tzfnAtBegin{ m } { - \IfBooleanT { #1 } {}{} % NOT USED! + \bool_gset_true:N \g_tzfn_BEGIN_cmd_bool + \tl_gset:No \g_tzfn_BEGIN_cmd_tl { #1 } +} - \tl_clear:N \l_tzplotcurve_opt_cmd_tl - \tl_clear:N \l_tzplotcurve_cmd_tl - \tl_clear:N \l_tzplotcurve_nodes_cmd_tl - \tl_clear:N \l_tzplotcurve_coors_cmd_tl - \tl_clear:N \l_tzplotcurve_code_at_end_tl +%% \tzfnAtEnd +\NewDocumentCommand\tzfnAtEnd{ m } +{ + \bool_gset_true:N \g_tzfn_END_cmd_bool + \tl_gset:No \g_tzfn_END_cmd_tl { #1 } +} - \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl - { - [ name~path = #6 , - tension = #3 , - smooth , - tzmark = \tzmarksize , +%%% \tzfn (main) +%%(variable =\x) +\use:x{ + \NewDocumentCommand \exp_not:N \tzfn + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} } +} +{ + \tl_clear:N \l_tzfn_opt_tl + \tl_clear:N \l_tzfn_path_tl + \tl_clear:N \l_tzfn_TEMP_cmd_tl + \tl_clear:N \l_tzfn_cmd_tl - \IfBooleanT { #1 } - { - \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl - { mark = * , } - } + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } - \IfValueTF { #5 } - { - \tl_set:Nn \l_tzplotcurve_shift_coor_tl { #5 } - \bool_set_true:N \l_tzplotcurve_shift_coor_bool - } + \tzfn_domain_process #6 + + \tl_set:No \l_label_pos_tl { \tl_to_str:n { #5 } } + \tl_set:No \l_tzfn_pathname_tl { \tl_tail:N \l_label_pos_tl } + \tl_put_right:Nx \l_tzfn_opt_tl + { + [ + samples = 201 , + name~path = + \tl_if_empty:nTF { #4 } { \l_tzfn_pathname_tl } { #4 } , + domain = \tzfnFromVal \c_colon_str \tzfnToVal , + shift = { (#3) } , +% variable = \exp_not:n { \x } , + \exp_not:n { #2 } + ] + } + + \bool_if:NTF { \l_tmpa_bool } { - \tl_clear:N \l_tzplotcurve_shift_coor_tl - \bool_set_false:N \l_tzplotcurve_shift_coor_bool + \tl_put_right:No \l_tzfn_path_tl + { plot ( { #5 } , \exp_not:n { \x } ) } % \x should not be expanded } - - \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl { - #2 - ] - plot [ #4 ] coordinates + \tl_put_right:No \l_tzfn_path_tl + { plot ( \exp_not:n { \x } , { #5 } ) } % \x should not be expanded } - \tzplotcurve_check_token:n + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfn_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfn_TEMP_cmd_tl { \l_tzfn_opt_tl } + \tl_put_right:No \l_tzfn_TEMP_cmd_tl { \l_tzfn_path_tl } + \exp_last_unbraced:Nf \path \l_tzfn_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_opt_tl } + \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfn_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_path_tl } + } + { + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_opt_tl } + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_path_tl } + } + \bool_if:NT \g_tzfn_END_cmd_bool + { + \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfn_cmd_tl + { node [ #8 ] { #7 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzfn_cmd_tl #9 ; + + \bool_gset_false:N \g_tzfn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfn_END_cmd_bool } -\cs_new:Npn \tzplotcurve_check_token:n #1 +\NewDocumentCommand\tzfn_domain_process{ m m } { -% \token_if_eq_charcode:NNTF #1 ( -% { \tzplotcurve_sub_fn #1 } -% { \tzplotcurve_stop_action } - \str_case:nnF { #1 } - { - { ( } { \tzplotcurve_sub_fn #1 } - { ; } { \tzplotcurve_late_opt_fn } - } - { - \tzplotcurve_stop_action - } + \def\tzfnFromVal{#1} + \def\tzfnToVal{#2} } -\NewDocumentCommand\tzplotcurve_sub_fn{ r() +G{} O{} } +%%% --- end of \tzfn + + +%%% \tzfnofy +%% (variable = \y) + +\bool_new:N \g_tzfnofy_BEGIN_cmd_bool +\bool_new:N \g_tzfnofy_END_cmd_bool + +%% \tzfnofyAtBegin +\NewDocumentCommand\tzfnofyAtBegin{ m } { - % collect coordinates only - \bool_if:NTF \l_tzplotcurve_shift_coor_bool - { - \tl_put_right:Nx \l_tzplotcurve_coors_cmd_tl - { ([shift = { (\l_tzplotcurve_shift_coor_tl) } ]#1) } - } - { - \tl_put_right:Nn \l_tzplotcurve_coors_cmd_tl { (#1) } - } - % collect nodes information - \bool_if:NTF \l_tzplotcurve_shift_coor_bool - { - \tl_put_right:Nx \l_tzplotcurve_nodes_cmd_tl - { ([shift = { (\l_tzplotcurve_shift_coor_tl) } ]#1) } - } - { - \tl_put_right:Nn \l_tzplotcurve_nodes_cmd_tl { (#1) } - } - \tl_put_right:Nx \l_tzplotcurve_nodes_cmd_tl - { node - [ label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } - ] {} - } - \tzplotcurve_check_token:n + \bool_gset_true:N \g_tzfnofy_BEGIN_cmd_bool + \tl_gset:No \g_tzfnofy_BEGIN_cmd_tl { #1 } } -\NewDocumentCommand\tzplotcurve_late_opt_fn { d() D<>{} } +%% \tzfnofyAtEnd +\NewDocumentCommand\tzfnofyAtEnd{ m } { - \IfValueTF { #1 } - { \edef\tztmpMarkSize { #1 } } - { \edef\tztmpMarkSize { \tz@initial@mark@size } } - \tl_put_right:Nn \l_tzplotcurve_code_at_end_tl { #2 } - \tzplotcurve_stop_action + \bool_gset_true:N \g_tzfnofy_END_cmd_bool + \tl_gset:No \g_tzfnofy_END_cmd_tl { #1 } } -\NewDocumentCommand\tzplotcurve_stop_action {} -{ - \renewcommand\tzmarksize{ \tztmpMarkSize } - % final action - \exp_last_unbraced:Nf - \draw - \l_tzplotcurve_opt_cmd_tl % [opt] plot [ smooth ] coordinates - { \l_tzplotcurve_coors_cmd_tl } % { (coor-1)(coor-2)...(coor-n) } - \l_tzplotcurve_code_at_end_tl % should precede _nodes_cmd_tl - \l_tzplotcurve_nodes_cmd_tl % (coor-i) node [opt] {text}, for all i - ; +%%% \tzfnofy (main) +%% (variable=\y) +\use:x{ + \NewDocumentCommand \exp_not:N \tzfnofy + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} + } } +{ + \tl_clear:N \l_tzfnofy_opt_tl + \tl_clear:N \l_tzfnofy_path_tl + \tl_clear:N \l_tzfnofy_TEMP_cmd_tl + \tl_clear:N \l_tzfnofy_cmd_tl -%%% --- end of \tzplotcurve + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + \tzfnofy_domain_process #6 -%%% \tzLFn -- plot Linear Function (LF) + \tl_set:No \l_label_pos_tl { \tl_to_str:n { #5 } } + \tl_set:No \l_tzfnofy_pathname_tl { \tl_tail:N \l_label_pos_tl } + \tl_put_right:Nx \l_tzfnofy_opt_tl + { + [ + samples = 201 , + name~path = + \tl_if_empty:nTF { #4 } { \l_tzfnofy_pathname_tl } { #4 } , + domain = \tzfnofyFromVal \c_colon_str \tzfnofyToVal , + shift = { (#3) } , + variable = \exp_not:n { \y } , + \exp_not:n { #2 } + ] + } -\bool_new:N \g_tzLFn_BEGIN_cmd_bool -\bool_new:N \g_tzLFn_END_cmd_bool + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:Nn \l_tzfnofy_path_tl + { plot ( \y , { #5 } ) } % \y should not be expanded + } + { + \tl_put_right:Nn \l_tzfnofy_path_tl + { plot ( { #5 } , \y ) } % \y should not be expanded + } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfnofy_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfnofy_TEMP_cmd_tl { \l_tzfnofy_opt_tl } + \tl_put_right:No \l_tzfnofy_TEMP_cmd_tl { \l_tzfnofy_path_tl } + \exp_last_unbraced:Nf \path \l_tzfnofy_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_opt_tl } + \tl_put_right:No \l_tzfnofy_cmd_tl { \g_tzfnofy_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfnofy_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_path_tl } + } + { + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_opt_tl } + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_path_tl } + } + \bool_if:NT \g_tzfnofy_END_cmd_bool + { + \tl_put_right:No \l_tzfnofy_cmd_tl { \g_tzfnofy_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfnofy_cmd_tl + { node [ #8 ] { #7 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzfnofy_cmd_tl #9 ; -%% \tzLFnAtBegin -\NewDocumentCommand\tzLFnAtBegin{ m } -{ - \bool_gset_true:N \g_tzLFn_BEGIN_cmd_bool - \tl_gset:No \g_tzLFn_BEGIN_cmd_tl { #1 } + \bool_gset_false:N \g_tzfnofy_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfnofy_END_cmd_bool } -%% \tzLFnAtEnd -\NewDocumentCommand\tzLFnAtEnd{ m } +\NewDocumentCommand\tzfnofy_domain_process{ m m } { - \bool_gset_true:N \g_tzLFn_END_cmd_bool - \tl_gset:No \g_tzLFn_END_cmd_tl { #1 } + \def\tzfnofyFromVal{#1} + \def\tzfnofyToVal{#2} } -%%% \tzLFn -%% \tzLFn : variable = \x (default) -%% \tzLFn': variable = \y +%%% --- end of \tzfnofy -\NewDocumentCommand \tzLFn { t' o D<>{0,0} d"" } -{ - \tl_clear:N \l_tzLFn_cmd_tl - \IfBooleanTF { #1 } - { \bool_set_true:N \l_tmpa_bool } - { \bool_set_false:N \l_tmpa_bool } - - \IfValueTF { #3 } - { - \tl_set:Nn \l_tzLFn_shift_tl - { shift = { (#3) } } - } - { \tl_clear:N \l_tzLFn_shift_tl } +%%% \tzfnmax +%% (variable=\x -- default) - \IfValueTF { #2 } - { \tl_set:Nn \l_tzLFn_opt_tl { #2 } } - { \tl_clear:N \l_tzLFn_opt_tl } - - \IfValueTF { #4 } - { \tl_set:Nn \l_tzLFn_namepath_tl { name~path = #4 } } - { \tl_clear:N \l_tzLFn_namepath_tl } - - \tzLFn_check_token:n +\bool_new:N \g_tzfnmax_BEGIN_cmd_bool +\bool_new:N \g_tzfnmax_END_cmd_bool + +%% \tzfnmaxAtBegin +\NewDocumentCommand\tzfnmaxAtBegin{ m } +{ + \bool_gset_true:N \g_tzfnmax_BEGIN_cmd_bool + \tl_gset:No \g_tzfnmax_BEGIN_cmd_tl { #1 } } -\cs_new:Npn \tzLFn_check_token:n #1 +%% \tzfnmaxAtEnd +\NewDocumentCommand\tzfnmaxAtEnd{ m } { - \str_if_eq:nnT { #1 } { ( } - { \tzLFn_sub_fn ( } + \bool_gset_true:N \g_tzfnmax_END_cmd_bool + \tl_gset:No \g_tzfnmax_END_cmd_tl { #1 } } + +%%% \tzfnmax (main) +%% (variable=\x) \use:x{ - \NewDocumentCommand \exp_not:N \tzLFn_sub_fn - { r() d() G{1} - >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] + G{} O{} D<>{} + \NewDocumentCommand \exp_not:N \tzfnmax + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} } } { - \tzLFn_domain_process #4 + \tl_clear:N \l_tzfnmax_opt_tl + \tl_clear:N \l_tzfnmax_path_tl + \tl_clear:N \l_tzfnmax_TEMP_cmd_tl + \tl_clear:N \l_tzfnmax_cmd_tl - \tl_put_right:Nx \l_tzLFn_cmd_tl - { - [ - \l_tzLFn_namepath_tl , - domain = \tzLFnFromVal \c_colon_str \tzLFnToVal , %%% [here?] -% samples = 200 , - \bool_if:NTF \l_tmpa_bool - { variable = \exp_not:n { \y } } - { variable = \exp_not:n { \x } } , - \l_tzLFn_shift_tl , - } - \tl_put_right:No \l_tzLFn_cmd_tl + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzfnmax_domain_process #6 + + \tl_put_right:Nx \l_tzfnmax_opt_tl { - \l_tzLFn_opt_tl + [ + thick , samples = 201 , + name~path = #4 , + domain = \tzfnmaxFromVal \c_colon_str \tzfnmaxToVal , + shift = { (#3) } , +% varialbe = \exp_not:n { \x } , + \exp_not:n { #2 } ] } - \bool_if:NT \g_tzLFn_BEGIN_cmd_bool - { \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_BEGIN_cmd_tl } } - - % define LF - \tzgetxyval(#1){\tzLFAval}{\tzLFBval} - \IfNoValueTF { #2 } + + \bool_if:NTF { \l_tmpa_bool } { - \bool_if:NTF \l_tmpa_bool - { \def\tzLFnDEF{#3*(\y-\tzLFBval)+\tzLFAval} } - { \def\tzLFnDEF{#3*(\x-\tzLFAval)+\tzLFBval} } + \tl_put_right:Nn \l_tzfnmax_path_tl + { plot ( { max(#5) } , \x ) } % \x should not be expanded } { - \tzgetxyval(#2){\tzLFAAval}{\tzLFBBval} - \bool_if:NTF \l_tmpa_bool + \tl_put_right:Nn \l_tzfnmax_path_tl + { plot ( \x , { max(#5) } ) } % \x should not be expanded + } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfnmax_BEGIN_cmd_bool { - \edef\tzLFSlope{(\tzLFAAval-\tzLFAval)/(\tzLFBBval-\tzLFBval)} - \def\tzLFnDEF{\tzLFSlope*(\y-\tzLFBval)+\tzLFAval} + \tl_put_right:No \l_tzfnmax_TEMP_cmd_tl { \l_tzfnmax_opt_tl } + \tl_put_right:No \l_tzfnmax_TEMP_cmd_tl { \l_tzfnmax_path_tl } + \exp_last_unbraced:Nf \path \l_tzfnmax_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_opt_tl } + \tl_put_right:No \l_tzfnmax_cmd_tl { \g_tzfnmax_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfnmax_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_path_tl } } { - \edef\tzLFSlope{(\tzLFBBval-\tzLFBval)/(\tzLFAAval-\tzLFAval)} - \def\tzLFnDEF{\tzLFSlope*(\x-\tzLFAval)+\tzLFBval} + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_opt_tl } + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_path_tl } } - } - - \bool_if:NTF \l_tmpa_bool - { - \tl_put_right:Nn \l_tzLFn_cmd_tl - { plot ( { \tzLFnDEF } , \y ) } % \y should not be expanded - } - { - \tl_put_right:Nn \l_tzLFn_cmd_tl - { plot ( \x , { \tzLFnDEF } ) } % \x should not be expanded - } - \bool_if:NT \g_tzLFn_END_cmd_bool - { \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_END_cmd_tl } } - \tl_put_right:Nn \l_tzLFn_cmd_tl - { node [ #6 ] { #5 } } + \bool_if:NT \g_tzfnmax_END_cmd_bool + { + \tl_put_right:No \l_tzfnmax_cmd_tl { \g_tzfnmax_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfnmax_cmd_tl + { node [ #8 ] { #7 } } % final action - \exp_last_unbraced:Nf \draw \l_tzLFn_cmd_tl #7 ; + \exp_last_unbraced:Nf \draw \l_tzfnmax_cmd_tl #9 ; - \bool_gset_false:N \g_tzLFn_BEGIN_cmd_bool - \bool_gset_false:N \g_tzLFn_END_cmd_bool + \bool_gset_false:N \g_tzfnmax_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfnmax_END_cmd_bool } -\NewDocumentCommand\tzLFn_domain_process{ m m } +\NewDocumentCommand\tzfnmax_domain_process{ m m } { - \def\tzLFnFromVal{#1} - \def\tzLFnToVal{#2} + \def\tzfnmaxFromVal{#1} + \def\tzfnmaxToVal{#2} } -%%% --- end of \tzLFn +%%% --- end of \tzfnmax -%% \tzfn (variable=\x -- default) -\bool_new:N \g_tzfn_BEGIN_cmd_bool -\bool_new:N \g_tzfn_END_cmd_bool +%%% \tzfnmin +%% (variable=\x -- default) -%% \tzfnAtBegin -\NewDocumentCommand\tzfnAtBegin{ m } +\bool_new:N \g_tzfnmin_BEGIN_cmd_bool +\bool_new:N \g_tzfnmin_END_cmd_bool + +%% \tzfnminAtBegin +\NewDocumentCommand\tzfnminAtBegin{ m } { - \bool_gset_true:N \g_tzfn_BEGIN_cmd_bool - \tl_gset:No \g_tzfn_BEGIN_cmd_tl { #1 } + \bool_gset_true:N \g_tzfnmin_BEGIN_cmd_bool + \tl_gset:No \g_tzfnmin_BEGIN_cmd_tl { #1 } } -%% \tzfnAtEnd -\NewDocumentCommand\tzfnAtEnd{ m } +%% \tzfnminAtEnd +\NewDocumentCommand\tzfnminAtEnd{ m } { - \bool_gset_true:N \g_tzfn_END_cmd_bool - \tl_gset:No \g_tzfn_END_cmd_tl { #1 } + \bool_gset_true:N \g_tzfnmin_END_cmd_bool + \tl_gset:No \g_tzfnmin_END_cmd_tl { #1 } } -%% \tzfn (variable=\x) -%% \tzfn' (variable=\y) -- equivalent to \tzfnofy + + +%%% \tzfnmin (main) +%% (variable=\x) \use:x{ - \NewDocumentCommand \exp_not:N \tzfn + \NewDocumentCommand \exp_not:N \tzfnmin { t' O{} D<>{0,0} D""{} m >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} } } { - \tl_clear:N \l_tzfn_cmd_tl + \tl_clear:N \l_tzfnmin_opt_tl + \tl_clear:N \l_tzfnmin_path_tl + \tl_clear:N \l_tzfnmin_TEMP_cmd_tl + \tl_clear:N \l_tzfnmin_cmd_tl \IfBooleanTF { #1 } { \bool_set_true:N \l_tmpa_bool } { \bool_set_false:N \l_tmpa_bool } - \tzfn_domain_process #6 + \tzfnmin_domain_process #6 - \tl_set:No \l_tmpa_tl { \tl_to_str:n { #5 } } - \tl_set:No \l_tzfn_pathname_tl { \tl_tail:N \l_tmpa_tl } - \tl_put_right:Nx \l_tzfn_cmd_tl +% \tl_set:No \l_label_pos_tl { \tl_to_str:n { #5 } } +% \tl_set:No \l_tzfnmin_pathname_tl { \tl_tail:N \l_label_pos_tl } + \tl_put_right:Nx \l_tzfnmin_opt_tl { [ - name~path = - \tl_if_empty:nTF { #4 } { \l_tzfn_pathname_tl } { #4 } , - domain = \tzfnFromVal \c_colon_str \tzfnToVal , - samples = 200 , + thick , samples = 201 , + name~path = #4 , +% \tl_if_empty:nTF { #4 } { } { #4 } , + domain = \tzfnminFromVal \c_colon_str \tzfnminToVal , shift = { (#3) } , - \bool_if:NTF \l_tmpa_bool - { variable = \exp_not:n { \y } } - { variable = \exp_not:n { \x } } , +% variable = \exp_not:n { \x } , \exp_not:n { #2 } ] } - \bool_if:NT \g_tzfn_BEGIN_cmd_bool - { \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_BEGIN_cmd_tl } } + \bool_if:NTF { \l_tmpa_bool } { - \tl_put_right:Nn \l_tzfn_cmd_tl - { plot ( { #5 } , \y ) } % \y should not be expanded + \tl_put_right:Nn \l_tzfnmin_path_tl + { plot ( { min(#5) } , \x ) } % \x should not be expanded } { - \tl_put_right:Nn \l_tzfn_cmd_tl - { plot ( \x , { #5 } ) } % \x should not be expanded + \tl_put_right:Nn \l_tzfnmin_path_tl + { plot ( \x , { min(#5) } ) } % \x should not be expanded } - \bool_if:NT \g_tzfn_END_cmd_bool - { \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_END_cmd_tl } } - \tl_put_right:Nn \l_tzfn_cmd_tl + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfnmin_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfnmin_TEMP_cmd_tl { \l_tzfnmin_opt_tl } + \tl_put_right:No \l_tzfnmin_TEMP_cmd_tl { \l_tzfnmin_path_tl } + \exp_last_unbraced:Nf \path \l_tzfnmin_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_opt_tl } + \tl_put_right:No \l_tzfnmin_cmd_tl { \g_tzfnmin_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfnmin_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_path_tl } + } + { + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_opt_tl } + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_path_tl } + } + \bool_if:NT \g_tzfnmin_END_cmd_bool + { + \tl_put_right:No \l_tzfnmin_cmd_tl { \g_tzfnmin_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfnmin_cmd_tl { node [ #8 ] { #7 } } % final action - \exp_last_unbraced:Nf \draw \l_tzfn_cmd_tl #9 ; + \exp_last_unbraced:Nf \draw \l_tzfnmin_cmd_tl #9 ; - \bool_gset_false:N \g_tzfn_BEGIN_cmd_bool - \bool_gset_false:N \g_tzfn_END_cmd_bool + \bool_gset_false:N \g_tzfnmin_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfnmin_END_cmd_bool } -\NewDocumentCommand\tzfn_domain_process{ m m } +\NewDocumentCommand\tzfnmin_domain_process{ m m } { - \def\tzfnFromVal{#1} - \def\tzfnToVal{#2} + \def\tzfnminFromVal{#1} + \def\tzfnminToVal{#2} } -%%% --- end of \tzfn +%%% --- end of \tzfnmin + + +%%% pdf + +%% normal distribution + +\NewExpandableDocumentCommand\tzpdfN{ s m m } +{ + \IfBooleanTF { #1 } + { % standard deviation + 1/(#3*sqrt(2*pi))*exp( -1/2*( (\exp_not:n{\x}-#2)^2 / (#3)^2 ) ) + } + { % variance (default) + 1/(sqrt(#3)*sqrt(2*pi))*exp(-1/2*((\exp_not:n{\x}-#2)^2/(sqrt(#3))^2)) + } +} + + +%% standard normal distribution + +\NewExpandableDocumentCommand\tzpdfZ{ } +{ +% \IfBooleanTF { #1 } {}{} % NOT USED! (to avoid coding error) + 1/sqrt(2*pi)*exp( -1/2*( \exp_not:n{\x} )^2 ) +} + + + +%%% \tzfnarea +%% no shift, no name path + +\use:x{ + \NewDocumentCommand \exp_not:N \tzfnarea + { s O{} m >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] G{.3} D<>{} } +} +{ + \tl_clear:N \l_tzfnarea_cmd_tl + + \tl_if_empty:nTF { #5 } + { \renewcommand\tzfillopacity{\tz@initial@fill@opacity} } + { \renewcommand\tzfillopacity{#5} } + + \tzfnarea_domain_process #4 + + % collect fill options + \IfBooleanTF { #1 } + { + \tl_put_right:Nx \l_tzfnarea_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , \exp_not:n { #2 } ] + } + } + { + \tl_put_right:Nn \l_tzfnarea_cmd_tl + { [ #2 ] } + } + + + \tl_put_right:Nx \l_tzfnarea_cmd_tl + { + (\tzfnareaFromVal,0) -- plot + [ samples = 201 , + domain = \tzfnareaFromVal \c_colon_str \tzfnareaToVal , +% variable = \exp_not:n { \x } , + ] + } + \tl_put_right:No \l_tzfnarea_cmd_tl + { + ( \exp_not:n { \x } , { #3 } ) -- (\tzfnareaToVal,0) + } + + % final action + \begin{pgfonlayer}{ \tzfnarealayer } % default = behind + \exp_last_unbraced:Nf + \path \l_tzfnarea_cmd_tl #6 ; + \end{pgfonlayer} +} + +\NewDocumentCommand\tzfnarea_domain_process{ m m } +{ + \def\tzfnareaFromVal{#1} + \def\tzfnareaToVal{#2} +} + +%%% --- end of \tzfnarea + + +\NewDocumentCommand\tzfnarealine{ t' O{} m m O{} D(){0,0} g O{} D(){0,0} } +{ + \tzvXpointat{#3}{#4}(tzfnAL) + + \IfBooleanTF { #1 } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAL) (tzfnAL -| #6) + \end{pgfonlayer} + } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAL) (tzfnAL |- #6) + \end{pgfonlayer} + } + + \IfValueT { #7 } + { + \tzvXpointat{#3}{#7}(tzfnAR) + + \IfBooleanTF { #1 } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAR) (tzfnAR -| #9) + \end{pgfonlayer} + } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAR) (tzfnAR|-#9) + \end{pgfonlayer} + } + } +} + + -%% \tzvfnat +%%% \tzvfnat +%% -- vertical line at x + +\bool_new:N \g_tzvfnat_BEGIN_cmd_bool +\bool_new:N \g_tzvfnat_END_cmd_bool + +%% \tzvfnatAtBegin +\NewDocumentCommand\tzvfnatAtBegin{ m } +{ + \bool_gset_true:N \g_tzvfnat_BEGIN_cmd_bool + \tl_gset:No \g_tzvfnat_BEGIN_cmd_tl { #1 } +} + +%% \tzvfnatAtEnd +\NewDocumentCommand\tzvfnatAtEnd{ m } +{ + \bool_gset_true:N \g_tzvfnat_END_cmd_bool + \tl_gset:No \g_tzvfnat_END_cmd_tl { #1 } +} + +%% \tzvfnat (main) \use:x{ \NewDocumentCommand \exp_not:N \tzvfnat { O{} D<>{0,0} D""{} m @@ -3157,12 +5868,14 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzvfnat_cmd_tl { [ +% samples = 201 , name~path = #3 , shift = { (#2) } , -% samples = 200 , \exp_not:n { #1 } ] } + \bool_if:NT \g_tzvfnat_BEGIN_cmd_bool + { \tl_put_right:No \l_tzvfnat_cmd_tl { \g_tzvfnat_BEGIN_cmd_tl } } \IfValueTF { #5 } { \tl_put_right:Nn \l_tzvfnat_cmd_tl @@ -3175,10 +5888,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) -- (#4,0 |- current~bounding~box.north) } } + \bool_if:NT \g_tzvfnat_END_cmd_bool + { \tl_put_right:No \l_tzvfnat_cmd_tl { \g_tzvfnat_END_cmd_tl } } \tl_put_right:Nn \l_tzvfnat_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzvfnat_cmd_tl #8 ; + + \bool_gset_false:N \g_tzvfnat_BEGIN_cmd_bool + \bool_gset_false:N \g_tzvfnat_END_cmd_bool } \NewDocumentCommand\tzvfnat_domain_process{ m m } @@ -3190,10 +5908,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzvfnat -%%% \tzvfn (On) -- vertical line through (x,y) +%%% \tzvfn (On) +%% -- vertical line through (x,y) + +\bool_new:N \g_tzvfn_BEGIN_cmd_bool +\bool_new:N \g_tzvfn_END_cmd_bool + +%% \tzvfnAtBegin +\NewDocumentCommand\tzvfnAtBegin{ m } +{ + \bool_gset_true:N \g_tzvfn_BEGIN_cmd_bool + \tl_gset:No \g_tzvfn_BEGIN_cmd_tl { #1 } +} +%% \tzvfnAtEnd +\NewDocumentCommand\tzvfnAtEnd{ m } +{ + \bool_gset_true:N \g_tzvfn_END_cmd_bool + \tl_gset:No \g_tzvfn_END_cmd_tl { #1 } +} -%%% \tzvfn +%%% \tzvfn (main) \use:x{ \NewDocumentCommand \exp_not:N \tzvfn { O{} d<> D""{} r() @@ -3212,6 +5947,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \exp_not:n { #1 } ] } + \bool_if:NT \g_tzvfn_BEGIN_cmd_bool + { \tl_put_right:No \l_tzvfn_cmd_tl { \g_tzvfn_BEGIN_cmd_tl } } \IfValueTF { #5 } { \IfValueTF { #2 } @@ -3243,10 +5980,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } } + \bool_if:NT \g_tzvfn_END_cmd_bool + { \tl_put_right:No \l_tzvfn_cmd_tl { \g_tzvfn_END_cmd_tl } } \tl_put_right:Nn \l_tzvfn_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzvfn_cmd_tl #8 ; + + \bool_gset_false:N \g_tzvfn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzvfn_END_cmd_bool } \NewDocumentCommand\tzvfn_domain_process{ m m } @@ -3258,7 +6000,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzvfn -%% \tzhfnat +%%% \tzhfnat +%% -- horizontal line at y + +\bool_new:N \g_tzhfnat_BEGIN_cmd_bool +\bool_new:N \g_tzhfnat_END_cmd_bool + +%% \tzhfnatAtBegin +\NewDocumentCommand\tzhfnatAtBegin{ m } +{ + \bool_gset_true:N \g_tzhfnat_BEGIN_cmd_bool + \tl_gset:No \g_tzhfnat_BEGIN_cmd_tl { #1 } +} + +%% \tzhfnatAtEnd +\NewDocumentCommand\tzhfnatAtEnd{ m } +{ + \bool_gset_true:N \g_tzhfnat_END_cmd_bool + \tl_gset:No \g_tzhfnat_END_cmd_tl { #1 } +} + +%% \tzhfnat (main) \use:x{ \NewDocumentCommand \exp_not:N \tzhfnat { O{} D<>{0,0} D""{} m @@ -3279,6 +6041,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \exp_not:n { #1 } ] } + \bool_if:NT \g_tzhfnat_BEGIN_cmd_bool + { \tl_put_right:No \l_tzhfnat_cmd_tl { \g_tzhfnat_BEGIN_cmd_tl } } \IfValueTF { #5 } { \tl_put_right:Nn \l_tzhfnat_cmd_tl @@ -3291,10 +6055,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) -- (0,#4 -| current~bounding~box.east) } } + \bool_if:NT \g_tzhfnat_END_cmd_bool + { \tl_put_right:No \l_tzhfnat_cmd_tl { \g_tzhfnat_END_cmd_tl } } \tl_put_right:Nn \l_tzhfnat_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzhfnat_cmd_tl #8 ; + + \bool_gset_false:N \g_tzhfnat_BEGIN_cmd_bool + \bool_gset_false:N \g_tzhfnat_END_cmd_bool } \NewDocumentCommand\tzhfnat_domain_process{ m m } @@ -3306,9 +6075,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzhfnat -%%% \tzhfn (On) -- horizontal line through (x,y) +%%% \tzhfn (On) +%% -- horizontal line through (x,y) + +\bool_new:N \g_tzhfn_BEGIN_cmd_bool +\bool_new:N \g_tzhfn_END_cmd_bool + +%% \tzhfnAtBegin +\NewDocumentCommand\tzhfnAtBegin{ m } +{ + \bool_gset_true:N \g_tzhfn_BEGIN_cmd_bool + \tl_gset:No \g_tzhfn_BEGIN_cmd_tl { #1 } +} + +%% \tzhfnAtEnd +\NewDocumentCommand\tzhfnAtEnd{ m } +{ + \bool_gset_true:N \g_tzhfn_END_cmd_bool + \tl_gset:No \g_tzhfn_END_cmd_tl { #1 } +} -%% \tzhfn +%% \tzhfn (main) \use:x{ \NewDocumentCommand \exp_not:N \tzhfn { O{} d<> D""{} r() @@ -3328,6 +6115,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \exp_not:n { #1 } ] } + \bool_if:NT \g_tzhfn_BEGIN_cmd_bool + { \tl_put_right:No \l_tzhfn_cmd_tl { \g_tzhfn_BEGIN_cmd_tl } } \IfValueTF { #5 } { \IfValueTF { #2 } @@ -3363,10 +6152,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } } + \bool_if:NT \g_tzhfn_END_cmd_bool + { \tl_put_right:No \l_tzhfn_cmd_tl { \g_tzhfn_END_cmd_tl } } \tl_put_right:Nn \l_tzhfn_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzhfn_cmd_tl #8 ; + + \bool_gset_false:N \g_tzhfn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzhfn_END_cmd_bool } \NewDocumentCommand\tzhfn_domain_process{ m m } @@ -3382,44 +6176,176 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzXpoint -- intersection point of two paths \NewDocumentCommand\tzXpoint - { s O{} m m D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } + { s O{} m m D(){intersection} O{1} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzXpoint_cmd_tl +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \path [ name~intersections = { of = #3 ~ and ~ #4 , name = #5 } ] ; \tl_put_right:Nn \l_tzXpoint_cmd_tl { - (#5-#6) coordinate (#5) + (#5-#6) coordinate (#5) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzXpoint_cmd_tl + { + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str + } + + \tl_put_right:Nn \l_tzXpoint_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \path \l_tzXpoint_cmd_tl ; +} + +%%% --- end of \tzXpoint + + +%%% \tzLFnXpoint : linear Xpoint +\NewDocumentCommand\tzLFnXpoint + { s O{} m m o D(){} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzLFnXpoint_cmd_tl + +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + + \IfValueTF { #5 } + { + \def\x{#5} + \path (\x,{#3}) coordinate (tzLFnXA-1) (\x,{#4}) coordinate (tzLFnXB-1); + \def\x{\fp_eval:n {1.01*#5+.1}} + \path (\x,{#3}) coordinate (tzLFnXA-2) (\x,{#4}) coordinate (tzLFnXB-2); + } + { + \def\x{0} + \path (\x,{#3}) coordinate (tzLFnXA-1) (\x,{#4}) coordinate (tzLFnXB-1); + \def\x{.1} + \path (\x,{#3}) coordinate (tzLFnXA-2) (\x,{#4}) coordinate (tzLFnXB-2); + } + + \tl_put_right:Nn \l_tzLFnXpoint_cmd_tl + { + (intersection~of~tzLFnXA-1--tzLFnXA-2 ~and~ tzLFnXB-1--tzLFnXB-2) + coordinate (#6) \IfBooleanTF {#1} { node [ tzdot , fill , minimum~size = #9 , } { node [ tzdot , draw = none , minimum~size = 0pt , } } - \tl_put_right:Nx \l_tzXpoint_cmd_tl + \tl_put_right:Nx \l_tzLFnXpoint_cmd_tl { - label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str } - \tl_put_right:Nn \l_tzXpoint_cmd_tl + \tl_put_right:Nn \l_tzLFnXpoint_cmd_tl { #2 ] {} } - \exp_last_unbraced:Nf \path \l_tzXpoint_cmd_tl ; + \exp_last_unbraced:Nf \draw \l_tzLFnXpoint_cmd_tl ; } -%%% --- end of \tzXpoint +%%% --- end of \tzLFnXpoint %%% \tzvXpointat -- vertical intersection point at x %%% *[]{}()()[]{