Debian Codegraph @

texmf-dist/tex/generic/tikz-ext/tikzlibraryext.paths.timer.code.tex

raw
1 % Copyright 2022 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 \def\tikz@rectB#1{% originally from tikz.code.tex
14 \tikz@make@last@position{#1}%
15 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
16 \let\tikz@timer\tikz@timer@rectangle% %% Timer: new timer
17 \tikz@@movetosave{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
18 \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\tikz@lasty}}%
19 \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
20 \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@ya}}%
21 \iftikz@snaked
22 \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
23 \fi
24 \pgfpathclose
25 \tikz@@movetosave{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
26 \def\pgfstrokehook{}%
27 \let\tikz@tangent\relax
28 \tikz@scan@next@command
29 }%
30
31 \def\tikz@@sine#1{% originally from tikz.code.tex
32 \let\tikz@tangent\tikz@tangent@lookup
33 \tikz@flush@moveto
34 \edef\tikz@timer@start{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position
35 \pgf@process{#1}%
36 \edef\tikz@timer@end{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% %% Timer: saver target position
37 \pgf@xc=\pgf@x
38 \pgf@yc=\pgf@y
39 \advance\pgf@xc by-\tikz@lastx
40 \advance\pgf@yc by-\tikz@lasty
41 \advance\tikz@lastx by\pgf@xc
42 \advance\tikz@lasty by\pgf@yc
43 \tikz@lastxsaved=\tikz@lastx
44 \tikz@lastysaved=\tikz@lasty
45 \tikz@updatecurrenttrue
46 \let\tikz@timer=\tikz@timer@sine% %% Timer: new timer
47 \pgfpathsine{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
48 \tikz@scan@next@command
49 }
50
51 \def\tikz@@cosine#1{% originally from tikz.code.tex
52 \let\tikz@tangent\tikz@tangent@lookup
53 \tikz@flush@moveto
54 \edef\tikz@timer@start{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position
55 \pgf@process{#1}%
56 \edef\tikz@timer@end{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% %% Timer: save target position
57 \pgf@xc=\pgf@x
58 \pgf@yc=\pgf@y
59 \advance\pgf@xc by-\tikz@lastx
60 \advance\pgf@yc by-\tikz@lasty
61 \advance\tikz@lastx by\pgf@xc
62 \advance\tikz@lasty by\pgf@yc
63 \tikz@lastxsaved=\tikz@lastx
64 \tikz@lastysaved=\tikz@lasty
65 \tikz@updatecurrenttrue
66 \let\tikz@timer=\tikz@timer@cosine% %% Timer: new timer
67 \pgfpathcosine{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
68 \tikz@scan@next@command
69 }
70
71 \def\tikzext@timer@rectangle{%
72 \pgfutil@tempdima\tikz@time pt
73 \ifdim\pgfutil@tempdima<.5pt\else % if we're at the return pos-ition we switch start and end
74 \advance\[email protected]
75 \let\pgf@tempa\tikz@timer@start
76 \let\tikz@timer@start\tikz@timer@end
77 \let\tikz@timer@end\pgf@tempa
78 \fi
79 \multiply\pgfutil@tempdima2
80 \edef\tikz@time{\pgf@sys@tonumber\pgfutil@tempdima}%
81 \tikz@timer@hvline}%
82
83 \def\tikz@parabola@semifinal#1{%
84 \tikz@flush@moveto
85 % Save original start:
86 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position
87 \pgf@xb=\tikz@lastx
88 \pgf@yb=\tikz@lasty
89 \tikz@make@last@position{#1}%
90 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save target position
91 \pgf@xc=\tikz@lastx
92 \pgf@yc=\tikz@lasty
93 \begingroup% now calculate bend:
94 \let\tikz@after@path\pgfutil@empty
95 \expandafter\tikzset\expandafter{\tikz@parabola@option}%
96 \tikz@lastxsaved=\tikz@parabola@bend@factor\tikz@lastx
97 \tikz@lastysaved=\tikz@parabola@bend@factor\tikz@lasty
98 \advance\tikz@lastxsaved by\pgf@xb
99 \advance\tikz@lastysaved by\pgf@yb
100 \advance\tikz@lastxsaved by-\tikz@parabola@bend@factor\pgf@xb
101 \advance\tikz@lastysaved by-\tikz@parabola@bend@factor\pgf@yb
102 \expandafter\tikz@make@last@position\expandafter{\tikz@parabola@bend}%
103 \edef\tikz@timer@middle{{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save bend position
104 % Calculate delta from bend
105 \advance\pgf@xc by-\tikz@lastx
106 \advance\pgf@yc by-\tikz@lasty
107 % Ok, now calculate delta to bend
108 \advance\tikz@lastx by-\pgf@xb
109 \advance\tikz@lasty by-\pgf@yb
110 \edef\tikz@marshal{%
111 \noexpand\let\noexpand\tikz@timer\noexpand\tikz@timer@parabola
112 \noexpand\edef\noexpand\tikz@timer@middle{\noexpand\pgfqpoint\tikz@timer@middle}%
113 \noexpand\pgfpathparabola{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
114 }%
115 \expandafter\endgroup%
116 \tikz@marshal
117 \expandafter\tikz@scan@next@command\tikz@after@path%
118 }%
119
120 \def\tikz@timer@parabola{% following calculations, see \def of \pgfpathparabola in pgfcorepathconstruct.code.tex (l. 1261)
121 \ifdim\tikz@time pt<.5pt\relax % first part
122 \pgf@process{\tikz@timer@middle}%
123 \pgf@xc\pgf@x\pgf@yc\pgf@y
124 \pgf@xb\pgf@x\pgf@yb\pgf@y
125 \pgf@process{\tikz@timer@start}%
126 \advance\pgf@xc-\pgf@x\[email protected]\pgf@xc
127 \advance\pgf@xc\pgf@x % = start_x + .1125 (middle_x - start_x)
128 \advance\pgf@yc-\pgf@y\[email protected]\pgf@yc
129 \advance\pgf@yc\pgf@y % = start_y + .225 (middle_y - start_y)
130 \advance\pgf@xb\pgf@x\[email protected]\pgf@xb % = .5 (middle_x + start_x) = start_x + .5 (middle_x - start_x)
131 \pgf@xa=\tikz@time pt%
132 \pgf@xa=2\pgf@xa % = 2 * \tikz@time
133 \edef\tikz@marshal{\noexpand\pgftransformcurveattime{\pgf@sys@tonumber\pgf@xa}{\noexpand\tikz@timer@start}%
134 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
135 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
136 {\noexpand\tikz@timer@middle}}%
137 \else % second part
138 \pgf@process{\tikz@timer@end}%
139 \pgf@xc\pgf@x
140 \pgf@xb\pgf@x
141 \pgf@yb\pgf@y
142 \pgf@process{\tikz@timer@middle}%
143 \advance\pgf@xc\pgf@x\[email protected]\pgf@xc % = .5 (end_x + middle_x) = middle_x + .5 (end_x - middle_x)
144 \advance\pgf@xb-\pgf@x\[email protected]\pgf@xb
145 \advance\pgf@xb\pgf@x % = middle_x + .8875 (end_x - middle_x)
146 \advance\pgf@yb-\pgf@y\[email protected]\pgf@yb
147 \advance\pgf@yb\pgf@y % = middle_y + .775 (end_y - middle_y)
148 \pgf@xa=\tikz@time pt%
149 \advance\[email protected]%
150 \pgf@xa=2\pgf@xa % = 2 (\tikz@zime - .5)
151 \edef\tikz@marshal{\noexpand\pgftransformcurveattime{\pgf@sys@tonumber\pgf@xa}{\noexpand\tikz@timer@middle}%
152 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}%
153 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
154 {\noexpand\tikz@timer@end}}%
155 \fi
156 \tikz@marshal
157 }
158
159 \def\tikz@timer@sine{% following calculations, see \def of \pgfpathsine in pgfcorepathconstruct.code.tex (l. 1315)
160 \pgf@process{\tikz@timer@end}%
161 \pgf@xc\pgf@x\pgf@yc\pgf@y
162 \pgf@xb\pgf@x\pgf@yb\pgf@y
163 \pgf@process{\tikz@timer@start}%
164 \advance\pgf@xc-\pgf@x\[email protected]\pgf@xc
165 \advance\pgf@xc\pgf@x % = start_x + .3260 (end_x - start_x)
166 \advance\pgf@yc-\pgf@y\[email protected]\pgf@yc
167 \advance\pgf@yc\pgf@y % = start_y + .5120 (end_y - start_y)
168 \advance\pgf@xb-\pgf@x\[email protected]\pgf@xb % = start_x + .6380 (end_x - start_x)
169 \advance\pgf@xb\pgf@x
170 \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\tikz@time}{\noexpand\tikz@timer@start}%
171 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
172 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
173 {\noexpand\tikz@timer@end}}%
174 \tikz@marshall
175 }
176 \def\tikz@timer@cosine{% following calculations, see \def of \pgfpathcosine in pgfcorepathconstruct.code.tex (l. 1345)
177 \pgf@process{\tikz@timer@end}%
178 \pgf@xc\pgf@x\pgf@yc\pgf@y
179 \pgf@xb\pgf@x\pgf@yb\pgf@y
180 \pgf@process{\tikz@timer@start}%
181 \advance\pgf@xb-\pgf@x\[email protected]\pgf@xb
182 \advance\pgf@xb\pgf@x % = start_x + .6740 (end_x - start_x)
183 \advance\pgf@yb-\pgf@y\[email protected]\pgf@yb
184 \advance\pgf@yb\pgf@y % = start_y + .4880 (end_y - start_y)
185 \advance\pgf@xc-\pgf@x\[email protected]\pgf@xc % = start_x + .3620 (end_x - start_x)
186 \advance\pgf@xc\pgf@x
187 \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\tikz@time}{\noexpand\tikz@timer@start}%
188 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}%
189 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
190 {\noexpand\tikz@timer@end}}%
191 \tikz@marshall
192 }
193
194 \tikzextset{
195 rectangle timer/.is choice,
196 rectangle timer/line/.code=\let\tikz@timer@rectangle\tikz@timer@line,
197 rectangle timer/rectangle/.code=\let\tikz@timer@rectangle\tikzext@timer@rectangle,
198 rectangle timer=rectangle,
199 /tikz-ext/compat/add library={paths.timer}{pre 0.6},
200 compat/paths.timer/warn/.append code=%
201 \tikzextutil@compatwarning@key{paths.timer}{pre 0.6}{/tikz/rectangle timer}{/tikz/ext/rectangle timer},
202 compat/paths.timer/pre 0.6/.append code=%
203 \pgfkeysdef{/tikz/rectangle timer}{\pgfkeysvalueof{/tikz/ext/rectangle timer/.@cmd}##1\pgfeov},
204 compat/paths.timer/\pgfkeysvalueof{/tikz/ext/compat/paths.timer}%
205 }
206 \endinput