Debian Codegraph @

texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex

raw
1 % Copyright 2019 by Till Tantau
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 Public License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 \ProvidesPackageRCS{tikz.code.tex}
11
12
13 \def\tikzerror#1{\pgfutil@packageerror{tikz}{#1}{}}
14
15 % Always-present libraries (|\usepgflibrary| defined in
16 % \file{pgfutil-common.tex}).
17 \usepgflibrary{plothandlers}
18
19 \newdimen\tikz@lastx
20 \newdimen\tikz@lasty
21 \newdimen\tikz@lastxsaved
22 \newdimen\tikz@lastysaved
23 \newdimen\tikz@lastmovetox
24 \newdimen\tikz@lastmovetoy
25
26 \newdimen\tikzleveldistance
27 \newdimen\tikzsiblingdistance
28
29 \newbox\tikz@figbox
30 \newbox\tikz@figbox@bg
31 \newbox\tikz@tempbox
32 \newbox\tikz@tempbox@bg
33
34 \newcount\tikztreelevel
35 \newcount\tikznumberofchildren
36 \newcount\tikznumberofcurrentchild
37
38 \newcount\tikz@fig@count
39
40 \newif\iftikz@node@is@a@label
41 \newif\iftikz@snaked
42 \newif\iftikz@decoratepath
43
44 \let\tikz@options\pgfutil@empty
45 % |\tikz@addoption| adds \texttt{#1} at the end of the replacement
46 % text of |\tikz@options| without expansion.
47 \def\tikz@addoption#1{%
48 \expandafter\def\expandafter\tikz@options\expandafter{\tikz@options#1}}%
49 % Same as |tikz@addoption| for |\tikz@mode|. Note that |\tikz@mode| is
50 % initially let to |\pgfutil@empty| later (see path usage options).
51 \def\tikz@addmode#1{%
52 \expandafter\def\expandafter\tikz@mode\expandafter{\tikz@mode#1}}%
53 % Same as |tikz@addoption| for |\tikz@transform|. Works even if
54 % |\tikz@transform| is not defined. In that case, nothing is added to
55 % |\tikz@transform|: \texttt{#1} is expanded.
56 \def\tikz@addtransform#1{%
57 \ifx\tikz@transform\relax
58 #1%
59 \else
60 \expandafter\def\expandafter\tikz@transform\expandafter{\tikz@transform#1}%
61 \fi
62 }%
63
64
65 % TikZ options management.
66
67 % Setting up the tikz key family (key management needs
68 % \file{pgfkeys.code.tex});
69 \pgfkeys{/tikz/.is family}%
70
71 % |\tikzset| is a shortcut to set keys that belongs to the tikz
72 % family.
73 \def\tikzset{\pgfqkeys{/tikz}}%
74
75 % Note: |\tikzoption| is supported for compatibility only. |\tikzset|
76 % should be used instead.
77 \def\tikzoption#1{%
78 \pgfutil@ifnextchar[%]
79 {\tikzoption@opt{#1}}{\tikzoption@noopt{#1}}}%
80 \def\tikzoption@opt#1[#2]#3{%
81 \pgfkeysdef{/tikz/#1}{#3}%
82 \pgfkeyssetvalue{/tikz/#1/.@def}{#2}}%
83 \def\tikzoption@noopt#1#2{%
84 \pgfkeysdef{/tikz/#1}{#2}%
85 \pgfkeyssetvalue{/tikz/#1/.@def}{\pgfkeysvaluerequired}}%
86
87 % Baseline options
88 \tikzoption{baseline}[0pt]{%
89 \pgfutil@ifnextchar(%)
90 {\tikz@baseline@coordinate}{\tikz@baseline@simple}#1\@nil}%
91 \def\tikz@baseline@simple#1\@nil{\pgfsetbaseline{#1}}%
92 \def\tikz@baseline@coordinate#1\@nil{%
93 \pgfsetbaselinepointlater{\tikz@scan@one@point\pgfutil@firstofone#1}}%
94
95 \tikzoption{trim left}[0pt]{\pgfutil@ifnextchar({\tikz@trim@coordinate{left}}{\tikz@trim@simple{left}}#1\@nil}%)%
96 \tikzoption{trim right}{\pgfutil@ifnextchar({\tikz@trim@coordinate{right}}{\tikz@trim@simple{right}}#1\@nil}%)%
97 \def\tikz@trim@simple#1#2\@nil{\csname pgfsettrim#1\endcsname{#2}}%
98 \def\tikz@trim@coordinate#1#2\@nil{\csname pgfsettrim#1pointlater\endcsname{\tikz@scan@one@point\pgfutil@firstofone#2}}%
99
100 % Draw options
101 \tikzoption{line width}{\tikz@semiaddlinewidth{#1}}%
102
103 \def\tikz@semiaddlinewidth#1{\tikz@addoption{\pgfsetlinewidth{#1}}\pgfmathsetlength\pgflinewidth{#1}}%
104
105 \tikzoption{cap}{\tikz@addoption{\csname pgfset#1cap\endcsname}}%
106 \tikzoption{join}{\tikz@addoption{\csname pgfset#1join\endcsname}}%
107 \tikzoption{line cap}{\tikz@addoption{\csname pgfset#1cap\endcsname}}%
108 \tikzoption{line join}{\tikz@addoption{\csname pgfset#1join\endcsname}}%
109 \tikzoption{miter limit}{\tikz@addoption{\pgfsetmiterlimit{#1}}}%
110
111 \tikzoption{dash pattern}{% syntax: on 2pt off 3pt on 4pt ...
112 \def\tikz@temp{#1}%
113 \ifx\tikz@temp\pgfutil@empty%
114 \def\tikz@dashpattern{}%
115 \tikz@addoption{\pgfsetdash{}{0pt}}%
116 \else%
117 \def\tikz@dashpattern{}%
118 \expandafter\tikz@scandashon\pgfutil@gobble#1o\@nil%
119 \edef\tikz@temp{{\tikz@dashpattern}{\noexpand\tikz@dashphase}}%
120 \expandafter\tikz@addoption\expandafter{\expandafter\pgfsetdash\tikz@temp}%
121 \fi}%
122 \tikzoption{dash phase}{%
123 \def\tikz@dashphase{#1}%
124 \edef\tikz@temp{{\tikz@dashpattern}{\noexpand\tikz@dashphase}}%
125 \expandafter\tikz@addoption\expandafter{\expandafter\pgfsetdash\tikz@temp}%
126 }%
127 \tikzoption{dash}{\tikz@parse@full@dash#1\pgf@stop}%
128 \def\tikz@parse@full@dash#1phase#2\pgf@stop{%
129 \def\tikz@dashphase{#2}%
130 \def\tikz@temp{#1}%
131 \ifx\tikz@temp\pgfutil@empty%
132 \def\tikz@dashpattern{}%
133 \tikz@addoption{\pgfsetdash{}{0pt}}%
134 \else%
135 \def\tikz@dashpattern{}%
136 \expandafter\tikz@scandashon\pgfutil@gobble#1o\@nil%
137 \edef\tikz@temp{{\tikz@dashpattern}{\noexpand\tikz@dashphase}}%
138 \expandafter\tikz@addoption\expandafter{\expandafter\pgfsetdash\tikz@temp}%
139 \fi%
140 }%
141 \def\tikz@dashphase{0pt}%
142 \def\tikz@dashpattern{}%
143
144 \def\tikz@scandashon n#1o{%
145 \expandafter\def\expandafter\tikz@dashpattern\expandafter{\tikz@dashpattern{#1}}%
146 \pgfutil@ifnextchar\@nil{\pgfutil@gobble}{\tikz@scandashoff}}%
147 \def\tikz@scandashoff ff#1o{%
148 \expandafter\def\expandafter\tikz@dashpattern\expandafter{\tikz@dashpattern{#1}}%
149 \pgfutil@ifnextchar\@nil{\pgfutil@gobble}{\tikz@scandashon}}%
150
151 % use a decoration to expand the `off' section of a dash pattern.
152 % https://tex.stackexchange.com/a/133357
153 \tikzset{
154 dash expand off/.code={%
155 \ifcsname tikz@library@decorations@loaded\endcsname\else
156 \tikzerror{You need \string\usetikzlibrary{decorations} for ``dash expand off''}%
157 \fi
158 \tikz@addoption{%
159 \pgfgetpath\currentpath
160 \pgfprocessround{\currentpath}{\currentpath}%
161 \pgf@decorate@parsesoftpath{\currentpath}{\currentpath}%
162 % All of \on, \off, \dashphase, \rest, and \onoff are unit-free.
163 % Parse \on and \off from the current path
164 \pgfmathsetmacro\on{\expandafter\pgfutil@firstoftwo\tikz@dashpattern}%
165 \pgfmathsetmacro\off{\expandafter\pgfutil@secondoftwo\tikz@dashpattern}%
166 % \dashphase = max(\on - \dashphase, 0)
167 \pgfmathsetmacro\tikz@dashphase{\tikz@dashphase}%
168 \pgfmathsubtract@{\on}{\tikz@dashphase}%
169 \pgfmathmax@{\pgfmathresult,0}%
170 \let\dashphase=\pgfmathresult
171 % \rest = \pgf@decorate@totalpathlength - \on + 2\dashphase
172 \edef\rest{\pgf@sys@tonumber\dimexpr\pgf@decorate@totalpathlength - \on pt + 2\dimexpr\dashphase pt\relax\relax}%
173 % \onoff = \on + \off
174 \edef\onoff{\pgf@sys@tonumber\dimexpr\on pt+\off pt\relax}%
175 % \nfullonoff = max(floor(\rest/\onoff), 1)
176 \pgfmathdivide@{\rest}{\onoff}%
177 \pgfmathfloor@{\pgfmathresult}%
178 \pgfmathmax@{\pgfmathresult,1}%
179 % \offexpand = max(\rest/\nfullonoff - \on, \off)
180 \pgfmathdivide@{\rest}{\pgfmathresult}%
181 \pgfmathsubtract@{\pgfmathresult}{\on}%
182 \pgfmathmax@{\pgfmathresult,\off}%
183 \edef\tikz@marshal{\noexpand\pgfsetdash{{+\on pt}{+\pgfmathresult pt}}{+\dashphase pt}}%
184 \tikz@marshal
185 }%
186 }
187 }
188
189 \tikzoption{draw opacity}{\tikz@addoption{\pgfsetstrokeopacity{#1}}}%
190
191 % Double draw options
192 \tikzoption{double}[]{%
193 \def\tikz@temp{#1}%
194 \ifx\tikz@temp\tikz@nonetext%
195 \tikz@addmode{\tikz@mode@doublefalse}%
196 \else%
197 \ifx\tikz@temp\pgfutil@empty%
198 \else%
199 \pgfsetinnerstrokecolor{#1}%
200 \fi%
201 \tikz@addmode{\tikz@mode@doubletrue}%
202 \tikzset{every double/.try}%
203 \fi}%
204 \tikzoption{double distance}{%
205 \pgfmathsetlength{\pgf@x}{#1}%
206 \edef\tikz@double@setup{%
207 \pgf@x=\the\pgf@x%
208 \advance\pgf@x by2\pgflinewidth%
209 \pgflinewidth=\pgf@x%
210 \noexpand\pgfsetlinewidth{\pgflinewidth}%
211 \noexpand\pgfsetinnerlinewidth{\the\pgf@x}%
212 }%
213 \tikzset{double}}%
214 \def\tikz@double@setup{%
215 \pgf@x=2\pgflinewidth%
216 \advance\pgf@x by0.6pt%
217 \pgflinewidth=\pgf@x%
218 \pgfsetlinewidth{\pgflinewidth}%
219 \pgfsetinnerlinewidth{0.6pt}%
220 }%
221 \tikzset{double distance between line centers/.code={
222 \pgfmathsetlength{\pgf@x}{#1}%
223 \edef\tikz@double@setup{%
224 \pgf@x=\pgflinewidth%
225 \pgf@xa=\the\pgf@x%
226 \advance\pgf@x by\pgf@xa%
227 \advance\pgf@xa by-\pgflinewidth%
228 \pgflinewidth=\pgf@x%
229 \noexpand\pgfsetlinewidth{\pgflinewidth}%
230 \noexpand\pgfsetinnerlinewidth{\pgf@xa}%
231 }%
232 \tikzset{double}}}%
233 \tikzset{double equal sign distance/.style={double distance between line centers=0.45ex}}%
234
235
236
237
238 % Fill options
239
240 \tikzoption{even odd rule}[]{\tikz@addoption{\pgfseteorule}}%
241 \tikzoption{nonzero rule}[]{\tikz@addoption{\pgfsetnonzerorule}}%
242
243 \tikzoption{fill opacity}{\tikz@addoption{\pgfsetfillopacity{#1}}}%
244
245
246 % Joined fill/draw options
247
248 \tikzoption{opacity}{\tikz@addoption{\pgfsetstrokeopacity{#1}\pgfsetfillopacity{#1}}}%
249
250
251 % Blend mode
252
253 \tikzset{blend mode/.code={\tikz@addoption{\pgfsetblendmode{#1}}}}%
254
255
256 % Main color options
257 \tikzoption{color}{%
258 \tikz@addoption{%
259 \ifx\tikz@fillcolor\pgfutil@empty%
260 \ifx\tikz@strokecolor\pgfutil@empty%
261 \else%
262 \pgfsys@color@reset@inorderfalse%
263 \let\tikz@strokecolor\pgfutil@empty%
264 \let\tikz@fillcolor\pgfutil@empty%
265 \fi%
266 \else%
267 \pgfsys@color@reset@inorderfalse%
268 \let\tikz@strokecolor\pgfutil@empty%
269 \let\tikz@fillcolor\pgfutil@empty%
270 \fi%
271 \pgfutil@colorlet{tikz@color}{#1}%
272 \pgfutil@colorlet{.}{tikz@color}%
273 %
274 \pgfsetcolor{.}%
275 \pgfsys@color@reset@inordertrue%
276 }%
277 \def\tikz@textcolor{#1}}%
278
279
280
281 % Rounding options
282 \tikzoption{rounded corners}[4pt]{\pgfsetcornersarced{\pgfpoint{#1}{#1}}}%
283 \tikzoption{sharp corners}[]{\pgfsetcornersarced{\pgfpointorigin}}%
284
285 % Radii and arc options
286 \tikzset{x radius/.initial=0pt}%
287 \tikzset{y radius/.initial=0pt}%
288 \tikzset{%
289 radius/.code={%
290 \pgfmathparse{#1}%
291 \ifpgfmathunitsdeclared
292 \pgfkeyssetevalue{/tikz/x radius}{\pgfmathresult pt}%
293 \pgfkeyssetevalue{/tikz/y radius}{\pgfmathresult pt}%
294 \else
295 \pgfkeyssetevalue{/tikz/x radius}{\pgfmathresult}%
296 \pgfkeyssetevalue{/tikz/y radius}{\pgfmathresult}%
297 \fi
298 }%
299 }%
300 \tikzset{start angle/.initial=}%
301 \tikzset{end angle/.initial=}%
302 \tikzset{delta angle/.initial=}%
303
304
305 % Coordinate options
306 \tikzoption{x}{\tikz@handle@vec{\pgfsetxvec}{\tikz@handle@x}#1\relax}%
307 \tikzoption{y}{\tikz@handle@vec{\pgfsetyvec}{\tikz@handle@y}#1\relax}%
308 \tikzoption{z}{\tikz@handle@vec{\pgfsetzvec}{\tikz@handle@z}#1\relax}%
309
310 \def\tikz@handle@vec#1#2{\pgfutil@ifnextchar({\tikz@handle@coordinate#1}{\tikz@handle@single#2}}%
311 \def\tikz@handle@coordinate#1{\tikz@scan@one@point#1}%
312 \def\tikz@handle@single#1#2\relax{#1{#2}}%
313 \def\tikz@handle@x#1{\pgfsetxvec{\pgfpoint{#1}{0pt}}}%
314 \def\tikz@handle@y#1{\pgfsetyvec{\pgfpoint{0pt}{#1}}}%
315 \def\tikz@handle@z#1{\pgfsetzvec{\pgfpoint{#1}{#1}}}%
316
317
318 % Transformation options
319 \tikzoption{scale}{\tikz@addtransform{\pgftransformscale{#1}}}%
320 \tikzoption{scale around}{\tikz@addtransform{\def\tikz@aroundaction{\pgftransformscale}\tikz@doaround{#1}}}%
321 \tikzoption{xscale}{\tikz@addtransform{\pgftransformxscale{#1}}}%
322 \tikzoption{xslant}{\tikz@addtransform{\pgftransformxslant{#1}}}%
323 \tikzoption{yscale}{\tikz@addtransform{\pgftransformyscale{#1}}}%
324 \tikzoption{yslant}{\tikz@addtransform{\pgftransformyslant{#1}}}%
325 \tikzoption{rotate}{\tikz@addtransform{\pgftransformrotate{#1}}}%
326 \tikzoption{rotate around}{\tikz@addtransform{\def\tikz@aroundaction{\pgftransformrotate}\tikz@doaround{#1}}}%
327 \def\tikz@doaround#1{%
328 \edef\tikz@temp{#1}% get rid of active stuff
329 \expandafter\tikz@doparseA\tikz@temp%
330 }%
331 \def\tikz@doparseA#1:{%
332 \def\tikz@temp@rot{#1}%
333 \tikz@scan@one@point\tikz@doparseB%
334 }%
335 \def\tikz@doparseB#1{%
336 \pgf@process{#1}%
337 \pgf@xc=\pgf@x%
338 \pgf@yc=\pgf@y%
339 \pgftransformshift{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
340 \tikz@aroundaction{\tikz@temp@rot}%
341 \pgftransformshift{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}%
342 }%
343
344 \tikzoption{shift}{\tikz@addtransform{\tikz@scan@one@point\pgftransformshift#1\relax}}%
345 \tikzoption{xshift}{\tikz@addtransform{\pgftransformxshift{#1}}}%
346 \tikzoption{yshift}{\tikz@addtransform{\pgftransformyshift{#1}}}%
347 \tikzoption{cm}{\tikz@addtransform{\tikz@parse@cm#1\relax}}%
348 \tikzoption{reset cm}[]{\tikz@addtransform{\pgftransformreset}}%
349 \tikzoption{shift only}[]{\tikz@addtransform{\pgftransformresetnontranslations}}%
350
351 \def\tikz@parse@cm#1,#2,#3,#4,{%
352 \def\tikz@p@cm{{#1}{#2}{#3}{#4}}%
353 \tikz@scan@one@point\tikz@parse@cmA}%
354 \def\tikz@parse@cmA#1{%
355 \expandafter\pgftransformcm\tikz@p@cm{#1}%
356 }%
357
358 \tikzset{transform canvas/.code=%
359 {%
360 \tikz@addoption
361 {%
362 {%
363 \pgftransformreset%
364 \let\tikz@transform=\relax%
365 \tikzset{#1}%
366 \pgflowlevelsynccm%
367 }%
368 \pgf@relevantforpicturesizefalse%
369 }%
370 }%
371 }%
372
373 \tikzset{turn/.code={%
374 \pgf@x=0pt%
375 \pgf@y\pgf@x%
376 \pgf@process{\tikz@tangent}%
377 \advance\pgf@x by-\tikz@lastx%
378 \advance\pgf@y by-\tikz@lasty%
379 \pgfpointnormalised{}% x/y = normalised vector
380 \pgf@x=-\pgf@x%
381 \pgf@ya=-\pgf@y%
382 \pgftransformcm%
383 {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@ya}}%
384 {\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@x}}{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
385 }%
386 }%
387
388 \def\tikz@tangent@lookup{%
389 \pgfgetpath\tikz@temp%
390 \pgfprocesspathextractpoints\tikz@temp%
391 \pgfpointsecondlastonpath%
392 }%
393
394 % Code for rotating the xyz coordinate system
395 % around the x, y, or z vector.
396 %
397 \def\tikz@xyz@rotate@let{%
398 \let\pgf@z=\pgf@yc%
399 \let\pgf@za=\pgf@xc%
400 }%
401
402 \def\tikz@xyz@rotate@xyz@xaxis#1#2#3#4{%
403 \tikz@xyz@rotate@let%
404 \pgf@x=#1\relax%
405 \pgf@ya=#2\relax%
406 \pgf@za=#3\relax%
407 \pgfmathsin@{#4}\let\tikz@xyz@sin=\pgfmathresult%
408 \pgfmathcos@{#4}\let\tikz@xyz@cos=\pgfmathresult%
409 \pgf@y=\tikz@xyz@cos\pgf@ya%
410 \advance\pgf@y by-\tikz@xyz@sin\pgf@za%
411 \pgf@z=\tikz@xyz@sin\pgf@ya%
412 \advance\pgf@z by\tikz@xyz@cos\pgf@za%
413 }%
414
415 \def\tikz@xyz@rotate@xyz@yaxis#1#2#3#4{%
416 \tikz@xyz@rotate@let%
417 \pgf@xa=#1\relax%
418 \pgf@y=#2\relax%
419 \pgf@za=#3\relax%
420 \pgfmathsin@{#4}\let\tikz@xyz@sin=\pgfmathresult%
421 \pgfmathcos@{#4}\let\tikz@xyz@cos=\pgfmathresult%
422 \pgf@x=\tikz@xyz@cos\pgf@xa%
423 \advance\pgf@x by\tikz@xyz@sin\pgf@za%
424 \pgf@z=-\tikz@xyz@sin\pgf@xa%
425 \advance\pgf@z by\tikz@xyz@cos\pgf@za%
426 }%
427
428 \def\tikz@xyz@rotate@xyz@zaxis#1#2#3#4{%
429 \tikz@xyz@rotate@let%
430 \pgf@xa=#1\relax%
431 \pgf@ya=#2\relax%
432 \pgf@z=#3\relax%
433 \pgfmathsin@{#4}\let\tikz@xyz@sin=\pgfmathresult%
434 \pgfmathcos@{#4}\let\tikz@xyz@cos=\pgfmathresult%
435 \pgf@x=\tikz@xyz@cos\pgf@xa%
436 \advance\pgf@x by-\tikz@xyz@sin\pgf@ya%
437 \pgf@y=\tikz@xyz@sin\pgf@xa%
438 \advance\pgf@y by\tikz@xyz@cos\pgf@ya%
439 }%
440
441 \tikzset{rotate around x/.code={%
442 \tikz@xyz@rotate@let%
443 \pgfmathparse{#1}\let\tikz@xyz@angle=\pgfmathresult%
444 \tikz@xyz@rotate@xyz@xaxis{0pt}{1pt}{0pt}{\tikz@xyz@angle}%
445 \pgfextract@process\tikz@xyz@rotate@yvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}%
446 \tikz@xyz@rotate@xyz@xaxis{0pt}{0pt}{1pt}{\tikz@xyz@angle}%
447 \pgfsetzvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}%
448 \pgfsetyvec{\tikz@xyz@rotate@yvec}%
449 },
450 rotate around y/.code={%
451 \tikz@xyz@rotate@let%
452 \pgfmathparse{#1}\let\tikz@xyz@angle=\pgfmathresult%
453 \tikz@xyz@rotate@xyz@yaxis{1pt}{0pt}{0pt}{\tikz@xyz@angle}%
454 \pgfextract@process\tikz@xyz@rotate@xvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}%
455 \tikz@xyz@rotate@xyz@yaxis{0pt}{0pt}{1pt}{\tikz@xyz@angle}%
456 \pgfsetzvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}%
457 \pgfsetxvec{\tikz@xyz@rotate@xvec}%
458 },
459 rotate around z/.code={%
460 \tikz@xyz@rotate@let%
461 \pgfmathparse{#1}\let\tikz@xyz@angle=\pgfmathresult%
462 \tikz@xyz@rotate@xyz@zaxis{1pt}{0pt}{0pt}{\tikz@xyz@angle}%
463 \pgfextract@process\tikz@xyz@rotate@xvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}%
464 \tikz@xyz@rotate@xyz@zaxis{0pt}{1pt}{0pt}{\tikz@xyz@angle}%
465 \pgfsetyvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}%
466 \pgfsetxvec{\tikz@xyz@rotate@xvec}%
467 },
468 }%
469
470 % Grid options
471 \tikzoption{xstep}{\def\tikz@grid@x{#1}}%
472 \tikzoption{ystep}{\def\tikz@grid@y{#1}}%
473 \tikzoption{step}{\tikz@handle@vec{\tikz@step@point}{\tikz@step@single}#1\relax}%
474 \def\tikz@step@single#1{\def\tikz@grid@x{#1}\def\tikz@grid@y{#1}}%
475 \def\tikz@step@point#1{\pgf@process{#1}\edef\tikz@grid@x{\the\pgf@x}\edef\tikz@grid@y{\the\pgf@y}}%
476
477 \def\tikz@grid@x{1cm}%
478 \def\tikz@grid@y{1cm}%
479
480
481 % Current point updates
482 \newif\iftikz@current@point@local
483 \tikzset{current point is local/.is if=tikz@current@point@local}%
484
485 % Path usage options
486 \newif\iftikz@mode@double
487 \newif\iftikz@mode@fill
488 \newif\iftikz@mode@draw
489 \newif\iftikz@mode@clip
490 \newif\iftikz@mode@boundary
491 \newif\iftikz@mode@shade
492 \newif\iftikz@mode@fade@path
493 \newif\iftikz@mode@fade@scope
494 \let\tikz@mode=\pgfutil@empty
495
496 \def\tikz@nonetext{none}%
497
498 \tikzoption{path only}[]{\let\tikz@mode=\pgfutil@empty}%
499 \tikzset{
500 shade/.is choice,
501 shade/.default=true,
502 shade/true/.code=\tikz@addmode{\tikz@mode@shadetrue},
503 shade/false/.code=\tikz@addmode{\tikz@mode@shadefalse},
504 shade/none/.code=\tikz@addmode{\tikz@mode@shadefalse},
505 }%
506
507 \tikzoption{fill}[]{%
508 \edef\tikz@temp{#1}%
509 \ifx\tikz@temp\tikz@nonetext%
510 \tikz@addmode{\tikz@mode@fillfalse}%
511 \else%
512 \ifx\tikz@temp\pgfutil@empty%
513 \else%
514 \tikz@addoption{\pgfsetfillcolor{#1}}%
515 \def\tikz@fillcolor{#1}%
516 \fi%
517 \tikz@addmode{\tikz@mode@filltrue}%
518 \fi%
519 }%
520 \tikzoption{draw}[]{%
521 \edef\tikz@temp{#1}%
522 \ifx\tikz@temp\tikz@nonetext%
523 \tikz@addmode{\tikz@mode@drawfalse}%
524 \else%
525 \ifx\tikz@temp\pgfutil@empty%
526 \else%
527 \tikz@addoption{\pgfsetstrokecolor{#1}}%
528 \def\tikz@strokecolor{#1}%
529 \fi%
530 \tikz@addmode{\tikz@mode@drawtrue}%
531 \fi%
532 }%
533 \tikzoption{clip}[]{\tikz@addmode{\tikz@mode@cliptrue}}%
534 \tikzoption{use as bounding box}[]{\tikz@addmode{\tikz@mode@boundarytrue}}%
535
536 \tikzoption{save path}{\tikz@addmode{\pgfsyssoftpath@getcurrentpath#1\global\let#1=#1}}%
537 \tikzoption{use path}{\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}%
538
539 \let\tikz@fillcolor=\pgfutil@empty
540 \let\tikz@strokecolor=\pgfutil@empty
541
542 % Insert a path using an option
543 \tikzset{insert path/.code=\tikz@scan@next@command#1\pgf@stop}%
544
545 % Pattern options
546 \tikzset{pattern/.code=\tikzerror{You need to say \string\usetikzlibrary{patterns}},
547 pattern color/.style=pattern}%
548
549 % Path pictures
550 \tikzset{path picture/.code=\tikz@addmode{\def\tikz@path@picture{#1}}}%
551
552 % Fading options
553 \tikzset{path fading/.code={
554 \def\tikz@temp{#1}%
555 \ifx\tikz@temp\tikz@nonetext%
556 \tikz@addmode{\tikz@mode@fade@pathfalse}%
557 \else%
558 \ifx\tikz@temp\pgfutil@empty%
559 \else%
560 \def\tikz@path@fading{#1}%
561 \fi%
562 \tikz@addmode{\tikz@mode@fade@pathtrue}%
563 \fi%
564 },
565 path fading/.default=,
566 scope fading/.code={
567 \def\tikz@temp{#1}%
568 \ifx\tikz@temp\tikz@nonetext%
569 \tikz@addmode{\tikz@mode@fade@scopefalse}%
570 \else%
571 \ifx\tikz@temp\pgfutil@empty%
572 \else%
573 \def\tikz@scope@fading{#1}%
574 \fi%
575 \tikz@addmode{\tikz@mode@fade@scopetrue}%
576 \fi%
577 },
578 scope fading/.default=}%
579 \tikzset{fit fading/.is if=tikz@fade@adjust}%
580 \tikzset{fading transform/.store in=\tikz@fade@transform}%
581 \tikzset{fading angle/.style={fading transform={rotate={#1}}}}%
582
583 \newif\iftikz@fade@adjust%
584 \tikz@fade@adjusttrue%
585 \let\tikz@fade@transform\pgfutil@empty%
586
587 \pgfutil@colorlet{transparent}{pgftransparent}%
588 \def\tikz@do@fade@transform{\let\tikz@transform=\relax\expandafter\tikzset\expandafter{\tikz@fade@transform}}%
589
590
591
592 % Transparency groups
593 \newif\iftikz@transparency@group%
594 \tikzset{/tikz/transparency group/.code=\tikz@transparency@grouptrue\def\tikz@transparency@group@options{isolated=true,#1}\let\tikz@blend@group\pgfutil@empty}%
595 \tikzset{/tikz/blend group/.code=\tikz@transparency@grouptrue\def\tikz@transparency@group@options{isolated=true}\def\tikz@blend@group{\pgfsetblendmode{#1}}}%
596
597 \let\tikz@blend@group\pgfutil@empty
598
599 % Shading options
600 \tikzoption{shading}{\def\tikz@shading{#1}\tikz@addmode{\tikz@mode@shadetrue}}%
601 \tikzoption{shading angle}{\def\tikz@shade@angle{#1}\tikz@addmode{\tikz@mode@shadetrue}}%
602 \tikzoption{top color}{%
603 \pgfutil@colorlet{tikz@axis@top}{#1}%
604 \pgfutil@colorlet{tikz@axis@middle}{tikz@axis@top!50!tikz@axis@bottom}%
605 \def\tikz@shading{axis}\def\tikz@shade@angle{0}\tikz@addmode{\tikz@mode@shadetrue}}%
606 \tikzoption{bottom color}{%
607 \pgfutil@colorlet{tikz@axis@bottom}{#1}%
608 \pgfutil@colorlet{tikz@axis@middle}{tikz@axis@top!50!tikz@axis@bottom}%
609 \def\tikz@shading{axis}\def\tikz@shade@angle{0}\tikz@addmode{\tikz@mode@shadetrue}}%
610 \tikzoption{middle color}{%
611 \pgfutil@colorlet{tikz@axis@middle}{#1}%
612 \def\tikz@shading{axis}\tikz@addmode{\tikz@mode@shadetrue}}%
613 \tikzoption{left color}{%
614 \pgfutil@colorlet{tikz@axis@top}{#1}%
615 \pgfutil@colorlet{tikz@axis@middle}{tikz@axis@top!50!tikz@axis@bottom}%
616 \def\tikz@shading{axis}\def\tikz@shade@angle{90}\tikz@addmode{\tikz@mode@shadetrue}}%
617 \tikzoption{right color}{%
618 \pgfutil@colorlet{tikz@axis@bottom}{#1}%
619 \pgfutil@colorlet{tikz@axis@middle}{tikz@axis@top!50!tikz@axis@bottom}%
620 \def\tikz@shading{axis}\def\tikz@shade@angle{90}\tikz@addmode{\tikz@mode@shadetrue}}%
621 \tikzoption{ball color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{ball}\tikz@addmode{\tikz@mode@shadetrue}}%
622 \tikzoption{inner color}{\pgfutil@colorlet{tikz@radial@inner}{#1}\def\tikz@shading{radial}\tikz@addmode{\tikz@mode@shadetrue}}%
623 \tikzoption{outer color}{\pgfutil@colorlet{tikz@radial@outer}{#1}\def\tikz@shading{radial}\tikz@addmode{\tikz@mode@shadetrue}}%
624
625 \def\tikz@shading{axis}%
626 \def\tikz@shade@angle{0}%
627
628 \pgfdeclareverticalshading[tikz@axis@top,tikz@axis@middle,tikz@axis@bottom]{axis}{100bp}{%
629 color(0bp)=(tikz@axis@bottom);
630 color(25bp)=(tikz@axis@bottom);
631 color(50bp)=(tikz@axis@middle);
632 color(75bp)=(tikz@axis@top);
633 color(100bp)=(tikz@axis@top)}%
634
635 \pgfutil@colorlet{tikz@axis@top}{gray}%
636 \pgfutil@colorlet{tikz@axis@middle}{gray!50!white}%
637 \pgfutil@colorlet{tikz@axis@bottom}{white}%
638
639 \pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
640 color(0bp)=(tikz@ball!15!white);
641 color(9bp)=(tikz@ball!75!white);
642 color(18bp)=(tikz@ball!70!black);
643 color(25bp)=(tikz@ball!50!black);
644 color(50bp)=(black)}%
645
646 \pgfutil@colorlet{tikz@ball}{blue}%
647
648 \pgfdeclareradialshading[tikz@radial@inner,tikz@radial@outer]{radial}{\pgfpointorigin}{%
649 color(0bp)=(tikz@radial@inner);
650 color(25bp)=(tikz@radial@outer);
651 color(50bp)=(tikz@radial@outer)}%
652
653 \pgfutil@colorlet{tikz@radial@inner}{gray}%
654 \pgfutil@colorlet{tikz@radial@outer}{white}%
655
656
657 % Pin options
658 \tikzset{
659 pin distance/.store in=\tikz@pin@distance,
660 pin distance=3ex,
661 pin position/.store in=\tikz@pin@default@pos,
662 pin position=above,
663 pin edge/.store in=\tikz@pin@edge@style,
664 pin edge={},
665 tikz@pin@post/.code={\global\let\tikz@pin@edge@style@smuggle=\tikz@pin@edge@style},
666 tikz@pre@pin@edge/.code={%
667 \toks0=\expandafter{\tikz@pin@edge@style@smuggle}%
668 \edef\pgf@marshal{\noexpand\tikzset{tikz@pin@options/.style={\the\toks0}}}%
669 \pgf@marshal
670 },%
671 }%
672
673 \tikzset{%
674 pin/.code={%
675 \begingroup
676 \ifnum\the\catcode`\:=\active\relax
677 \def\tikz@next{%
678 \endgroup
679 \tikz@parse@pin@active@i{#1}}%
680 \else
681 \def\tikz@next{%
682 \endgroup
683 \pgfutil@ifnextchar[%]
684 {\tikz@parse@pin@nonactive}
685 {\tikz@parse@pin@nonactive[]}#1:\pgf@nil}%
686 \fi
687 \tikz@next}}%
688
689 \begingroup
690 \catcode`\:=\active\relax
691
692 \gdef\tikz@parse@pin@active@i#1{%
693 \pgfutil@ifnextchar[%]
694 {\tikz@parse@pin@active}
695 {\tikz@parse@pin@active[]}#1:\pgf@nil}%
696
697 \long\gdef\tikz@parse@pin@active[#1]#2:#3\pgf@nil{%
698 \def\tikz@temp{#3}%
699 \ifx\tikz@temp\pgfutil@empty
700 % no position, use default
701 \tikz@@parse@pin@active[#1]\tikz@pin@default@pos:#2:\pgf@nil%
702 \else
703 \tikz@@parse@pin@active[#1]#2:#3\pgf@nil%
704 \fi}%
705
706 \long\gdef\tikz@@parse@pin@active[#1]#2:#3:\pgf@nil{%
707 \tikzset{%
708 append after command = {%
709 \bgroup
710 [current point is local = true]
711 \pgfextra{\let\tikz@save@last@node=\tikzlastnode\tikz@node@is@a@labelfalse}%
712 node [tikz@label@angle = #2,
713 anchor=@auto,
714 every pin,
715 #1,
716 append after command = {%
717 (\tikz@save@last@node)
718 edge [every pin edge,
719 tikz@pre@pin@edge,
720 tikz@pin@options]
721 (\tikzlastnode)},
722 tikz@label@post = \tikz@pin@distance,
723 tikz@pin@post] {#3}
724 \egroup}}}%
725 \endgroup
726
727 \long\def\tikz@parse@pin@nonactive[#1]#2:#3\pgf@nil{%
728 \def\tikz@temp{#3}%
729 \ifx\tikz@temp\pgfutil@empty
730 % no position, use default
731 \tikz@@parse@pin@nonactive[#1]\tikz@pin@default@pos:#2:\pgf@nil%
732 \else
733 \tikz@@parse@pin@nonactive[#1]#2:#3\pgf@nil%
734 \fi}%
735
736 \long\def\tikz@@parse@pin@nonactive[#1]#2:#3:\pgf@nil{%
737 \tikzset{%
738 append after command = {%
739 \bgroup
740 [current point is local = true]
741 \pgfextra{\let\tikz@save@last@node=\tikzlastnode\tikz@node@is@a@labelfalse}%
742 node [tikz@label@angle = #2,
743 anchor=@auto,
744 every pin,
745 #1,
746 append after command = {%
747 (\tikz@save@last@node)
748 edge [every pin edge,
749 tikz@pre@pin@edge,
750 tikz@pin@options]
751 (\tikzlastnode)},
752 tikz@label@post = \tikz@pin@distance,
753 tikz@pin@post] {#3}
754 \egroup}}}%
755
756 % Label and pin options
757
758 \tikzset{
759 label distance/.store in=\tikz@label@distance,
760 label distance=0pt,
761 label position/.store in=\tikz@label@default@pos,
762 label position=above,
763 absolute/.is if=tikz@absolute,
764 tikz@label@angle/.store in=\tikz@label@angle
765 }%
766
767 \newif\iftikz@absolute
768 \def\tikz@on@text{center}%
769
770 \tikzset{tikz@label@post/.code 2 args={
771 \edef\tikz@label@angle{\tikz@label@angle}%
772 \expandafter\pgfkeys@spdef\expandafter\tikz@label@angle\expandafter{\tikz@label@angle}%
773 \csname tikz@label@angle@is@\tikz@label@angle\endcsname
774 \ifx\tikz@label@angle\tikz@on@text%
775 \def\tikz@node@at{\pgfpointanchor{\tikzlastnode}{center}}%
776 \def\tikz@anchor{center}%
777 \else%
778 \iftikz@absolute%
779 \pgftransformreset%
780 \pgf@process{%
781 \pgfpointshapeborder{\tikzlastnode}%
782 {\pgfpointadd{\pgfpointanchor{\tikzlastnode}{center}}{\pgfpointpolar{\tikz@label@angle}{1pt}}}}%
783 \edef\tikz@node@at{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
784 \tikz@compute@direction{\tikz@label@angle}%
785 \tikz@addtransform{\pgftransformshift{\pgfpointpolar{\tikz@label@angle}{#1}}}%
786 \else%
787 \pgf@process{\pgfpointanchor{\tikzlastnode}{\tikz@label@angle}}%
788 \edef\tikz@node@at{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
789 \pgf@xb=\pgf@x%
790 \pgf@yb=\pgf@y%
791 \pgf@process{\pgfpointanchor{\tikzlastnode}{center}}%
792 \pgf@xc=\pgf@x%
793 \pgf@yc=\pgf@y%
794 \tikz@label@simplefalse%
795 \ifdim\pgf@xc=\pgf@xb\relax%
796 \ifdim\pgf@yc=\pgf@yb\relax%
797 \tikz@label@simpletrue%
798 \fi%
799 \fi%
800 \iftikz@label@simple%
801 \tikz@compute@direction{\tikz@label@angle}%
802 \tikz@addtransform{\pgftransformshift{\pgfpointpolar{\tikz@label@angle}{#1}}}%
803 \else%
804 \pgf@process{\pgfpointnormalised{%
805 \pgfpointdiff{\pgfpointtransformed{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgfpointtransformed{\pgfqpoint{\pgf@xb}{\pgf@yb}}}}}%
806 \edef\pgf@marshal{%
807 \noexpand\tikz@addtransform{\noexpand\pgftransformshift{\noexpand\pgfpointscale{#1}{
808 \noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}}}%
809 \pgf@marshal%
810 \pgf@xc=\pgf@x%
811 \pgf@yc=\pgf@y%
812 \pgf@x=\pgf@yc%
813 \pgf@y=-\pgf@xc%
814 \ifx\tikz@anchor\tikz@auto@text%
815 \tikz@auto@anchor%
816 \fi%
817 \fi%
818 \fi%
819 \fi}
820 }%
821
822 \newif\iftikz@label@simple%
823
824 \tikzset{%
825 label/.code={%
826 \begingroup
827 \ifnum\the\catcode`\:=\active\relax
828 \def\tikz@next{%
829 \endgroup
830 \tikz@parse@label@active@i{#1}}%
831 \else
832 \def\tikz@next{%
833 \endgroup
834 \pgfutil@ifnextchar[%]
835 {\tikz@parse@label@nonactive}
836 {\tikz@parse@label@nonactive[]}#1:\pgf@nil}%
837 \fi
838 \tikz@next}}%
839
840 \begingroup
841 \catcode`\:=\active\relax
842
843 \gdef\tikz@parse@label@active@i#1{%
844 \pgfutil@ifnextchar[%]
845 {\tikz@parse@label@active}
846 {\tikz@parse@label@active[]}#1:\pgf@nil}%
847
848 \gdef\tikz@parse@label@active[#1]#2:#3\pgf@nil{%
849 \def\tikz@temp{#3}%
850 \ifx\tikz@temp\pgfutil@empty
851 % no position, use default
852 \tikz@@parse@label@active[#1]\tikz@label@default@pos:#2:\pgf@nil%
853 \else
854 \def\tikz@temp{#2}%
855 \ifx\tikz@temp\pgfutil@empty
856 \tikz@@parse@label@active[#1]\tikz@label@default@pos:#3\pgf@nil%
857 \else
858 \tikz@@parse@label@active[#1]#2:#3\pgf@nil%
859 \fi
860 \fi
861 }%
862
863 \gdef\tikz@@parse@label@active[#1]#2:#3:\pgf@nil{%
864 \tikzset{%
865 append after command = {%
866 \bgroup
867 [current point is local=true]
868 \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name\tikz@node@is@a@labelfalse}
869 node [tikz@label@angle = #2,
870 anchor=@auto,
871 every label,
872 #1,
873 tikz@label@post = \tikz@label@distance] {\iftikz@handle@active@nodes\expandafter\scantokens\else\expandafter\pgfutil@firstofone\fi{#3\noexpand}}
874 \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name}
875 \egroup}}}%
876 \endgroup
877
878 \def\tikz@parse@label@nonactive[#1]#2:#3\pgf@nil{%
879 \def\tikz@temp{#3}%
880 \ifx\tikz@temp\pgfutil@empty
881 % no position, use default
882 \tikz@@parse@label@nonactive[#1]\tikz@label@default@pos:#2:\pgf@nil%
883 \else
884 \def\tikz@temp{#2}%
885 \ifx\tikz@temp\pgfutil@empty
886 \tikz@@parse@label@nonactive[#1]\tikz@label@default@pos:#3\pgf@nil%
887 \else
888 \tikz@@parse@label@nonactive[#1]#2:#3\pgf@nil%
889 \fi
890 \fi
891 }%
892
893 \def\tikz@@parse@label@nonactive[#1]#2:#3:\pgf@nil{%
894 \tikzset{%
895 append after command = {%
896 \bgroup
897 [current point is local=true]
898 \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name\tikz@node@is@a@labelfalse}
899 node [tikz@label@angle = #2,
900 anchor=@auto,
901 every label,
902 #1,
903 tikz@label@post = \tikz@label@distance] {\iftikz@handle@active@nodes\expandafter\scantokens\else\expandafter\pgfutil@firstofone\fi{#3\noexpand}}
904 \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name}
905 \egroup}}}%
906
907 \expandafter\def\csname tikz@label@angle@is@right\endcsname{\def\tikz@label@angle{0}}%
908 \expandafter\def\csname tikz@label@angle@is@above right\endcsname{\def\tikz@label@angle{45}}%
909 \expandafter\def\csname tikz@label@angle@is@above\endcsname{\def\tikz@label@angle{90}}%
910 \expandafter\def\csname tikz@label@angle@is@above left\endcsname{\def\tikz@label@angle{135}}%
911 \expandafter\def\csname tikz@label@angle@is@left\endcsname{\def\tikz@label@angle{180}}%
912 \expandafter\def\csname tikz@label@angle@is@below left\endcsname{\def\tikz@label@angle{225}}%
913 \expandafter\def\csname tikz@label@angle@is@below\endcsname{\def\tikz@label@angle{270}}%
914 \expandafter\def\csname tikz@label@angle@is@below right\endcsname{\def\tikz@label@angle{315}}%
915
916 \def\tikz@compute@direction#1{%
917 \ifx\tikz@anchor\tikz@auto@text%
918 \let\tikz@do@auto@anchor=\relax
919 \pgfmathsetcount{\c@pgf@counta}{#1}%
920 \ifnum\c@pgf@counta<0\relax
921 \advance\c@pgf@counta by 360\relax%
922 \fi%
923 \ifnum\c@pgf@counta>359\relax
924 \advance\c@pgf@counta by-360\relax%
925 \fi%
926 \ifnum\c@pgf@counta<4\relax%
927 \def\tikz@anchor{west}%
928 \else\ifnum\c@pgf@counta<87\relax%
929 \def\tikz@anchor{south west}%
930 \else\ifnum\c@pgf@counta<94\relax%
931 \def\tikz@anchor{south}%
932 \else\ifnum\c@pgf@counta<177\relax%
933 \def\tikz@anchor{south east}%
934 \else\ifnum\c@pgf@counta<184\relax%
935 \def\tikz@anchor{east}%
936 \else\ifnum\c@pgf@counta<267\relax%
937 \def\tikz@anchor{north east}%
938 \else\ifnum\c@pgf@counta<274\relax%
939 \def\tikz@anchor{north}%
940 \else\ifnum\c@pgf@counta<357\relax%
941 \def\tikz@anchor{north west}%
942 \else%
943 \def\tikz@anchor{west}%
944 \fi\fi\fi\fi\fi\fi\fi\fi%
945 \fi%
946 }%
947 \def\tikz@auto@text{@auto}%
948
949 % General node options
950 \tikzset{
951 name/.code={\edef\tikz@fig@name{\tikz@pp@name{#1}}\let\tikz@id@name\tikz@fig@name},%
952 name prefix/.initial=,%
953 name suffix/.initial=,%
954 local bounding box/.style={/pgf/local bounding box/.expanded=\tikz@pp@name{#1}}
955 }%
956 \def\tikz@pp@name#1{\csname pgfk@/tikz/name prefix\endcsname#1\csname pgfk@/tikz/name suffix\endcsname}%
957
958
959 \tikzset{
960 node contents/.code=\def\tikz@node@content{#1},
961 pic type/.code=\def\tikz@node@content{#1}, % alias
962 }%
963
964 \tikzset{
965 behind path/.code=\def\tikz@whichbox{\tikz@figbox@bg},
966 in front of path/.code=\def\tikz@whichbox{\tikz@figbox}
967 }%
968 \def\tikz@whichbox{\tikz@figbox}%
969
970 \tikzoption{at}{\tikz@scan@one@point\tikz@set@at#1}%
971 \def\tikz@set@at#1{\def\tikz@node@at{#1}}%
972
973 \tikzoption{shape}{\edef\tikz@shape{#1}}%
974
975 \tikzoption{nodes}{\tikzset{every node/.append style={#1}}}%
976
977 \tikzset{alias/.code={%
978 \tikz@fig@mustbenamed
979 \begingroup
980 \toks0=\expandafter{\tikz@alias}%
981 \edef\pgf@temp{\noexpand\pgfnodealias{\tikz@pp@name{#1}}{\noexpand\tikz@fig@name}}%
982 \toks1=\expandafter{\pgf@temp}%
983 \xdef\pgf@marshal{%
984 \noexpand\def\noexpand\tikz@alias{\the\toks0 \the\toks1 }%
985 }%
986 \endgroup
987 \pgf@marshal
988 }}%
989
990 % deprecated:
991 \def\tikzaddafternodepathoption#1{#1\tikzset{prefix after command={\pgfextra{#1}}}}%
992 \tikzset{after node path/.style={append after command={#1}}}%
993
994
995 % Pic options
996 \tikzset{pic text/.store in=\tikzpictext}%
997 \let\tikzpictext\relax
998 \tikzset{pic text options/.store in=\tikzpictextoptions}%
999 \let\tikzpictextoptions\pgfutil@empty
1000
1001
1002 % Anchoring
1003
1004 \tikzoption{anchor}{\def\tikz@anchor{#1}\let\tikz@do@auto@anchor=\relax}%
1005
1006 \tikzoption{left}[]{\def\tikz@anchor{east}\tikz@possibly@transform{x}{-}{#1}}%
1007 \tikzoption{right}[]{\def\tikz@anchor{west}\tikz@possibly@transform{x}{}{#1}}%
1008 \tikzoption{above}[]{\def\tikz@anchor{south}\tikz@possibly@transform{y}{}{#1}}%
1009 \tikzoption{below}[]{\def\tikz@anchor{north}\tikz@possibly@transform{y}{-}{#1}}%
1010 \tikzoption{above left}[]%
1011 {\def\tikz@anchor{south east}%
1012 \tikz@possibly@transform{x}{-}{#1}\tikz@possibly@transform{y}{}{#1}}%
1013 \tikzoption{above right}[]%
1014 {\def\tikz@anchor{south west}%
1015 \tikz@possibly@transform{x}{}{#1}\tikz@possibly@transform{y}{}{#1}}%
1016 \tikzoption{below left}[]%
1017 {\def\tikz@anchor{north east}%
1018 \tikz@possibly@transform{x}{-}{#1}\tikz@possibly@transform{y}{-}{#1}}%
1019 \tikzoption{below right}[]%
1020 {\def\tikz@anchor{north west}%
1021 \tikz@possibly@transform{x}{}{#1}\tikz@possibly@transform{y}{-}{#1}}%
1022 \tikzset{centered/.code=\def\tikz@anchor{center}}%
1023
1024 \tikzoption{node distance}{\def\tikz@node@distance{#1}}%
1025 \def\tikz@node@distance{1cm}%
1026
1027 % The following are deprecated:
1028 \tikzoption{above of}{\tikz@of{#1}{90}}%
1029 \tikzoption{below of}{\tikz@of{#1}{-90}}%
1030 \tikzoption{left of}{\tikz@of{#1}{180}}%
1031 \tikzoption{right of}{\tikz@of{#1}{0}}%
1032 \tikzoption{above left of}{\tikz@of{#1}{135}}%
1033 \tikzoption{below left of}{\tikz@of{#1}{-135}}%
1034 \tikzoption{above right of}{\tikz@of{#1}{45}}%
1035 \tikzoption{below right of}{\tikz@of{#1}{-45}}%
1036 \def\tikz@of#1#2{%
1037 \def\tikz@anchor{center}%
1038 \let\tikz@do@auto@anchor=\relax%
1039 \tikz@addtransform{%
1040 \expandafter\tikz@extract@node@dist\tikz@node@distance and\pgf@stop%
1041 \pgftransformshift{\pgfpointpolar{#2}{\tikz@extracted@node@distance}}}%
1042 \def\tikz@node@at{\pgfpointanchor{\tikz@pp@name{#1}}{center}}}%
1043 \def\tikz@extract@node@dist#1and#2\pgf@stop{%
1044 \def\tikz@extracted@node@distance{#1}}%
1045
1046 \tikzset{
1047 transform shape nonlinear/.is choice,
1048 transform shape nonlinear/.default=true,
1049 transform shape nonlinear/true/.code=\let\tikz@nlt\relax,
1050 transform shape nonlinear/false/.code=\def\tikz@nlt{\pgfapproximatenonlineartranslation},
1051 transform shape nonlinear=false,
1052 }%
1053
1054
1055 \tikzoption{transform shape}[true]{%
1056 \csname tikz@fullytransformed#1\endcsname%
1057 \iftikz@fullytransformed%
1058 \pgfresetnontranslationattimefalse%
1059 \else%
1060 \pgfresetnontranslationattimetrue%
1061 \fi%
1062 }%
1063
1064 \newif\iftikz@fullytransformed
1065 \pgfresetnontranslationattimetrue%
1066
1067 \def\tikz@anchor{center}%
1068 \def\tikz@shape{rectangle}%
1069
1070 \def\tikz@possibly@transform#1#2#3{%
1071 \let\tikz@do@auto@anchor=\relax%
1072 \def\tikz@test{#3}%
1073 \ifx\tikz@test\pgfutil@empty%
1074 \else%
1075 \pgfmathsetlength{\pgf@x}{#3}%
1076 \pgf@x=#2\pgf@x\relax%
1077 \edef\tikz@marshal{\noexpand\tikz@addtransform{%
1078 \expandafter\noexpand\csname pgftransform#1shift\endcsname{\the\pgf@x}}}%
1079 \tikz@marshal%
1080 \fi%
1081 }%
1082
1083
1084 % Inter-picture options
1085 \tikzoption{remember picture}[true]{\csname pgfrememberpicturepositiononpage#1\endcsname}
1086 \tikzset{
1087 overlay/.is choice,
1088 overlay/true/.code={\pgf@relevantforpicturesizefalse},
1089 overlay/false/.code={\pgf@relevantforpicturesizetrue},
1090 overlay/.default=true
1091 }
1092
1093
1094
1095 % Line/curve label placement options
1096 \tikzoption{sloped}[true]{\csname pgfslopedattime#1\endcsname}%
1097 \tikzoption{allow upside down}[true]{\csname pgfallowupsidedownattime#1\endcsname}%
1098
1099 \tikzoption{pos}{\edef\tikz@time{#1}\ifx\tikz@time\pgfutil@empty\else\pgfmathsetmacro\tikz@time{\tikz@time}\fi}%
1100
1101 \tikzoption{auto}[]{\csname tikz@install@auto@anchor@#1\endcsname}%
1102 \tikzoption{swap}[]{%
1103 \def\tikz@temp{left}%
1104 \ifx\tikz@auto@anchor@direction\tikz@temp%
1105 \def\tikz@auto@anchor@direction{right}%
1106 \else%
1107 \def\tikz@auto@anchor@direction{left}%
1108 \fi%
1109 }%
1110 \tikzset{'/.style=swap}% shorthand
1111
1112
1113 \def\tikz@install@auto@anchor@{\let\tikz@do@auto@anchor=\tikz@auto@anchor@on}%
1114 \def\tikz@install@auto@anchor@false{\let\tikz@do@auto@anchor=\relax}%
1115 \def\tikz@install@auto@anchor@left{\let\tikz@do@auto@anchor=\tikz@auto@anchor@on\def\tikz@auto@anchor@direction{left}}%
1116 \def\tikz@install@auto@anchor@right{\let\tikz@do@auto@anchor=\tikz@auto@anchor@on\def\tikz@auto@anchor@direction{right}}%
1117
1118 \let\tikz@do@auto@anchor=\relax%
1119
1120 \def\tikz@auto@anchor@on{\csname tikz@auto@anchor@\tikz@auto@anchor@direction\endcsname}
1121
1122 \def\tikz@auto@anchor@left{\tikz@auto@pre\tikz@auto@anchor\tikz@auto@post}%
1123 \def\tikz@auto@anchor@right{\tikz@auto@pre\tikz@auto@anchor@prime\tikz@auto@post}%
1124
1125 \def\tikz@auto@anchor@direction{left}%
1126
1127 % Text options
1128 \tikzoption{text}{\def\tikz@textcolor{#1}}%
1129 \tikzoption{font}{\def\tikz@textfont{#1}}%
1130 \tikzoption{node font}{\def\tikz@node@textfont{#1}}%
1131 \tikzoption{text opacity}{\def\tikz@textopacity{#1}}%
1132 \tikzoption{text width}{\def\tikz@text@width{#1}}%
1133 \tikzoption{text height}{\def\tikz@text@height{#1}}%
1134 \tikzoption{text depth}{\def\tikz@text@depth{#1}}%
1135 \tikzoption{text ragged}[]%
1136 {\def\tikz@text@action{\pgfutil@raggedright\rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}}%
1137 \tikzoption{text badly ragged}[]{\def\tikz@text@action{\pgfutil@raggedright\relax}}%
1138 \tikzoption{text ragged left}[]%
1139 {\def\tikz@text@action{\pgfutil@raggedleft\leftskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}}%
1140 \tikzoption{text badly ragged left}[]{\def\tikz@text@action{\pgfutil@raggedleft\relax}}%
1141 \tikzoption{text justified}[]{\def\tikz@text@action{\leftskip0pt\rightskip0pt\relax}}%
1142 \tikzoption{text centered}[]{\def\tikz@text@action{%
1143 \leftskip0pt plus2em%
1144 \rightskip0pt plus2em%
1145 \spaceskip.3333em \xspaceskip.5em%
1146 \parfillskip=0pt%
1147 \iftikz@warn@for@narrow@centered\else\hbadness10000\fi%
1148 \let\\=\@centercr% for latex
1149 \relax}}%
1150 \tikzoption{text badly centered}[]%
1151 {\def\tikz@text@action{%
1152 \let\\=\@centercr% for latex
1153 \parfillskip=0pt%
1154 \rightskip\pgfutil@flushglue%
1155 \leftskip\pgfutil@flushglue\relax}}%
1156 \tikzset{badness warnings for centered text/.is if=tikz@warn@for@narrow@centered}%
1157 \newif\iftikz@warn@for@narrow@centered
1158
1159 \def\tikz@text@reset{%
1160 \let\tikz@text@width=\pgfutil@empty
1161 \let\tikz@text@height=\pgfutil@empty
1162 \let\tikz@text@depth=\pgfutil@empty
1163 \let\tikz@textcolor=\pgfutil@empty
1164 \let\tikz@textfont=\pgfutil@empty
1165 \let\tikz@textopacity=\pgfutil@empty
1166 \let\tikz@node@textfont=\pgfutil@empty
1167 \def\tikz@text@action{\pgfutil@raggedright\rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}%
1168 }
1169 \tikz@text@reset
1170
1171
1172 % Alignment
1173 \tikzset{
1174 node halign header/.initial=,
1175 align/.is choice,
1176 align/left/.style ={text ragged,node halign header=\tikz@align@left@header},
1177 align/flush left/.style ={text badly ragged,node halign header=\tikz@align@left@header},
1178 align/right/.style ={text ragged left,node halign header=\tikz@align@right@header},
1179 align/flush right/.style ={text badly ragged left,node halign header=\tikz@align@right@header},
1180 align/center/.style={text centered,node halign header=\tikz@align@center@header},
1181 align/flush center/.style={text badly centered,node halign header=\tikz@align@center@header},
1182 align/justify/.style ={text justified,node halign header=\tikz@align@left@header},
1183 align/none/.style ={text justified,node halign header=},
1184 }%
1185 \def\tikz@align@left@header{##\hfil\cr}%
1186 \def\tikz@align@right@header{\hfil##\cr}%
1187 \def\tikz@align@center@header{\hfil##\hfil\cr}%
1188
1189
1190
1191 % Arrow options
1192 \tikzoption{arrows}{\tikz@processarrows{#1}}%
1193
1194
1195 \tikzoption{>}{\pgfdeclarearrow{name=<->,means={#1}}}%
1196 \pgfdeclarearrow{name=|<->|, means={>[sep=0pt].|}}%
1197
1198 \tikzoption{shorten <}{\pgfsetshortenstart{#1}}%
1199 \tikzoption{shorten >}{\pgfsetshortenend{#1}}%
1200
1201 \def\tikz@processarrows#1{%
1202 \def\tikz@current@arrows{#1}%
1203 \def\tikz@temp{#1}%
1204 \ifx\tikz@temp\pgfutil@empty%
1205 \else%
1206 \pgfsetarrows{#1}%
1207 \fi%
1208 }%
1209
1210 \def\tikz@current@arrows{-}%
1211
1212 % Parabola options
1213 \tikzoption{bend}{\tikz@scan@one@point\tikz@set@parabola@bend#1\relax}%
1214 \tikzoption{bend pos}{\def\tikz@parabola@bend@factor{#1}}%
1215 \tikzoption{parabola height}{%
1216 \def\tikz@parabola@bend@factor{.5}%
1217 \def\tikz@parabola@bend{\pgfpointadd{\pgfpoint{0pt}{#1}}{\tikz@last@position@saved}}}%
1218
1219 \def\tikz@parabola@bend{\tikz@last@position@saved}%
1220 \def\tikz@parabola@bend@factor{0}%
1221
1222 \def\tikz@set@parabola@bend#1{\def\tikz@parabola@bend{#1}}%
1223
1224 % Axis options
1225 \tikzoption{domain}{\edef\tikz@plot@domain{#1}\expandafter\tikz@plot@samples@recalc\tikz@plot@domain\relax}%
1226 \tikzoption{range}{\def\tikz@plot@range{#1}}%
1227 \tikzoption{yrange}{\def\tikz@plot@range{#1}}%
1228 \let\tikz@plot@range=\pgfutil@empty
1229 \tikzoption{xrange}{\def\tikz@plot@xrange{#1}}%
1230 \let\tikz@plot@xrange=\pgfutil@empty
1231
1232 % Plot options
1233 \tikzoption{smooth}[]{\let\tikz@plot@handler=\pgfplothandlercurveto}%
1234 \tikzoption{smooth cycle}[]{\let\tikz@plot@handler=\pgfplothandlerclosedcurve}%
1235 \tikzoption{sharp plot}[]{\let\tikz@plot@handler\pgfplothandlerlineto}%
1236 \tikzoption{sharp cycle}[]{\let\tikz@plot@handler\pgfplothandlerpolygon}%
1237
1238 \tikzoption{tension}{\pgfsetplottension{#1}}%
1239
1240 \tikzoption{xcomb}[]{\let\tikz@plot@handler=\pgfplothandlerxcomb}%
1241 \tikzoption{ycomb}[]{\let\tikz@plot@handler=\pgfplothandlerycomb}%
1242 \tikzoption{polar comb}[]{\let\tikz@plot@handler=\pgfplothandlerpolarcomb}%
1243 \tikzoption{ybar}[]{\let\tikz@plot@handler=\pgfplothandlerybar}%
1244 \tikzoption{ybar interval}[]{\let\tikz@plot@handler=\pgfplothandlerybarinterval}%
1245 \tikzoption{xbar interval}[]{\let\tikz@plot@handler=\pgfplothandlerxbarinterval}%
1246 \tikzoption{xbar}[]{\let\tikz@plot@handler=\pgfplothandlerxbar}%
1247 \tikzoption{const plot}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto}%
1248 \tikzoption{const plot mark left}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto}%
1249 \tikzoption{const plot mark right}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright}%
1250 \tikzoption{const plot mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkmid}%
1251 \tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright}%
1252 \tikzoption{jump mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkmid}%
1253 \tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft}%
1254
1255 \tikzoption{raw gnuplot}[true]{\csname tikz@plot@raw@gnuplot#1\endcsname}%
1256 \tikzoption{prefix}{\def\tikz@plot@prefix{#1}}%
1257 \tikzoption{id}{\def\tikz@plot@id{#1}}%
1258
1259 \tikzoption{samples}{\pgfmathsetmacro\tikz@plot@samples{max(2,#1)}\expandafter\tikz@plot@samples@recalc\tikz@plot@domain\relax}%
1260 \tikzoption{samples at}{\def\tikz@plot@samplesat{#1}}%
1261 \tikzoption{parametric}[true]{\csname tikz@plot@parametric#1\endcsname}%
1262
1263 \tikzoption{variable}{\def\tikz@plot@var{#1}}%
1264
1265 \tikzoption{only marks}[]{\let\tikz@plot@handler\pgfplothandlerdiscard}%
1266
1267 \tikzoption{mark}{%
1268 \def\tikz@plot@mark{#1}%
1269 \def\tikz@temp{none}%
1270 \ifx\tikz@temp\tikz@plot@mark
1271 \let\tikz@plot@mark=\pgfutil@empty
1272 \fi
1273 }%
1274 \tikzset{
1275 no marks/.style={mark=none},%
1276 no markers/.style={mark=none},%
1277 every mark/.style={},
1278 mark options/.style={%
1279 every mark/.style={#1}%
1280 }}%
1281 \tikzoption{mark size}{\pgfsetplotmarksize{#1}}%
1282
1283 \tikzoption{mark indices}{\def\tikz@mark@list{#1}}%
1284 \tikzoption{mark phase}{\pgfsetplotmarkphase{#1}}%
1285 \tikzoption{mark repeat}{\pgfsetplotmarkrepeat{#1}}%
1286
1287 \let\tikz@mark@list=\pgfutil@empty
1288
1289 \let\tikz@plot@handler=\pgfplothandlerlineto
1290 \let\tikz@plot@mark=\pgfutil@empty
1291
1292 \def\tikz@plot@samples{25}%
1293 \def\tikz@plot@domain{-5:5}%
1294 \def\tikz@plot@var{\x}%
1295 \def\tikz@plot@samplesat{-5,-4.5833333,...,5}%
1296 \def\tikz@plot@samples@recalc#1:#2\relax{%
1297 \begingroup
1298 \pgfmathparse{#1}%
1299 \let\tikz@temp@start=\pgfmathresult%
1300 \pgfmathparse{#2}%
1301 \let\tikz@temp@end=\pgfmathresult%
1302 \pgfmathsetmacro\tikz@temp@diff{(\tikz@temp@end-\tikz@temp@start)/(\tikz@plot@samples-1)}%
1303 %
1304 % this particular item is for backwards compatibility.
1305 % Pgfplots <= 1.8 called 'samples' in a context where the 'fpu' was
1306 % active... and I fear there is no simple solution to replace the
1307 % new \ifdim below. Sorry.
1308 \pgfkeys{/pgf/fpu/output format/fixed/.try}%
1309 %
1310 \pgfmathsetmacro\tikz@temp@diff@abs{abs(\tikz@temp@diff)}%
1311 \ifdim\tikz@temp@diff@abs pt<0.0001pt\relax%
1312 \edef\tikz@plot@samplesat{\tikz@temp@start,\tikz@temp@end}%
1313 \else%
1314 \pgfmathparse{\tikz@temp@start+\tikz@temp@diff}%
1315 \edef\tikz@plot@samplesat{\tikz@temp@start,\pgfmathresult,...,\tikz@temp@end}%
1316 \fi%
1317 \pgfmath@smuggleone\tikz@plot@samplesat
1318 \endgroup
1319 }%
1320
1321
1322 \def\tikz@plot@prefix{\jobname.}%
1323 \def\tikz@plot@id{pgf-plot}%
1324
1325 \newif\iftikz@plot@parametric
1326 \newif\iftikz@plot@raw@gnuplot
1327
1328
1329 %
1330 % To and edge options
1331 %
1332 \tikzoption{to path}{\def\tikz@to@path{#1}}%
1333
1334 \def\tikz@to@path{-- (\tikztotarget) \tikztonodes}%
1335
1336 \tikzset{edge macro/.store in=\tikz@edge@macro}%
1337 \let\tikz@edge@macro\pgfutil@empty
1338
1339 \tikzset{
1340 edge node/.code={
1341 \expandafter\def\expandafter\tikz@tonodes\expandafter{\tikz@tonodes #1}
1342 },
1343 edge label/.style={/tikz/edge node={node[auto]{#1}}},
1344 edge label'/.style={/tikz/edge node={node[auto,swap]{#1}}},
1345 }%
1346
1347
1348 % After command options
1349 \tikzset{
1350 append after command/.code=\expandafter\def\expandafter\tikz@after@path\expandafter{\tikz@after@path#1},
1351 prefix after command/.code={%
1352 \def\tikz@temp{#1}%
1353 \expandafter\expandafter\expandafter\def%
1354 \expandafter\expandafter\expandafter\tikz@after@path%
1355 \expandafter\expandafter\expandafter{%
1356 \expandafter\tikz@temp\tikz@after@path}%
1357 },
1358 }%
1359 \let\tikz@after@path\pgfutil@empty
1360
1361
1362 % Tree options
1363 \newif\iftikz@child@missing
1364 \pgfkeys{/tikz/missing/.is if=tikz@child@missing}%
1365
1366 \tikzset{edge from parent macro/.initial=\tikz@edge@from@parent@macro}%
1367 \def\tikz@edge@from@parent@macro#1#2{
1368 [style=edge from parent, #1, /utils/exec=\tikz@node@is@a@labeltrue] \tikz@edge@to@parent@path #2}%
1369
1370 \tikzoption{edge from parent path}{\def\tikz@edge@to@parent@path{#1}}%
1371
1372 \tikzoption{parent anchor}{\def\tikzparentanchor{.#1}\ifx\tikzparentanchor\tikz@border@text\let\tikzparentanchor\pgfutil@empty\fi}%
1373 \tikzoption{child anchor}{\def\tikzchildanchor{.#1}\ifx\tikzchildanchor\tikz@border@text\let\tikzchildanchor\pgfutil@empty\fi}%
1374
1375 \tikzoption{level distance}{\pgfmathsetlength\tikzleveldistance{#1}}%
1376 \tikzoption{sibling distance}{\pgfmathsetlength\tikzsiblingdistance{#1}}%
1377
1378 \tikzoption{growth function}{\let\tikz@grow=#1}%
1379
1380 \tikzset{grow siblings on line/.style={growth function=\tikz@grow@direction}}%
1381
1382 \tikzoption{growth parent anchor}{\def\tikz@growth@anchor{#1}}%
1383 \tikzoption{grow}{\tikz@set@growth{#1}\edef\tikz@special@level{\the\tikztreelevel}}%
1384 \tikzoption{grow'}{\tikz@set@growth{#1}\tikz@swap@growth\edef\tikz@special@level{\the\tikztreelevel}}%
1385
1386 \def\tikz@growth@anchor{center}%
1387
1388 \def\tikz@special@level{-1}% never
1389
1390 \def\tikz@swap@growth{%
1391 % Swap left and right
1392 \let\tikz@temp=\tikz@angle@grow@right%
1393 \let\tikz@angle@grow@right=\tikz@angle@grow@left%
1394 \let\tikz@angle@grow@left=\tikz@temp%
1395 }%
1396
1397 \def\tikz@set@growth#1{%
1398 \let\tikz@grow=\tikz@grow@direction%
1399 \expandafter\ifx\csname tikz@grow@direction@#1\endcsname\relax%
1400 \c@pgf@counta=#1\relax%
1401 \else%
1402 \c@pgf@counta=\csname tikz@grow@direction@#1\endcsname%
1403 \fi%
1404 \edef\tikz@angle@grow{\the\c@pgf@counta}%
1405 \advance\c@pgf@counta by-90\relax%
1406 \edef\tikz@angle@grow@left{\the\c@pgf@counta}%
1407 \advance\c@pgf@counta by180\relax%
1408 \edef\tikz@angle@grow@right{\the\c@pgf@counta}%
1409 }%
1410
1411 \def\tikz@border@text{.border}%
1412 \let\tikzparentanchor=\pgfutil@empty
1413 \let\tikzchildanchor=\pgfutil@empty
1414 \def\tikz@edge@to@parent@path{(\tikzparentnode\tikzparentanchor) -- (\tikzchildnode\tikzchildanchor)}%
1415
1416 \tikzleveldistance=15mm%
1417 \tikzsiblingdistance=15mm%
1418
1419 \def\tikz@grow@direction@down{-90}%
1420 \def\tikz@grow@direction@up{90}%
1421 \def\tikz@grow@direction@left{180}%
1422 \def\tikz@grow@direction@right{0}%
1423
1424 \def\tikz@grow@direction@south{-90}%
1425 \def\tikz@grow@direction@north{90}%
1426 \def\tikz@grow@direction@west{180}%
1427 \def\tikz@grow@direction@east{0}%
1428
1429 \expandafter\def\csname tikz@grow@direction@north east\endcsname{45}%
1430 \expandafter\def\csname tikz@grow@direction@north west\endcsname{135}%
1431 \expandafter\def\csname tikz@grow@direction@south east\endcsname{-45}%
1432 \expandafter\def\csname tikz@grow@direction@south west\endcsname{-135}%
1433
1434 \def\tikz@grow@direction{%
1435 \pgftransformshift{\pgfpointpolar{\tikz@angle@grow}{\tikzleveldistance}}%
1436 \ifnum\tikztreelevel=\tikz@special@level%
1437 \else%
1438 \pgf@xc=.5\tikzsiblingdistance%
1439 \c@pgf@counta=\tikznumberofchildren%
1440 \advance\c@pgf@counta by1\relax%
1441 \pgfutil@tempdima=\c@pgf@counta\pgf@xc%
1442 \pgftransformshift{\pgfpointpolar{\tikz@angle@grow@left}{\pgfutil@tempdima}}%
1443 \pgftransformshift{\pgfpointpolar{\tikz@angle@grow@right}{\tikznumberofcurrentchild\tikzsiblingdistance}}%
1444 \fi%
1445 }%
1446
1447 \tikzset{grow=down}%
1448
1449
1450 % Snakes are in a lib:
1451 \tikzset{snake/.code=\tikzerror{You need to say \string\usetikzlibrary{snakes}}}%
1452
1453 % Decorations
1454 \tikzset{decorate/.code=\tikzerror{You need to load a decoration library}}%
1455
1456 % Matrix options
1457 \usepgfmodule{matrix}%
1458
1459 \tikzoption{matrix}[true]{\csname tikz@is@matrix#1\endcsname}%
1460
1461 \tikzoption{matrix anchor}{\def\tikz@matrix@anchor{#1}}%
1462
1463 \tikzoption{column sep}{\def\pgfmatrixcolumnsep{#1}}%
1464 \tikzoption{row sep}{\def\pgfmatrixrowsep{#1}}%
1465
1466 \tikzoption{cells}{\tikzset{every cell/.append style={#1}}}%
1467
1468 \tikzoption{ampersand replacement}{\def\tikz@ampersand@replacement{#1}}%
1469
1470 \newif\iftikz@is@matrix
1471 \let\tikz@matrix@anchor=\pgfutil@empty
1472 \let\tikz@ampersand@replacement=\pgfutil@empty
1473
1474
1475 % Automatic shorthand management
1476 \tikzset{%
1477 handle active characters in code/.is if=tikz@handle@active@code,
1478 handle active characters in nodes/.is if=tikz@handle@active@nodes,
1479 }%
1480 \newif\iftikz@handle@active@code
1481 \newif\iftikz@handle@active@nodes
1482
1483
1484 % Execute option
1485 \tikzoption{execute at begin picture}{\expandafter\def\expandafter\tikz@atbegin@picture\expandafter{\tikz@atbegin@picture#1}}%
1486 \tikzoption{execute at end picture}{\expandafter\def\expandafter\tikz@atend@picture\expandafter{\tikz@atend@picture#1}}%
1487 \tikzoption{execute at begin scope}{\expandafter\def\expandafter\tikz@atbegin@scope\expandafter{\tikz@atbegin@scope#1}}%
1488 \tikzoption{execute at end scope}{\expandafter\def\expandafter\tikz@atend@scope\expandafter{\tikz@atend@scope#1}}%
1489 \tikzoption{execute at begin to}{\expandafter\def\expandafter\tikz@atbegin@to\expandafter{\tikz@atbegin@to#1}}%
1490 \tikzoption{execute at end to}{\expandafter\def\expandafter\tikz@atend@to\expandafter{\tikz@atend@to#1}}%
1491 \tikzoption{execute at begin node}{\expandafter\def\expandafter\tikz@atbegin@node\expandafter{\tikz@atbegin@node#1}}%
1492 \tikzoption{execute at end node}{\expandafter\def\expandafter\tikz@atend@node\expandafter{\tikz@atend@node#1}}%
1493 \tikzoption{execute at begin matrix}{\expandafter\def\expandafter\tikz@atbegin@matrix\expandafter{\tikz@atbegin@matrix#1}}%
1494 \tikzoption{execute at end matrix}{\expandafter\def\expandafter\tikz@atend@matrix\expandafter{\tikz@atend@matrix#1}}%
1495 \tikzoption{execute at begin cell}{\expandafter\def\expandafter\tikz@atbegin@cell\expandafter{\tikz@atbegin@cell#1}}%
1496 \tikzoption{execute at end cell}{\expandafter\def\expandafter\tikz@atend@cell\expandafter{\tikz@atend@cell#1}}%
1497 \tikzoption{execute at empty cell}{\expandafter\def\expandafter\tikz@at@emptycell\expandafter{\tikz@at@emptycell#1}}%
1498
1499 \let\tikz@atbegin@picture=\pgfutil@empty
1500 \let\tikz@atend@picture=\pgfutil@empty
1501 \let\tikz@atbegin@scope=\pgfutil@empty
1502 \let\tikz@atend@scope=\pgfutil@empty
1503 \let\tikz@atbegin@to=\pgfutil@empty
1504 \let\tikz@atend@to=\pgfutil@empty
1505 \let\tikz@atbegin@node=\pgfutil@empty
1506 \let\tikz@atend@node=\pgfutil@empty
1507 \let\tikz@atbegin@cell=\pgfutil@empty
1508 \let\tikz@atend@cell=\pgfutil@empty
1509 \let\tikz@at@emptycell=\pgfutil@empty
1510 \let\tikz@atbegin@matrix=\pgfutil@empty
1511 \let\tikz@atend@matrix=\pgfutil@empty
1512
1513
1514 % Pre and post actions
1515 \tikzset{preaction/.code=\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\tikz@extra@preaction{#1}}}%
1516 \tikzset{postaction/.code=\expandafter\def\expandafter\tikz@postactions\expandafter{\tikz@postactions\tikz@extra@postaction{#1}}}%
1517 \let\tikz@preactions=\pgfutil@empty
1518 \let\tikz@postactions=\pgfutil@empty
1519
1520 % Styles
1521 \tikzoption{set style}{\tikzstyle#1}%
1522
1523 % Handled in a special way.
1524 \def\tikzstyle{\pgfutil@ifnextchar\bgroup\tikz@style@parseA\tikz@style@parseB}%
1525 \def\tikz@style@parseB#1={\tikz@style@parseA{#1}=}%
1526 \def\tikz@style@parseA#1#2=#3[#4]{% check for an optional argument
1527 \pgfutil@in@[{#2}%]
1528 \ifpgfutil@in@%
1529 \tikz@style@parseC{#1}#2={#4}%
1530 \else%
1531 \tikz@style@parseD{#1}#2={#4}%
1532 \fi%
1533 }%
1534
1535 \def\tikz@style@parseC#1[#2]#3=#4{%
1536 \pgfkeys{/tikz/#1/.default={#2}}%
1537 \pgfutil@in@+{#3}%
1538 \ifpgfutil@in@%
1539 \pgfkeys{/tikz/#1/.append style={#4}}%
1540 \else%
1541 \pgfkeys{/tikz/#1/.style={#4}}%
1542 \fi}%
1543 \def\tikz@style@parseD#1#2=#3{%
1544 \pgfutil@in@+{#2}%
1545 \ifpgfutil@in@%
1546 \pgfkeys{/tikz/#1/.append style={#3}}%
1547 \else%
1548 \pgfkeys{/tikz/#1/.style={#3}}%
1549 \fi}%
1550
1551
1552 %
1553 %
1554 % Predefined styles
1555 %
1556 %
1557
1558 \tikzset{help lines/.style= {color=gray,line width=0.2pt}}%
1559
1560 \tikzset{every picture/.style= {}}%
1561 \tikzset{every path/.style= {}}%
1562 \tikzset{every scope/.style= {}}%
1563 \tikzset{every plot/.style= {}}%
1564 \tikzset{every node/.style= {}}%
1565 \tikzset{every child/.style= {}}%
1566 \tikzset{every child node/.style= {}}%
1567 \tikzset{every to/.style= {}}%
1568 \tikzset{every cell/.style= {}}%
1569 \tikzset{every matrix/.style= {}}%
1570 \tikzset{every edge/.style= {draw}}%
1571 \tikzset{every label/.style= {draw=none,fill=none}}%
1572 \tikzset{every pin/.style= {draw=none,fill=none}}%
1573 \tikzset{every pin edge/.style= {help lines}}%
1574
1575 \tikzset{ultra thin/.style= {line width=0.1pt}}%
1576 \tikzset{very thin/.style= {line width=0.2pt}}%
1577 \tikzset{thin/.style= {line width=0.4pt}}%
1578 \tikzset{semithick/.style= {line width=0.6pt}}%
1579 \tikzset{thick/.style= {line width=0.8pt}}%
1580 \tikzset{very thick/.style= {line width=1.2pt}}%
1581 \tikzset{ultra thick/.style= {line width=1.6pt}}%
1582
1583 \tikzset{solid/.style= {dash pattern=}}%
1584 \tikzset{dotted/.style= {dash pattern=on \pgflinewidth off 2pt}}%
1585 \tikzset{densely dotted/.style= {dash pattern=on \pgflinewidth off 1pt}}%
1586 \tikzset{loosely dotted/.style= {dash pattern=on \pgflinewidth off 4pt}}%
1587 \tikzset{dashed/.style= {dash pattern=on 3pt off 3pt}}%
1588 \tikzset{densely dashed/.style= {dash pattern=on 3pt off 2pt}}%
1589 \tikzset{loosely dashed/.style= {dash pattern=on 3pt off 6pt}}%
1590 \tikzset{dashdotted/.style= {dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt}}%
1591 \tikzset{dash dot/.style= {dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt}}%
1592 \tikzset{densely dashdotted/.style= {dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt}}%
1593 \tikzset{densely dash dot/.style= {dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt}}%
1594 \tikzset{loosely dashdotted/.style= {dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt}}%
1595 \tikzset{loosely dash dot/.style= {dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt}}%
1596 \tikzset{dashdotdotted/.style= {dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt}}%
1597 \tikzset{densely dashdotdotted/.style= {dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt on \the\pgflinewidth off 1pt}}%
1598 \tikzset{loosely dashdotdotted/.style= {dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt on \the\pgflinewidth off 4pt}}%
1599 \tikzset{dash dot dot/.style= {dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt}}%
1600 \tikzset{densely dash dot dot/.style= {dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt on \the\pgflinewidth off 1pt}}%
1601 \tikzset{loosely dash dot dot/.style= {dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt on \the\pgflinewidth off 4pt}}%
1602
1603
1604 \tikzset{transparent/.style= {opacity=0}}%
1605 \tikzset{ultra nearly transparent/.style={opacity=0.05}}%
1606 \tikzset{very nearly transparent/.style= {opacity=0.1}}%
1607 \tikzset{nearly transparent/.style= {opacity=0.25}}%
1608 \tikzset{semitransparent/.style= {opacity=0.5}}%
1609 \tikzset{nearly opaque/.style= {opacity=0.75}}%
1610 \tikzset{very nearly opaque/.style= {opacity=0.9}}%
1611 \tikzset{ultra nearly opaque/.style= {opacity=0.95}}%
1612 \tikzset{opaque/.style= {opacity=1}}%
1613
1614 \tikzset{at start/.style= {pos=0}}%
1615 \tikzset{very near start/.style= {pos=0.125}}%
1616 \tikzset{near start/.style= {pos=0.25}}%
1617 \tikzset{midway/.style= {pos=0.5}}%
1618 \tikzset{near end/.style= {pos=0.75}}%
1619 \tikzset{very near end/.style= {pos=0.875}}%
1620 \tikzset{at end/.style= {pos=1}}%
1621
1622 \tikzset{bend at start/.style= {bend pos=0,bend={+(0,0)}}}%
1623 \tikzset{bend at end/.style= {bend pos=1,bend={+(0,0)}}}%
1624
1625 \tikzset{edge from parent/.style= {draw}}%
1626
1627
1628
1629 % Animation callbacks
1630 \tikzset{
1631 animate/.code=\tikzerror{You need to say \string\usetikzlibrary{animations} to use animations}
1632 }
1633
1634 % ID callbacks
1635 \newif\iftikz@is@node
1636 \let\tikz@id@name\pgfutil@empty
1637 \let\tikz@id@hook\pgfutil@empty
1638 \def\tikz@call@id@hook{\ifx\tikz@id@hook\pgfutil@empty\else\tikz@id@hook\pgfuseid{\tikz@id@name}\fi}%
1639
1640
1641 % RDF stuff
1642 \let\tikz@clear@rdf@options\relax
1643 \let\tikz@do@rdf@post@options\relax
1644 \let\tikz@do@rdf@pre@options\relax
1645
1646
1647 %
1648 % Setting keys
1649 %
1650
1651 \pgfkeys{/tikz/style/.style={#1}}%
1652
1653 \pgfkeys{/tikz/.unknown/.code=%
1654 % Is it a pgf key?
1655 \let\tikz@key\pgfkeyscurrentname%
1656 \pgfkeys{/pgf/\tikz@key/.try={#1}}%
1657 \ifpgfkeyssuccess%
1658 \else%
1659 \expandafter\pgfutil@in@\expandafter!\expandafter{\tikz@key}%
1660 \ifpgfutil@in@%
1661 % this is a color!
1662 \expandafter\tikz@addoption\expandafter{\expandafter\tikz@compat@color@set\expandafter{\tikz@key}}%
1663 \edef\tikz@textcolor{\tikz@key}%
1664 \else%
1665 \pgfutil@doifcolorelse{\tikz@key}
1666 {%
1667 \expandafter\tikz@addoption\expandafter{\expandafter\tikz@compat@color@set\expandafter{\tikz@key}}%
1668 \edef\tikz@textcolor{\tikz@key}%
1669 }%
1670 {%
1671 % Ok, second chance: This might be an arrow specification:
1672 \expandafter\pgfutil@in@\expandafter-\expandafter{\tikz@key}%
1673 \ifpgfutil@in@%
1674 % Ah, an arrow spec!
1675 \expandafter\tikz@processarrows\expandafter{\tikz@key}%
1676 \else%
1677 % Ok, third chance: A shape!
1678 \expandafter\ifx\csname pgf@sh@s@\tikz@key\endcsname\relax%
1679 \pgfkeys{/errors/unknown key/.expand
1680 once=\expandafter{\expandafter/\expandafter t\expandafter i\expandafter k\expandafter z\expandafter/\tikz@key}{#1}}%
1681 \else%
1682 \edef\tikz@shape{\tikz@key}%
1683 \fi%
1684 \fi%
1685 }%
1686 \fi%
1687 \fi%
1688 }%
1689 \def\tikz@compat@color@set#1{%
1690 \pgfutil@color{#1}\pgfutil@colorlet{pgffillcolor}{#1}%
1691 \expandafter\let\expandafter\pgf@temp\csname\string\color@pgffillcolor\endcsname%
1692 % for arrow tips:
1693 \global\let\pgf@strokecolor@global=\pgf@temp
1694 \global\let\pgf@fillcolor@global=\pgf@temp
1695 }%
1696
1697 \def\tikz@startup@env{%
1698 \ifnum\the\catcode`\;=\active\relax\expandafter\let\expandafter\tikz@origsemi\expandafter=\tikz@activesemicolon\fi%
1699 \ifnum\the\catcode`\:=\active\relax\expandafter\let\expandafter\tikz@origcolon\expandafter=\tikz@activecolon\fi%
1700 \ifnum\the\catcode`\|=\active\relax\expandafter\let\expandafter\tikz@origbar\expandafter=\tikz@activebar\fi%
1701 \tikz@deactivatthings%
1702 \iftikz@handle@active@code%
1703 \tikz@switchoff@shorthands%
1704 \fi%
1705 }%
1706
1707 %
1708 % Main TikZ Environment
1709 %
1710 \newif\iftikz@inside@picture
1711 \tikz@inside@picturefalse
1712 \def\tikz@check@inside@picture{%
1713 \iftikz@inside@picture%
1714 \pgfwarning{Nesting tikzpictures is NOT supported}%
1715 \fi%
1716 \tikz@inside@picturetrue%
1717 }
1718
1719 \def\tikzpicture{%
1720 \begingroup%
1721 \tikz@startup@env%
1722 \tikz@collect@scope@anims\tikz@picture}%
1723 \def\tikz@picture[#1]{%
1724 %\tikz@check@inside@picture%
1725 \pgfpicture%
1726 \let\tikz@atbegin@picture=\pgfutil@empty%
1727 \let\tikz@atend@picture=\pgfutil@empty%
1728 \let\tikz@transform=\relax%
1729 \def\tikz@time{.5}%
1730 \tikz@installcommands%
1731 \scope[every picture,#1]%
1732 \iftikz@handle@active@code%
1733 \tikz@switchoff@shorthands%
1734 \fi%
1735 \expandafter\tikz@atbegin@picture%
1736 \tikz@lib@scope@check%
1737 }%
1738 \def\endtikzpicture{%
1739 \tikz@atend@picture%
1740 \global\let\pgf@shift@baseline@smuggle=\pgf@baseline%
1741 \global\let\pgf@trimleft@final@smuggle=\pgf@trimleft%
1742 \global\let\pgf@trimright@final@smuggle=\pgf@trimright%
1743 \global\let\pgf@remember@smuggle=\ifpgfrememberpicturepositiononpage%
1744 \pgf@remember@layerlist@globally
1745 \endscope%
1746 \let\pgf@baseline=\pgf@shift@baseline@smuggle%
1747 \let\pgf@trimleft=\pgf@trimleft@final@smuggle%
1748 \let\pgf@trimright=\pgf@trimright@final@smuggle%
1749 \let\ifpgfrememberpicturepositiononpage=\pgf@remember@smuggle%
1750 \pgf@restore@layerlist@from@global
1751 \endpgfpicture\endgroup}%
1752
1753
1754 % Inlined picture
1755 %
1756 % #1 - some code to be put in a tikzpicture environment.
1757 %
1758 % If the command is not followed by braces, everything up to the next
1759 % semicolon is used as argument.
1760 %
1761 % Example:
1762 %
1763 % The rectangle \tikz{\draw (0,0) rectangle (1em,1ex)} has width 1em and
1764 % height 1ex.
1765
1766
1767 \def\tikz{%
1768 \begingroup%
1769 \tikz@startup@env%
1770 \tikz@collect@scope@anims\tikz@opt}%
1771 \def\tikz@opt[#1]{\tikzpicture[#1]\pgfutil@ifnextchar\bgroup{\tikz@}{\tikz@@single}}%
1772 \def\tikz@{\bgroup\tikz@auto@end@pathtrue\aftergroup\endtikzpicture\aftergroup\endgroup\let\pgf@temp=}%
1773 \def\tikz@@single#1{%
1774 \expandafter\ifx\csname tikz@protected@command\string#1\endcsname\relax%
1775 \expandafter\tikz@@%
1776 \else%
1777 \begingroup\def\tikz@path@do@at@end{\endgroup\endtikzpicture\endgroup}%
1778 \fi%
1779 #1%
1780 }%
1781
1782 \expandafter\let\csname tikz@protected@command\string\draw\endcsname\pgfutil@empty%
1783 \expandafter\let\csname tikz@protected@command\string\pattern\endcsname\pgfutil@empty%
1784 \expandafter\let\csname tikz@protected@command\string\fill\endcsname\pgfutil@empty%
1785 \expandafter\let\csname tikz@protected@command\string\filldraw\endcsname\pgfutil@empty%
1786 \expandafter\let\csname tikz@protected@command\string\shade\endcsname\pgfutil@empty%
1787 \expandafter\let\csname tikz@protected@command\string\shadedraw\endcsname\pgfutil@empty%
1788 \expandafter\let\csname tikz@protected@command\string\clip\endcsname\pgfutil@empty%
1789 \expandafter\let\csname tikz@protected@command\string\graph\endcsname\pgfutil@empty%
1790 \expandafter\let\csname tikz@protected@command\string\useasboundingbox\endcsname\pgfutil@empty%
1791 \expandafter\let\csname tikz@protected@command\string\node\endcsname\pgfutil@empty%
1792 \expandafter\let\csname tikz@protected@command\string\coordinate\endcsname\pgfutil@empty%
1793 \expandafter\let\csname tikz@protected@command\string\matrix\endcsname\pgfutil@empty%
1794 \expandafter\let\csname tikz@protected@command\string\datavisualization\endcsname\pgfutil@empty%
1795 \expandafter\let\csname tikz@protected@command\string\path\endcsname\pgfutil@empty%
1796 \expandafter\let\csname tikz@protected@command\string\pic\endcsname\pgfutil@empty%
1797
1798 % Comment by TT: I hope I fixed the \tikz \foreach problem. The new
1799 % version will take a conservative approach and will only do fancy
1800 % stuff when the next keyword after \tikz is one of the following:
1801 % \draw, \fill, \filldraw, \graph, \matrix,
1802 \def\tikz@@{%
1803 \let\tikz@next=\tikz@collectnormalsemicolon%
1804 \ifnum\the\catcode`\;=\active\relax%
1805 \let\tikz@next=\tikz@collectactivesemicolon%
1806 \fi%
1807 \tikz@next}%
1808 \def\tikz@collectnormalsemicolon#1;{#1;\endtikzpicture\endgroup}
1809 {
1810 \catcode`\;=\active
1811 \gdef\tikz@collectactivesemicolon#1;{#1;\endtikzpicture\endgroup}
1812 }%
1813 % End old code
1814
1815 % Invokes '#1' if the command is invoked within a tikzpicture and
1816 % '#2' if not.
1817 \def\tikzifinpicture#1#2{%
1818 \pgfutil@ifundefined{filldraw}{#2}{#1}% TT: This is a wrong
1819 % test! Who uses this?...
1820 }%
1821
1822
1823 \def\tikz@collect@scope@anims#1{%
1824 \pgfutil@ifnextchar[#1{#1[]}%]
1825 }%
1826
1827 %
1828 % Environment for scoping graphic state settings
1829 %
1830 \def\tikz@scope@env{%
1831 \pgfscope%
1832 \begingroup%
1833 \let\tikz@atbegin@scope=\pgfutil@empty%
1834 \let\tikz@atend@scope=\pgfutil@empty%
1835 \let\tikz@options=\pgfutil@empty%
1836 \tikz@clear@rdf@options%
1837 \let\tikz@mode=\pgfutil@empty%
1838 \let\tikz@id@name=\pgfutil@empty%
1839 \tikz@transparency@groupfalse%
1840 \tikzset{every scope/.try}%
1841 \tikz@collect@scope@anims\tikz@scope@opt%
1842 }%
1843 \def\tikz@scope@opt[#1]{%
1844 \tikzset{#1}%
1845 \tikz@options%
1846 \tikz@do@rdf@pre@options%
1847 \iftikz@transparency@group\expandafter\pgftransparencygroup\expandafter[\tikz@transparency@group@options]\tikz@blend@group\fi%
1848 \tikz@is@nodefalse%
1849 \tikz@call@id@hook%
1850 \pgfidscope%
1851 \tikz@do@rdf@post@options%
1852 \begingroup%
1853 \let\tikz@id@name\pgfutil@empty%
1854 \expandafter\tikz@atbegin@scope%
1855 \expandafter\pgfclearid%
1856 \tikz@lib@scope@check%
1857 }%
1858 \def\endtikz@scope@env{%
1859 \tikz@atend@scope%
1860 \endgroup%
1861 \endpgfidscope%
1862 \iftikz@transparency@group\endpgftransparencygroup\fi%
1863 \endgroup%
1864 \endpgfscope%
1865 \tikz@lib@scope@check%
1866 }%
1867
1868
1869 \def\tikz@scoped{\tikz@collect@scope@anims\tikz@scoped@opt}%
1870 \def\tikz@scoped@opt[#1]{\scope[#1]\pgfutil@ifnextchar\bgroup{\tikz@scoped@}{\tikz@scoped@@single}}%
1871 \def\tikz@scoped@{\bgroup\tikz@auto@end@pathtrue\aftergroup\endscope\let\pgf@temp=}%
1872 \def\tikz@scoped@@single#1{%
1873 \expandafter\ifx\csname tikz@scoped@protected@command\string#1\endcsname\relax%
1874 \expandafter\tikz@scoped@@%
1875 \else%
1876 \begingroup\def\tikz@scoped@path@do@at@end{\endgroup\endscope}%
1877 \fi%
1878 #1%
1879 }%
1880 \def\tikz@scoped@@{%
1881 \let\tikz@scoped@next=\tikz@scoped@collectnormalsemicolon%
1882 \ifnum\the\catcode`\;=\active\relax%
1883 \let\tikz@scoped@next=\tikz@scoped@collectactivesemicolon%
1884 \fi%
1885 \tikz@scoped@next}%
1886 \def\tikz@scoped@collectnormalsemicolon#1;{#1;\endscope}
1887 {
1888 \catcode`\;=\active
1889 \gdef\tikz@scoped@collectactivesemicolon#1;{#1;\endscope}
1890 }%
1891
1892
1893 % Install a shortcut command which is only valid inside of a
1894 % tikzpicture.
1895 %
1896 % It works in the same way as the '\path' shortcut does: it introduces
1897 % a \let#1=#2 at the beginning of tikzpicture.
1898 %
1899 % #1: shortcut command inside of tikzpicture
1900 % #2: real command name
1901 \def\tikzaddtikzonlycommandshortcutlet#1#2{%
1902 \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands
1903 \let#1=#2%
1904 }%
1905 }%
1906
1907 % Has the same effect as \tikzaddtikzonlycommandshortcutlet but uses
1908 % \def#1{#2} instead of \let.
1909 \def\tikzaddtikzonlycommandshortcutdef#1#2{%
1910 \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands
1911 \def#1{#2}%
1912 }%
1913 }%
1914
1915 %
1916 % Install the abbreviated commands
1917 %
1918 \def\tikz@installcommands{%
1919 \let\tikz@origscope=\scope%
1920 \let\tikz@origscoped=\scoped%
1921 \let\tikz@origendscope=\endscope%
1922 \let\tikz@origstartscope=\startscope%
1923 \let\tikz@origstopscope=\stopscope%
1924 \let\tikz@origpath=\path%
1925 \let\tikz@origagainpath=\againpath%
1926 \let\tikz@origdraw=\draw%
1927 \let\tikz@origpattern=\pattern%
1928 \let\tikz@origfill=\fill%
1929 \let\tikz@origfilldraw=\filldraw%
1930 \let\tikz@origshade=\shade%
1931 \let\tikz@origshadedraw=\shadedraw%
1932 \let\tikz@origclip=\clip%
1933 \let\tikz@origuseasboundingbox=\useasboundingbox%
1934 \let\tikz@orignode=\node%
1935 \let\tikz@origpic=\pic%
1936 \let\tikz@origcoordinate=\coordinate%
1937 \let\tikz@origmatrix=\matrix%
1938 \let\tikz@origcalendar=\calendar%
1939 \let\tikz@origdv=\datavisualization%
1940 \let\tikz@origgraph=\graph%
1941 %
1942 \let\scope=\tikz@scope@env%
1943 \let\scoped=\tikz@scoped%
1944 \let\endscope=\endtikz@scope@env%
1945 \let\startscope=\scope%
1946 \let\stopscope=\endscope%
1947 \let\path=\tikz@command@path%
1948 \let\againpath=\tikz@command@againpath%
1949 %
1950 \def\draw{\path[draw]}%
1951 \def\pattern{\path[pattern]}%
1952 \def\fill{\path[fill]}%
1953 \def\filldraw{\path[fill,draw]}%
1954 \def\shade{\path[shade]}%
1955 \def\shadedraw{\path[shade,draw]}%
1956 \def\clip{\path[clip]}%
1957 \def\graph{\path graph}%
1958 \def\useasboundingbox{\path[use as bounding box]}%
1959 \def\node{\tikz@path@overlay{node}}%
1960 \def\pic{\tikz@path@overlay{pic}}%
1961 \def\coordinate{\tikz@path@overlay{coordinate}}%
1962 \def\matrix{\tikz@path@overlay{node[matrix]}}%
1963 \def\calendar{\tikz@lib@cal@calendar}%
1964 \def\datavisualization{\tikz@lib@datavisualization}%
1965 }%
1966 \ifx\tikz@lib@cal@calendar\@undefined
1967 \def\tikz@lib@cal@calendar{\tikzerror{You need to say \string\usetikzlibrary{calendar} to use the \string\calendar{} command}}%
1968 \fi
1969 \ifx\tikz@lib@datavisualization\@undefined
1970 \def\tikz@lib@datavisualization{\tikzerror{You need to say \string\usetikzlibrary{datavisualization} to use the \string\datavisualization{} command}}%
1971 \fi
1972
1973 \def\tikz@path@overlay#1{%
1974 \let\tikz@signal@path=\tikz@signal@path% for detection at begin of matrix cell
1975 \pgfutil@ifnextchar<{\tikz@path@overlayed{#1}}{\path #1}}%
1976 \def\tikz@path@overlayed#1<#2>{\path<#2> #1}%
1977
1978 \def\tikz@uninstallcommands{%
1979 \let\scope=\tikz@origscope%
1980 \let\scoped=\tikz@origscoped%
1981 \let\endscope=\tikz@origendscope%
1982 \let\startscope=\tikz@origstartscope%
1983 \let\stopscope=\tikz@origstopscope%
1984 \let\path=\tikz@origpath%
1985 \let\againpath=\tikz@origagainpath%
1986 \let\draw=\tikz@origdraw%
1987 \let\pattern=\tikz@origpattern%
1988 \let\fill=\tikz@origfill%
1989 \let\filldraw=\tikz@origfilldraw%
1990 \let\shade=\tikz@origshade%
1991 \let\shadedraw=\tikz@origshadedraw%
1992 \let\clip=\tikz@origclip%
1993 \let\useasboundingbox=\tikz@origuseasboundingbox%
1994 \let\node=\tikz@orignode%
1995 \let\pic=\tikz@origpic%
1996 \let\coordinate=\tikz@origcoordinate%
1997 \let\matrix=\tikz@origmatrix%
1998 \let\calendar=\tikz@origcalendar%
1999 \let\datavisualization=\tikz@origdv%
2000 \let\graph=\tikz@origgraph%
2001 }%
2002
2003
2004 {%
2005 \catcode`\;=12
2006 \gdef\tikz@nonactivesemicolon{;}%
2007 \catcode`\:=12
2008 \gdef\tikz@nonactivecolon{:}%
2009 \catcode`\|=12
2010 \gdef\tikz@nonactivebar{|}%
2011 \catcode`\!=12
2012 \gdef\tikz@nonactiveexlmark{!}%
2013 \catcode`\;=\active
2014 \catcode`\:=\active
2015 \catcode`\|=\active
2016 \catcode`\"=\active
2017 \catcode`\!=\active
2018 \gdef\tikz@activesemicolon{;}%
2019 \gdef\tikz@activecolon{:}%
2020 \gdef\tikz@activebar{|}%
2021 \gdef\tikz@activequotes{"}%
2022 \global\let\tikz@active@quotes@token="%
2023 \gdef\tikz@activeexlmark{!}%
2024 \gdef\tikz@deactivatthings{%
2025 \def;{\tikz@nonactivesemicolon}%
2026 \def:{\tikz@nonactivecolon}%
2027 \def|{\tikz@nonactivebar}%
2028 \def!{\tikz@nonactiveexlmark}%
2029 }%
2030 }%
2031
2032 \let\tikz@orig@shorthands\pgfutil@empty
2033 \def\tikz@switchoff@shorthands{%
2034 \ifx\tikz@orig@shorthands\pgfutil@empty%
2035 \edef\tikz@orig@shorthands{%
2036 \catcode\noexpand`\noexpand\;\the\catcode`\;\relax%
2037 \catcode\noexpand`\noexpand\:\the\catcode`\:\relax%
2038 \catcode\noexpand`\noexpand\|\the\catcode`\|\relax%
2039 \catcode\noexpand`\noexpand\!\the\catcode`\!\relax%
2040 \catcode\noexpand`\noexpand\,\the\catcode`\,\relax%
2041 \catcode\noexpand`\noexpand\<\the\catcode`\<\relax%
2042 \catcode\noexpand`\noexpand\>\the\catcode`\>\relax%
2043 \catcode\noexpand`\noexpand\"\the\catcode`\"\relax%
2044 \catcode\noexpand`\noexpand\'\the\catcode`\'\relax%
2045 \catcode\noexpand`\noexpand\-\the\catcode`\-\relax%
2046 \catcode\noexpand`\noexpand\=\the\catcode`\=\relax%
2047 \catcode\noexpand`\noexpand\.\the\catcode`\.\relax%
2048 \catcode\noexpand`\noexpand\$\the\catcode`\$\relax%
2049 }%
2050 \catcode`\;12\relax%
2051 \catcode`\:12\relax%
2052 \catcode`\|12\relax%
2053 \catcode`\!12\relax%
2054 \catcode`\,12\relax%
2055 \catcode`\<12\relax%
2056 \catcode`\>12\relax%
2057 \catcode`\"12\relax%
2058 \catcode`\'12\relax%
2059 \catcode`\-12\relax%
2060 \catcode`\=12\relax%
2061 \catcode`\.12\relax%
2062 \catcode`\$3\relax%
2063 \fi%
2064 }%
2065
2066
2067
2068 % Constructs a path and draws/fills them according to the current
2069 % settings.
2070
2071 \def\tikz@command@path{%
2072 \let\tikz@signal@path=\tikz@signal@path% for detection at begin of matrix cell
2073 \pgfutil@ifnextchar[{\tikz@check@earg}%]
2074 {\pgfutil@ifnextchar<{\tikz@doopt}{\tikz@@command@path}}}%
2075 \pgfutil@protected\def\tikz@signal@path{\tikz@signal@path}%
2076 \def\tikz@check@earg[#1]{%
2077 \pgfutil@ifnextchar<{\tikz@swap@args[#1]}{\tikz@@command@path[#1]}}
2078 \def\tikz@swap@args[#1]<#2>{\tikz@command@path<#2>[#1]}%
2079
2080 \def\tikz@doopt{%
2081 \let\tikz@next=\tikz@eargnormalsemicolon%
2082 \ifnum\the\catcode`\;=\active\relax%
2083 \let\tikz@next=\tikz@eargactivesemicolon%
2084 \fi%
2085 \tikz@next}%
2086 \long\def\tikz@eargnormalsemicolon<#1>#2;{\alt<#1>{\tikz@@command@path#2;}{\tikz@path@do@at@end}}%
2087 {
2088 \catcode`\;=\active
2089 \long\global\def\tikz@eargactivesemicolon<#1>#2;{\alt<#1>{\tikz@@command@path#2;}{\tikz@path@do@at@end}}%
2090 }
2091
2092 \def\tikz@@command@path{%
2093 \edef\tikzscope@linewidth{\the\pgflinewidth}%
2094 \begingroup%
2095 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
2096 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
2097 \let\tikz@path@do@at@end=\tikz@lib@scope@check%
2098 \let\tikz@options=\pgfutil@empty%
2099 \tikz@clear@rdf@options%
2100 \let\tikz@mode=\pgfutil@empty%
2101 \let\tikz@moveto@waiting=\relax%
2102 \let\tikz@timer=\relax%
2103 \let\tikz@tangent=\relax%
2104 \let\tikz@collected@onpath=\pgfutil@empty%
2105 \let\tikz@preactions=\pgfutil@empty%
2106 \let\tikz@postactions=\pgfutil@empty%
2107 \tikz@snakedfalse%
2108 \tikz@decoratepathfalse%
2109 \tikz@node@is@a@labelfalse%
2110 \tikz@resetexpandcount
2111 \pgf@path@lastx=0pt%
2112 \pgf@path@lasty=0pt%
2113 \tikz@lastx=0pt%
2114 \tikz@lasty=0pt%
2115 \tikz@lastxsaved=0pt%
2116 \tikz@lastysaved=0pt%
2117 \tikzset{every path/.try}%
2118 \tikz@scan@next@command%
2119 }%
2120 \def\tikz@scan@next@command{%
2121 \ifx\tikz@collected@onpath\pgfutil@empty%
2122 \else%
2123 \tikz@invoke@collected@onpath%
2124 \fi%
2125 \afterassignment\tikz@handle\let\pgf@let@token=%
2126 }%
2127 \newcount\tikz@expandcount
2128 \def\tikz@resetexpandcount{\tikz@expandcount=100\relax}
2129 \let\tikz@collected@onpath=\pgfutil@empty%
2130
2131 \edef\tikz@frozen@relax@token{\ifnum0=0\fi}
2132
2133 % Central dispatcher for commands
2134 \def\tikz@handle{%
2135 \pgfutil@switch\pgfutil@ifx\pgf@let@token{%
2136 {(}{\let\pgfutil@next\tikz@movetoabs}%)
2137 {+}{\let\pgfutil@next\tikz@movetorel}%
2138 {-}{\let\pgfutil@next\tikz@lineto}%
2139 {.}{\let\pgfutil@next\tikz@dot}%
2140 {r}{\let\pgfutil@next\tikz@rect}%
2141 {n}{\let\pgfutil@next\tikz@fig}%
2142 {[}{\let\pgfutil@next\tikz@parse@options}%]
2143 {c}{\let\pgfutil@next\tikz@cchar}%
2144 {\bgroup}{\let\pgfutil@next\tikz@beginscope}%
2145 {\egroup}{\let\pgfutil@next\tikz@endscope}%
2146 {;}{\let\pgfutil@next\tikz@finish}%
2147 {a}{\let\pgfutil@next\tikz@a@char}%
2148 {e}{\let\pgfutil@next\tikz@e@char}%
2149 {g}{\let\pgfutil@next\tikz@g@char}%
2150 {s}{\let\pgfutil@next\tikz@schar}%
2151 {|}{\let\pgfutil@next\tikz@vh@lineto}%
2152 {p}{\pgfsetmovetofirstplotpoint\let\pgfutil@next\tikz@pchar}%
2153 {t}{\let\pgfutil@next\tikz@to}%
2154 {\pgfextra}{\let\pgfutil@next\tikz@extra}%
2155 {\foreach}{\let\pgfutil@next\tikz@foreach}%
2156 {f}{\let\pgfutil@next\tikz@fchar}%
2157 {\pgf@stop}{\let\pgfutil@next\relax}%
2158 {\par}{\let\pgfutil@next\tikz@scan@next@command}%
2159 {d}{\let\pgfutil@next\tikz@decoration}%
2160 {l}{\let\pgfutil@next\tikz@l@char}%
2161 {:}{\let\pgfutil@next\tikz@colon@char}%
2162 {\relax}{\relax\let\pgfutil@next\tikz@scan@next@command}%
2163 }{\tikz@resetexpandcount\pgfutil@next}{\tikz@expand}%
2164 }%
2165
2166 \def\tikz@l@char{%
2167 \pgfutil@ifnextchar e{\tikz@let@command}{%
2168 \pgfutil@ifnextchar i{\tikz@lsystem}{%
2169 \pgfutil@ifnextchar-{\tikz@@lsystem}{\tikz@expand}%
2170 }%
2171 }%
2172 }%
2173
2174 \def\tikz@lsystem{%
2175 \tikzerror{You need to say \string\usetikzlibrary{lindenmayersystems} to draw Lindenmayer systems}
2176 }%
2177
2178 \def\tikz@@lsystem{%
2179 \tikzerror{You need to say \string\usetikzlibrary{lindenmayersystems} to draw L-systems}
2180 }%
2181
2182 \def\tikz@pchar{\pgfutil@ifnextchar l{\tikz@plot}{\pgfutil@ifnextchar i{\tikz@subpicture}{\tikz@parabola}}}%
2183 \def\tikz@cchar{%
2184 \pgfutil@ifnextchar i{\tikz@circle}%
2185 {\pgfutil@ifnextchar h{\tikz@children}{\tikz@cochar}}}%
2186 \def\tikz@cochar o{%
2187 \pgfutil@ifnextchar o{\tikz@coordinate}{\tikz@cosine}}%
2188 \def\tikz@e@char{%
2189 \pgfutil@ifnextchar l{\tikz@ellipse}{\tikz@@e@char}}%
2190 \def\tikz@a@char{%
2191 \pgfutil@ifnextchar r{\tikz@arcA}{\tikzerror{Arc expected}}}%
2192 \def\tikz@@e@char dge{%
2193 \pgfutil@ifnextchar f{\tikz@edgetoparent}{\tikz@edge@plain}}%
2194
2195 \def\tikz@schar{\pgfutil@ifnextchar i{\tikz@sine}{\tikz@svg@path}}%
2196
2197 \def\tikz@g@char r{\pgfutil@ifnextchar i{\tikz@grid}{\tikz@graph}}%
2198
2199 % svg syntax
2200 % svg[options] {...}
2201
2202 \def\tikz@svg@path{%
2203 \tikzerror{You need to say \string\usetikzlibrary{svg.path} to use the svg path command}
2204 }%
2205
2206
2207 \def\tikz@finish{%
2208 % Rendering pipeline
2209 %
2210 % Step 1: The path background box
2211 %
2212 \box\tikz@figbox@bg%
2213 %
2214 % Step 2: Decorate path
2215 %
2216 \iftikz@decoratepath%
2217 \tikz@lib@dec@decorate@path%
2218 \fi%
2219 %
2220 % Step 3: Preactions
2221 %
2222 \pgfsyssoftpath@getcurrentpath\tikz@actions@path%
2223 \edef\tikz@restorepathsize{%
2224 \global\pgf@pathmaxx=\the\pgf@pathmaxx%
2225 \global\pgf@pathmaxy=\the\pgf@pathmaxy%
2226 \global\pgf@pathminx=\the\pgf@pathminx%
2227 \global\pgf@pathminy=\the\pgf@pathminy%
2228 }%
2229 \tikz@preactions%
2230 %
2231 % Step 4: Reset modes
2232 %
2233 \let\tikz@path@picture=\pgfutil@empty%
2234 \tikz@mode@fillfalse%
2235 \tikz@mode@drawfalse%
2236 \tikz@mode@doublefalse%
2237 \tikz@mode@clipfalse%
2238 \tikz@mode@boundaryfalse%
2239 \tikz@mode@fade@pathfalse%
2240 \tikz@mode@fade@scopefalse%
2241 \edef\tikz@pathextend{%
2242 {\noexpand\pgfqpoint{\the\pgf@pathminx}{\the\pgf@pathminy}}%
2243 {\noexpand\pgfqpoint{\the\pgf@pathmaxx}{\the\pgf@pathmaxy}}%
2244 }%
2245 \tikz@mode% installs the mode settings
2246 % Path fading counts as an option:
2247 \iftikz@mode@fade@path%
2248 \tikz@addoption{%
2249 \iftikz@fade@adjust%
2250 \iftikz@mode@draw%
2251 \pgfsetfadingforcurrentpathstroked{\tikz@path@fading}{\tikz@do@fade@transform}%
2252 \else%
2253 \pgfsetfadingforcurrentpath{\tikz@path@fading}{\tikz@do@fade@transform}%
2254 \fi%
2255 \else%
2256 \pgfsetfading{\tikz@path@fading}{\tikz@do@fade@transform}%
2257 \fi%
2258 \tikz@mode@fade@pathfalse% no more fading...
2259 }%
2260 \fi%
2261 %
2262 % Step 5: Install scope fading
2263 %
2264 \iftikz@mode@fade@scope%
2265 \iftikz@fade@adjust%
2266 \iftikz@mode@draw%
2267 \pgfsetfadingforcurrentpathstroked{\tikz@scope@fading}{\tikz@do@fade@transform}%
2268 \else%
2269 \pgfsetfadingforcurrentpath{\tikz@scope@fading}{\tikz@do@fade@transform}%
2270 \fi%
2271 \else%
2272 \pgfsetfading{\tikz@scope@fading}{\tikz@do@fade@transform}%
2273 \fi%
2274 \tikz@mode@fade@scopefalse%
2275 \fi%
2276 %
2277 % Step 5': Setup options
2278 %
2279 \ifx\tikz@options\pgfutil@empty%
2280 \else%
2281 \pgfsys@beginscope%
2282 \let\pgfscope@stroke@color=\pgf@strokecolor@global%
2283 \let\pgfscope@fill@color=\pgf@fillcolor@global%
2284 \begingroup%
2285 \tikz@options%
2286 \fi%
2287 \tikz@do@rdf@pre@options%
2288 %
2289 % Step 5'': Setup animations
2290 %
2291 \tikz@is@nodefalse%
2292 \tikz@call@id@hook%
2293 \iftikz@mode@clip\else%
2294 \pgfidscope%
2295 \tikz@do@rdf@post@options%
2296 \begingroup%
2297 \fi% open an animation scope here, unless clipping is done
2298 %
2299 % Step 6: Do a fill if shade or a path picture follows.
2300 %
2301 \iftikz@mode@fill%
2302 \iftikz@mode@shade%
2303 \pgfsyssoftpath@getcurrentpath\tikz@temppath
2304 \pgfprocessround{\tikz@temppath}{\tikz@temppath}% change the path
2305 \pgfsyssoftpath@setcurrentpath\tikz@temppath%
2306 \pgfsyssoftpath@invokecurrentpath%
2307 \pgfpushtype%
2308 \pgfusetype{.path fill}%
2309 \pgfsys@fill%
2310 \pgfpoptype%
2311 \tikz@mode@fillfalse% no more filling...
2312 \else%
2313 \ifx\tikz@path@picture\pgfutil@empty%
2314 \else%
2315 \pgfsyssoftpath@getcurrentpath\tikz@temppath
2316 \pgfprocessround{\tikz@temppath}{\tikz@temppath}% change the path
2317 \pgfsyssoftpath@setcurrentpath\tikz@temppath%
2318 \pgfsyssoftpath@invokecurrentpath%
2319 \pgfpushtype%
2320 \pgfusetype{.path fill}%
2321 \pgfsys@fill%
2322 \pgfpoptype%
2323 \tikz@mode@fillfalse% no more filling...
2324 \fi%
2325 \fi%
2326 \fi%
2327 %
2328 % Step 7: Do a shade if necessary.
2329 %
2330 \iftikz@mode@shade%
2331 \pgfsyssoftpath@getcurrentpath\tikz@temppath
2332 \pgfprocessround{\tikz@temppath}{\tikz@temppath}% change the path
2333 \pgfsyssoftpath@setcurrentpath\tikz@temppath%
2334 \pgfpushtype%
2335 \pgfusetype{.path shade}%
2336 \pgfshadepath{\tikz@shading}{\tikz@shade@angle}%
2337 \pgfpoptype%
2338 \tikz@mode@shadefalse% no more shading...
2339 \fi%
2340 %
2341 % Step 8: Do a path picture if necessary.
2342 %
2343 \ifx\tikz@path@picture\pgfutil@empty%
2344 \else%
2345 \begingroup%
2346 \pgfusetype{.path picture}%
2347 \pgfidscope%
2348 \pgfsys@beginscope%
2349 \let\tikz@id@name\pgfutil@empty%
2350 \pgfclearid%
2351 \pgfsyssoftpath@getcurrentpath\tikz@temppath
2352 \pgfprocessround{\tikz@temppath}{\tikz@temppath}% change the path
2353 \pgfsyssoftpath@setcurrentpath\tikz@temppath%
2354 \pgfsyssoftpath@invokecurrentpath%
2355 \pgfsys@clipnext%
2356 \pgfsys@discardpath%
2357 \pgf@relevantforpicturesizefalse%
2358 \expandafter\def\csname pgf@sh@ns@path picture bounding box\endcsname{rectangle}
2359 \expandafter\edef\csname pgf@sh@np@path picture bounding box\endcsname{%
2360 \def\noexpand\southwest{\noexpand\pgfqpoint{\the\pgf@pathminx}{\the\pgf@pathminy}}%
2361 \def\noexpand\northeast{\noexpand\pgfqpoint{\the\pgf@pathmaxx}{\the\pgf@pathmaxy}}%
2362 }
2363 \expandafter\def\csname pgf@sh@nt@path picture bounding box\endcsname{{1}{0}{0}{1}{0pt}{0pt}}
2364 \expandafter\def\csname pgf@sh@pi@path picture bounding box\endcsname{\pgfpictureid}
2365 \pgfinterruptpath%
2366 \tikz@path@picture%
2367 \endpgfinterruptpath%
2368 \pgfsys@endscope%
2369 \endpgfidscope%
2370 \endgroup%
2371 \let\tikz@path@picture=\pgfutil@empty%
2372 \fi%
2373 %
2374 % Step 9: Double stroke, if necessary
2375 %
2376 \iftikz@mode@draw%
2377 \iftikz@mode@double%
2378 % Change line width
2379 \begingroup%
2380 \pgfsys@beginscope%
2381 \tikz@double@setup%
2382 \fi%
2383 \fi%
2384 %
2385 % Step 10: Do stroke/fill/clip as needed
2386 %
2387 \pgfpushtype%
2388 \edef\tikz@temp{\noexpand\pgfusepath{%
2389 \iftikz@mode@fill fill,\fi%
2390 \iftikz@mode@draw draw,\fi%
2391 \iftikz@mode@clip clip\fi%
2392 }}%
2393 \pgfusetype{.path}%
2394 \tikz@temp%
2395 \pgfpoptype%
2396 \tikz@mode@fillfalse% no more filling
2397 %
2398 % Step 11: Double stroke, if necessary
2399 %
2400 \iftikz@mode@draw%
2401 \iftikz@mode@double%
2402 \pgfsys@endscope%
2403 \endgroup%
2404 \fi%
2405 \fi%
2406 \tikz@mode@drawfalse% no more stroking
2407 %
2408 % Step 12: Postactions
2409 %
2410 \tikz@postactions%
2411 %
2412 % Step 13: Add labels and nodes
2413 %
2414 \box\tikz@figbox%
2415 %
2416 % Step 14: Close animations
2417 %
2418 \iftikz@mode@clip\else\endgroup\endpgfidscope\fi%
2419 %
2420 % Step 14: Close option brace
2421 %
2422 \ifx\tikz@options\pgfutil@empty%
2423 \else%
2424 \endgroup%
2425 \global\let\pgf@strokecolor@global=\pgfscope@stroke@color%
2426 \global\let\pgf@fillcolor@global=\pgfscope@fill@color%
2427 \pgfsys@endscope%
2428 \iftikz@mode@clip%
2429 \tikzerror{Extra options not allowed for clipping path command.}%
2430 \fi%
2431 \fi%
2432 \iftikz@mode@clip%
2433 \aftergroup\pgf@relevantforpicturesizefalse%
2434 \fi%
2435 \iftikz@mode@boundary%
2436 \aftergroup\pgf@relevantforpicturesizefalse%
2437 \fi%
2438 \endgroup%
2439 \global\pgflinewidth=\tikzscope@linewidth%
2440 \tikz@path@do@at@end%
2441 }%
2442 \let\tikz@lib@scope@check\pgfutil@empty% this is a hook for the scopes library
2443 \def\tikz@path@do@at@end{\tikz@lib@scope@check}%
2444 \def\tikz@@pathtext{@path}%
2445
2446 \def\pgf@outer@auto@adjust@hook{%
2447 {%
2448 \tikz@mode@drawfalse%
2449 \tikz@mode%
2450 \expandafter%
2451 }%
2452 \iftikz@mode@draw\else%
2453 \pgfkeyslet{/pgf/outer xsep}\pgf@zero@text
2454 \pgfkeyslet{/pgf/outer ysep}\pgf@zero@text
2455 \fi%
2456 }%
2457
2458 % Extra actions
2459
2460 \def\tikz@extra@preaction#1{%
2461 {%
2462 \pgfsys@beginscope%
2463 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
2464 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
2465 \path[#1];% do extra path
2466 \pgfsyssoftpath@setcurrentpath\tikz@actions@path% restore
2467 \tikz@restorepathsize%
2468 \pgfsys@endscope%
2469 }%
2470 }%
2471
2472 \def\tikz@extra@postaction#1{%
2473 {%
2474 \pgfsys@beginscope%
2475 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
2476 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
2477 \tikz@restorepathsize%
2478 \path[#1]\pgfextra{\pgfsyssoftpath@setcurrentpath\tikz@actions@path};% do extra path
2479 \pgf@resetpathsizes%
2480 \pgfsys@endscope%
2481 }%
2482 }%
2483
2484
2485
2486 \def\tikz@skip#1{\tikz@scan@next@command#1}%
2487 \def\tikz@expand{%
2488 \advance\tikz@expandcount by -1
2489 \ifnum\tikz@expandcount<0\relax%
2490 \expandafter\pgfutil@firstoftwo
2491 \else
2492 \expandafter\pgfutil@secondoftwo
2493 \fi
2494 {%
2495 \tikzerror{Giving up on this path. Did you forget a semicolon?}%
2496 % since the last token caused an error we should reinsert it and therefore save it
2497 \global\let\tikz@expand@last@token=\pgf@let@token
2498 \tikz@finish%
2499 %
2500 % To be compatible with `scopes` lib, which uses a redefined
2501 % \tikz@lib@scope@check to check the next token, the reinsertion is done
2502 % here, not at the end of (every) \tikz@finish.
2503 %
2504 \expandafter\let\expandafter\tikz@expand@last@token@\csname tikz@expand@last@token\endcsname
2505 \global\let\tikz@expand@last@token=\relax
2506 \tikz@expand@last@token@
2507 }{%
2508 \tikz@@expand
2509 }%
2510 }
2511
2512 \def\tikz@@expand{%
2513 \expandafter\tikz@scan@next@command\pgf@let@token}%
2514
2515
2516
2517 % Syntax for scopes:
2518 % {scoped path commands}
2519
2520 \newif\iftikz@auto@end@path
2521
2522 \def\tikz@beginscope{\begingroup\tikz@auto@end@pathfalse\tikz@scan@next@command}%
2523 \def\tikz@endscope{%
2524 \iftikz@auto@end@path\expandafter\tikz@finish\expandafter\egroup\else\expandafter\tikz@@endscope\fi%
2525 }%
2526 \def\tikz@@endscope{%
2527 \global\setbox\tikz@tempbox=\box\tikz@figbox%
2528 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
2529 \global\let\tikz@tangent@temp\tikz@tangent%
2530 \edef\tikz@marshal{%
2531 \tikz@lastx=\the\tikz@lastx%
2532 \tikz@lasty=\the\tikz@lasty%
2533 \iftikz@current@point@local%
2534 \else%
2535 \tikz@lastxsaved=\the\tikz@lastxsaved%
2536 \tikz@lastysaved=\the\tikz@lastysaved%
2537 \ifx\tikz@moveto@waiting\relax%
2538 \let\tikz@moveto@waiting\relax%
2539 \else%
2540 \def\noexpand\tikz@moveto@waiting{\tikz@moveto@waiting}%
2541 \fi%
2542 \iftikz@shapeborder%
2543 \noexpand\tikz@shapebordertrue%
2544 \def\noexpand\tikz@shapeborder@name{\tikz@shapeborder@name}%
2545 \else%
2546 \noexpand\tikz@shapeborderfalse%
2547 \fi%
2548 \fi%
2549 }%
2550 \expandafter%
2551 \endgroup\tikz@marshal%
2552 \setbox\tikz@figbox=\box\tikz@tempbox%
2553 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
2554 \let\tikz@tangent\tikz@tangent@temp%
2555 \tikz@scan@next@command}%
2556
2557
2558 % Syntax for pgfextra:
2559 % \pgfextra {normal tex text}
2560 % \pgfextra normal tex text \endpgfextra
2561
2562 \def\tikz@extra{\pgfutil@ifnextchar\bgroup\tikz@@extra\relax}%
2563 \long\def\tikz@@extra#1{#1\tikz@scan@next@command}%
2564 \let\endpgfextra=\tikz@scan@next@command
2565
2566 \def\pgfextra{pgfextra}%
2567
2568
2569 % Syntax for foreach:
2570 %
2571 % foreach \var in {list} {path text}
2572 %
2573 % or
2574 %
2575 % \foreach \var in {list} {path text}
2576 %
2577 % Example:
2578 %
2579 % \draw (0,0) \foreach \x in {1,2,3} {-- (\x,0) circle (1cm)} -- (5,5);
2580
2581 \def\tikz@fchar oreach{\tikz@foreach}%
2582
2583 \def\tikz@foreach{%
2584 \def\pgffor@beginhook{%
2585 \tikz@lastx=\tikz@foreach@save@lastx%
2586 \tikz@lasty=\tikz@foreach@save@lasty%
2587 \tikz@lastxsaved=\tikz@foreach@save@lastxsaved%
2588 \tikz@lastysaved=\tikz@foreach@save@lastysaved%
2589 \setbox\tikz@figbox=\box\tikz@tempbox%
2590 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
2591 \expandafter\tikz@scan@next@command\pgfutil@firstofone}%
2592 \def\pgffor@endhook{\pgfextra{%
2593 \xdef\tikz@foreach@save@lastx{\the\tikz@lastx}%
2594 \xdef\tikz@foreach@save@lasty{\the\tikz@lasty}%
2595 \xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}%
2596 \xdef\tikz@foreach@save@lastysaved{\the\tikz@lastysaved}%
2597 \global\setbox\tikz@tempbox=\box\tikz@figbox%
2598 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
2599 \pgfutil@gobble}}%
2600 \def\pgffor@afterhook{%
2601 \tikz@lastx=\tikz@foreach@save@lastx%
2602 \tikz@lasty=\tikz@foreach@save@lasty%
2603 \tikz@lastxsaved=\tikz@foreach@save@lastxsaved%
2604 \tikz@lastysaved=\tikz@foreach@save@lastysaved%
2605 \let\pgffor@beginhook\relax%
2606 \let\pgffor@endhook\relax%
2607 \let\pgffor@afterhook\relax%
2608 \setbox\tikz@figbox=\box\tikz@tempbox%
2609 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
2610 \tikz@scan@next@command}%
2611 \global\setbox\tikz@tempbox=\box\tikz@figbox%
2612 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
2613 \xdef\tikz@foreach@save@lastx{\the\tikz@lastx}%
2614 \xdef\tikz@foreach@save@lasty{\the\tikz@lasty}%
2615 \xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}%
2616 \xdef\tikz@foreach@save@lastysaved{\the\tikz@lastysaved}%
2617 \foreach}%
2618
2619
2620 % Syntax for againpath:
2621 % \againpath \somepathname
2622
2623 \def\tikz@command@againpath#1{%
2624 \pgfextra{%
2625 \pgfsyssoftpath@getcurrentpath\tikz@temp%
2626 \expandafter\pgfutil@g@addto@macro\expandafter\tikz@temp\expandafter{#1}%
2627 \pgfsyssoftpath@setcurrentpath\tikz@temp%
2628 }%
2629 }%
2630
2631
2632 % animation syntax
2633 % :attribute = {...}
2634
2635 \def\tikz@colon@char#1=#2{%
2636 \tikz@scan@next@command{[animate={myself:{#1}={#2}}]}%
2637 }%
2638
2639
2640
2641 %
2642 % When this if is set, a just-scanned point is a shape and its border
2643 % position still needs to be determined, depending on subsequent
2644 % commands.
2645 %
2646
2647 \newif\iftikz@shapeborder
2648
2649
2650 % Syntax for moveto:
2651 % <point>
2652 \def\tikz@movetoabs{\tikz@moveto(}%
2653 \def\tikz@movetorel{\tikz@moveto+}%
2654 \def\tikz@moveto{%
2655 \tikz@scan@one@point{\tikz@@moveto}}%
2656 \def\tikz@@moveto#1{%
2657 \tikz@make@last@position{#1}%
2658 \iftikz@shapeborder%
2659 % ok, the moveto will have to wait. flag that we have a moveto in
2660 % waiting:
2661 \edef\tikz@moveto@waiting{\tikz@shapeborder@name}%
2662 \else%
2663 \tikz@@movetosave{\tikz@last@position}%
2664 \let\tikz@moveto@waiting=\relax%
2665 \fi%
2666 \tikz@scan@next@command%
2667 }%
2668
2669 % Wrapper around \pgfpathmoveto that adds a save
2670 \def\tikz@@movetosave#1{%
2671 {\pgftransformreset
2672 \pgf@process{#1}%
2673 \xdef\tikz@marshal{%
2674 \tikz@lastmovetox=\the\pgf@x\relax%
2675 \tikz@lastmovetoy=\the\pgf@y\relax%
2676 }%
2677 }%
2678 \tikz@marshal
2679 \pgfpathmoveto{#1}%
2680 }%
2681
2682
2683 \let\tikz@moveto@waiting=\relax % normally, nothing is waiting...
2684
2685 \def\tikz@flush@moveto{%
2686 \ifx\tikz@moveto@waiting\relax%
2687 \else%
2688 \tikz@@movetosave{\tikz@last@position}%
2689 \fi%
2690 \let\tikz@moveto@waiting=\relax%
2691 }%
2692
2693
2694 \def\tikz@flush@moveto@toward#1#2#3{%
2695 % #1 = a point towards which the last moveto should be corrected
2696 % #2 = a dimension to which the corrected x-coordinate should be stored
2697 % #3 = a dimension for the corrected y-coordinate
2698 \ifx\tikz@moveto@waiting\relax%
2699 % do nothing
2700 \else%
2701 \pgf@process{\pgfpointshapeborder{\tikz@moveto@waiting}{#1}}%
2702 #2=\pgf@x%
2703 #3=\pgf@y%
2704 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
2705 \tikz@@movetosave{\pgfqpoint{\pgf@x}{\pgf@y}}%
2706 \fi%
2707 \let\tikz@moveto@waiting=\relax%
2708 }%
2709
2710
2711 %
2712 % Collecting labels on the path
2713 %
2714
2715 \def\tikz@collect@coordinate@onpath#1c{%
2716 \pgfutil@ifnextchar y{\tikz@cycle@expander@add#1}{\tikz@collect@coordinate@onpath@{#1}}}%
2717 \def\tikz@collect@coordinate@onpath@#1oordinate{%
2718 \pgfutil@ifnextchar[{\tikz@@collect@coordinate@opt#1}{\tikz@@collect@coordinate@opt#1[]}}%}%
2719 \def\tikz@@collect@coordinate@opt#1[#2]{%
2720 \pgfutil@ifnextchar({\tikz@@collect@coordinate#1[#2]}{%
2721 \tikz@collect@label@onpath#1node[shape=coordinate,#2]{}}}%}%
2722 \def\tikz@@collect@coordinate#1[#2](#3){%
2723 \tikz@collect@label@onpath#1node[shape=coordinate,#2](#3){}}%
2724
2725 \newif\iftikz@collect@pic
2726
2727 \def\tikz@collect@label@onpath#1node{%
2728 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath node}%
2729 \let\tikz@collect@cont#1%
2730 \tikz@collect@picfalse%
2731 \tikz@collect@label@scan}%
2732
2733 \def\tikz@collect@pic@onpath#1pic{%
2734 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath pic}%
2735 \let\tikz@collect@cont#1
2736 \tikz@collect@pictrue%
2737 \tikz@collect@label@scan}%
2738
2739 \def\tikz@collect@label@scan{%
2740 \pgfutil@ifnextchar f{\tikz@collect@nodes}{%
2741 \pgfutil@ifnextchar({\tikz@collect@paran}%
2742 {\pgfutil@ifnextchar[{\tikz@collect@options}%
2743 {\pgfutil@ifnextchar:{\tikz@collect@animation}%
2744 {\pgfutil@ifnextchar\bgroup{\tikz@collect@arg}%
2745 {\tikz@collect@cont}}}}}%
2746 }%}}%
2747
2748 \def\tikz@collect@nodes foreach#1in{%
2749 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath foreach#1in}%
2750 \pgfutil@ifnextchar\bgroup\tikz@collect@nodes@group\tikz@collect@nodes@one%
2751 }%
2752 \def\tikz@collect@nodes@one#1{%
2753 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath #1}%
2754 \tikz@collect@label@scan%
2755 }%
2756 \def\tikz@collect@nodes@group#1{%
2757 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#1}}%
2758 \tikz@collect@label@scan%
2759 }%
2760
2761 \def\tikz@collect@animation#1=#2{%
2762 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath#1={#2}}%
2763 \tikz@collect@label@scan%
2764 }%
2765 \def\tikz@collect@paran#1){%
2766 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath#1)}%
2767 \tikz@collect@label@scan%
2768 }%
2769 \def\tikz@collect@options#1]{%
2770 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath#1]}%
2771 \tikz@collect@label@scan%
2772 }%
2773 \def\tikz@collect@arg#1{%
2774 \iftikz@handle@active@nodes%
2775 \iftikz@collect@pic%
2776 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#1}}%
2777 \else%
2778 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{\scantokens{#1}}}%
2779 \fi%
2780 \else%
2781 \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#1}}%
2782 \fi%
2783 \tikz@collect@cont%
2784 }%
2785
2786 \def\tikz@invoke@collected@onpath{%
2787 \tikz@node@is@a@labeltrue%
2788 \let\tikz@temp=\tikz@collected@onpath%
2789 \let\tikz@collected@onpath=\pgfutil@empty%
2790 \expandafter\tikz@scan@next@command\tikz@temp\pgf@stop%
2791 \tikz@node@is@a@labelfalse%
2792 }%
2793
2794
2795 %
2796 % Macros for the cycle command
2797 %
2798
2799 \def\tikz@cycle@expander#1{\pgfutil@ifnextchar c{\tikz@cycle@expander@{#1}}{#1}}%
2800 \def\tikz@cycle@expander@#1c{\pgfutil@ifnextchar y{\tikz@cycle@expander@add{#1}}{#1c}}%
2801 \def\tikz@cycle@expander@add#1ycle{#1(current subpath start)--cycle}%
2802
2803
2804
2805
2806 % Syntax for lineto:
2807 % -- <point>
2808
2809 \def\tikz@lineto{%
2810 \pgfutil@ifnextchar |%
2811 {\expandafter\tikz@hv@lineto\pgfutil@gobble}%
2812 {\expandafter\pgfutil@ifnextchar\tikz@activebar{\expandafter\tikz@hv@lineto\pgfutil@gobble}%
2813 {\expandafter\tikz@lineto@mid\pgfutil@gobble}}}%
2814 \def\tikz@lineto@mid{%
2815 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@lineto@mid}%
2816 {%
2817 \pgfutil@ifnextchar c{\tikz@close}{%
2818 \pgfutil@ifnextchar p{\tikz@lineto@plot@or@pic}{\tikz@scan@one@point{\tikz@@lineto}}}}}%
2819 \def\tikz@lineto@plot@or@pic p{%
2820 \pgfutil@ifnextchar i{\tikz@collect@pic@onpath\tikz@lineto@mid p}{%
2821 \pgfsetlinetofirstplotpoint\tikz@plot}%
2822 }%
2823 \def\tikz@@lineto#1{%
2824 % Record the starting point for later labels on the path:
2825 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}
2826 \iftikz@shapeborder%
2827 % ok, target is a shape. recalculate end
2828 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\tikz@last@position}}%
2829 \tikz@make@last@position{\pgfqpoint{\pgf@x}{\pgf@y}}%
2830 \tikz@flush@moveto@toward{\tikz@last@position}\pgf@x\pgf@y%
2831 \tikz@path@lineto{\tikz@last@position}%
2832 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
2833 \tikz@make@last@position{#1}%
2834 \edef\tikz@moveto@waiting{\tikz@shapeborder@name}%
2835 \else%
2836 % target is a reasonable point...
2837 % Record the starting point for later labels on the path:
2838 \tikz@make@last@position{#1}%
2839 \tikz@flush@moveto@toward{\tikz@last@position}\pgf@x\pgf@y%
2840 \tikz@path@lineto{\tikz@last@position}%
2841 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
2842 \fi%
2843 \let\tikz@timer=\tikz@timer@line%
2844 \let\tikz@tangent\tikz@timer@start%
2845 \tikz@scan@next@command%
2846 }%
2847
2848 % snake or lineto?
2849 \def\tikz@path@lineto#1{%
2850 \iftikz@snaked%
2851 {
2852 \pgfsyssoftpathmovetorelevantfalse%
2853 \pgfpathsnakesto{\tikz@presnake,{\tikz@snake}{\tikz@mainsnakelength}{\noexpand\tikz@snake@install@trans}{},\tikz@postsnake}{#1}%
2854 }
2855 \else%
2856 \pgfpathlineto{#1}%
2857 \fi%
2858 }%
2859
2860 % snake or lineto?
2861 \def\tikz@path@close#1{%
2862 \iftikz@snaked%
2863 {%
2864 \pgftransformreset%
2865 \pgfpathsnakesto{\tikz@presnake,{\tikz@snake}{\tikz@mainsnakelength}{\noexpand\tikz@snake@install@trans}{},\tikz@postsnake}{#1}%
2866 }%
2867 \fi%
2868 \pgfpathclose%
2869 }%
2870
2871
2872 % Syntax for lineto horizontal/vertical:
2873 % -| <point>
2874
2875 \def\tikz@hv@lineto{%
2876 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@hv@lineto}{%
2877 \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@hv@lineto}%
2878 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@hv@lineto}%
2879 {\tikz@scan@one@point{\tikz@@hv@lineto}}}}}%
2880 \def\tikz@@hv@lineto#1{%
2881 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
2882 \pgf@yc=\tikz@lasty%
2883 \tikz@make@last@position{#1}%
2884 \edef\tikz@tangent{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}%
2885 \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\pgf@yc}}\pgf@x\pgf@yc%
2886 \iftikz@shapeborder%
2887 % ok, target is a shape. have to work now:
2888 {%
2889 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\tikz@lastx}{\pgf@yc}}}%
2890 \tikz@make@last@position{\pgfqpoint{\pgf@x}{\pgf@y}}%
2891 \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@yc}}%
2892 \tikz@path@lineto{\tikz@last@position}%
2893 \xdef\tikz@timer@end@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% move out of group
2894 }%
2895 \let\tikz@timer@end=\tikz@timer@end@temp%
2896 \edef\tikz@moveto@waiting{\tikz@shapeborder@name}%
2897 \else%
2898 \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@yc}}%
2899 \tikz@path@lineto{\tikz@last@position}%
2900 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% move out of group
2901 \fi%
2902 \let\tikz@timer=\tikz@timer@hvline%
2903 \tikz@scan@next@command%
2904 }%
2905
2906 % Syntax for lineto vertical/horizontal:
2907 % |- <point>
2908
2909 \def\tikz@vh@lineto-{\tikz@vh@lineto@next}%
2910 \def\tikz@vh@lineto@next{%
2911 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@vh@lineto@next}{%
2912 \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@vh@lineto@next}%
2913 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@vh@lineto@next}%
2914 {\tikz@scan@one@point\tikz@@vh@lineto}}}}%
2915 \def\tikz@@vh@lineto#1{%
2916 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
2917 \pgf@xc=\tikz@lastx%
2918 \tikz@make@last@position{#1}%
2919 \edef\tikz@tangent{\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}%
2920 \tikz@flush@moveto@toward{\pgfqpoint{\pgf@xc}{\tikz@lasty}}\pgf@xc\pgf@y%
2921 \iftikz@shapeborder%
2922 % ok, target is a shape. have to work now:
2923 {%
2924 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@xc}{\tikz@lasty}}}%
2925 \tikz@make@last@position{\pgfqpoint{\pgf@x}{\pgf@y}}%
2926 \tikz@path@lineto{\pgfqpoint{\pgf@xc}{\tikz@lasty}}%
2927 \tikz@path@lineto{\tikz@last@position}%
2928 \xdef\tikz@timer@end@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% move out of group
2929 }%
2930 \let\tikz@timer@end=\tikz@timer@end@temp%
2931 \edef\tikz@moveto@waiting{\tikz@shapeborder@name}%
2932 \else%
2933 \tikz@path@lineto{\pgfqpoint{\pgf@xc}{\tikz@lasty}}%
2934 \tikz@path@lineto{\tikz@last@position}%
2935 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
2936 \fi%
2937 \let\tikz@timer=\tikz@timer@vhline%
2938 \tikz@scan@next@command%
2939 }%
2940
2941 % Syntax for cycle:
2942 % -- cycle
2943 \def\tikz@close c{%
2944 \pgfutil@ifnextchar o{\tikz@collect@coordinate@onpath\tikz@lineto@mid c}% oops, a coordinate
2945 {\tikz@@close c}}%
2946 \def\tikz@@close cycle{%
2947 \tikz@flush@moveto%
2948 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}
2949 \tikz@make@last@position{\expandafter\pgfpoint\pgfsyssoftpath@lastmoveto}%
2950 \tikz@path@close{\expandafter\pgfpoint\pgfsyssoftpath@lastmoveto}%
2951 \def\pgfstrokehook{}%
2952 \edef\tikz@timer@end{%\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
2953 \noexpand\pgfqpoint{\the\tikz@lastmovetox}{\the\tikz@lastmovetoy}}%
2954 \let\tikz@timer=\tikz@timer@line%
2955 \let\tikz@tangent\tikz@timer@start%
2956 \tikz@scan@next@command%
2957 }%
2958
2959
2960 % Syntax for options:
2961 % [options]
2962 \def\tikz@parse@options#1]{%
2963 \tikzset{#1}%
2964 \tikz@scan@next@command%
2965 }%
2966
2967 % Syntax for edges:
2968 % edge [options] (coordinate)
2969 % edge [options] node {node text} (coordinate)
2970 % edge :attribute={...} [options] node {node text} (coordinate)
2971 \def\tikz@edge@plain{%
2972 \begingroup%
2973 \ifx\tikz@to@use@whom\pgfutil@undefined\else\tikz@to@use@whom\fi
2974 \let\tikz@to@or@edge@function=\tikz@do@edge%
2975 \let\tikz@@to@local@options\pgfutil@empty%
2976 \let\tikz@collected@onpath=\pgfutil@empty%
2977 \tikz@to@or@edge}%
2978
2979 % Syntax for to paths:
2980 % to [options] (coordinate)
2981 % to [options] node {node text} (coordinate)
2982 % to :attribute={...} [options] node {node text} (coordinate)
2983 \def\tikz@to o{%
2984 \tikz@to@use@last@coordinate%
2985 \let\tikz@to@or@edge@function=\tikz@do@to%
2986 \let\tikz@@to@local@options\pgfutil@empty%
2987 \let\tikz@collected@onpath=\pgfutil@empty%
2988 \tikz@to@or@edge}%
2989
2990 \def\tikz@to@or@edge{%
2991 \pgfutil@ifnextchar[{\tikz@to@or@edge@option}{%
2992 \pgfutil@ifnextchar:{\tikz@to@or@edge@animation}{%
2993 \tikz@@to@collect}}%]
2994 }%
2995 \def\tikz@to@or@edge@option[#1]{%
2996 \expandafter\def\expandafter\tikz@@to@local@options\expandafter{\tikz@@to@local@options,#1}%
2997 \tikz@to@or@edge%
2998 }%
2999 \def\tikz@to@or@edge@animation:#1=#2{%
3000 \expandafter\def\expandafter\tikz@@to@local@options\expandafter{\tikz@@to@local@options,%
3001 animate={myself:{#1}={#2}}}%
3002 \tikz@to@or@edge%
3003 }%
3004 \def\tikz@@to@collect{%
3005 \pgfutil@ifnextchar(\tikz@@to@or@edge@coordinate%)
3006 {\pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@@to@collect}%
3007 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@@to@collect}%
3008 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@@to@collect}%
3009 {\pgfutil@ifnextchar +{\tikz@scan@one@point\tikz@@to@or@edge@math}%
3010 {\tikzerror{(, +, coordinate, pic, or node expected}%)
3011 \tikz@@to@or@edge@coordinate()}}}}}%
3012 }%
3013
3014 \def\tikz@@to@or@edge@coordinate({%
3015 \pgfutil@ifnextchar${%$
3016 % Ok, parse directly
3017 \tikz@scan@one@point\tikz@@to@or@edge@math(%
3018 }{%
3019 \pgfutil@ifnextchar[{%]
3020 \tikz@scan@one@point\tikz@@to@or@edge@math(%
3021 }{%
3022 \tikz@@to@or@edge@@coordinate(%
3023 }%
3024 }%
3025 }%
3026 \def\tikz@@to@or@edge@math#1{%
3027 \pgf@process{#1}%
3028 \iftikz@updatecurrent\else
3029 \tikz@updatenextfalse
3030 \fi
3031 \edef\tikztotarget{\the\pgf@x,\the\pgf@y}%
3032 \tikz@to@or@edge@function%
3033 }%
3034
3035 \def\tikz@@to@or@edge@@coordinate(#1){%
3036 \def\tikztotarget{#1}%
3037 \tikz@to@or@edge@function%
3038 }%
3039
3040 \def\tikz@do@edge{%
3041 \ifx\tikz@edge@macro\pgfutil@empty%
3042 \setbox\tikz@whichbox=\hbox\bgroup%
3043 \unhbox\tikz@whichbox%
3044 \hbox\bgroup
3045 \bgroup%
3046 \pgfinterruptpath%
3047 \pgfscope%
3048 \let\tikz@transform=\pgfutil@empty%
3049 \let\tikz@options=\pgfutil@empty%
3050 \tikz@clear@rdf@options%
3051 \let\tikz@tonodes=\tikz@collected@onpath%
3052 \def\tikztonodes{{\pgfextra{\tikz@node@is@a@labeltrue}\tikz@tonodes}}%
3053 \let\tikz@collected@onpath=\pgfutil@empty%
3054 \tikz@options%
3055 \tikz@do@rdf@pre@options%
3056 \pgfidscope%
3057 \tikz@do@rdf@post@options%
3058 \tikz@transform%
3059 \let\tikz@transform=\relax%
3060 % Typeset node:
3061 \let\tikz@after@path\pgfutil@empty%
3062 \tikz@atbegin@to%
3063 \tikz@enable@edge@quotes%
3064 \path[style=every edge]\expandafter[\tikz@@to@local@options](\tikztostart)\tikz@to@path
3065 \pgfextra{\global\let\tikz@after@path@smuggle=\tikz@after@path};%
3066 \tikz@atend@to%
3067 \endpgfidscope%
3068 \endpgfscope%
3069 \endpgfinterruptpath%
3070 \egroup
3071 \egroup%
3072 \egroup%
3073 \global\setbox\tikz@tempbox=\box\tikz@whichbox%
3074 \expandafter\endgroup%
3075 \expandafter\setbox\tikz@whichbox=\box\tikz@tempbox%
3076 \else%
3077 \expandafter\expandafter\expandafter\tikz@edge@macro%
3078 \expandafter\expandafter\expandafter{\expandafter\tikz@@to@local@options\expandafter}\expandafter{\tikz@collected@onpath}%
3079 \endgroup%
3080 \let\tikz@after@path@smuggle=\pgfutil@empty%
3081 \fi%
3082 \expandafter\tikz@scan@next@command\tikz@after@path@smuggle%
3083 }%
3084
3085 \def\tikz@do@to{%
3086 \let\tikz@tonodes=\tikz@collected@onpath%
3087 \def\tikztonodes{{\pgfextra{\tikz@node@is@a@labeltrue}\tikz@tonodes}}%
3088 \let\tikz@collected@onpath=\pgfutil@empty%
3089 \tikz@scan@next@command%
3090 {%
3091 \pgfextra{\let\tikz@after@path\pgfutil@empty}%
3092 \pgfextra{\tikz@atbegin@to}%
3093 \pgfextra{\tikz@enable@edge@quotes}%
3094 [style=every to]\expandafter[\tikz@@to@local@options]\tikz@to@path%
3095 \pgfextra{\tikz@atend@to}%
3096 \pgf@stop%
3097 \expandafter\tikz@scan@next@command\expandafter%
3098 }\tikz@after@path%
3099 \pgfextra{\tikz@updatenexttrue\tikz@updatecurrenttrue}%
3100 }%
3101
3102
3103 \def\tikz@to@use@last@coordinate{%
3104 \iftikz@shapeborder%
3105 \edef\tikztostart{\tikz@shapeborder@name}%
3106 \else%
3107 \edef\tikztostart{\the\tikz@lastx,\the\tikz@lasty}%
3108 \fi%
3109 }%
3110 \def\tikz@to@use@last@fig@name{%
3111 \edef\tikztostart{\tikz@to@last@fig@name}%
3112 }%
3113
3114
3115
3116 % Syntax for graph path command:
3117 % graph [options] {...}
3118 % See the graph library for details
3119
3120 \def\tikz@graph aph{\tikz@lib@graph@parser}%
3121
3122 \def\tikz@lib@graph@parser{\pgfutil@ifnextchar[\tikz@graph@error{\tikz@graph@error[]}}%]%
3123 \def\tikz@graph@error[#1]#2{%
3124 \tikzerror{You need to say \string\usetikzlibrary{graphs} in order to use the graph syntax}%
3125 \tikz@lib@graph@parser@done%
3126 }%
3127
3128 \def\tikz@lib@graph@parser@done{%
3129 \tikz@scan@next@command%
3130 }%
3131
3132
3133
3134
3135 % Syntax for edge from parent:
3136 % edge from parent [options]
3137 \def\tikz@edgetoparent from parent{\pgfutil@ifnextchar[\tikz@@edgetoparent{\tikz@@edgetoparent[]}}%}%
3138 \def\tikz@@edgetoparent[#1]{%
3139 \let\tikz@edge@to@parent@needed=\pgfutil@empty%
3140 \def\tikz@edgetoparent@options{#1}%
3141 \begingroup%
3142 \let\tikz@collected@onpath=\pgfutil@empty%
3143 \tikz@edgetoparentcollect%
3144 }%
3145 \def\tikz@edgetoparentcollect{%
3146 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@edgetoparentcollect}%
3147 {%
3148 \expandafter%
3149 \endgroup%
3150 \expandafter\tikz@edgetoparent@rollout\expandafter{\tikz@collected@onpath}%
3151 }%
3152 }%
3153
3154 \def\tikz@edgetoparent@rollout#1{%
3155 \pgfkeysgetvalue{/tikz/edge from parent macro}\tikz@etop@temp
3156 \expandafter\tikz@scan@next@command\expandafter\tikz@etop@temp\expandafter{\tikz@edgetoparent@options}{#1}%
3157 }%
3158
3159
3160 % Syntax for bezier curves
3161 % .. controls(point) and (point) .. (target)
3162 % .. controls(point) .. (target)
3163 % .. (target) % currently not supported
3164
3165 \def\tikz@dot.{\tikz@@dot}%
3166 \def\tikz@@dot{%
3167 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@@dot}{%
3168 \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@@dot}%
3169 {\pgfutil@ifnextchar c{\tikz@curveto@double}{\tikz@curveto@auto}}}%
3170 }%
3171
3172 \def\tikz@curveto@double co{%
3173 \pgfutil@ifnextchar o{\tikz@collect@coordinate@onpath\tikz@@dot co}
3174 {\tikz@cureveto@@double}}%
3175 \def\tikz@cureveto@@double ntrols#1{%
3176 \tikz@scan@one@point\tikz@curveA#1%
3177 }%
3178 \def\tikz@curveA#1{%
3179 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3180 {%
3181 \tikz@lastxsaved=\tikz@lastx%
3182 \tikz@lastysaved=\tikz@lasty%
3183 \tikz@make@last@position{#1}%
3184 \xdef\tikz@curve@first{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3185 }%
3186 \pgfutil@ifnextchar a
3187 {\tikz@curveBand}%
3188 {\let\tikz@curve@second\tikz@curve@first\tikz@curveCdots}%
3189 }%
3190 \def\tikz@curveBand and{%
3191 \tikz@scan@one@point\tikz@curveB%
3192 }%
3193 \def\tikz@curveB#1{%
3194 \def\tikz@curve@second{#1}%
3195 \tikz@curveCdots}
3196 \def\tikz@curveCdots{%
3197 \afterassignment\tikz@curveCdot\let\pgfutil@next=}%
3198 \def\tikz@curveCdot.{%
3199 \ifx\pgfutil@next.%
3200 \else%
3201 \tikzerror{Dot expected}%
3202 \fi%
3203 \iftikz@updatenext
3204 \tikz@updatecurrenttrue%
3205 \fi
3206 \tikz@curveCcheck%
3207 }%
3208 \def\tikz@curveCcheck{%
3209 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@curveCcheck}{%
3210 \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@curveCcheck}%
3211 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@curveCcheck}
3212 {\tikz@scan@one@point\tikz@curveC}}}%
3213 }%
3214 \def\tikz@curveC#1{%
3215 \tikz@make@last@position{#1}%
3216 \edef\tikz@curve@third{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3217 {%
3218 \tikz@lastxsaved=\tikz@lastx%
3219 \tikz@lastysaved=\tikz@lasty%
3220 \tikz@make@last@position{\tikz@curve@second}%
3221 \xdef\tikz@curve@second{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3222 }%
3223 %
3224 % Start recalculating things in case start and end are shapes.
3225 %
3226 % First, the start:
3227 \ifx\tikz@moveto@waiting\relax%
3228 \else%
3229 \pgf@process{\pgfpointshapeborder{\tikz@moveto@waiting}{\tikz@curve@first}}%
3230 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
3231 \tikz@@movetosave{\pgfqpoint{\pgf@x}{\pgf@y}}%
3232 \fi%
3233 \let\tikz@timer@cont@one=\tikz@curve@first%
3234 \let\tikz@timer@cont@two=\tikz@curve@second%
3235 % Second, the end:
3236 \iftikz@shapeborder%
3237 % ok, target is a shape. recalculate third
3238 {%
3239 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\tikz@curve@second}}%
3240 \tikz@make@last@position{\pgfqpoint{\pgf@x}{\pgf@y}}%
3241 \edef\tikz@curve@third{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3242 \pgfpathcurveto{\tikz@curve@first}{\tikz@curve@second}{\tikz@curve@third}%
3243 \global\let\tikz@timer@end@temp=\tikz@curve@third% move out of group
3244 }%
3245 \let\tikz@timer@end=\tikz@timer@end@temp%
3246 \edef\tikz@moveto@waiting{\tikz@shapeborder@name}%
3247 \else%
3248 \pgfpathcurveto{\tikz@curve@first}{\tikz@curve@second}{\tikz@curve@third}%
3249 \let\tikz@timer@end=\tikz@curve@third
3250 \let\tikz@moveto@waiting=\relax%
3251 \fi%
3252 \let\tikz@timer=\tikz@timer@curve%
3253 \let\tikz@tangent=\tikz@curve@second%
3254 \tikz@scan@next@command%
3255 }%
3256
3257
3258 % Syntax for rectangles:
3259 % rectangle <corner point>
3260 \def\tikz@rect ectangle{%
3261 \tikz@flush@moveto%
3262 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3263 \tikz@@rect}%
3264 \def\tikz@@rect{%
3265 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@@rect}{%
3266 \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@@rect}%
3267 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@@rect}%
3268 {
3269 \pgf@xa=\tikz@lastx\relax%
3270 \pgf@ya=\tikz@lasty\relax%
3271 \tikz@scan@one@point\tikz@rectB}}}}%
3272 \def\tikz@rectB#1{%
3273 \tikz@make@last@position{#1}%
3274 \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3275 \let\tikz@timer=\tikz@timer@line%
3276 \tikz@@movetosave{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
3277 \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\tikz@lasty}}%
3278 \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
3279 \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@ya}}%
3280 \iftikz@snaked%
3281 \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
3282 \fi%
3283 \pgfpathclose%
3284 \tikz@@movetosave{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
3285 \def\pgfstrokehook{}%
3286 \let\tikz@tangent\relax%
3287 \tikz@scan@next@command%
3288 }%
3289
3290
3291
3292 % Syntax for grids:
3293 % grid <corner point>
3294 \def\tikz@grid id{%
3295 \tikz@flush@moveto%
3296 \pgf@xa=\tikz@lastx\relax%
3297 \pgf@ya=\tikz@lasty\relax%
3298 \pgfutil@ifnextchar[{\tikz@gridA}{\tikz@gridA[]}}%}%
3299 \def\tikz@gridA[#1]{%
3300 \def\tikz@grid@options{#1}%
3301 \tikz@cycle@expander{\tikz@scan@one@point\tikz@gridB}}%
3302 \def\tikz@gridB#1{%
3303 \tikz@make@last@position{#1}%
3304 \let\tikz@tangent\relax%
3305 {%
3306 \let\tikz@after@path\pgfutil@empty%
3307 \expandafter\tikzset\expandafter{\tikz@grid@options}
3308 \tikz@checkunit{\tikz@grid@x}%
3309 \iftikz@isdimension%
3310 \pgf@process{\pgfpoint{\tikz@grid@x}{0pt}}%
3311 \else%
3312 \pgf@process{\pgfpointxy{\tikz@grid@x}{0}}%
3313 \fi%
3314 \pgf@xb=\pgf@x%
3315 \pgf@yb=\pgf@y%
3316 \tikz@checkunit{\tikz@grid@y}%
3317 \iftikz@isdimension%
3318 \pgf@process{\pgfpoint{0pt}{\tikz@grid@y}}%
3319 \else%
3320 \pgf@process{\pgfpointxy{0}{\tikz@grid@y}}%
3321 \fi%
3322 \advance\pgf@xb by\pgf@x%
3323 \advance\pgf@yb by\pgf@y%
3324 \pgfpathgrid[stepx=\pgf@xb,stepy=\pgf@yb]%
3325 {\pgfqpoint{\pgf@xa}{\pgf@ya}}{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
3326 \expandafter}%
3327 \expandafter\tikz@scan@next@command\tikz@after@path%
3328 }%
3329
3330
3331
3332 % Syntax for plot:
3333 % plot [local options] ... % starts with a moveto
3334 % -- plot [local options] ... % starts with a lineto
3335 \def\tikz@plot lot{%
3336 \tikz@flush@moveto%
3337 \pgfutil@ifnextchar[{\tikz@@plot}{\tikz@@plot[]}}%}%
3338 \def\tikz@@plot[#1]{%
3339 \let\tikz@tangent\tikz@tangent@lookup%
3340 \begingroup%
3341 \let\tikz@after@path\pgfutil@empty%
3342 \let\tikz@options=\pgfutil@empty%
3343 \tikzset{every plot/.try}%
3344 \tikzset{#1}%
3345 \pgfutil@ifnextchar f{\tikz@plot@f}%
3346 {\pgfutil@ifnextchar c{\tikz@plot@scan@points}%
3347 {\pgfutil@ifnextchar ({\tikz@plot@expression}{%
3348 \tikzerror{Cannot parse this plotting data}%
3349 \endgroup}}}}%
3350 \def\tikz@plot@f f{\pgfutil@ifnextchar i{\tikz@plot@file}{\tikz@plot@function}}%
3351
3352 \def\tikz@plot@file ile#1{\def\tikz@plot@data{\pgfplotxyfile{#1}}\tikz@@@plot}%
3353 \def\tikz@plot@scan@points coordinates#1{%
3354 \pgfplothandlerrecord\tikz@plot@data%
3355 \pgfplotstreamstart%
3356 \pgfutil@ifnextchar\pgf@stop{\pgfplotstreamend\expandafter\tikz@@@plot\pgfutil@gobble}
3357 {\tikz@scan@one@point\tikz@plot@next@point}%
3358 #1\pgf@stop%
3359 }%
3360 \def\tikz@plot@next@point#1{%
3361 \pgfplotstreampoint{#1}%
3362 \pgfutil@ifnextchar\pgf@stop{\pgfplotstreamend\expandafter\tikz@@@plot\pgfutil@gobble}%
3363 {\tikz@scan@one@point\tikz@plot@next@point}%
3364 }%
3365 \def\tikz@plot@function unction#1{%
3366 \def\tikz@plot@filename{\tikz@plot@prefix\tikz@plot@id}%
3367 \iftikz@plot@raw@gnuplot%
3368 \def\tikz@plot@data{%
3369 \pgfplotgnuplot[\tikz@plot@filename]{\pgfutil@trimspaces@e{#1}}}%
3370 \else%
3371 \iftikz@plot@parametric%
3372 \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{%
3373 set samples \tikz@plot@samples;
3374 set parametric;
3375 plot [t=\tikz@plot@domain]
3376 [\tikz@plot@xrange]
3377 [\tikz@plot@range]
3378 \pgfutil@trimspaces@e{#1}}}%
3379 \else%
3380 \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{%
3381 set samples \tikz@plot@samples;
3382 plot [x=\tikz@plot@domain]
3383 \ifx\tikz@plot@range\pgfutil@empty\else[\tikz@plot@range]\fi
3384 \pgfutil@trimspaces@e{#1}}}%
3385 \fi%
3386 \fi%
3387 \tikz@@@plot%
3388 }%
3389
3390 \def\tikz@plot@no@resample{%
3391 \pgfutil@IfFileExists{\tikz@[email protected]}%
3392 {\def\tikz@plot@data{\pgfplotxyfile{\tikz@[email protected]}}}%
3393 {}%
3394 }%
3395
3396 \def\tikz@plot@expression(#1){%
3397 \edef\tikz@plot@data{\noexpand\pgfplotfunction{\expandafter\noexpand\tikz@plot@var}{\tikz@plot@samplesat}}%
3398 \expandafter\def\expandafter\tikz@plot@data\expandafter{\tikz@plot@data{\tikz@scan@one@point\pgfutil@firstofone(#1)}}%
3399 \tikz@@@plot%
3400 }%
3401
3402 \def\tikz@@@plot{%
3403 \def\pgfplotlastpoint{\pgfpointorigin}%
3404 \tikz@plot@handler%
3405 \tikz@plot@data%
3406 \global\let\tikz@@@temp=\pgfplotlastpoint%
3407 \ifx\tikz@plot@mark\pgfutil@empty%
3408 \else%
3409 % Marks are drawn after the path.
3410 \setbox\tikz@whichbox=\hbox{%
3411 \unhbox\tikz@whichbox%
3412 \hbox{{%
3413 \pgfinterruptpath%
3414 \pgfscope%
3415 \let\tikz@options=\pgfutil@empty%
3416 \let\tikz@transform=\pgfutil@empty%
3417 \tikzset{every mark}%
3418 \tikz@options%
3419 \ifx\tikz@mark@list\pgfutil@empty%
3420 \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}%
3421 \else
3422 \pgfplothandlermarklisted{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}{\tikz@mark@list}%
3423 \fi
3424 \tikz@plot@data%
3425 \endpgfscope
3426 \endpgfinterruptpath%
3427 }}%
3428 }%
3429 \fi%
3430 \global\setbox\tikz@tempbox=\box\tikz@whichbox%
3431 \global\let\tikz@after@path@smuggle=\tikz@after@path
3432 \expandafter\endgroup%
3433 \expandafter\setbox\tikz@whichbox=\box\tikz@tempbox%
3434 \tikz@make@last@position{\tikz@@@temp}%
3435 \expandafter\tikz@scan@next@command\tikz@after@path@smuggle%
3436 }%
3437
3438
3439 \pgfdeclareplotmark{ball}
3440 {%
3441 \def\tikz@shading{ball}%
3442 \shade (0pt,0pt) circle (\pgfplotmarksize);%
3443 }%
3444
3445
3446
3447
3448 % Syntax for cosine curves:
3449 % cos <end of quarter-period>
3450 \def\tikz@cosine s{\tikz@cycle@expander{\tikz@scan@one@point\tikz@@cosine}}
3451 \def\tikz@@cosine#1{%
3452 \let\tikz@tangent\tikz@tangent@lookup%
3453 \tikz@flush@moveto%
3454 \pgf@process{#1}%
3455 \pgf@xc=\pgf@x%
3456 \pgf@yc=\pgf@y%
3457 \advance\pgf@xc by-\tikz@lastx%
3458 \advance\pgf@yc by-\tikz@lasty%
3459 \advance\tikz@lastx by\pgf@xc%
3460 \advance\tikz@lasty by\pgf@yc%
3461 \tikz@lastxsaved=\tikz@lastx%
3462 \tikz@lastysaved=\tikz@lasty%
3463 \tikz@updatecurrenttrue%
3464 \pgfpathcosine{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
3465 \tikz@scan@next@command%
3466 }%
3467
3468 % Syntax for sine curves:
3469 % sin <end of quarter-period>
3470 \def\tikz@sine in{\tikz@cycle@expander{\tikz@scan@one@point\tikz@@sine}}
3471 \def\tikz@@sine#1{%
3472 \let\tikz@tangent\tikz@tangent@lookup%
3473 \tikz@flush@moveto%
3474 \pgf@process{#1}%
3475 \pgf@xc=\pgf@x%
3476 \pgf@yc=\pgf@y%
3477 \advance\pgf@xc by-\tikz@lastx%
3478 \advance\pgf@yc by-\tikz@lasty%
3479 \advance\tikz@lastx by\pgf@xc%
3480 \advance\tikz@lasty by\pgf@yc%
3481 \tikz@lastxsaved=\tikz@lastx%
3482 \tikz@lastysaved=\tikz@lasty%
3483 \tikz@updatecurrenttrue%
3484 \pgfpathsine{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
3485 \tikz@scan@next@command%
3486 }%
3487
3488 % Syntax for parabolas:
3489 % parabola[options] bend <coordinate> <coordinate>
3490 \def\tikz@parabola arabola{%
3491 \let\tikz@tangent\tikz@tangent@lookup%
3492 \pgfutil@ifnextchar[{\tikz@parabola@options}{\tikz@parabola@options[]}}%}%
3493
3494 \def\tikz@parabola@options[#1]{%
3495 \def\tikz@parabola@option{#1}%
3496 \pgfutil@ifnextchar b{\tikz@parabola@scan@bend}{\tikz@cycle@expander{\tikz@scan@one@point\tikz@parabola@semifinal}}}%
3497 \def\tikz@parabola@scan@bend bend{\tikz@scan@one@point\tikz@parabola@scan@bendB}%
3498 \def\tikz@parabola@scan@bendB#1{%
3499 \def\tikz@parabola@bend{#1}%
3500 \tikz@cycle@expander{\tikz@scan@one@point\tikz@parabola@semifinal}%
3501 }%
3502 \def\tikz@parabola@semifinal#1{%
3503 \tikz@flush@moveto%
3504 % Save original start:
3505 \pgf@xb=\tikz@lastx%
3506 \pgf@yb=\tikz@lasty%
3507 \tikz@make@last@position{#1}%
3508 \pgf@xc=\tikz@lastx%
3509 \pgf@yc=\tikz@lasty%
3510 \begingroup% now calculate bend:
3511 \let\tikz@after@path\pgfutil@empty%
3512 \expandafter\tikzset\expandafter{\tikz@parabola@option}%
3513 \tikz@lastxsaved=\tikz@parabola@bend@factor\tikz@lastx%
3514 \tikz@lastysaved=\tikz@parabola@bend@factor\tikz@lasty%
3515 \advance\tikz@lastxsaved by\pgf@xb%
3516 \advance\tikz@lastysaved by\pgf@yb%
3517 \advance\tikz@lastxsaved by-\tikz@parabola@bend@factor\pgf@xb%
3518 \advance\tikz@lastysaved by-\tikz@parabola@bend@factor\pgf@yb%
3519 \expandafter\tikz@make@last@position\expandafter{\tikz@parabola@bend}%
3520 % Calculate delta from bend
3521 \advance\pgf@xc by-\tikz@lastx%
3522 \advance\pgf@yc by-\tikz@lasty%
3523 % Ok, now calculate delta to bend
3524 \advance\tikz@lastx by-\pgf@xb%
3525 \advance\tikz@lasty by-\pgf@yb%
3526 \xdef\tikz@parabola@b{{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}}%
3527 \expandafter\endgroup%
3528 \expandafter\expandafter\expandafter\pgfpathparabola\expandafter\tikz@parabola@b%
3529 \expandafter\tikz@scan@next@command\tikz@after@path%
3530 }%
3531
3532
3533 % Syntax for circles:
3534 % circle [options] % where options should set, at least, radius
3535 % circle (radius) % deprecated
3536 %
3537 % Syntax for ellipses:
3538 % ellipse [options] % identical to circle.
3539 % ellipse (x-radius and y-radius) % deprecated
3540 %
3541 % radii can be dimensionless, then they are in the xy-system
3542 \def\tikz@circle ircle{\tikz@flush@moveto\tikz@@circle}%
3543 \def\tikz@ellipse llipse{\tikz@flush@moveto\tikz@@circle}%
3544 \def\tikz@@circle{%
3545 \let\tikz@tangent\relax%
3546 \pgfutil@ifnextchar(\tikz@@@circle
3547 {\pgfutil@ifnextchar[\tikz@circle@opt{%])
3548 \advance\tikz@expandcount by -10\relax% go down quickly
3549 \ifnum\tikz@expandcount<0\relax%
3550 \let\pgfutil@next=\tikz@@circle@normal%
3551 \else%
3552 \let\pgfutil@next=\tikz@@circle@scanexpand%
3553 \fi%
3554 \pgfutil@next%
3555 }}%
3556 }%
3557 \def\tikz@@circle@scanexpand{\expandafter\tikz@@circle}%
3558 \def\tikz@@circle@normal{\tikz@circle@opt[]}%
3559
3560 \def\tikz@circle@opt[#1]{%
3561 {%
3562 \def\tikz@node@at{\tikz@last@position}%
3563 \let\tikz@transform=\pgfutil@empty%
3564 \tikzset{every circle/.try,#1}%
3565 \pgftransformshift{\tikz@node@at}%
3566 \tikz@transform%
3567 \tikz@do@ellipse{\pgfkeysvalueof{/tikz/x radius}}{\pgfkeysvalueof{/tikz/y radius}}
3568 }%
3569 \tikz@scan@next@command%
3570 }%
3571
3572 \def\tikz@@@circle(#1){%
3573 {%
3574 \pgftransformshift{\tikz@last@position}%
3575 \pgfutil@in@{ and }{#1}%
3576 \ifpgfutil@in@%
3577 \tikz@@ellipseB(#1)%
3578 \else%
3579 \tikz@do@circle{#1}%
3580 \fi%
3581 }%
3582 \tikz@scan@next@command%
3583 }%
3584 \def\tikz@@ellipseB(#1 and #2){%
3585 \tikz@do@ellipse{#1}{#2}%
3586 }%
3587 \def\tikz@do@circle#1{%
3588 \pgfmathparse{#1}%
3589 \let\tikz@ellipse@x=\pgfmathresult
3590 \ifpgfmathunitsdeclared
3591 \pgfpathellipse{\pgfpointorigin}%
3592 {\pgfqpoint{\tikz@ellipse@x pt}{0pt}}%
3593 {\pgfpoint{0pt}{\tikz@ellipse@x pt}}%
3594 \else
3595 \pgfpathellipse{\pgfpointorigin}%
3596 {\pgfpointxy{\tikz@ellipse@x}{0}}%
3597 {\pgfpointxy{0}{\tikz@ellipse@x}}%
3598 \fi
3599 }
3600 \def\tikz@do@ellipse#1#2{
3601 \pgfmathparse{#1}%
3602 \let\tikz@ellipse@x=\pgfmathresult%
3603 \ifpgfmathunitsdeclared%
3604 \pgfmathparse{#2}%
3605 \let\tikz@ellipse@y=\pgfmathresult%
3606 \ifpgfmathunitsdeclared%
3607 \pgfpathellipse{\pgfpointorigin}{%
3608 \pgfqpoint{\tikz@ellipse@x pt}{0pt}}{\pgfpoint{0pt}{\tikz@ellipse@y pt}}%
3609 \else%
3610 \tikzerror{You cannot mix dimensions and dimensionless values in an ellipse}%
3611 \fi%
3612 \else%
3613 \pgfmathparse{#2}%
3614 \let\tikz@ellipse@y=\pgfmathresult%
3615 \ifpgfmathunitsdeclared%
3616 \tikzerror{You cannot mix dimensions and dimensionless values in an ellipse}%
3617 \else%
3618 \pgfpathellipse{\pgfpointorigin}{%
3619 \pgfpointxy{\tikz@ellipse@x}{0}}{\pgfpointxy{0}{\tikz@ellipse@y}}%
3620 \fi%
3621 \fi%
3622 }%
3623
3624 % Syntax for arcs:
3625 % arc [options]
3626 %
3627 % (The syntax with parentheses is deprecated.)
3628 \def\tikz@arcA rc{\tikz@flush@moveto\tikz@arc@cont}%
3629 \def\tikz@arc@cont{%
3630 \pgfutil@ifnextchar(%)
3631 {\tikz@@arcto}{%
3632 \pgfutil@ifnextchar[%]
3633 {\tikz@arc@opt}%
3634 {%
3635 \advance\tikz@expandcount by -10\relax% go down quickly
3636 \ifnum\tikz@expandcount<0\relax%
3637 \let\pgfutil@next=\tikz@@arc@normal%
3638 \else%
3639 \let\pgfutil@next=\tikz@@arc@scanexpand%
3640 \fi%
3641 \pgfutil@next%
3642 }%
3643 }%
3644 }%
3645 \def\tikz@@arc@scanexpand{\expandafter\tikz@arc@cont}%
3646 \def\tikz@@arc@normal{\tikz@arc@opt[]}%
3647
3648
3649 \def\tikz@arc@opt[#1]{%
3650 {%
3651 \tikzset{every arc/.try,#1}%
3652 \pgfkeysgetvalue{/tikz/start angle}\tikz@s
3653 \pgfkeysgetvalue{/tikz/end angle}\tikz@e
3654 \pgfkeysgetvalue{/tikz/delta angle}\tikz@d
3655 \ifx\tikz@s\pgfutil@empty%
3656 \pgfmathsetmacro\tikz@s{\tikz@e-\tikz@d}
3657 \else
3658 \ifx\tikz@e\pgfutil@empty%
3659 \pgfmathsetmacro\tikz@e{\tikz@s+\tikz@d}
3660 \fi%
3661 \fi%
3662 \xdef\pgf@marshal{\noexpand%
3663 \tikz@do@arc{\tikz@s}{\tikz@e}
3664 {\pgfkeysvalueof{/tikz/x radius}}
3665 {\pgfkeysvalueof{/tikz/y radius}}}%
3666 }%
3667 \pgf@marshal%
3668 \tikz@arcfinal%
3669 }%
3670
3671 \def\tikz@@arcto(#1){%
3672 \edef\tikz@temp{(#1)}%
3673 \expandafter\tikz@@@arcto@check@slashand\tikz@temp%
3674 }%
3675
3676 \def\tikz@@@arcto@check@slashand(#1:#2:#3){%
3677 \pgfutil@in@{ and }{#3}%
3678 \ifpgfutil@in@%
3679 \tikz@parse@arc@and(#1:#2:#3)%
3680 \else%
3681 \tikz@parse@arc@and(#1:#2:{#3} and {#3})%
3682 \fi%
3683 \tikz@arcfinal%
3684 }%
3685
3686 \def\tikz@parse@arc@and(#1:#2:#3 and #4){%
3687 \tikz@do@arc{#1}{#2}{#3}{#4}%
3688 }%
3689 \def\tikz@do@arc#1#2#3#4{%
3690 \let\tikz@tangent\tikz@tangent@lookup%
3691 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3692 \pgfmathsetmacro\tikz@timer@start@angle{#1}%
3693 \pgfmathsetmacro\tikz@timer@end@angle{#2}%
3694 \pgfmathparse{#3}%
3695 \let\tikz@arc@x=\pgfmathresult%
3696 \ifpgfmathunitsdeclared%
3697 \pgfmathparse{#4}%
3698 \let\tikz@arc@y=\pgfmathresult%
3699 \ifpgfmathunitsdeclared%
3700 \tikz@@@arcfinal{\pgfpatharc{\tikz@timer@start@angle}{\tikz@timer@end@angle}{\tikz@arc@x pt and \tikz@arc@y pt}}
3701 {\pgfpointpolar{\tikz@timer@start@angle}{\tikz@arc@x pt and \tikz@arc@y pt}}
3702 {\pgfpointpolar{\tikz@timer@end@angle}{\tikz@arc@x pt and \tikz@arc@y pt}}%
3703 \edef\tikz@timer@zero@axis{\noexpand\pgfqpoint{\tikz@arc@x pt}{0pt}}
3704 \edef\tikz@timer@ninety@axis{\noexpand\pgfqpoint{0pt}{\tikz@arc@y pt}}
3705 \else%
3706 \tikzerror{You cannot mix dimensions and dimensionless values in an arc}%
3707 \fi%
3708 \else%
3709 \pgfmathparse{#4}%
3710 \let\tikz@arc@y=\pgfmathresult%
3711 \ifpgfmathunitsdeclared%
3712 \tikzerror{You cannot mix dimensions and dimensionless values in an arc}%
3713 \else%
3714 \tikz@@@arcfinal{\pgfpatharcaxes{\tikz@timer@start@angle}{\tikz@timer@end@angle}{\pgfpointxy{\tikz@arc@x}{0}}{\pgfpointxy{0}{\tikz@arc@y}}}
3715 {\pgfpointpolarxy{\tikz@timer@start@angle}{\tikz@arc@x and \tikz@arc@y}}{\pgfpointpolarxy{\tikz@timer@end@angle}{\tikz@arc@x and \tikz@arc@y}}%
3716 \pgf@process{\pgfpointxy{\tikz@arc@x}{0}}
3717 \edef\tikz@timer@zero@axis{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
3718 \pgf@process{\pgfpointxy{0}{\tikz@arc@y}}
3719 \edef\tikz@timer@ninety@axis{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
3720 \fi%
3721 \fi%
3722 }%
3723
3724 \def\tikz@@@arcfinal#1#2#3{%
3725 #1%
3726 \pgf@process{#2}
3727 \xdef\tikz@arc@save@first{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
3728 \pgf@process{#3}
3729 \xdef\tikz@arc@save@second{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
3730 }%
3731
3732 \def\tikz@arcfinal{%
3733 \pgf@process{\tikz@arc@save@first}%
3734 \advance\tikz@lastx by-\pgf@x%
3735 \advance\tikz@lasty by-\pgf@y%
3736 \pgf@process{\tikz@arc@save@second}%
3737 \advance\tikz@lastx by\pgf@x%
3738 \advance\tikz@lasty by\pgf@y%
3739 \tikz@lastxsaved=\tikz@lastx%
3740 \tikz@lastysaved=\tikz@lasty%
3741 \let\tikz@timer=\tikz@timer@arc%
3742 \tikz@scan@next@command%
3743 }%
3744
3745
3746 % Syntax for coordinates:
3747 % coordinate[options] (coordinate name) at (point)
3748 % where ``at (point)'' is optional
3749 \def\tikz@coordinate ordinate{%
3750 \pgfutil@ifnextchar[{\tikz@@coordinate@opt}{\tikz@@coordinate@opt[]}}%
3751 \def\tikz@@coordinate@opt[#1]{%
3752 \pgfutil@ifnextchar({\tikz@@coordinate[#1]}
3753 {\tikz@fig ode[shape=coordinate,#1]{}}}%}%
3754 \def\tikz@@coordinate[#1](#2){%
3755 \pgfutil@ifnextchar a{\tikz@@coordinate@at[#1](#2)}
3756 {\tikz@fig ode[shape=coordinate,#1](#2){}}}%
3757 \def\tikz@@coordinate@at[#1](#2)a{%
3758 \pgfutil@ifnextchar t{\tikz@@coordinate@@at[#1](#2)a}%
3759 {\tikz@fig ode[shape=coordinate,#1](#2){}a}%
3760 }%
3761 \def\tikz@@coordinate@@at[#1](#2)at#3({%
3762 \def\tikz@coordinate@caller{\tikz@fig ode[shape=coordinate,#1](#2)at}%
3763 \tikz@scan@one@point\tikz@@coordinate@at@math(%
3764 }%
3765 \def\tikz@@coordinate@at@math#1{%
3766 \pgf@process{#1}%
3767 \edef\tikz@temp{(\the\pgf@x,\the\pgf@y)}%
3768 \expandafter\tikz@coordinate@caller\tikz@temp{}%
3769 }%
3770
3771
3772
3773 % Syntax for nodes:
3774 % node foreach \var in {list} ... :attribute={...} [options] (node name) at (pos) {label text}
3775 %
3776 % all of :attribute, [options], (node name), at(pos), and foreach are
3777 % optional. There can be multiple options and the ordering is not
3778 % important as in node[draw] (a) [rotate=10] {text}, *except* that all
3779 % foreach statements must come first.
3780 %
3781 % A label text always ``ends'' the node.
3782 %
3783 \def\tikz@fig ode{%
3784 \pgfutil@ifnextchar a\tikz@test@also{%
3785 \pgfutil@ifnextchar f{\tikz@nodes@start}\tikz@normal@fig}}%
3786 \def\tikz@test@also a{\pgfutil@ifnextchar l\tikz@node@also{\tikz@normal@fig a}}%
3787 \def\tikz@normal@fig{%
3788 \edef\tikz@save@line@width{\the\pgflinewidth}%
3789 \begingroup%
3790 \let\tikz@fig@name=\pgfutil@empty%
3791 \begingroup%
3792 \tikz@is@matrixfalse%
3793 \let\nodepart=\tikz@nodepart%
3794 \let\tikz@atbegin@scope=\pgfutil@empty%
3795 \let\tikz@atend@scope=\pgfutil@empty%
3796 \let\tikz@do@after@node=\tikz@scan@next@command%
3797 \let\tikz@options=\pgfutil@empty%
3798 \tikz@clear@rdf@options%
3799 \let\tikz@id@name=\pgfutil@empty%
3800 \let\tikz@after@path=\pgfutil@empty%
3801 \let\tikz@transform=\pgfutil@empty%
3802 \let\tikz@mode=\pgfutil@empty%
3803 \tikz@decoratepathfalse%
3804 \let\tikz@preactions=\pgfutil@empty%
3805 \let\tikz@postactions=\pgfutil@empty%
3806 \let\tikz@alias=\pgfutil@empty%
3807 \def\tikz@node@at{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
3808 \let\tikz@time@for@matrix\tikz@time%
3809 \let\tikz@node@content\relax%
3810 \pgfgetpath\tikzpathuptonow%
3811 \iftikz@node@is@a@label%
3812 \else%
3813 \let\tikz@time\pgfutil@empty%
3814 \fi%
3815 \tikz@node@reset@hook%
3816 \tikzset{every node/.try}%
3817 \tikz@@scan@fig}%
3818 \def\tikz@@scan@fig{%
3819 \pgfutil@ifnextchar a{\tikz@fig@scan@at}
3820 {\pgfutil@ifnextchar({\tikz@fig@scan@name}
3821 {\pgfutil@ifnextchar[{\tikz@fig@scan@options}%
3822 {\pgfutil@ifnextchar:{\tikz@fig@scan@animation}%
3823 {\pgfutil@ifnextchar\bgroup{\tikz@fig@main}%
3824 {\tikzerror{A node must have a (possibly empty) label text}%
3825 \tikz@fig@main{}}}}}}}%}}%
3826 \def\tikz@fig@scan@at at{%
3827 \tikz@scan@one@point\tikz@@fig@scan@at}%
3828 \def\tikz@@fig@scan@at#1{%
3829 \def\tikz@node@at{#1}\tikz@@scan@fig}%
3830 \def\tikz@fig@scan@name(#1){%
3831 \pgfkeysvalueof{/tikz/name/.@cmd}#1\pgfeov% CF : this is now ALWAYS consistent with 'name=' option; allows overrides.
3832 \tikz@@scan@fig}%
3833 % make it \long to allow \par in "pin" options etc:
3834 \long\def\tikz@fig@scan@options[#1]{\iftikz@node@is@pic\tikz@enable@pic@quotes\else\tikz@enable@node@quotes\fi\tikzset{#1}\ifx\tikz@node@content\relax\expandafter\tikz@@scan@fig\else\tikz@expand@node@contents\fi}%
3835 \def\tikz@fig@scan@animation:#1=#2{\tikzset{animate={myself:{#1}={#2}}}\tikz@@scan@fig}%
3836 \def\tikz@expand@node@contents{%
3837 \expandafter\tikz@@scan@fig\expandafter{\tikz@node@content}%
3838 }%
3839 \let\tikz@node@reset@hook=\pgfutil@empty%
3840 \let\tikz@node@begin@hook=\pgfutil@empty%
3841 \def\tikz@fig@main{%
3842 \iftikz@node@is@pic%
3843 \tikz@node@is@picfalse%
3844 \expandafter\tikz@subpicture@handle%
3845 \else%
3846 \afterassignment\tikz@@fig@main\expandafter\let\expandafter\next\expandafter=%
3847 \fi}%
3848 \def\tikz@@fig@main{%
3849 \pgfutil@ifundefined{pgf@sh@s@\tikz@shape}%
3850 {\tikzerror{Unknown shape ``\tikz@shape.'' Using ``rectangle'' instead}%
3851 \def\tikz@shape{rectangle}}%
3852 {}%
3853 \expandafter\xdef\csname tikz@dcl@coord@\tikz@fig@name\endcsname{%
3854 \csname tikz@scan@point@coordinate\endcsname}%
3855 \tikzset{every \tikz@shape\space node/.try}%
3856 \tikz@node@textfont%
3857 \tikz@node@begin@hook%
3858 \iftikz@is@matrix%
3859 \let\tikz@next=\tikz@do@matrix%
3860 \else%
3861 \let\tikz@next=\tikz@do@fig%
3862 \fi%
3863 \tikz@next%
3864 }%
3865 \let\tikz@nodepart@list\pgfutil@empty
3866 \def\tikz@do@fig{%
3867 % Ok, reset all node part boxes
3868 \pgfutil@for\tikz@temp:=\tikz@nodepart@list\do{%
3869 \expandafter\setbox\csname pgfnodepart\tikz@temp box\endcsname=\box\pgfutil@voidb@x%
3870 }%
3871 \setbox\pgfnodeparttextbox=\hbox%
3872 \bgroup%
3873 \pgfinterruptpicture%
3874 \pgfsys@begin@text%
3875 \pgfsys@text@to@black@hook%
3876 \tikzset{every text node part/.try}%
3877 \ifx\tikz@textopacity\pgfutil@empty%
3878 \else%
3879 \pgfsetfillopacity{\tikz@textopacity}%
3880 \pgfsetstrokeopacity{\tikz@textopacity}%
3881 \fi%
3882 \ifx\tikz@text@width\pgfutil@empty%
3883 \tikz@textfont%
3884 \else%
3885 \begingroup%
3886 \pgfmathsetlength{\pgf@x}{\tikz@text@width}%
3887 \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}%
3888 \tikz@textfont%
3889 \tikz@text@action%
3890 \fi%
3891 \tikz@atbegin@node%
3892 \bgroup%
3893 \aftergroup\unskip%
3894 % Some color stuff has been moved from here to outside; this is
3895 % necessary for support of dvisvgm and of animation
3896 % snapshots.
3897 \ifx\tikz@textcolor\pgfutil@empty%
3898 \else%
3899 \pgfutil@colorlet{.}{\tikz@textcolor}%
3900 \pgfutil@color{\tikz@textcolor}%
3901 \fi%
3902 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
3903 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
3904 \tikz@uninstallcommands%
3905 \iftikz@handle@active@code%
3906 \tikz@orig@shorthands%
3907 \let\tikz@orig@shorthands\pgfutil@empty%
3908 \fi%
3909 \ifnum\the\catcode`\;=\active\relax\expandafter\let\tikz@activesemicolon=\tikz@origsemi\fi%
3910 \ifnum\the\catcode`\:=\active\relax\expandafter\let\tikz@activecolon=\tikz@origcolon\fi%
3911 \ifnum\the\catcode`\|=\active\relax\expandafter\let\tikz@activebar=\tikz@origbar\fi%
3912 \aftergroup\tikz@fig@collectresetcolor%
3913 \tikz@signal@halign@check%
3914 \tikz@text@reset%
3915 \tikz@halign@check%
3916 \ignorespaces%
3917 }%
3918 \def\tikz@fig@collectresetcolor{%
3919 % Hacks for special packages that mess with \aftergroup
3920 \pgfutil@ifnextchar\reset@color% hack for color package
3921 {\reset@color\afterassignment\tikz@fig@collectresetcolor\let\tikz@temp=}\tikz@fig@boxdone%
3922 }%
3923 \def\tikz@fig@boxdone{%
3924 \tikz@atend@node%
3925 \ifx\tikz@text@width\pgfutil@empty%
3926 \else%
3927 \pgfutil@endminipage%
3928 \endgroup%
3929 \fi%
3930 \pgfsys@end@text%
3931 \endpgfinterruptpicture%
3932 \egroup%
3933 \pgfutil@ifnextchar c{\tikz@fig@mustbenamed\tikz@fig@continue}%
3934 {\pgfutil@ifnextchar[{\tikz@fig@mustbenamed\tikz@fig@continue}%
3935 {\pgfutil@ifnextchar t{\tikz@fig@mustbenamed\tikz@fig@continue}
3936 {\pgfutil@ifnextchar e{\tikz@fig@mustbenamed\tikz@fig@continue}
3937 {\ifx\tikz@after@path\pgfutil@empty\expandafter\tikz@fig@continue\else\expandafter\tikz@fig@mustbenamed\expandafter\tikz@fig@continue\fi}}}}}%}%
3938
3939 \tikzset{
3940 matrix/inner style/every cell/.code={%
3941 \tikzset{every cell/.try={\the\pgfmatrixcurrentrow}{\the\pgfmatrixcurrentcolumn}}%
3942 },
3943 matrix/inner style/column/.code={%
3944 \tikzset{column \the\pgfmatrixcurrentcolumn/.try}%
3945 },
3946 matrix/inner style/even odd column/.code={
3947 \ifodd\pgfmatrixcurrentcolumn%
3948 \tikzset{every odd column/.try}%
3949 \else%
3950 \tikzset{every even column/.try}%
3951 \fi
3952 },
3953 matrix/inner style/row/.code={%
3954 \tikzset{row \the\pgfmatrixcurrentrow/.try}%
3955 },
3956 matrix/inner style/even odd row/.code={%
3957 \ifodd\pgfmatrixcurrentrow%
3958 \tikzset{every odd row/.try}%
3959 \else%
3960 \tikzset{every even row/.try}%
3961 \fi
3962 },
3963 matrix/inner style/cell/.code={%
3964 \tikzset{row \the\pgfmatrixcurrentrow\space column \the\pgfmatrixcurrentcolumn/.try}%
3965 },
3966 matrix/inner style order/.store in=\tikz@common@matrix@code@styleorder,
3967 matrix/inner style order={
3968 every cell,
3969 column,
3970 even odd column,
3971 row,
3972 even odd row,
3973 cell
3974 },
3975 }%
3976
3977 \def\tikz@do@matrix{%
3978 \tikzset{every matrix/.try}%
3979 \tikz@node@transformations%
3980 \tikz@fig@mustbenamed%
3981 \setbox\tikz@whichbox=\hbox\bgroup%
3982 \unhbox\tikz@whichbox%
3983 \hbox\bgroup\bgroup%
3984 \pgfinterruptpath%
3985 \pgfscope%
3986 \ifx\tikz@time\pgfutil@empty\let\tikz@time\tikz@time@for@matrix\fi%
3987 \tikz@options%
3988 \tikz@do@rdf@pre@options%
3989 \tikz@is@nodefalse%
3990 \tikz@call@id@hook%
3991 \pgfidscope%
3992 \tikz@do@rdf@post@options%
3993 \begingroup%
3994 \let\tikz@id@name\pgfutil@empty%
3995 \pgfclearid%
3996 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
3997 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
3998 \let\tikzmatrixname=\tikz@fig@name%
3999 \edef\tikz@m@anchor{\ifx\tikz@matrix@anchor\pgfutil@empty\tikz@anchor\else\tikz@matrix@anchor\fi}%
4000 \expandafter\pgfutil@in@\expandafter{\expandafter.\expandafter}\expandafter{\tikz@m@anchor}%
4001 \ifpgfutil@in@%
4002 \expandafter\tikz@matrix@split\tikz@m@anchor\relax%
4003 \else%
4004 \def\tikz@matrix@shift{\pgfpointorigin}%
4005 \fi%
4006 \let\tikz@transform=\relax%
4007 \pgfmatrixbeforeassemblenode{\tikzset{every outer matrix/.try}}%
4008 \pgfmatrix%
4009 {\tikz@shape}%
4010 {\tikz@m@anchor}%
4011 {\tikz@fig@name}%
4012 {%
4013 \pgfutil@tempdima=\pgflinewidth%
4014 {\begingroup\tikz@finish}%
4015 \global\pgflinewidth=\pgfutil@tempdima%
4016 }%
4017 {\tikz@matrix@shift}%
4018 {%
4019 \tikz@matrix@make@active@ampersand%
4020 \def\pgfmatrixbegincode{%
4021 \pgfsys@beginscope%
4022 \tikz@common@matrix@code%
4023 \tikz@atbegin@cell%
4024 }%
4025 \def\tikz@common@matrix@code{%
4026 \let\tikz@options=\pgfutil@empty%
4027 \let\tikz@mode=\pgfutil@empty%
4028 \pgfutil@for\pgf@temp:=\tikz@common@matrix@code@styleorder\do{%
4029 \toks0=\expandafter{\romannumeral-`0\expandafter\pgfutil@trimspaces\expandafter{\pgf@temp}}%
4030 \def\pgf@marshal{}%
4031 \pgfutil@ifxempty\pgf@temp{}{%
4032 \edef\pgf@marshal{\noexpand\tikzset{matrix/inner style/.cd,\the\toks0}}%
4033 }%
4034 \pgf@marshal
4035 }%
4036 \tikz@options%
4037 }%
4038 \def\pgfmatrixendcode{%
4039 \tikz@atend@cell%
4040 \pgfsys@endscope%
4041 }%
4042 \def\pgfmatrixemptycode{%
4043 \pgfsys@beginscope%
4044 \tikz@common@matrix@code%
4045 \tikz@at@emptycell%
4046 \pgfsys@endscope%
4047 }%
4048 \tikz@atbegin@matrix%
4049 \aftergroup\tikz@do@matrix@cont}%
4050 \bgroup%
4051 }%
4052 \def\tikz@do@matrix@cont{%
4053 \tikz@atend@matrix%
4054 \endgroup%
4055 \endpgfidscope%
4056 \endpgfscope
4057 \endpgfinterruptpath%
4058 \egroup\egroup%
4059 \egroup%
4060 %
4061 \tikz@node@finish%
4062 }%
4063 {%
4064 \catcode`\&=13
4065 \gdef\tikz@matrix@make@active@ampersand{%
4066 \ifx\tikz@ampersand@replacement\pgfutil@empty%
4067 \catcode`\&=13%
4068 \let&=\pgfmatrixnextcell%
4069 \else%
4070 \expandafter\let\tikz@ampersand@replacement=\pgfmatrixnextcell%
4071 \fi%
4072 }%
4073 }%
4074
4075
4076 \def\tikz@matrix@split#1.#2\relax{%
4077 \def\tikz@m@anchor{text}%
4078 \def\tikz@matrix@shift{\pgfpointanchor{#1}{#2}}%
4079 }%
4080
4081 \def\tikz@fig@continue{%
4082 \ifx\tikz@text@width\pgfutil@empty%
4083 \else%
4084 \pgfmathsetlength{\pgf@x}{\tikz@text@width}%
4085 \wd\pgfnodeparttextbox=\pgf@x%
4086 \fi%
4087 \ifx\tikz@text@height\pgfutil@empty%
4088 \else%
4089 \pgfmathsetlength{\pgf@x}{\tikz@text@height}%
4090 \ht\pgfnodeparttextbox=\pgf@x%
4091 \fi%
4092 \ifx\tikz@text@depth\pgfutil@empty%
4093 \else%
4094 \pgfmathsetlength{\pgf@x}{\tikz@text@depth}%
4095 \dp\pgfnodeparttextbox=\pgf@x%
4096 \fi%
4097 %
4098 % Node transformation
4099 %
4100 \tikz@node@transformations%
4101 \tikz@nlt%
4102 %
4103 \setbox\tikz@whichbox=\hbox{%
4104 \unhbox\tikz@whichbox%
4105 \hbox{{%
4106 \pgfinterruptpath%
4107 \pgfscope%
4108 \tikz@options%
4109 \tikz@do@rdf@pre@options%
4110 \tikz@is@nodetrue%
4111 \tikz@call@id@hook%
4112 \pgfidscope%
4113 \tikz@do@rdf@post@options%
4114 \let\tikz@id@name\pgfutil@empty%
4115 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
4116 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
4117 % Add color modifications to text box
4118 \setbox\pgfnodeparttextbox=\hbox{{%
4119 \pgfsys@begin@text% Colors moved here...
4120 \ifx\tikz@textcolor\pgfutil@empty%
4121 \else%
4122 \pgfutil@colorlet{.}{\tikz@textcolor}%
4123 \fi%
4124 \pgfsetcolor{.}%
4125 \pgfusetype{.text}%
4126 \pgfidscope%
4127 \box\pgfnodeparttextbox%
4128 \endpgfidscope%
4129 \pgfsys@end@text%
4130 }}%
4131 \pgfmultipartnode{\tikz@shape}{\tikz@anchor}{\tikz@fig@name}{%
4132 \pgfutil@tempdima=\pgflinewidth%
4133 {\begingroup\tikz@finish}%
4134 \global\pgflinewidth=\pgfutil@tempdima%
4135 }%
4136 \endpgfidscope%
4137 \endpgfscope%
4138 \endpgfinterruptpath%
4139 }}%
4140 }%
4141 %
4142 \tikz@alias%
4143 \tikz@node@finish%
4144 }%
4145
4146
4147 \def\tikz@fig@mustbenamed{%
4148 \ifx\tikz@fig@name\pgfutil@empty%
4149 % Assign a dummy name
4150 \global\advance\tikz@fig@count by1\relax
4151 \edef\tikz@fig@name{tikz@f@\the\tikz@fig@count}%
4152 \let\tikz@id@name\tikz@fig@name%
4153 \fi%
4154 }%
4155
4156 \def\tikz@node@transformations{%
4157 %
4158 % Possibly, we are ``online''
4159 %
4160 \ifx\tikz@time\pgfutil@empty%
4161 \pgftransformshift{\tikz@node@at}%
4162 \iftikz@fullytransformed%
4163 \else%
4164 \pgftransformresetnontranslations%
4165 \fi%
4166 \else%
4167 \tikz@do@auto@anchor%
4168 \tikz@timer%
4169 \fi%
4170 % Invoke local transformations
4171 \tikz@transform%
4172 }%
4173
4174 \def\tikz@node@finish{%
4175 \global\let\tikz@last@fig@name=\tikz@fig@name%
4176 \global\let\tikz@after@path@smuggle=\tikz@after@path%
4177 % shift box outside group
4178 \global\setbox\tikz@tempbox=\box\tikz@figbox%
4179 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
4180 \endgroup\endgroup%
4181 \setbox\tikz@figbox=\box\tikz@tempbox%
4182 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
4183 \global\pgflinewidth=\tikz@save@line@width%
4184 \tikz@do@after@path@smuggle%
4185 \tikz@node@is@picfalse
4186 \tikz@do@after@node%
4187 }%
4188 \let\tikz@fig@continue@orig=\tikz@fig@continue
4189
4190 \def\tikz@do@after@node{\tikz@scan@next@command}%
4191
4192 \def\tikz@do@after@path@smuggle{%
4193 \let\tikz@to@last@fig@name=\tikz@last@fig@name%
4194 \let\tikz@to@use@whom=\tikz@to@use@last@fig@name%
4195 \let\tikzlastnode=\tikz@last@fig@name%
4196 \ifx\tikz@after@path@smuggle\pgfutil@empty%
4197 \else%
4198 \ifpgflatenodepositioning%
4199 \expandafter\expandafter\expandafter\tikz@call@late%
4200 \expandafter\expandafter\expandafter{\expandafter\tikz@last@fig@name\expandafter}\expandafter{\tikz@after@path@smuggle}%
4201 \else%
4202 \tikz@scan@next@command{\tikz@after@path@smuggle}\pgf@stop%
4203 \fi%
4204 \fi%
4205 }%
4206
4207 \def\tikz@call@late#1#2{\pgfnodepostsetupcode{#1}{\path[late options={name={#1},append after command={#2}}];}}%
4208
4209 \newif\iftikz@do@align
4210
4211 % Alignment handling
4212 \def\tikz@signal@halign@check{%
4213 \tikz@do@alignfalse
4214 \ifx\tikz@text@width\pgfutil@empty%
4215 \pgfkeysgetvalue{/tikz/node halign header}\tikz@align@header%
4216 \ifx\tikz@align@header\pgfutil@empty%
4217 \else%
4218 \tikz@do@aligntrue%
4219 \fi%
4220 \fi%
4221 }
4222 \def\tikz@halign@check{%
4223 \iftikz@do@align%
4224 % Bingo
4225 \setbox\tikz@align@aligned@box=\box\pgfutil@voidb@x% void
4226 \let\\=\tikz@align@newline%
4227 \expandafter\tikz@start@align%
4228 \fi%
4229 }%
4230 \def\tikz@align@newline{\pgfutil@protect\tikz@align@newline@}%
4231 \def\tikz@align@newline@{\unskip\pgfutil@ifnextchar[\tikz@@align@newline{\tikz@@align@newline[0pt]}}%}%
4232 \def\tikz@@align@newline[#1]{\egroup\tikz@align@continue\pgfmathparse{#1}\let\tikz@align@temp=\pgfmathresult\tikz@start@align}%
4233 % Two safe boxes for alignment:
4234 \let\tikz@align@aligned@box=\pgfnodeparttextbox
4235 \let\tikz@align@line@box=\tikz@figbox
4236
4237 \def\tikz@start@align{%
4238 % Start collecting text:
4239 \setbox\tikz@align@line@box=\hbox\bgroup\bgroup%
4240 \aftergroup\tikz@align@collectresetcolor\ignorespaces%
4241 }%
4242 \def\tikz@align@collectresetcolor{%
4243 \pgfutil@ifnextchar\reset@color%
4244 {\reset@color\afterassignment\tikz@align@collectresetcolor\let\tikz@temp=}%
4245 {\tikz@align@end@check}%
4246 }%
4247 \def\tikz@align@end@check{%
4248 \egroup%
4249 \ifvoid\tikz@align@aligned@box%
4250 \setbox\tikz@align@aligned@box=\box\tikz@align@line@box%
4251 \else%
4252 \setbox\tikz@align@aligned@box=\vbox{%
4253 \expandafter\expandafter\expandafter\halign\expandafter\expandafter\expandafter{\tikz@align@header%
4254 \box\tikz@align@aligned@box\cr%
4255 \noalign{\vskip\tikz@align@temp pt}%
4256 \unhbox\tikz@align@line@box\unskip\cr}}%
4257 \fi%
4258 \pgfutil@ifnextchar\tikz@align@continue{}
4259 {%
4260 % Main continue
4261 \box\tikz@align@aligned@box%
4262 \egroup%
4263 }%
4264 }%
4265 \def\tikz@align@continue{\tikz@@align@continue}%
4266 \let\tikz@@align@continue=\pgfutil@empty
4267
4268
4269 \def\tikz@node@also lso{\pgfutil@ifnextchar[\tikz@node@also@opt{\tikz@node@also@opt[]}}%
4270 \def\tikz@node@also@opt[#1]{
4271 \pgfutil@ifnextchar(%)
4272 {\tikz@node@also@opt@cont[#1]}%
4273 {\tikzerror{Syntax error in node also: ``('' expected.}%
4274 \tikz@scan@next@command}%
4275 }%
4276 \def\tikz@node@also@opt@cont[#1](#2){\tikzset{late options={name=#2,#1}}\tikz@scan@next@command}%
4277
4278
4279
4280 % Syntax for parts of nodes:
4281 % node ... {... \nodepart[options]{name} ... \nodepart{name} ...}
4282
4283 \def\tikz@nodepart{\pgfutil@ifnextchar[\tikz@@nodepart{\tikz@@nodepart[]}}%}%
4284 \def\tikz@@nodepart[#1]#2{%
4285 \tikz@atend@node%
4286 \unskip%
4287 \gdef\tikz@nodepart@options{#1}%
4288 \gdef\tikz@nodepart@name{#2}%
4289 \global\let\tikz@fig@continue=\tikz@nodepart@continue%
4290 \pgfutil@ifnextchar x{\egroup\relax}{\egroup\relax}% gobble spaces
4291 }%
4292 \def\tikz@nodepart@continue{%
4293 \global\let\tikz@fig@continue=\tikz@fig@continue@orig%
4294 \ifx\tikz@nodepart@list\pgfutil@empty%
4295 \let\tikz@nodepart@list\tikz@nodepart@name%
4296 \else%
4297 \edef\tikz@nodepart@list{\tikz@nodepart@list,\tikz@nodepart@name}%
4298 \fi%
4299 % Now start new box:
4300 \expandafter\setbox\csname pgfnodepart\tikz@nodepart@name box\endcsname=\hbox%
4301 \bgroup%
4302 \pgfinterruptpicture%
4303 \pgfsys@begin@text%
4304 \pgfsys@text@to@black@hook%
4305 \tikzset{every \tikz@nodepart@name\space node part/.try}%
4306 \expandafter\tikzset\expandafter{\tikz@nodepart@options}%
4307 \ifx\tikz@textopacity\pgfutil@empty%
4308 \else%
4309 \pgfsetfillopacity{\tikz@textopacity}%
4310 \pgfsetstrokeopacity{\tikz@textopacity}%
4311 \fi%
4312 % Colors moved here...
4313 \ifx\tikz@textcolor\pgfutil@empty%
4314 \else%
4315 \pgfutil@colorlet{.}{\tikz@textcolor}%
4316 \fi%
4317 \pgfsetcolor{.}%
4318 \ifx\tikz@text@width\pgfutil@empty%
4319 \tikz@textfont%
4320 \else%
4321 \begingroup%
4322 \pgfmathsetlength{\pgf@x}{\tikz@text@width}%
4323 \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}%
4324 \tikz@textfont%
4325 \tikz@text@action%
4326 \fi%
4327 \bgroup%
4328 \aftergroup\unskip%
4329 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
4330 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
4331 \tikz@uninstallcommands%
4332 \iftikz@handle@active@code%
4333 \tikz@orig@shorthands%
4334 \let\tikz@orig@shorthands\pgfutil@empty%
4335 \fi%
4336 \ifnum\the\catcode`\;=\active\relax\expandafter\let\tikz@activesemicolon=\tikz@origsemi\fi%
4337 \ifnum\the\catcode`\:=\active\relax\expandafter\let\tikz@activecolon=\tikz@origcolon\fi%
4338 \ifnum\the\catcode`\|=\active\relax\expandafter\let\tikz@activebar=\tikz@origbar\fi%
4339 \tikz@atbegin@node%
4340 \aftergroup\tikz@fig@collectresetcolor%
4341 \tikz@signal@halign@check%
4342 \tikz@text@reset%
4343 \tikz@halign@check%
4344 \ignorespaces%
4345 }%
4346
4347
4348 %
4349 % Node foreach
4350 %
4351
4352 \def\tikz@nodes@start{%
4353 \let\tikz@nodes@list\pgfutil@empty%
4354 \iftikz@node@is@pic%
4355 \def\tikz@nodes@collect{pic }%
4356 \else%
4357 \def\tikz@nodes@collect{node }%
4358 \fi%
4359 \tikz@nodes%
4360 }%
4361 \def\tikz@nodes foreach{\pgfutil@ifnextchar x\tikz@nodes@\tikz@nodes@}% get rid of spaces
4362 \def\tikz@nodes@#1in{%
4363 \expandafter\def\expandafter\tikz@nodes@list\expandafter{\tikz@nodes@list\foreach#1in}%
4364 \pgfutil@ifnextchar\bgroup\tikz@nodes@group\tikz@nodes@one%
4365 }%
4366 \def\tikz@nodes@one#1{%
4367 \expandafter\def\expandafter\tikz@nodes@list\expandafter{\tikz@nodes@list#1}%
4368 \pgfutil@ifnextchar f\tikz@nodes\tikz@nodes@scan%
4369 }%
4370 \def\tikz@nodes@group#1{%
4371 \expandafter\def\expandafter\tikz@nodes@list\expandafter{\tikz@nodes@list{#1}}%
4372 \pgfutil@ifnextchar f\tikz@nodes\tikz@nodes@scan%
4373 }%
4374 \def\tikz@nodes@scan{%
4375 \pgfutil@ifnextchar a{\tikz@nodes@at}%
4376 {\pgfutil@ifnextchar({\tikz@nodes@name}%
4377 {\pgfutil@ifnextchar[{\tikz@nodes@opt}%
4378 {\pgfutil@ifnextchar\bgroup{\tikz@nodes@main}%
4379 {\tikzerror{Nodes must have a (possibly empty) label text}%
4380 \tikz@fig@main{}}}}}}%}}%
4381
4382 % Look ahead whether the next character is a (. If that is the case, we scan
4383 % until ), otherwise we grab a single token and append.
4384 \def\tikz@nodes@at at{\pgfutil@ifnextchar({\tikz@nodes@at@}{\tikz@nodes@at@@}}%
4385 \def\tikz@nodes@at@#1){%
4386 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect at#1)}%
4387 \tikz@nodes@scan}%
4388 \def\tikz@nodes@at@@#1{%
4389 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect at#1}%
4390 \tikz@nodes@scan}%
4391
4392 \def\tikz@nodes@name#1){%
4393 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect#1)}%
4394 \tikz@nodes@scan}%
4395 \def\tikz@nodes@opt#1]{%
4396 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect#1]}%
4397 \tikz@nodes@scan}%
4398 \def\tikz@nodes@main#1{%
4399 \iftikz@handle@active@nodes%
4400 \iftikz@node@is@pic%
4401 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect{#1}}%
4402 \else%
4403 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect{\scantokens{#1}}}%
4404 \fi%
4405 \else%
4406 \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect{#1}}%
4407 \fi%
4408 % Ok, got everything.
4409 % Now, start building parse text.
4410 \global\setbox\tikz@tempbox=\box\tikz@figbox%
4411 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
4412 \tikz@nodes@list{%
4413 \setbox\tikz@figbox=\box\tikz@tempbox%
4414 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
4415 \expandafter\tikz@scan@next@command\tikz@nodes@collect\pgfextra\relax%
4416 \global\setbox\tikz@tempbox=\box\tikz@figbox%
4417 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
4418 }%
4419 \setbox\tikz@figbox=\box\tikz@tempbox%
4420 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
4421 \tikz@scan@next@command%
4422 }%
4423
4424
4425
4426 %
4427 % "late" options can be used to "redo" a node
4428 %
4429 \tikzset{late options/.code=\tikz@late@options{#1}}%
4430 \def\tikz@late@options#1{%
4431 % Do a "virtual" node:
4432 \begingroup%
4433 \iftikz@shapeborder%
4434 \let\tikz@fig@name=\tikz@shapeborder@name%
4435 \else%
4436 \let\tikz@fig@name=\pgfutil@empty%
4437 \fi%
4438 \tikz@is@matrixfalse%
4439 \let\tikz@options=\pgfutil@empty%
4440 \tikz@clear@rdf@options%
4441 \let\tikz@after@path=\pgfutil@empty%
4442 \let\tikz@afternodepathoptions=\pgfutil@empty%
4443 \let\tikz@alias=\pgfutil@empty%
4444 \let\tikz@transform=\pgfutil@empty%
4445 \tikz@decoratepathfalse%
4446 \tikz@node@reset@hook%
4447 \tikz@enable@node@quotes%
4448 \tikzset{every node/.try,#1}%
4449 \ifx\tikz@fig@name\pgfutil@empty%
4450 \tikzerror{Late options must reference some existing node}%
4451 \fi%
4452 \tikz@node@begin@hook%
4453 \tikz@alias%
4454 \tikzgdlatenodeoptionacallback{\tikz@fig@name}%
4455 \global\let\tikz@last@fig@name=\tikz@fig@name%
4456 \global\let\tikz@after@path@smuggle=\tikz@after@path%
4457 \endgroup%
4458 \tikz@do@after@path@smuggle%
4459 }%
4460
4461
4462 % Auto placement
4463
4464 \def\tikz@auto@pre{%
4465 \begingroup
4466 \pgfresetnontranslationattimefalse
4467 \ifpgfslopedattime
4468 \pgfslopedattimefalse%
4469 \else
4470 \pgfslopedattimetrue%
4471 \fi
4472 \pgfallowupsidedownattimetrue%
4473 \tikz@timer%
4474 \pgf@x=\pgf@pt@aa pt%
4475 \pgf@y=\pgf@pt@ab pt%
4476 \pgfpointnormalised{}%
4477 }%
4478
4479 \def\tikz@auto@post{%
4480 \global\let\tikz@anchor@smuggle=\tikz@anchor%
4481 \endgroup%
4482 \let\tikz@anchor=\tikz@anchor@smuggle%
4483 }%
4484
4485 \def\tikz@auto@anchor{%
4486 \ifdim\pgf@x>0.05pt%
4487 \ifdim\pgf@y>0.05pt%
4488 \def\tikz@anchor{south east}%
4489 \else\ifdim\pgf@y<-0.05pt%
4490 \def\tikz@anchor{south west}%
4491 \else
4492 \def\tikz@anchor{south}%
4493 \fi\fi%
4494 \else\ifdim\pgf@x<-0.05pt%
4495 \ifdim\pgf@y>0.05pt%
4496 \def\tikz@anchor{north east}%
4497 \else\ifdim\pgf@y<-0.05pt%
4498 \def\tikz@anchor{north west}%
4499 \else
4500 \def\tikz@anchor{north}%
4501 \fi\fi%
4502 \else%
4503 \ifdim\pgf@y>0pt%
4504 \def\tikz@anchor{east}%
4505 \else%
4506 \def\tikz@anchor{west}%
4507 \fi%
4508 \fi\fi%
4509 }%
4510
4511 \def\tikz@auto@anchor@prime{%
4512 \ifdim\pgf@x>0.05pt%
4513 \ifdim\pgf@y>0.05pt%
4514 \def\tikz@anchor{north west}%
4515 \else\ifdim\pgf@y<-0.05pt%
4516 \def\tikz@anchor{north east}%
4517 \else
4518 \def\tikz@anchor{north}%
4519 \fi\fi%
4520 \else\ifdim\pgf@x<-0.05pt%
4521 \ifdim\pgf@y>0.05pt%
4522 \def\tikz@anchor{south west}%
4523 \else\ifdim\pgf@y<-0.05pt%
4524 \def\tikz@anchor{south east}%
4525 \else
4526 \def\tikz@anchor{south}%
4527 \fi\fi%
4528 \else%
4529 \ifdim\pgf@y>0pt%
4530 \def\tikz@anchor{west}%
4531 \else%
4532 \def\tikz@anchor{east}%
4533 \fi%
4534 \fi\fi%
4535 }%
4536
4537
4538 %
4539 % Callbacks: Please see the documentation of the graph drawing
4540 % lib for info on these callbacks
4541 %
4542 \def\tikzgdeventcallback#1#2{}%
4543 \def\tikzgdeventgroupcallback#1{}%
4544 \def\tikzgdlatenodeoptionacallback#1{}%
4545
4546 % Syntax for trees:
4547 % node {...} child [options] {...} child [options] {...} ...
4548 % node {...} child [options] foreach \var in {list} [options] {...} ...
4549
4550 \def\tikz@children{%
4551 % Start collecting the children:
4552 \let\tikz@children@list=\pgfutil@empty%
4553 \tikznumberofchildren=0\relax%
4554 \tikz@collect@children c}%
4555
4556 \def\tikz@collect@children{\pgfutil@ifnextchar c{\tikz@collect@children@cchar}{\tikz@children@collected}}%
4557 \def\tikz@collect@children@cchar c{\pgfutil@ifnextchar h{\tikz@collect@child}{\tikz@children@collected c}}%
4558 \def\tikz@collect@child hild{\pgfutil@ifnextchar[{\tikz@collect@childA}{\tikz@collect@childA[]}}%}%
4559 \def\tikz@collect@childA[#1]{\pgfutil@ifnextchar f{\tikz@collect@children@foreach[#1]}{\tikz@collect@childB[#1]}}%
4560 \def\tikz@collect@childB[#1]{%
4561 \advance\tikznumberofchildren by1\relax
4562 \expandafter\def\expandafter\tikz@children@list\expandafter{\tikz@children@list \tikz@childnode[#1]}%
4563 \pgfutil@ifnextchar\bgroup{\tikz@collect@child@code}{\tikz@collect@child@code{}}}%
4564 \def\tikz@collect@child@code#1{%
4565 \expandafter\def\expandafter\tikz@children@list\expandafter{\tikz@children@list{#1}}%
4566 \tikz@collect@children%
4567 }%
4568 \def\tikz@collect@children@foreach[#1]foreach#2in#3{%
4569 \pgfutil@ifnextchar\bgroup{\tikz@collect@children@foreachA{#1}{#2}{#3}}{\tikz@collect@children@foreachA{#1}{#2}{#3}{}}}%
4570 \def\tikz@collect@children@foreachA#1#2#3#4{%
4571 \expandafter\def\expandafter\tikz@children@list\expandafter
4572 {\tikz@children@list\tikz@childrennodes[#1]{#2}{#3}{#4}}%
4573 \c@pgf@counta=\tikznumberofchildren%
4574 \foreach#2in{#3}%
4575 {%
4576 \global\advance\c@pgf@counta by1\relax%
4577 }%
4578 \tikznumberofchildren=\c@pgf@counta%
4579 \tikz@collect@children%
4580 }%
4581 \long\def\tikz@children@collected{%
4582 \begingroup%
4583 \advance\tikztreelevel by 1\relax%
4584 \tikzgdeventgroupcallback{descendants}%
4585 \let\tikz@options=\pgfutil@empty%
4586 \tikz@clear@rdf@options%
4587 \let\tikz@transform=\pgfutil@empty%
4588 \tikzset{level/.try=\the\tikztreelevel,level \the\tikztreelevel/.try}%
4589 \tikz@transform%
4590 \let\tikz@transform=\relax%
4591 \let\tikzparentnode=\tikz@last@fig@name%
4592 \ifx\tikz@grow\relax\else%
4593 % Transform to center of node
4594 \pgftransformshift{\pgfpointanchor{\tikzparentnode}{\tikz@growth@anchor}}%
4595 \fi%
4596 \tikznumberofcurrentchild=0\relax%
4597 \tikz@children@list%
4598 \global\setbox\tikz@tempbox=\box\tikz@figbox%
4599 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
4600 \endgroup%
4601 \setbox\tikz@figbox=\box\tikz@tempbox%
4602 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
4603 \tikz@scan@next@command%
4604 }%
4605
4606 % Syntax for children:
4607 %
4608 % child [all children options] foreach \var in {values} [child options] {...}
4609 \def\tikz@childrennodes[#1]#2#3#4{%
4610 \c@pgf@counta=\tikznumberofcurrentchild\relax%
4611 \setbox\tikz@tempbox=\box\tikz@figbox%
4612 \setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
4613 \foreach#2in{#3}{%
4614 \tikznumberofcurrentchild=\c@pgf@counta\relax%
4615 \setbox\tikz@figbox=\box\tikz@tempbox%
4616 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
4617 \tikz@childnode[#1]{#4}%
4618 % we must now make the current child number and the figbox survive
4619 % the group
4620 \global\c@pgf@counta=\tikznumberofcurrentchild\relax%
4621 \global\setbox\tikz@tempbox=\box\tikz@figbox%
4622 \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
4623 }%
4624 \tikznumberofcurrentchild=\c@pgf@counta\relax%
4625 \setbox\tikz@figbox=\box\tikz@tempbox%
4626 \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
4627 }%
4628
4629
4630 % Syntax for child:
4631 %
4632 % child
4633 %
4634 % child[options]
4635 %
4636 % child[options] {node (name) {child node text} ...
4637 % edge from parent[options] node {label text} node {label text}}
4638
4639 \def\tikz@childnode[#1]#2{%
4640 \advance\tikznumberofcurrentchild by1\relax%
4641 {\tikzset{every child/.try,#1}\expandafter}%
4642 \iftikz@child@missing%
4643 \tikzgdeventcallback{node}{}%
4644 \else%
4645 \setbox\tikz@whichbox=\hbox\bgroup%
4646 \unhbox\tikz@whichbox%
4647 \hbox\bgroup\bgroup%
4648 \pgfinterruptpath%
4649 \pgfscope%
4650 \let\tikz@transform=\pgfutil@empty%
4651 \tikzset{every child/.try,#1}%
4652 \tikz@options%
4653 \tikz@transform%
4654 \let\tikz@transform=\relax%
4655 \tikz@grow%
4656 % Typeset node:
4657 \edef\tikz@parent@node@name{[name=\tikzparentnode-\the\tikznumberofcurrentchild,style=every child node]}%
4658 \def\tikz@child@node@text{[shape=coordinate]{}}
4659 \tikz@parse@child@node#2\pgf@stop%
4660 \expandafter\expandafter\expandafter\node
4661 \expandafter\tikz@parent@node@name
4662 \tikz@child@node@text
4663 \pgfextra{\global\let\tikz@childnode@name=\tikz@last@fig@name};%
4664 \let\tikzchildnode=\tikz@childnode@name%
4665 {%
4666 \def\tikz@edge@to@parent@needed{edge from parent}
4667 \ifx\tikz@child@node@rest\pgfutil@empty%
4668 \path edge from parent;%
4669 \else%
4670 \path \tikz@child@node@rest \tikz@edge@to@parent@needed;%
4671 \fi%
4672 }%
4673 \endpgfscope%
4674 \endpgfinterruptpath%
4675 \egroup\egroup%
4676 \egroup%
4677 \fi%
4678 }%
4679
4680 \def\tikz@parse@child@node{%
4681 \pgfutil@ifnextchar n{\tikz@parse@child@node@n}%
4682 {\pgfutil@ifnextchar c{\tikz@parse@child@node@c}%
4683 {\pgfutil@ifnextchar\pgf@stop\tikz@parse@child@node@rest\tikz@parse@child@node@expand}}}%
4684 \def\tikz@parse@child@node@expand{%
4685 \advance\tikz@expandcount by-1\relax%
4686 \ifnum\tikz@expandcount<0\relax%
4687 \expandafter\tikz@parse@child@node@rest%
4688 \else%
4689 \expandafter\expandafter\expandafter\tikz@parse@child@node%
4690 \fi%
4691 }%
4692 \def\tikz@parse@child@node@rest#1\pgf@stop{\tikz@resetexpandcount\def\tikz@child@node@rest{#1}}%
4693 \def\tikz@parse@child@node@c c{\tikz@resetexpandcount\pgfutil@ifnextchar o{\tikz@parse@child@node@co}{\tikz@parse@child@node@rest c}}%
4694 \def\tikz@parse@child@node@co o{\pgfutil@ifnextchar o{\tikz@parse@child@node@coordinate}{\tikz@parse@child@node@rest co}}%
4695 \def\tikz@parse@child@node@coordinate ordinate{%
4696 \pgfutil@ifnextchar ({\tikz@@parse@child@node@coordinate}{%
4697 \def\tikz@child@node@text{[shape=coordinate]{}}%
4698 \tikz@parse@child@node@rest}}%}%
4699 \def\tikz@@parse@child@node@coordinate(#1){%
4700 \pgfutil@ifnextchar a{\tikz@p@c@n@c@at(#1)}{%
4701 \def\tikz@child@node@text{[shape=coordinate,name=#1]{}}%
4702 \tikz@parse@child@node@rest}}%
4703 \def\tikz@p@c@n@c@at(#1)at#2({%
4704 \def\tikz@child@node@text@pre{[shape=coordinate,name=#1]at}%
4705 \tikz@scan@one@point\tikz@p@c@n@c@at@math(%
4706 }%
4707 \def\tikz@p@c@n@c@at@math#1{%
4708 \pgf@process{#1}%
4709 \edef\tikz@marshal{(\the\pgf@x,\the\pgf@y){}}%
4710 \expandafter\expandafter\expandafter\def%
4711 \expandafter\expandafter\expandafter\tikz@child@node@text%
4712 \expandafter\expandafter\expandafter{\expandafter\tikz@child@node@text@pre\tikz@marshal}%
4713 \tikz@parse@child@node@rest%
4714 }%
4715 \def\tikz@parse@child@node@n node{\tikz@resetexpandcount%
4716 \let\tikz@child@node@text=\pgfutil@empty%
4717 \tikz@p@c@s}%
4718 \def\tikz@p@c@s{%
4719 \pgfutil@ifnextchar a{\tikz@p@c@s@at}
4720 {\pgfutil@ifnextchar ({\tikz@p@c@s@paran}
4721 {\pgfutil@ifnextchar [{\tikz@p@c@s@bra}
4722 {\pgfutil@ifnextchar \bgroup{\tikz@p@c@s@group}
4723 {\tikzerror{Cannot parse this node}}}}}}%}}%
4724 \def\tikz@p@c@s@at at#1({%
4725 \tikz@scan@one@point\tikz@p@c@s@at@math(%
4726 }%
4727 \def\tikz@p@c@s@at@math#1{%
4728 \pgf@process{#1}%
4729 \edef\tikz@marshal{ at(\the\pgf@x,\the\pgf@y)}%
4730 \expandafter\expandafter\expandafter\def%
4731 \expandafter\expandafter\expandafter\tikz@child@node@text%
4732 \expandafter\expandafter\expandafter{\expandafter\tikz@child@node@text\tikz@marshal}
4733 \tikz@p@c@s}%
4734 \def\tikz@p@c@s@paran(#1){%
4735 \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text(#1)}
4736 \tikz@p@c@s}%
4737 \def\tikz@p@c@s@bra[#1]{%
4738 \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text[#1]}
4739 \tikz@p@c@s}%
4740 \def\tikz@p@c@s@group#1{%
4741 \iftikz@handle@active@nodes%
4742 \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text{\scantokens{#1}}}%
4743 \else%
4744 \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text{#1}}
4745 \fi%
4746 \tikz@parse@child@node@rest%
4747 }%
4748
4749
4750
4751 %
4752 % Syntax for decorated subpaths:
4753 %
4754 % decorate [option] { subpath }
4755 %
4756 \def\tikz@decoration ecorate{%
4757 \pgfutil@ifnextchar[{\tikz@lib@decoration}{\tikz@lib@decoration[]}%]
4758 }%
4759
4760 \def\tikz@lib@decoration[#1]#2{\tikzerror{You need to load a decoration library}}%
4761
4762 % The decorate path command:
4763 \def\tikz@lib@dec@decorate@path{\tikzerror{You need to load a decoration library}}%
4764
4765
4766
4767 %
4768 % Syntax for let :
4769 %
4770 % let \p1 = (coordinate), \p2 = (coordinate),... in
4771 %
4772 \def\tikz@let@command et#1in{%
4773 \tikzerror{You need to say \string\usetikzlibrary{calc} to use the let command}%
4774 \tikz@scan@next@command%
4775 }%
4776
4777
4778 %
4779 % Syntax for pictures:
4780 %
4781 % as for nodes, but with "pic" instead of "node"
4782 %
4783 \newif\iftikz@node@is@pic
4784 \def\tikz@subpicture ic{\tikz@node@is@pictrue\tikz@scan@next@command node}%
4785 \def\tikz@subpicture@handle#1{%
4786 \pgfkeys@spdef\tikz@temp{#1}%
4787 \expandafter\tikz@subpicture@handle@\expandafter{\tikz@temp}%
4788 }%
4789 \def\tikz@subpicture@handle@#1{
4790 \pgfkeys{/tikz/pics/.cd,#1}%
4791 \tikz@node@transformations%
4792 \let\tikz@transform=\relax%
4793 \let\tikz@picmode\tikz@mode%
4794 \tikzset{name prefix ../.style/.expanded={/tikz/name prefix=\pgfkeysvalueof{/tikz/name prefix}}}%
4795 \ifx\tikz@fig@name\pgfutil@empty\else%
4796 \tikzset{name prefix/.expanded=\tikz@fig@name}%
4797 \fi%
4798 \pgfkeysvalueof{/tikz/pics/setup code}%
4799 \pgfkeysgetvalue{/tikz/pics/code}{\tikz@pic@code}
4800 \ifx\tikz@pic@code\pgfutil@empty\else%
4801 \setbox\tikz@whichbox=\hbox\bgroup%
4802 \unhbox\tikz@whichbox%
4803 \hbox\bgroup
4804 \bgroup%
4805 \pgfinterruptpath%
4806 \pgfscope%
4807 \tikz@options%
4808 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
4809 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
4810 \tikz@atbegin@scope%
4811 \scope[every pic/.try]%
4812 \tikz@pic@code%
4813 \endscope%
4814 \tikz@atend@scope%
4815 \endpgfscope%
4816 \endpgfinterruptpath%
4817 \egroup
4818 \egroup%
4819 \egroup%
4820 \fi%
4821 \pgfkeysgetvalue{/tikz/pics/foreground code}{\tikz@pic@code}
4822 \ifx\tikz@pic@code\pgfutil@empty\else%
4823 \setbox\tikz@figbox=\hbox\bgroup%
4824 \unhbox\tikz@figbox%
4825 \hbox\bgroup
4826 \bgroup%
4827 \pgfinterruptpath%
4828 \pgfscope%
4829 \tikz@options%
4830 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
4831 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
4832 \tikz@atbegin@scope%
4833 \scope[every front pic/.try]%
4834 \tikz@pic@code%
4835 \endscope%
4836 \tikz@atend@scope%
4837 \endpgfscope%
4838 \endpgfinterruptpath%
4839 \egroup
4840 \egroup%
4841 \egroup%
4842 \fi%
4843 \pgfkeysgetvalue{/tikz/pics/background code}{\tikz@pic@code}
4844 \ifx\tikz@pic@code\pgfutil@empty\else%
4845 \setbox\tikz@figbox@bg=\hbox\bgroup%
4846 \unhbox\tikz@figbox@bg%
4847 \hbox\bgroup
4848 \bgroup%
4849 \pgfinterruptpath%
4850 \pgfscope%
4851 \tikz@options%
4852 \setbox\tikz@figbox=\box\pgfutil@voidb@x%
4853 \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x%
4854 \tikz@atbegin@scope%
4855 \scope[every behind pic/.try]%
4856 \tikz@pic@code%
4857 \endscope%
4858 \tikz@atend@scope%
4859 \endpgfscope%
4860 \endpgfinterruptpath%
4861 \egroup
4862 \egroup%
4863 \egroup%
4864 \fi%
4865 \tikz@node@finish%
4866 }%
4867 \tikzset{
4868 pic actions/.code=\tikz@addmode{\tikz@picmode}
4869 }%
4870
4871 % Setting up the picture codes:
4872 \tikzset{
4873 pics/setup code/.initial=,
4874 pics/code/.initial=,
4875 pics/background code/.initial=,
4876 pics/foreground code/.initial=
4877 }%
4878
4879 % Defining pictures:
4880
4881 \def\tikzdeclarepic#1#2{\pgfkeys{/tikz/#1/.cd,#2}}%
4882
4883 \pgfkeysdef{/handlers/.pic}{%
4884 \edef\pgf@temp{\pgfkeyscurrentpath}%
4885 \edef\pgf@temp{\expandafter\tikz@smuggle@pics@in\pgf@temp\pgf@stop}%
4886 \expandafter\pgfkeys\expandafter{\pgf@temp/.style={code={#1}}}%
4887 }%
4888 \def\tikz@smuggle@pics@in/tikz/#1\pgf@stop{/tikz/pics/#1}%
4889
4890 %
4891 % Timers
4892 %
4893
4894 \def\tikz@timer@line{%
4895 \pgftransformlineattime{\tikz@time}{\tikz@timer@start}{\tikz@timer@end}%
4896 }%
4897
4898 \def\tikz@timer@vhline{%
4899 \ifdim\tikz@time pt<0.5pt% first half
4900 \pgf@process{\tikz@timer@start}%
4901 \pgf@xa=\pgf@x%
4902 \pgf@ya=\pgf@y%
4903 \pgf@process{\tikz@timer@end}%
4904 \pgf@xb=\tikz@time pt%
4905 \pgf@xb=2\pgf@xb%
4906 \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}{\noexpand\tikz@timer@start}{%
4907 \noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@y}}}%
4908 \tikz@marshal%
4909 \else% second half
4910 \pgf@process{\tikz@timer@start}%
4911 \pgf@xa=\pgf@x%
4912 \pgf@ya=\pgf@y%
4913 \pgf@process{\tikz@timer@end}%
4914 \pgf@xb=\tikz@time pt%
4915 \pgf@xb=2\pgf@xb%
4916 \advance\pgf@xb by-1pt%
4917 \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}%
4918 {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@y}}{\noexpand\tikz@timer@end}}%
4919 \tikz@marshal%
4920 \fi%
4921 }%
4922
4923 \def\tikz@timer@hvline{%
4924 \ifdim\tikz@time pt<0.5pt% first half
4925 \pgf@process{\tikz@timer@start}%
4926 \pgf@xa=\pgf@x%
4927 \pgf@ya=\pgf@y%
4928 \pgf@process{\tikz@timer@end}%
4929 \pgf@xb=\tikz@time pt%
4930 \pgf@xb=2\pgf@xb%
4931 \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}{\noexpand\tikz@timer@start}{%
4932 \noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@ya}}}%
4933 \tikz@marshal%
4934 \else% second half
4935 \pgf@process{\tikz@timer@start}%
4936 \pgf@xa=\pgf@x%
4937 \pgf@ya=\pgf@y%
4938 \pgf@process{\tikz@timer@end}%
4939 \pgf@xb=\tikz@time pt%
4940 \pgf@xb=2\pgf@xb%
4941 \advance\pgf@xb by-1pt%
4942 \edef\tikz@marshal{\noexpand\pgftransformlineattime{\pgf@sys@tonumber{\pgf@xb}}%
4943 {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@ya}}{\noexpand\tikz@timer@end}}%
4944 \tikz@marshal%
4945 \fi%
4946 }%
4947
4948 \def\tikz@timer@curve{%
4949 \pgftransformcurveattime{\tikz@time}{\tikz@timer@start}{\tikz@timer@cont@one}{\tikz@timer@cont@two}{\tikz@timer@end}%
4950 }%
4951
4952
4953 \def\tikz@timer@arc{%
4954 \pgfmathcos@{\tikz@timer@start@angle}%
4955 \let\tikz@angle@cos\pgfmathresult%
4956 \pgfmathsin@{\tikz@timer@start@angle}%
4957 \let\tikz@angle@sin\pgfmathresult%
4958 \pgftransformarcaxesattime{\tikz@time}{%
4959 \pgfpointdiff{%
4960 \pgfpointadd{%
4961 \pgfpointscale{\tikz@angle@cos}{\tikz@timer@zero@axis}%
4962 }{%
4963 \pgfpointscale{\tikz@angle@sin}{\tikz@timer@ninety@axis}%
4964 }%
4965 }%
4966 {\tikz@timer@start}%
4967 }%
4968 {\tikz@timer@zero@axis}%
4969 {\tikz@timer@ninety@axis}%
4970 {\tikz@timer@start@angle}{\tikz@timer@end@angle}%
4971 }%
4972
4973
4974
4975 %
4976 % Coordinate systems
4977 %
4978
4979 \def\tikzdeclarecoordinatesystem#1#2{%
4980 \expandafter\def\csname tikz@parse@cs@#1\endcsname(##1){%
4981 \pgf@process{%
4982 #2%
4983 \global\let\tikz@smubble@b=\tikz@shapeborder@name%
4984 }%
4985 \let\tikz@shapeborder@name=\tikz@smubble@b%
4986 \edef\tikz@return@coordinate{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
4987 }%
4988 \def\tikzaliascoordinatesystem#1#2{%
4989 \edef\pgf@marshal{\noexpand\let\expandafter\noexpand\csname
4990 tikz@parse@cs@#1\endcsname=\expandafter\noexpand\csname
4991 tikz@parse@cs@#2\endcsname}%
4992 \pgf@marshal%
4993 }%
4994
4995
4996 % Default coordinate systems:
4997
4998 \tikzdeclarecoordinatesystem{canvas}
4999 {%
5000 \tikzset{cs/.cd,x=0pt,y=0pt,#1}%
5001 \pgfpoint{\tikz@cs@x}{\tikz@cs@y}%
5002 }%
5003
5004 \tikzdeclarecoordinatesystem{canvas polar}
5005 {%
5006 \tikzset{cs/.cd,angle=0,radius=0cm,#1}%
5007 \pgfpointpolar{\tikz@cs@angle}{\tikz@cs@xradius and \tikz@cs@yradius}%
5008 }%
5009
5010 \tikzdeclarecoordinatesystem{xyz}
5011 {%
5012 \tikzset{cs/.cd,x=0,y=0,z=0,#1}%
5013 \pgfpointxyz{\tikz@cs@x}{\tikz@cs@y}{\tikz@cs@z}%
5014 }%
5015
5016 \tikzdeclarecoordinatesystem{xyz polar}
5017 {%
5018 \tikzset{cs/.cd,angle=0,radius=0,#1}%
5019 \pgfpointpolarxy{\tikz@cs@angle}{\tikz@cs@xradius and \tikz@cs@yradius}%
5020 }%
5021 \tikzaliascoordinatesystem{xy polar}{xyz polar}%
5022
5023
5024 \tikzdeclarecoordinatesystem{node}
5025 {%
5026 \tikzset{cs/.cd,name=,anchor=none,angle=none,#1}%
5027 \ifx\tikz@cs@anchor\tikz@nonetext%
5028 \ifx\tikz@cs@angle\tikz@nonetext%
5029 \expandafter\ifx\csname pgf@sh@ns@\tikz@cs@node\endcsname\tikz@coordinate@text%
5030 \else
5031 \aftergroup\tikz@shapebordertrue%
5032 \edef\tikz@shapeborder@name{\tikz@pp@name{\tikz@cs@node}}%
5033 \fi%
5034 \pgfpointanchor{\tikz@pp@name{\tikz@cs@node}}{center}%
5035 \else%
5036 \pgfpointanchor{\tikz@pp@name{\tikz@cs@node}}{\tikz@cs@angle}%
5037 \fi%
5038 \else%
5039 \pgfpointanchor{\tikz@pp@name{\tikz@cs@node}}{\tikz@cs@anchor}%
5040 \fi%
5041 }%
5042
5043 % Intersection coordinates
5044 \tikzset{cs/first line/.code=\def\tikz@cs@line@a{#1}\def\tikz@cs@type@a{line}}%
5045 \tikzset{cs/second line/.code=\def\tikz@cs@line@b{#1}\def\tikz@cs@type@b{line}}%
5046
5047 \tikzset{cs/first node/.code=\tikz@cs@unpack{\tikz@cs@node@a}{\tikz@cs@type@a}{#1}}%
5048 \tikzset{cs/second node/.code=\tikz@cs@unpack{\tikz@cs@node@b}{\tikz@cs@type@b}{#1}}%
5049
5050 \def\tikz@cs@unpack#1#2#3{%
5051 \expandafter\ifx\csname pgf@sh@ns@#3\endcsname\relax%
5052 \tikzerror{Undefined node ``#3''}%
5053 \else%
5054 \def#1{#3}%
5055 \edef#2{\csname pgf@sh@ns@#3\endcsname}%
5056 \fi%
5057 }%
5058
5059 \tikzset{cs/solution/.initial=1}%
5060
5061 \tikzset{cs/horizontal line through/.store in=\tikz@cs@hori@line}%
5062 \tikzset{cs/vertical line through/.store in=\tikz@cs@vert@line}%
5063
5064 \tikzdeclarecoordinatesystem{intersection}
5065 {%
5066 \tikzset{cs/.cd,#1}%
5067 \expandafter\ifx\csname tikz@intersect@\tikz@cs@type@a @and@\tikz@cs@type@b\endcsname\relax%
5068 \tikzerror{I do not know how to compute the intersection
5069 of a \tikz@cs@type@a and a \tikz@cs@type@b. Try saying
5070 \string\usetikzlibrary{calc}}%
5071 \pgfpointorigin%
5072 \else%
5073 \csname tikz@intersect@\tikz@cs@type@a @and@\tikz@cs@type@b\endcsname%
5074 \fi%
5075 }%
5076
5077 \def\tikz@intersect@line@and@line{%
5078 \expandafter\tikz@scan@one@point\expandafter\tikz@parse@line\tikz@cs@line@a%
5079 \pgf@xa=\pgf@xc%
5080 \pgf@ya=\pgf@yc%
5081 \pgf@xb=\pgf@x%
5082 \pgf@yb=\pgf@y%
5083 \expandafter\tikz@scan@one@point\expandafter\tikz@parse@line\tikz@cs@line@b%
5084 \edef\pgf@marshal{%
5085 {\noexpand\pgfpointintersectionoflines%
5086 {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
5087 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
5088 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
5089 {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}}%
5090 \pgf@marshal%
5091 }%
5092
5093 \def\tikz@parse@line#1--{%
5094 \pgf@process{#1}%
5095 \pgf@xc=\pgf@x%
5096 \pgf@yc=\pgf@y%
5097 \tikz@scan@one@point\pgf@process%
5098 }%
5099
5100
5101 \tikzdeclarecoordinatesystem{perpendicular}
5102 {%
5103 \tikzset{cs/.cd,#1}%
5104 \expandafter\tikz@scan@one@point\expandafter\tikz@parse@intersection@a\tikz@cs@hori@line%
5105 \expandafter\tikz@scan@one@point\expandafter\tikz@parse@intersection@b\tikz@cs@vert@line%
5106 \pgfqpoint{\the\pgf@xb}{\the\pgf@ya}
5107 }%
5108
5109 \tikzdeclarecoordinatesystem{barycentric}
5110 {%
5111 {%
5112 \pgf@xa=0pt% point
5113 \pgf@ya=0pt%
5114 \pgf@xb=0pt% sum
5115 \tikz@bary@dolist#1,=,%
5116 \pgfmathparse{1/\the\pgf@xb}%
5117 \global\pgf@x=\pgfmathresult\pgf@xa%
5118 \global\pgf@y=\pgfmathresult\pgf@ya%
5119 }%
5120 }%
5121
5122 \def\tikz@bary@dolist#1=#2,{%
5123 \def\tikz@temp{#1}%
5124 \ifx\tikz@temp\pgfutil@empty%
5125 \else
5126 \pgf@process{\pgfpointanchor{#1}{center}}%
5127 \pgfmathparse{#2}%
5128 \advance\pgf@xa by\pgfmathresult\pgf@x%
5129 \advance\pgf@ya by\pgfmathresult\pgf@y%
5130 \advance\pgf@xb by\pgfmathresult pt%
5131 \expandafter\tikz@bary@dolist%
5132 \fi%
5133 }%
5134
5135 \tikzset{cs/x/.store in=\tikz@cs@x}%
5136 \tikzset{cs/y/.store in=\tikz@cs@y}%
5137 \tikzset{cs/z/.store in=\tikz@cs@z}%
5138 \tikzset{cs/angle/.store in=\tikz@cs@angle}%
5139 \tikzset{cs/x radius/.store in=\tikz@cs@xradius}%
5140 \tikzset{cs/y radius/.store in=\tikz@cs@yradius}%
5141 \tikzset{cs/radius/.style={/tikz/cs/x radius={#1},/tikz/cs/y radius={#1}}}%
5142 \tikzset{cs/name/.store in=\tikz@cs@node}%
5143 \tikzset{cs/anchor/.store in=\tikz@cs@anchor}%
5144
5145
5146
5147 %
5148 % Coordinate management
5149 %
5150
5151
5152 % Last position visited
5153 \def\tikz@last@position{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
5154 \def\tikz@last@position@saved{\pgfqpoint{\tikz@lastxsaved}{\tikz@lastysaved}}%
5155
5156 % Make given point the last position visited
5157 \def\tikz@make@last@position#1{%
5158 \pgf@process{#1}%
5159 \tikz@lastx=\pgf@x\relax%
5160 \tikz@lasty=\pgf@y\relax%
5161 \iftikz@updatecurrent%
5162 \tikz@lastxsaved=\pgf@x\relax%
5163 \tikz@lastysaved=\pgf@y\relax%
5164 \fi%
5165 \iftikz@updatenext
5166 \tikz@updatecurrenttrue%
5167 \fi
5168 }%
5169
5170 \newif\iftikz@updatecurrent
5171 \tikz@updatecurrenttrue
5172 \newif\iftikz@updatenext
5173 \tikz@updatenexttrue
5174
5175
5176
5177 % Scanner: Scans a point or a relative point.
5178 % It then calls the first parameter with the argument set to an
5179 % appropriate pgf command representing that point.
5180
5181 \def\tikz@scan@one@point#1{%
5182 \let\tikz@to@use@whom=\tikz@to@use@last@coordinate%
5183 \tikz@shapeborderfalse%
5184 \pgfutil@ifnextchar+{\tikz@scan@relative#1}{\tikz@scan@absolute#1}}%
5185 \def\tikz@scan@absolute#1{%
5186 \pgfutil@ifnextchar({\tikz@scan@@absolute#1}%)
5187 {%
5188 \advance\tikz@expandcount by -1
5189 \ifnum\tikz@expandcount<0\relax%
5190 \let\pgfutil@next=\tikz@@scangiveup%
5191 \else%
5192 \let\pgfutil@next=\tikz@@scanexpand%
5193 \fi%
5194 \pgfutil@next{#1}%
5195 }%
5196 }%
5197 \def\tikz@@scanexpand#1{\expandafter\tikz@scan@one@point\expandafter#1}%
5198 \def\tikz@@scangiveup#1{\tikzerror{Cannot parse this coordinate}#1{\pgfpointorigin}}%
5199 \def\tikz@scan@@absolute#1({%
5200 \pgfutil@ifnextchar[% uhoh... options!
5201 {\def\tikz@scan@point@recall{#1}\tikz@scan@options}%
5202 {\tikz@@@scan@@absolute#1(}%
5203 }%
5204
5205 \def\tikz@scan@options[#1]#2{%
5206 \def\tikz@scan@point@options{#1}%
5207 \tikz@@@scan@@absolute\tikz@scan@handle@options(#2%
5208 }%
5209
5210 \def\tikz@scan@handle@options#1{%
5211 {%
5212 % Ok, compute point with options set and zero transformation
5213 % matrix:
5214 \pgftransformreset%
5215 \let\tikz@transform=\pgfutil@empty%
5216 \expandafter\tikzset\expandafter{\tikz@scan@point@options}%
5217 \tikz@transform%
5218 \pgf@process{\pgfpointtransformed{#1}}%
5219 \xdef\tikz@marshal{\expandafter\noexpand\tikz@scan@point@recall{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
5220 }%
5221 \tikz@marshal%
5222 }%
5223
5224 \def\tikz@@@scan@@absolute#1({%
5225 \pgfutil@ifnextchar{$}%$
5226 {\tikz@parse@calculator#1(}
5227 {\tikz@scan@no@calculator#1(}%
5228 }%
5229 \def\tikz@scan@no@calculator#1(#2){%
5230 \edef\tikz@scan@point@coordinate{(#2)}%
5231 \expandafter\tikz@@scan@@no@calculator\expandafter#1\tikz@scan@point@coordinate%
5232 }%
5233 \def\tikz@@scan@@no@calculator#1(#2){%
5234 \pgfutil@in@{cs:}{#2}%
5235 \ifpgfutil@in@%
5236 \let\pgfutil@next\tikz@parse@coordinatesystem%
5237 \else%
5238 \pgfutil@in@{intersection }{#2}%
5239 \ifpgfutil@in@%
5240 \let\pgfutil@next\tikz@parse@intersection%
5241 \else%
5242 \pgfutil@in@|{#2}%
5243 \ifpgfutil@in@
5244 \pgfutil@in@{-|}{#2}%
5245 \ifpgfutil@in@
5246 \let\pgfutil@next\tikz@parse@hv%
5247 \else%
5248 \let\pgfutil@next\tikz@parse@vh%
5249 \fi%
5250 \else%
5251 \pgfutil@in@:{#2}%
5252 \ifpgfutil@in@
5253 \let\pgfutil@next\tikz@parse@polar%
5254 \else%
5255 \pgfutil@in@,{#2}%
5256 \ifpgfutil@in@%
5257 \let\pgfutil@next\tikz@parse@regular%
5258 \else%
5259 \let\pgfutil@next\tikz@parse@node%
5260 \fi%
5261 \fi%
5262 \fi%
5263 \fi%
5264 \fi%
5265 \pgfutil@next#1(#2)%
5266 }%
5267
5268 \def\tikz@parse@calculator#1($#2$){%
5269 \tikzerror{You need to say \string\usetikzlibrary{calc} for coordinate calculation}%
5270 #1{\pgfpointorigin}%
5271 }%
5272
5273 \def\tikz@parse@coordinatesystem#1(#2 cs:#3){%
5274 \let\tikz@return@coordinate=\pgfpointorigin%
5275 \pgfutil@ifundefined{tikz@parse@cs@#2}
5276 {\tikzerror{Unknown coordinate system '#2'}}
5277 {\csname tikz@parse@cs@#2\endcsname(#3)}%
5278 \expandafter#1\expandafter{\tikz@return@coordinate}%
5279 }%
5280
5281
5282 \newif\iftikz@isdimension
5283 \def\tikz@checkunit#1{%
5284 \pgfmathparse{#1}%
5285 \let\iftikz@isdimension=\ifpgfmathunitsdeclared%
5286 }%
5287
5288 \def\tikz@parse@polar#1(#2:#3){%
5289 \pgfutil@ifundefined{tikz@polar@dir@#2}
5290 {\tikz@@parse@polar#1({#2}:{#3})}
5291 {\tikz@@parse@polar#1(\csname tikz@polar@dir@#2\endcsname:{#3})}%
5292 }%
5293 \def\tikz@@parse@polar#1(#2:#3){%
5294 \pgfutil@in@{ and }{#3}%
5295 \ifpgfutil@in@%
5296 \edef\tikz@args{({#2}:#3)}%
5297 \else%
5298 \edef\tikz@args{({#2}:{#3} and {#3})}%
5299 \fi%
5300 \expandafter\tikz@@@parse@polar\expandafter#1\tikz@args%
5301 }%
5302 \def\tikz@@@parse@polar#1(#2:#3 and #4){%
5303 \tikz@checkunit{#3}%
5304 \iftikz@isdimension%
5305 \tikz@checkunit{#4}%
5306 \iftikz@isdimension%
5307 \def\tikz@next{#1{\pgfpointpolar{#2}{#3 and #4}}}%
5308 \else%
5309 \tikzerror{You cannot mix dimension and dimensionless values for polar coordinates}
5310 \def\tikz@next{#1{\pgfpointorigin}}%
5311 \fi%
5312 \else%
5313 \tikz@checkunit{#4}%
5314 \iftikz@isdimension%
5315 \tikzerror{You cannot mix dimension and dimensionless values for polar coordinates}
5316 \def\tikz@next{#1{\pgfpointorigin}}%
5317 \else%
5318 \def\tikz@next{#1{\pgfpointpolarxy{#2}{#3 and #4}}}%
5319 \fi%
5320 \fi%
5321 \tikz@next%
5322 }%
5323 \def\tikz@polar@dir@up{90}%
5324 \def\tikz@polar@dir@down{-90}%
5325 \def\tikz@polar@dir@left{180}%
5326 \def\tikz@polar@dir@right{0}%
5327 \def\tikz@polar@dir@north{90}%
5328 \def\tikz@polar@dir@south{-90}%
5329 \def\tikz@polar@dir@east{0}%
5330 \def\tikz@polar@dir@west{180}%
5331 \expandafter\def\csname tikz@polar@dir@north east\endcsname{45}%
5332 \expandafter\def\csname tikz@polar@dir@north west\endcsname{135}%
5333 \expandafter\def\csname tikz@polar@dir@south east\endcsname{-45}%
5334 \expandafter\def\csname tikz@polar@dir@south west\endcsname{-135}%
5335
5336
5337 % MW:
5338 % Check to see if the y-coordinate is inside {}. If it is, scan it and
5339 % reinsert it into the stream inside an extra group.
5340 %
5341 \def\tikz@parse@regular#1(#2,{%
5342 \pgfutil@ifnextchar\bgroup{\tikz@@parse@regular#1{#2}}{\tikz@@@parse@regular#1{#2}}%
5343 }%
5344 \def\tikz@@parse@regular#1#2#3{%
5345 \pgfutil@ifnextchar[{% Uh oh! An array index.
5346 \tikz@@@parse@regular#1{#2}{#3}}%
5347 {\tikz@@@parse@regular#1{#2}{{#3}}}}%
5348
5349 % Originally \def\tikz@parse@regular#1(#2,#3){%
5350 %
5351 \def\tikz@@@parse@regular#1#2#3){%
5352 \pgfutil@in@,{#3}%
5353 \ifpgfutil@in@%
5354 \tikz@parse@splitxyz{#1}{#2}#3,%
5355 \else%
5356 \tikz@checkunit{#2}%
5357 \iftikz@isdimension%
5358 \tikz@checkunit{#3}%
5359 \iftikz@isdimension%
5360 \def\pgfutil@next{#1{\pgfpoint{#2}{#3}}}%
5361 \else%
5362 \def\pgfutil@next{#1{\pgfpointadd{\pgfpoint{#2}{0pt}}{\pgfpointxy{0}{#3}}}}%
5363 \fi%
5364 \else%
5365 \tikz@checkunit{#3}%
5366 \iftikz@isdimension%
5367 \def\pgfutil@next{#1{\pgfpointadd{\pgfpoint{0pt}{#3}}{\pgfpointxy{#2}{0}}}}%
5368 \else%
5369 \def\pgfutil@next{#1{\pgfpointxy{#2}{#3}}}%
5370 \fi%
5371 \fi%
5372 \fi%
5373 \pgfutil@next%
5374 }%
5375
5376 \def\tikz@parse@splitxyz#1#2#3,#4,{%
5377 \def\pgfutil@next{#1{\pgfpointxyz{#2}{#3}{#4}}}%
5378 }%
5379
5380 \def\tikz@coordinate@text{coordinate}%
5381
5382 \def\tikz@parse@node#1(#2){%
5383 \pgfutil@in@.{#2}% Ok, flag this
5384 \ifpgfutil@in@
5385 \tikz@calc@anchor#2\tikz@stop%
5386 \else%
5387 \tikz@calc@anchor#2.center\tikz@stop% to be on the save side, in
5388 % case iftikz@shapeborder is ignored...
5389 \ifcsname pgf@sh@ns@\tikz@pp@name{#2}\endcsname
5390 \expandafter\ifx\csname pgf@sh@ns@\tikz@pp@name{#2}\endcsname\tikz@coordinate@text%
5391 \else
5392 \tikz@shapebordertrue%
5393 \def\tikz@shapeborder@name{\tikz@pp@name{#2}}%
5394 \fi%
5395 \else\ifcsname pgf@sh@ns@#2\endcsname
5396 \expandafter\ifx\csname pgf@sh@ns@#2\endcsname\tikz@coordinate@text%
5397 \else
5398 \tikz@shapebordertrue%
5399 \def\tikz@shapeborder@name{#2}%
5400 \fi%
5401 \fi\fi
5402 \fi%
5403 \edef\tikz@marshal{\noexpand#1{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
5404 \tikz@marshal%
5405 }%
5406
5407 \def\tikz@calc@anchor#1.#2\tikz@stop{%
5408 % Check if a shape with name prefix exists, otherwise try the global name
5409 % without prefix.
5410 \ifcsname pgf@sh@ns@\tikz@pp@name{#1}\endcsname%
5411 \pgfpointanchor{\tikz@pp@name{#1}}{#2}%
5412 \else
5413 \pgfpointanchor{#1}{#2}%
5414 \fi
5415 }%
5416
5417
5418 \def\tikz@parse@hv#1(#2){%
5419 \pgfutil@in@{ -| }{#2}%
5420 \ifpgfutil@in@%
5421 \let\tikz@next=\tikz@parse@hvboth%
5422 \else%
5423 \pgfutil@in@{ -|}{#2}%
5424 \ifpgfutil@in@%
5425 \let\tikz@next=\tikz@parse@hvleft%
5426 \else%
5427 \pgfutil@in@{-| }{#2}%
5428 \ifpgfutil@in@%
5429 \let\tikz@next=\tikz@parse@hvright%
5430 \else%
5431 \let\tikz@next=\tikz@parse@hvdone%
5432 \fi%
5433 \fi%
5434 \fi%
5435 \tikz@next#1(#2)}%
5436 \def\tikz@parse@hvboth#1(#2 -| #3){\tikz@parse@vhdone#1({#3}|-{#2})}%
5437 \def\tikz@parse@hvleft#1(#2 -|#3){\tikz@parse@vhdone#1({#3}|-{#2})}%
5438 \def\tikz@parse@hvright#1(#2-| #3){\tikz@parse@vhdone#1({#3}|-{#2})}%
5439 \def\tikz@parse@hvdone#1(#2-|#3){\tikz@parse@vhdone#1({#3}|-{#2})}%
5440
5441 \def\tikz@parse@vh#1(#2){%
5442 \pgfutil@in@{ |- }{#2}%
5443 \ifpgfutil@in@%
5444 \let\tikz@next=\tikz@parse@vhboth%
5445 \else%
5446 \pgfutil@in@{ |-}{#2}%
5447 \ifpgfutil@in@%
5448 \let\tikz@next=\tikz@parse@vhleft%
5449 \else%
5450 \pgfutil@in@{|- }{#2}%
5451 \ifpgfutil@in@%
5452 \let\tikz@next=\tikz@parse@vhright%
5453 \else%
5454 \let\tikz@next=\tikz@parse@vhdone%
5455 \fi%
5456 \fi%
5457 \fi%
5458 \tikz@next#1(#2)}%
5459 \def\tikz@parse@vhboth#1(#2 |- #3){\tikz@parse@vhdone#1({#2}|-{#3})}%
5460 \def\tikz@parse@vhleft#1(#2 |-#3){\tikz@parse@vhdone#1({#2}|-{#3})}%
5461 \def\tikz@parse@vhright#1(#2|- #3){\tikz@parse@vhdone#1({#2}|-{#3})}%
5462 \def\tikz@parse@vhdone#1(#2|-#3){%
5463 {%
5464 \tikz@@@scan@@absolute\tikz@parse@vh@mid(#2)%
5465 \tikz@@@scan@@absolute\tikz@parse@vh@end(#3)%
5466 \xdef\tikz@marshal{\noexpand#1{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}}%
5467 }%
5468 \tikz@marshal%
5469 }%
5470 \def\tikz@parse@vh@mid#1{\pgf@process{#1}\pgf@xa=\pgf@x}%
5471 \def\tikz@parse@vh@end#1{\pgf@process{#1}\pgf@ya=\pgf@y}%
5472
5473 \def\tikz@parse@intersection#1(intersection{%
5474 \pgfutil@ifnextchar o{%
5475 \tikz@parse@main@intersection#1 1%
5476 }{%
5477 \tikz@parse@main@intersection#1%
5478 }%
5479 }%
5480 \def\tikz@parse@main@intersection#1#2of #3 and #4){%
5481 \tikzset{cs/solution={#2}}%
5482 \pgfutil@in@{--}{#3}%
5483 \ifpgfutil@in@%
5484 \tikz@reparse@line{first}#3\pgf@stop%
5485 \else%
5486 \tikzset{cs/first node={#3}}%
5487 \fi%
5488 \pgfutil@in@{--}{#4}%
5489 \ifpgfutil@in@%
5490 \tikz@reparse@line{second}#4\pgf@stop%
5491 \else%
5492 \tikzset{cs/second node={#4}}%
5493 \fi%
5494 \tikz@parse@cs@intersection()% advanced hackery...
5495 \edef\pgf@marshal{\noexpand#1{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
5496 \pgf@marshal%
5497 }%
5498 \def\tikz@reparse@line#1#2--#3\pgf@stop{%
5499 \tikzset{cs/#1 line={(#2)--(#3)}}%
5500 }%
5501
5502
5503 \def\tikz@parse@intersection@a#1{\pgf@process{#1}\pgf@xa=\pgf@x\pgf@ya=\pgf@y}%
5504 \def\tikz@parse@intersection@b#1{\pgf@process{#1}\pgf@xb=\pgf@x\pgf@yb=\pgf@y}%
5505
5506 \def\tikz@scan@relative#1+{%
5507 \pgfutil@ifnextchar+{\tikz@scan@plusplus#1}{\tikz@scan@oneplus#1}}%
5508
5509 \def\tikz@scan@plusplus#1+{%
5510 \def\tikz@doafter{#1}%
5511 \tikz@scan@absolute\tikz@add%
5512 }%
5513 \def\tikz@add#1{%
5514 \tikz@doafter{\pgfpointadd{#1}{\tikz@last@position@saved}}%
5515 }%
5516 \def\tikz@scan@oneplus#1{%
5517 \def\tikz@doafter{#1}%
5518 \tikz@updatecurrentfalse%
5519 \tikz@scan@absolute\tikz@add%
5520 }%
5521
5522
5523
5524 %
5525 % Quote handling
5526 %
5527
5528 \let\tikz@enable@node@quotes\relax
5529 \let\tikz@enable@edge@quotes\relax
5530 \let\tikz@enable@pic@quotes\relax
5531
5532
5533
5534 % Loading further libraries
5535
5536 % Include a library file.
5537 %
5538 % #1 = List of names of library file.
5539 %
5540 % Description:
5541 %
5542 % This command includes a list of TikZ library files. For each file X in the
5543 % list, the file tikzlibraryX.code.tex is included, provided this has
5544 % not been done earlier.
5545 %
5546 % For the convenience of Context users, both round and square brackets
5547 % are possible for the argument.
5548 %
5549 % If no file tikzlibraryX.code.tex exists, the file
5550 % pgflibraryX.code.tex is tried instead. If this file, also, does not
5551 % exist, an error message is printed.
5552 %
5553 % Example:
5554 %
5555 % \usetikzlibrary{arrows}
5556 % \usetikzlibrary[patterns,topaths]
5557
5558 \def\usetikzlibrary{\pgfutil@ifnextchar[{\use@tikzlibrary}{\use@@tikzlibrary}}%}%
5559 \def\use@tikzlibrary[#1]{\use@@tikzlibrary{#1}}%
5560 \def\use@@tikzlibrary#1{%
5561 \edef\pgf@list{#1}%
5562 \pgfutil@for\pgf@temp:=\pgf@list\do{%
5563 \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}%
5564 \ifx\pgf@temp\pgfutil@empty
5565 \else
5566 \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax%
5567 \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty%
5568 \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@}
5569 \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|}
5570 \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$}
5571 \catcode`\@=11
5572 \catcode`\|=12
5573 \catcode`\$=3
5574 \pgfutil@InputIfFileExists{tikzlibrary\[email protected]}{}{
5575 \pgfutil@IfFileExists{pgflibrary\[email protected]}{%
5576 \expandafter\usepgflibrary\expandafter{\pgf@temp}%
5577 }{%
5578 \tikzerror{I did not find the tikz library
5579 '\pgf@temp'. I looked for files named
5580 tikzlibrary\[email protected] and
5581 pgflibrary\[email protected], but neither
5582 could be found in the current texmf trees.}
5583 }}%
5584 \catcode`\@=\csname tikz@library@#1@atcode\endcsname
5585 \catcode`\|=\csname tikz@library@#1@barcode\endcsname
5586 \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname
5587 \fi%
5588 \fi
5589 }%
5590 }%
5591
5592
5593 % Always-present libraries:
5594
5595 \usetikzlibrary{topaths}%
5596
5597
5598
5599
5600 \endinput