summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/tikzlibrarypaths.timer.code.tex
blob: 3a4d30e68f0d1c39007c814600dd4b518c8e2fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
% Copyright 2022 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
\def\tikz@rectB#1{% originally from tikz.code.tex
  \tikz@make@last@position{#1}%
  \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
  \let\tikz@timer\tikz@timer@rectangle% %% Timer: new timer
  \tikz@@movetosave{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
  \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\tikz@lasty}}%
  \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
  \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@ya}}%
  \iftikz@snaked
    \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
  \fi
  \pgfpathclose
          \tikz@@movetosave{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
  \def\pgfstrokehook{}%
  \let\tikz@tangent\relax
  \tikz@scan@next@command
}%

\def\tikz@@sine#1{% originally from tikz.code.tex
  \let\tikz@tangent\tikz@tangent@lookup
  \tikz@flush@moveto
  \edef\tikz@timer@start{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position
  \pgf@process{#1}%
  \edef\tikz@timer@end{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% %% Timer: saver target position
  \pgf@xc=\pgf@x
  \pgf@yc=\pgf@y
  \advance\pgf@xc by-\tikz@lastx
  \advance\pgf@yc by-\tikz@lasty
  \advance\tikz@lastx by\pgf@xc
  \advance\tikz@lasty by\pgf@yc
  \tikz@lastxsaved=\tikz@lastx
  \tikz@lastysaved=\tikz@lasty
  \tikz@updatecurrenttrue
  \let\tikz@timer=\tikz@timer@sine% %% Timer: new timer
  \pgfpathsine{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
  \tikz@scan@next@command
}

\def\tikz@@cosine#1{% originally from tikz.code.tex
  \let\tikz@tangent\tikz@tangent@lookup
  \tikz@flush@moveto
  \edef\tikz@timer@start{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position
  \pgf@process{#1}%
  \edef\tikz@timer@end{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% %% Timer: save target position
  \pgf@xc=\pgf@x
  \pgf@yc=\pgf@y
  \advance\pgf@xc by-\tikz@lastx
  \advance\pgf@yc by-\tikz@lasty
  \advance\tikz@lastx by\pgf@xc
  \advance\tikz@lasty by\pgf@yc
  \tikz@lastxsaved=\tikz@lastx
  \tikz@lastysaved=\tikz@lasty
  \tikz@updatecurrenttrue
  \let\tikz@timer=\tikz@timer@cosine% %% Timer: new timer
  \pgfpathcosine{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
  \tikz@scan@next@command
}

\def\tikz@timer@rectangle{%
  \pgfutil@tempdima\tikz@time pt
  \ifdim\pgfutil@tempdima<.5pt\else % if we're at the return pos-ition we switch start and end
    \advance\pgfutil@tempdima-.5pt
    \let\pgf@tempa\tikz@timer@start
    \let\tikz@timer@start\tikz@timer@end
    \let\tikz@timer@end\pgf@tempa
  \fi
  \multiply\pgfutil@tempdima2
  \edef\tikz@time{\strip@pt\pgfutil@tempdima}%
  \tikz@timer@hvline}%

\def\tikz@parabola@semifinal#1{%
    \tikz@flush@moveto
    % Save original start:
    \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save start position
    \pgf@xb=\tikz@lastx
    \pgf@yb=\tikz@lasty
    \tikz@make@last@position{#1}%
    \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save target position
    \pgf@xc=\tikz@lastx
    \pgf@yc=\tikz@lasty
    \begingroup% now calculate bend:
        \let\tikz@after@path\pgfutil@empty
        \expandafter\tikzset\expandafter{\tikz@parabola@option}%
        \tikz@lastxsaved=\tikz@parabola@bend@factor\tikz@lastx
        \tikz@lastysaved=\tikz@parabola@bend@factor\tikz@lasty
        \advance\tikz@lastxsaved by\pgf@xb
        \advance\tikz@lastysaved by\pgf@yb
        \advance\tikz@lastxsaved by-\tikz@parabola@bend@factor\pgf@xb
        \advance\tikz@lastysaved by-\tikz@parabola@bend@factor\pgf@yb
        \expandafter\tikz@make@last@position\expandafter{\tikz@parabola@bend}%
        \edef\tikz@timer@middle{{\the\tikz@lastx}{\the\tikz@lasty}}% %% Timer: save bend postion
        % Calculate delta from bend
        \advance\pgf@xc by-\tikz@lastx
        \advance\pgf@yc by-\tikz@lasty
        % Ok, now calculate delta to bend
        \advance\tikz@lastx by-\pgf@xb
        \advance\tikz@lasty by-\pgf@yb
        \edef\tikz@marshall{%
          \noexpand\let\noexpand\tikz@timer\noexpand\tikz@timer@parabola
          \noexpand\edef\noexpand\tikz@timer@middle{\noexpand\pgfqpoint\tikz@timer@middle}%
          \noexpand\pgfpathparabola{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
        }%
    \expandafter\endgroup%
    \tikz@marshall
    \expandafter\tikz@scan@next@command\tikz@after@path%
}%

\def\tikz@timer@parabola{% following calculations, see \def of \pgfpathparabola in pgfcorepathconstruct.code.tex (l. 1261)
  \ifdim\tikz@time pt<.5pt\relax % first part
    \pgf@process{\tikz@timer@middle}%
    \pgf@xc\pgf@x\pgf@yc\pgf@y
    \pgf@xb\pgf@x\pgf@yb\pgf@y
    \pgf@process{\tikz@timer@start}%
    \advance\pgf@xc-\pgf@x\pgf@xc.1125\pgf@xc
    \advance\pgf@xc\pgf@x                 % = start_x + .1125 (middle_x - start_x)
    \advance\pgf@yc-\pgf@y\pgf@yc.225\pgf@yc
    \advance\pgf@yc\pgf@y                 % = start_y + .225 (middle_y - start_y)
    \advance\pgf@xb\pgf@x\pgf@xb.5\pgf@xb % = .5 (middle_x + start_x) = start_x + .5 (middle_x - start_x)
    \pgf@xa=\tikz@time pt%
    \pgf@xa=2\pgf@xa                      % = 2 * \tikz@time
    \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\strip@pt\pgf@xa}{\noexpand\tikz@timer@start}%
      {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
      {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
      {\noexpand\tikz@timer@middle}}%
  \else % second part
    \pgf@process{\tikz@timer@end}%
    \pgf@xc\pgf@x
    \pgf@xb\pgf@x
    \pgf@yb\pgf@y
    \pgf@process{\tikz@timer@middle}%
    \advance\pgf@xc\pgf@x\pgf@xc.5\pgf@xc % = .5 (end_x + middle_x) = middle_x + .5 (end_x - middle_x)
    \advance\pgf@xb-\pgf@x\pgf@xb.8875\pgf@xb
    \advance\pgf@xb\pgf@x                 % = middle_x + .8875 (end_x - middle_x)
    \advance\pgf@yb-\pgf@y\pgf@yb.775\pgf@yb
    \advance\pgf@yb\pgf@y                 % = middle_y + .775 (end_y - middle_y)
    \pgf@xa=\tikz@time pt%
    \advance\pgf@xa-.5pt%
    \pgf@xa=2\pgf@xa                      % = 2 (\tikz@zime - .5)
    \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\strip@pt\pgf@xa}{\noexpand\tikz@timer@middle}%
      {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}%
      {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
      {\noexpand\tikz@timer@end}}%
  \fi
  \tikz@marshall
}

\def\tikz@timer@sine{% following calculations, see \def of \pgfpathsine in pgfcorepathconstruct.code.tex (l. 1315)
  \pgf@process{\tikz@timer@end}%
  \pgf@xc\pgf@x\pgf@yc\pgf@y
  \pgf@xb\pgf@x\pgf@yb\pgf@y
  \pgf@process{\tikz@timer@start}%
  \advance\pgf@xc-\pgf@x\pgf@xc.3260\pgf@xc
  \advance\pgf@xc\pgf@x                     % = start_x + .3260 (end_x - start_x)
  \advance\pgf@yc-\pgf@y\pgf@yc.5120\pgf@yc
  \advance\pgf@yc\pgf@y                     % = start_y + .5120 (end_y - start_y)
  \advance\pgf@xb-\pgf@x\pgf@xb.6380\pgf@xb % = start_x + .6380 (end_x - start_x)
  \advance\pgf@xb\pgf@x
  \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\tikz@time}{\noexpand\tikz@timer@start}%
    {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
    {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
    {\noexpand\tikz@timer@end}}%
  \tikz@marshall
}
\def\tikz@timer@cosine{% following calculations, see \def of \pgfpathcosine in pgfcorepathconstruct.code.tex (l. 1345)
  \pgf@process{\tikz@timer@end}%
  \pgf@xc\pgf@x\pgf@yc\pgf@y
  \pgf@xb\pgf@x\pgf@yb\pgf@y
  \pgf@process{\tikz@timer@start}%
  \advance\pgf@xb-\pgf@x\pgf@xb.6740\pgf@xb
  \advance\pgf@xb\pgf@x                     % = start_x + .6740 (end_x - start_x)
  \advance\pgf@yb-\pgf@y\pgf@yb.4880\pgf@yb
  \advance\pgf@yb\pgf@y                     % = start_y + .4880 (end_y - start_y)
  \advance\pgf@xc-\pgf@x\pgf@xc.3620\pgf@xc % = start_x + .3620 (end_x - start_x)
  \advance\pgf@xc\pgf@x
  \edef\tikz@marshall{\noexpand\pgftransformcurveattime{\tikz@time}{\noexpand\tikz@timer@start}%
    {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@y}}%
    {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
    {\noexpand\tikz@timer@end}}%
  \tikz@marshall
}
\endinput