| 1 |
% Copyright 2024 by Qrrbrbirlbel |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Free Documentation License. |
| 7 |
% |
| 8 |
|
| 9 |
\unless\ifcsname tikzextset\endcsname |
| 10 |
\input tikzext-util.tex |
| 11 |
\fi |
| 12 |
|
| 13 |
|
| 14 |
% \tikzext@arrow@evalshift |
| 15 |
% |
| 16 |
% Stores the shift amount into \tikzext@arrow@shift@ |
| 17 |
% |
| 18 |
\def\tikzext@arrow@evalshift#1#2#3{% |
| 19 |
\pgf@arrow@compute@shortening#1% |
| 20 |
\ifcase\pgfkeysvalueof{/tikz/ext/arrow/shift mode}\relax |
| 21 |
\def#3{0pt}% |
| 22 |
\or |
| 23 |
\pgfmathsetlengthmacro#3% |
| 24 |
{(\pgfkeysvalueof{/tikz/ext/arrow shift factor #2})*-\pgf@xb}% |
| 25 |
\or |
| 26 |
\pgfmathsetlengthmacro#3% |
| 27 |
{(\pgfkeysvalueof{/tikz/ext/arrow shift factor #2})*-\pgf@xa}% |
| 28 |
\fi |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
% For bended arrows the shifting can't simply be done by a transformation |
| 33 |
\def\tikzext@arrow@sneak#1\pgf@stop#2#3{% TODO |
| 34 |
\unless\ifdim#3=0pt |
| 35 |
\def#2{#1\pgf@arrow@handle{_}{\pgfarrowsep=#3\relax}}% |
| 36 |
\fi |
| 37 |
} |
| 38 |
|
| 39 |
% |
| 40 |
% Arrow keys |
| 41 |
% |
| 42 |
\pgfkeysdef{/tikz/ext/pos > angle}{% |
| 43 |
\pgfkeysvalueof{/tikz/pos/.@cmd}(#1-\tikz@timer@start@angle)/(\tikz@timer@end@angle-\tikz@timer@start@angle)\pgfeov} |
| 44 |
\tikzextset{% |
| 45 |
every softpath arrows/.code= |
| 46 |
\pgfkeysdef{/tikz/pos >}{\pgfkeysvalueof{/tikz/pos/.@cmd}##1\pgfeov}% |
| 47 |
\pgfkeysdef{/tikz/pos <}{\pgfkeyssetvalue{/tikz/ext/pos <}{##1}}, |
| 48 |
every arc arrows/.code= |
| 49 |
\pgfkeysdef{/tikz/pos > angle}{\pgfkeysvalueof{/tikz/ext/pos > angle/.@cmd}##1\pgfeov}% |
| 50 |
\pgfkeysdef{/tikz/pos < angle}{\pgfkeysvalueof{/tikz/ext/pos < angle/.@cmd}##1\pgfeov}% |
| 51 |
\pgfkeysdef{/tikz/pos >}{\pgfkeysvalueof{/tikz/pos/.@cmd}##1\pgfeov}% |
| 52 |
\pgfkeysdef{/tikz/pos <}{\pgfkeyssetvalue{/tikz/ext/pos <}{##1}}, |
| 53 |
pos < angle/.code=\pgfkeyssetvalue{/tikz/ext/pos <}{(#1-\tikz@timer@start@angle)/(\tikz@timer@end@angle-\tikz@timer@start@angle)}, |
| 54 |
softpath arrows/.default=, |
| 55 |
softpath arrows/.code={% |
| 56 |
\begingroup |
| 57 |
\tikzset{ext/every softpath arrows,#1}% |
| 58 |
\pgfsyssoftpath@getcurrentpath\tikz@temp |
| 59 |
\pgfprocesssplitsubpath\tikz@temp |
| 60 |
\expandafter\pgf@parse@end\pgfprocessresultsubpathsuffix\pgf@stop\pgf@stop\pgf@stop |
| 61 |
\tikzext@arrow@softpath@curve |
| 62 |
\setbox\tikz@whichbox=\hbox\bgroup |
| 63 |
\unhbox\tikz@whichbox |
| 64 |
\hbox\bgroup\bgroup |
| 65 |
\pgfinterruptpath |
| 66 |
\pgfscope |
| 67 |
\pgfutil@ifxempty\pgf@start@tip@sequence{}{% |
| 68 |
\tikzext@arrow@evalshift\pgf@start@tip@sequence{start}\tikzext@arrow@shift@start |
| 69 |
\expandafter\tikzext@arrow@sneak\pgf@start@tip@sequence\pgf@stop\pgf@start@tip@sequence\tikzext@arrow@shift@start |
| 70 |
}% |
| 71 |
\pgfutil@ifxempty\pgf@end@tip@sequence{}{% |
| 72 |
\tikzext@arrow@evalshift\pgf@end@tip@sequence{end}\tikzext@arrow@shift@end |
| 73 |
\expandafter\tikzext@arrow@sneak\pgf@end@tip@sequence\pgf@stop\pgf@end@tip@sequence\tikzext@arrow@shift@end |
| 74 |
}% |
| 75 |
\pgfset{tips}% |
| 76 |
\pgftransformreset |
| 77 |
\tikzext@arrow@softpath |
| 78 |
\pgfusepath{}% |
| 79 |
\endpgfscope |
| 80 |
\endpgfinterruptpath |
| 81 |
\egroup\egroup |
| 82 |
\egroup |
| 83 |
\global\setbox\tikz@tempbox=\box\tikz@whichbox% |
| 84 |
\expandafter\endgroup% |
| 85 |
\expandafter\setbox\tikz@whichbox=\box\tikz@tempbox% |
| 86 |
}, |
| 87 |
arc arrows/.default=, |
| 88 |
arc arrows/.code={% |
| 89 |
\ifx\tikz@timer\tikz@timer@arc |
| 90 |
\begingroup |
| 91 |
\tikzset{ext/every arc arrows,#1}% |
| 92 |
\setbox\tikz@whichbox=\hbox\bgroup |
| 93 |
\unhbox\tikz@whichbox |
| 94 |
\hbox\bgroup\bgroup |
| 95 |
\pgfinterruptpath |
| 96 |
\pgfscope |
| 97 |
\pgfutil@ifxempty\pgf@start@tip@sequence{}{% |
| 98 |
\tikzext@arrow@evalshift\pgf@start@tip@sequence{start}\tikzext@arrow@shift@start |
| 99 |
\expandafter\tikzext@arrow@sneak\pgf@start@tip@sequence\pgf@stop\pgf@start@tip@sequence\tikzext@arrow@shift@start |
| 100 |
}% |
| 101 |
\pgfutil@ifxempty\pgf@end@tip@sequence{}{% |
| 102 |
\tikzext@arrow@evalshift\pgf@end@tip@sequence{end}\tikzext@arrow@shift@end |
| 103 |
\expandafter\tikzext@arrow@sneak\pgf@end@tip@sequence\pgf@stop\pgf@end@tip@sequence\tikzext@arrow@shift@end |
| 104 |
}% |
| 105 |
\pgfset{tips}% |
| 106 |
\tikzext@arrow@arcpath |
| 107 |
\pgfusepath{}% |
| 108 |
\endpgfscope |
| 109 |
\endpgfinterruptpath |
| 110 |
\egroup\egroup |
| 111 |
\egroup |
| 112 |
\global\setbox\tikz@tempbox=\box\tikz@whichbox |
| 113 |
\expandafter\endgroup |
| 114 |
\expandafter\setbox\tikz@whichbox=\box\tikz@tempbox |
| 115 |
\else |
| 116 |
\pgfutil@packagewarning{tikz-ext} |
| 117 |
{arc arrow used on non-arc path segment, using ``softpath arrows'' instead}% |
| 118 |
\tikzset{ext/softpath arrows={#1}}% |
| 119 |
\fi |
| 120 |
}, |
| 121 |
pos </.initial=0.0, |
| 122 |
pos >/.style={/tikz/pos={#1}}, |
| 123 |
arrow shift mode/.is choice, |
| 124 |
arrow shift mode/off/.code =\pgfkeyssetvalue{/tikz/ext/arrow/shift mode}{0}, |
| 125 |
arrow shift mode/total length/.code =\pgfkeyssetvalue{/tikz/ext/arrow/shift mode}{1}, |
| 126 |
arrow shift mode/total/.code =\pgfkeyssetvalue{/tikz/ext/arrow/shift mode}{1}, |
| 127 |
arrow shift mode/length until line end/.code=\pgfkeyssetvalue{/tikz/ext/arrow/shift mode}{2}, |
| 128 |
arrow shift mode/line end/.code =\pgfkeyssetvalue{/tikz/ext/arrow/shift mode}{2}, |
| 129 |
arrow shift mode=total length, |
| 130 |
arrow shift factor/.code=\pgfkeyssetvalue{/tikz/ext/arrow shift factor start}{#1}% |
| 131 |
\pgfkeyssetvalue{/tikz/ext/arrow shift factor end}{#1}, |
| 132 |
arrow shift factor start/.initial=.5, |
| 133 |
arrow shift factor end/.initial=.5 |
| 134 |
} |
| 135 |
% |
| 136 |
% Arrow pics |
| 137 |
% |
| 138 |
\tikzset{ |
| 139 |
pics/ext/arrow/.default=, |
| 140 |
pics/ext/arrow/.style={ |
| 141 |
/tikz/sloped, /tikz/allow upside down, |
| 142 |
foreground code=, background code=, setup code=, |
| 143 |
code=% |
| 144 |
\edef\tikzext@temp{#1}% |
| 145 |
\pgfutil@ifxempty\tikzext@temp{}{% |
| 146 |
\pgfsetarrowsend{#1}% |
| 147 |
}% |
| 148 |
\tikzext@arrow@evalshift\pgf@end@tip@sequence{end}\tikzext@arrow@shift@end |
| 149 |
\pgftransformxshift{+-\tikzext@arrow@shift@end}% |
| 150 |
\pgf@arrow@draw@arrow\pgf@end@tip@sequence\pgf@xb |
| 151 |
}, |
| 152 |
pics/ext/softpath arrow/.default=, |
| 153 |
pics/ext/softpath arrow/.code={% |
| 154 |
\let\pgf@start@tip@sequence\pgfutil@empty |
| 155 |
\edef\tikzext@temp{#1}% |
| 156 |
\pgfutil@ifxempty\tikzext@temp{}{% |
| 157 |
\pgfsetarrowsend{#1}% |
| 158 |
}% |
| 159 |
\pgfqkeys{/tikz/pics}{ext/softpath arrows}% |
| 160 |
}, |
| 161 |
pics/ext/softpath arrows/.default=, |
| 162 |
pics/ext/softpath arrows/.style={ |
| 163 |
foreground code=, background code=, |
| 164 |
setup code={% |
| 165 |
\edef\tikzext@temp{#1}% |
| 166 |
\pgfutil@ifxempty\tikzext@temp{}{% |
| 167 |
\pgfsetarrows{#1}% |
| 168 |
}% |
| 169 |
\pgfutil@ifxempty\pgf@start@tip@sequence{}{% |
| 170 |
\tikzext@arrow@evalshift\pgf@start@tip@sequence{start}\tikzext@arrow@shift@start |
| 171 |
\expandafter\tikzext@arrow@sneak\pgf@start@tip@sequence\pgf@stop\pgf@start@tip@sequence\tikzext@arrow@shift@start |
| 172 |
}% |
| 173 |
\pgfutil@ifxempty\pgf@end@tip@sequence{}{% |
| 174 |
\tikzext@arrow@evalshift\pgf@end@tip@sequence{end}\tikzext@arrow@shift@end |
| 175 |
\expandafter\tikzext@arrow@sneak\pgf@end@tip@sequence\pgf@stop\pgf@end@tip@sequence\tikzext@arrow@shift@end |
| 176 |
}% |
| 177 |
\pgfsyssoftpath@getcurrentpath\tikz@temp |
| 178 |
\pgfprocesssplitsubpath\tikz@temp |
| 179 |
\expandafter\pgf@parse@end\pgfprocessresultsubpathsuffix\pgf@stop\pgf@stop\pgf@stop |
| 180 |
\tikzext@arrow@softpath@curve |
| 181 |
}, |
| 182 |
code=% |
| 183 |
\pgfset{tips}% |
| 184 |
\pgftransformreset |
| 185 |
\tikzext@arrow@softpath |
| 186 |
\pgfusepath{}% |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
% curve |
| 191 |
\def\tikzext@arrow@softpath@curve{% |
| 192 |
\ifx\pgfpointthirdlastonpath\relax |
| 193 |
\let\tikzext@arrow@softpath\tikzext@arrow@linepath |
| 194 |
\else |
| 195 |
\let\tikzext@arrow@softpath\tikzext@arrow@curvepath |
| 196 |
\fi |
| 197 |
} |
| 198 |
% |
| 199 |
% Paths |
| 200 |
% |
| 201 |
% Line |
| 202 |
\def\tikzext@arrow@linepath{% |
| 203 |
\pgfpathmoveto{% |
| 204 |
\pgfpointlineattime |
| 205 |
{\pgfkeysvalueof{/tikz/ext/pos <}} |
| 206 |
{\pgfpointsecondlastonpath} |
| 207 |
{\pgfpointlastonpath}% |
| 208 |
}% |
| 209 |
\pgfpathlineto{% |
| 210 |
\pgfpointlineattime |
| 211 |
{\tikz@time} |
| 212 |
{\pgfpointsecondlastonpath} |
| 213 |
{\pgfpointlastonpath}% |
| 214 |
}% |
| 215 |
} |
| 216 |
% Curve |
| 217 |
\def\tikzext@arrow@curvepath{% |
| 218 |
\pgfpathcurvebetweentime |
| 219 |
{\pgfkeysvalueof{/tikz/ext/pos <}} |
| 220 |
{\tikz@time} |
| 221 |
{\pgfpointfourthlastonpath} |
| 222 |
{\pgfpointthirdlastonpath} |
| 223 |
{\pgfpointsecondlastonpath} |
| 224 |
{\pgfpointlastonpath}% |
| 225 |
} |
| 226 |
|
| 227 |
\def\tikzext@arrow@arcpath{% |
| 228 |
\pgfmathcos@{\tikz@timer@start@angle}% |
| 229 |
\let\tikz@angle@cos\pgfmathresult |
| 230 |
\pgfmathsin@{\tikz@timer@start@angle}% |
| 231 |
\let\tikz@angle@sin\pgfmathresult |
| 232 |
\pgfpathmoveto{% |
| 233 |
\pgfpointarcaxesattime |
| 234 |
{\pgfkeysvalueof{/tikz/ext/pos <}} |
| 235 |
{\pgfpointdiff{% |
| 236 |
\pgfpointadd{\pgfpointscale{\tikz@angle@cos}{\tikz@timer@zero@axis}} |
| 237 |
{\pgfpointscale{\tikz@angle@sin}{\tikz@timer@ninety@axis}}}{\tikz@timer@start}} |
| 238 |
{\tikz@timer@zero@axis} |
| 239 |
{\tikz@timer@ninety@axis} |
| 240 |
{\tikz@timer@start@angle} |
| 241 |
{\tikz@timer@end@angle}% |
| 242 |
}% |
| 243 |
\pgfpatharcaxes |
| 244 |
{(\tikz@timer@end@angle-\tikz@timer@start@angle)*% |
| 245 |
(\pgfkeysvalueof{/tikz/ext/pos <})+\tikz@timer@start@angle} |
| 246 |
{(\tikz@timer@end@angle-\tikz@timer@start@angle)*% |
| 247 |
(\tikz@time)+\tikz@timer@start@angle} |
| 248 |
{\tikz@timer@zero@axis} |
| 249 |
{\tikz@timer@ninety@axis}% |
| 250 |
} |
| 251 |
% |
| 252 |
% \arrow(reversed)*(*) macro for decoration.markings |
| 253 |
% |
| 254 |
\def\pgf@lib@dec@doarrowhead{% |
| 255 |
\pgfutil@ifnextchar*% |
| 256 |
{\tikzext@lib@dec@doarrowhead{1}} |
| 257 |
{\pgfutil@ifnextchar[% |
| 258 |
{\tikz@lib@dec@doarrowhead} |
| 259 |
{\tikz@lib@dec@doarrowhead[]}% |
| 260 |
}% |
| 261 |
} |
| 262 |
\def\pgf@lib@dec@doarrowheadrev{% |
| 263 |
\pgfutil@ifnextchar*% |
| 264 |
{\tikzext@lib@dec@doarrowhead{-1}} |
| 265 |
{\pgfutil@ifnextchar[% |
| 266 |
{\tikz@lib@dec@doarrowheadrev} |
| 267 |
{\tikz@lib@dec@doarrowheadrev[]}% |
| 268 |
}% |
| 269 |
} |
| 270 |
|
| 271 |
\def\tikzext@lib@dec@doarrowhead#1*{% |
| 272 |
\pgfutil@ifnextchar*% |
| 273 |
{\tikzext@lib@dec@doarrowhead@@{#1}} |
| 274 |
{\pgfutil@ifnextchar[% |
| 275 |
{\tikzext@lib@dec@doarrowhead@{#1}} |
| 276 |
{\tikzext@lib@dec@doarrowhead@{#1}[]}}% |
| 277 |
} |
| 278 |
\def\tikzext@lib@dec@doarrowhead@#1[#2]#3{% |
| 279 |
\scope[{#2}]% |
| 280 |
\pgfsetarrowsend{#3}% |
| 281 |
\pgfutil@ifxempty\pgf@end@tip@sequence{}{% |
| 282 |
\tikzext@arrow@evalshift\pgf@end@tip@sequence{end}\tikzext@arrow@shift@end |
| 283 |
\pgftransformxscale{#1}% |
| 284 |
\pgftransformxshift{+-\tikzext@arrow@shift@end}% |
| 285 |
\pgf@arrow@draw@arrow\pgf@end@tip@sequence\pgf@xb |
| 286 |
}% |
| 287 |
\endscope |
| 288 |
} |
| 289 |
\def\tikzext@lib@dec@doarrowhead@@#1*{% |
| 290 |
\pgfutil@ifnextchar[%] |
| 291 |
{\tikzext@lib@dec@doarrowhead@@@{#1}} |
| 292 |
{\tikzext@lib@dec@doarrowhead@@@{#1}[]}% |
| 293 |
} |
| 294 |
|
| 295 |
\def\tikzext@lib@dec@doarrowhead@@@#1[#2]#3{% |
| 296 |
\ifx\pgfdecorationcurrentinputsegment\pgfdecorationinputsegmentcurveto |
| 297 |
\pgftransformreset |
| 298 |
\pgfset{tips}% |
| 299 |
\ifnum#1<0 |
| 300 |
\pgfsetarrows{[reversed]}% |
| 301 |
\fi |
| 302 |
\scope[{#2}]% |
| 303 |
\pgfsetarrowsend{#3}% |
| 304 |
\pgfutil@ifxempty\pgf@end@tip@sequence{}{% |
| 305 |
\tikzext@arrow@evalshift\pgf@end@tip@sequence{end}\tikzext@arrow@shift@end |
| 306 |
\expandafter\tikzext@arrow@sneak\pgf@end@tip@sequence\pgf@stop\pgf@end@tip@sequence\tikzext@arrow@shift@end |
| 307 |
\ifdim\pgf@decorate@inputsegmenttime pt=1pt % something weird for 1.0 |
| 308 |
\def\pgf@decorate@inputsegmenttime{1}% |
| 309 |
\fi |
| 310 |
\ifdim\pgf@decorate@inputsegmenttime pt<0.05pt % zero is bad |
| 311 |
\def\pgf@decorate@inputsegmenttime{0.05}% |
| 312 |
\fi |
| 313 |
\pgfpathcurvebetweentime{0}{\pgf@decorate@inputsegmenttime}% |
| 314 |
{\pgf@decorate@inputsegment@first}{\pgf@decorate@inputsegment@supporta}% |
| 315 |
{\pgf@decorate@inputsegment@supportb}{\pgf@decorate@inputsegment@last}% |
| 316 |
\pgfusepath{}% |
| 317 |
}% |
| 318 |
\endscope |
| 319 |
\else |
| 320 |
\tikzext@lib@dec@doarrowhead@{#1}[{#2}]{#3}% |
| 321 |
\fi |
| 322 |
} |
| 323 |
\endinput |