Debian Codegraph @

texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.geometric.code.tex

raw
1 % Copyright 2018 by Till Tantau and Mark Wibrow
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 \ProvidesFileRCS{pgflibraryshapes.geometric.code.tex}
11
12 \pgfdeclareshape{ellipse}
13 %
14 % Draws a circle around the text
15 %
16 {%
17 \savedanchor\centerpoint{%
18 \pgf@x=.5\wd\pgfnodeparttextbox%
19 \pgf@y=.5\ht\pgfnodeparttextbox%
20 \advance\pgf@y by-.5\dp\pgfnodeparttextbox%
21 }%
22 \savedanchor\radius{%
23 %
24 % Calculate ``height radius''
25 %
26 \pgf@y=.5\ht\pgfnodeparttextbox%
27 \advance\pgf@y by.5\dp\pgfnodeparttextbox%
28 \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}%
29 \advance\pgf@y by\pgf@yb%
30 %
31 % Calculate ``width radius''
32 %
33 \pgf@x=.5\wd\pgfnodeparttextbox%
34 \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}%
35 \advance\pgf@x by\pgf@xb%
36 %
37 % Adjust
38 %
39 \pgf@x=1.4142136\pgf@x%
40 \pgf@y=1.4142136\pgf@y%
41 %
42 % Adjust height, if necessary
43 %
44 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/minimum height}}%
45 \ifdim\pgf@y<.5\pgf@yc%
46 \pgf@y=.5\pgf@yc%
47 \fi%
48 %
49 % Adjust width, if necessary
50 %
51 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum width}}%
52 \ifdim\pgf@x<.5\pgf@xc%
53 \pgf@x=.5\pgf@xc%
54 \fi%
55 %
56 % Add outer sep
57 %
58 \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
59 \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
60 \advance\pgf@x by\pgf@xb%
61 \advance\pgf@y by\pgf@yb%
62 }%
63
64 %
65 % Anchors
66 %
67 \anchor{center}{\centerpoint}%
68 \anchor{mid}{\centerpoint\pgfmathsetlength\pgf@y{.5ex}}%
69 \anchor{base}{\centerpoint\pgf@y=0pt}%
70 \anchor{north}
71 {
72 \pgf@process{\radius}
73 \pgf@ya=\pgf@y%
74 \pgf@process{\centerpoint}
75 \advance\pgf@y by\pgf@ya
76 }%
77 \anchor{south}
78 {
79 \pgf@process{\radius}
80 \pgf@ya=\pgf@y%
81 \pgf@process{\centerpoint}
82 \advance\pgf@y by-\pgf@ya
83 }%
84 \anchor{west}
85 {
86 \pgf@process{\radius}
87 \pgf@xa=\pgf@x%
88 \pgf@process{\centerpoint}
89 \advance\pgf@x by-\pgf@xa
90 }%
91 \anchor{mid west}
92 {%
93 \pgf@process{\radius}
94 \pgf@xa=\pgf@x%
95 \pgf@process{\centerpoint}
96 \advance\pgf@x by-\pgf@xa%
97 \pgfmathsetlength\pgf@y{.5ex}
98 }%
99 \anchor{base west}
100 {%
101 \pgf@process{\radius}
102 \pgf@xa=\pgf@x%
103 \pgf@process{\centerpoint}
104 \advance\pgf@x by-\pgf@xa%
105 \pgf@y=0pt
106 }%
107 \anchor{north west}
108 {
109 \pgf@process{\radius}
110 \pgf@xa=\pgf@x%
111 \pgf@ya=\pgf@y%
112 \pgf@process{\centerpoint}
113 \advance\pgf@x by-0.707107\pgf@xa
114 \advance\pgf@y by0.707107\pgf@ya
115 }%
116 \anchor{south west}
117 {
118 \pgf@process{\radius}
119 \pgf@xa=\pgf@x%
120 \pgf@ya=\pgf@y%
121 \pgf@process{\centerpoint}
122 \advance\pgf@x by-0.707107\pgf@xa
123 \advance\pgf@y by-0.707107\pgf@ya
124 }%
125 \anchor{east}
126 {%
127 \pgf@process{\radius}
128 \pgf@xa=\pgf@x%
129 \pgf@process{\centerpoint}
130 \advance\pgf@x by\pgf@xa
131 }%
132 \anchor{mid east}
133 {%
134 \pgf@process{\radius}
135 \pgf@xa=\pgf@x%
136 \pgf@process{\centerpoint}
137 \advance\pgf@x by\pgf@xa%
138 \pgfmathsetlength\pgf@y{.5ex}
139 }%
140 \anchor{base east}
141 {%
142 \pgf@process{\radius}
143 \pgf@xa=\pgf@x%
144 \pgf@process{\centerpoint}
145 \advance\pgf@x by\pgf@xa%
146 \pgf@y=0pt
147 }%
148 \anchor{north east}
149 {
150 \pgf@process{\radius}
151 \pgf@xa=\pgf@x%
152 \pgf@ya=\pgf@y%
153 \pgf@process{\centerpoint}
154 \advance\pgf@x by0.707107\pgf@xa
155 \advance\pgf@y by0.707107\pgf@ya
156 }%
157 \anchor{south east}
158 {
159 \pgf@process{\radius}
160 \pgf@xa=\pgf@x%
161 \pgf@ya=\pgf@y%
162 \pgf@process{\centerpoint}
163 \advance\pgf@x by0.707107\pgf@xa
164 \advance\pgf@y by-0.707107\pgf@ya
165 }%
166 \anchorborder{%
167 \edef\pgf@marshal{%
168 \noexpand\pgfpointborderellipse
169 {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
170 {\noexpand\radius}%
171 }%
172 \pgf@marshal%
173 \pgf@xa=\pgf@x%
174 \pgf@ya=\pgf@y%
175 \centerpoint%
176 \advance\pgf@x by\pgf@xa%
177 \advance\pgf@y by\pgf@ya%
178 }%
179
180 %
181 % Background path
182 %
183 \backgroundpath
184 {
185 \pgf@process{\radius}%
186 \pgfutil@tempdima=\pgf@x%
187 \pgfutil@tempdimb=\pgf@y%
188 \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
189 \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
190 \advance\pgfutil@tempdima by-\pgf@xb%
191 \advance\pgfutil@tempdimb by-\pgf@yb%
192 \pgfpathellipse{\centerpoint}{\pgfqpoint{\pgfutil@tempdima}{0pt}}{\pgfqpoint{0pt}{\pgfutil@tempdimb}}%
193 }%
194 }%
195
196
197
198
199 % Set the recommended shape aspect ratio
200 %
201 % #1 = aspect ratio
202 %
203 % Example:
204 %
205 % \pgfsetshapeaspect{1.5}
206
207 % Keys for shape aspect ratio.
208 %
209 % /pgf/aspect : recommended width/height quotient.
210 %
211 \pgfkeys{/pgf/.cd,
212 aspect/.code={\pgfsetshapeaspect{#1}},% this for tikz...
213 shape aspect/.initial=1,% but this is consistent with other pgfset stuff.
214 shape aspect/.code={%
215 \pgfkeys{/pgf/aspect={#1}}%
216 \pgfkeyssetvalue{/pgf/shape aspect}{#1}
217 }%
218 }%
219
220
221 \def\pgfsetshapeaspect#1{%
222 \def\pgfshapeaspect{#1}%
223 % Invert
224 \pgfutil@tempdima=#1pt%
225 \pgfutil@tempdima=.125\pgfutil@tempdima%
226 \c@pgf@counta=\pgfutil@tempdima\relax% 8192*determinant
227 \pgfutil@tempdima=8192pt%
228 \divide\pgfutil@tempdima by\c@pgf@counta%
229 \edef\pgfshapeaspectinverse{\pgf@sys@tonumber{\pgfutil@tempdima}}%
230 }%
231
232 \pgfsetshapeaspect{1}%
233
234 \pgfdeclareshape{diamond}
235 {%
236 \savedanchor\outernortheast{%
237 %
238 % Calculate width and height of the inner rectangle
239 %
240 \pgf@xa=.5\wd\pgfnodeparttextbox%
241 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}%
242 \advance\pgf@xa by\pgf@xc%
243 \pgf@ya=.5\ht\pgfnodeparttextbox%
244 \advance\pgf@ya by.5\dp\pgfnodeparttextbox%
245 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}%
246 \advance\pgf@ya by\pgf@yc%
247 %
248 % Calculate width and height of diamond
249 %
250 \pgf@x=\pgf@xa%
251 \advance\pgf@x by\pgfshapeaspect\pgf@ya%
252 \pgf@y=\pgfshapeaspectinverse\pgf@xa%
253 \advance\pgf@y by\pgf@ya%
254 %
255 % Check against minimum height/width
256 %
257 \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}%
258 \pgf@xb=.5\pgf@xb%
259 \ifdim\pgf@x<\pgf@xb%
260 % yes, too small. Enlarge...
261 \pgf@x=\pgf@xb%
262 \fi%
263 \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}%
264 \pgf@yb=.5\pgf@yb%
265 \ifdim\pgf@y<\pgf@yb%
266 % yes, too small. Enlarge...
267 \pgf@y=\pgf@yb%
268 \fi%
269 %
270 % Add outer border
271 %
272 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}%
273 \advance\pgf@x by\pgf@xa%
274 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}%
275 \advance\pgf@y by\pgf@ya%
276 }%
277 \savedanchor\text{%
278 \pgf@x=-.5\wd\pgfnodeparttextbox%
279 \pgf@y=-.5\ht\pgfnodeparttextbox%
280 \advance\pgf@y by.5\dp\pgfnodeparttextbox%
281 }%
282
283 %
284 % Anchors
285 %
286 \anchor{text}{\text}%
287 \anchor{center}{\pgfpointorigin}%
288 \anchor{mid}{%
289 \pgf@process{\text}%
290 \pgf@x=0pt%
291 \pgfmathsetlength\pgf@ya{.5ex}%
292 \advance\pgf@y by\pgf@ya%
293 }%
294 \anchor{base}{\pgf@process{\text}\pgf@x=0pt}%
295 \anchor{north}{\pgf@process{\outernortheast}\pgf@x=0pt}%
296 \anchor{south}{\pgf@process{\outernortheast}\pgf@x=0pt\pgf@y=-\pgf@y}%
297 \anchor{west}{\pgf@process{\outernortheast}\pgf@x=-\pgf@x\pgf@y=0pt}%
298 \anchor{north west}{\pgf@process{\outernortheast}\pgf@x=-.5\pgf@x\pgf@y=.5\pgf@y}%
299 \anchor{south west}{\pgf@process{\outernortheast}\pgf@x=-.5\pgf@x\pgf@y=-.5\pgf@y}%
300 \anchor{east}{\pgf@process{\outernortheast}\pgf@y=0pt}%
301 \anchor{north east}{\pgf@process{\outernortheast}\pgf@x=.5\pgf@x\pgf@y=.5\pgf@y}%
302 \anchor{south east}{\pgf@process{\outernortheast}\pgf@x=.5\pgf@x\pgf@y=-.5\pgf@y}%
303 \anchorborder{%
304 \pgf@xa=\pgf@x%
305 \pgf@ya=\pgf@y%
306 \pgf@process{\outernortheast}%
307 \ifdim\pgf@xa>0pt%
308 \else%
309 \pgf@x=-\pgf@x%
310 \fi%
311 \ifdim\pgf@ya>0pt%
312 \else%
313 \pgf@y=-\pgf@y%
314 \fi%
315 \edef\pgf@marshal{%
316 \noexpand\pgfpointintersectionoflines
317 {\noexpand\pgfpointorigin}
318 {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}
319 {\noexpand\pgfqpoint{\the\pgf@x}{0pt}}
320 {\noexpand\pgfqpoint{0pt}{\the\pgf@y}}%
321 }%
322 \pgf@process{\pgf@marshal}%
323 }%
324
325 %
326 % Background path
327 %
328 \backgroundpath{
329 \pgf@process{\outernortheast}%
330 \pgf@xc=\pgf@x%
331 \pgf@yc=\pgf@y%
332 \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/outer xsep}}%
333 \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/outer ysep}}%
334 \advance\pgf@xc by-1.414213\pgf@xa%
335 \advance\pgf@yc by-1.414213\pgf@ya%
336 \pgfpathmoveto{\pgfqpoint{\pgf@xc}{0pt}}%
337 \pgfpathlineto{\pgfqpoint{0pt}{\pgf@yc}}%
338 \pgfpathlineto{\pgfqpoint{-\pgf@xc}{0pt}}%
339 \pgfpathlineto{\pgfqpoint{0pt}{-\pgf@yc}}%
340 \pgfpathclose%
341 }%
342 }%
343
344
345
346
347
348
349 \newif\ifpgf@lib@shapes@starouterradiususesratio
350 \pgf@lib@shapes@starouterradiususesratiotrue
351
352 % Keys for star shape
353 %
354 % /pgf/star points : Number of points on the star.
355 % /pgf/star point height : The height of the outer star points.
356 % /pgf/star point ratio : The ratio of the outer point and inner point radii.
357
358 \pgfkeys{/pgf/.cd,
359 star points/.initial=5,
360 star point height/.initial=.5cm,
361 star point height/.code={%
362 \def\pgf@lib@temp{#1}%
363 \pgfkeyslet{/pgf/star point height}{\pgf@lib@temp}%
364 \pgf@lib@shapes@starouterradiususesratiofalse%
365 },
366 star point ratio/.initial=1.5,
367 star point ratio/.code={%
368 \def\pgf@lib@temp{#1}%
369 \pgfkeyslet{/pgf/star point ratio}{\pgf@lib@temp}%
370 \pgf@lib@shapes@starouterradiususesratiotrue%
371 },%
372 star rotate/.style={/pgf/shape border rotate={#1}},% For compatibility with 1.18
373 }%
374
375
376 % Shape star.
377 %
378 \pgfdeclareshape{star}{%
379 \savedmacro\totalstarpoints{%
380 \pgfmathsetcounter{pgf@counta}{\pgfkeysvalueof{/pgf/star points}}%
381 \multiply\c@pgf@counta2\relax%
382 \edef\totalstarpoints{\the\c@pgf@counta}%
383 }%
384 \savedmacro\anglestep{%
385 \pgfmathdivide{180}{\pgfkeysvalueof{/pgf/star points}}%
386 \let\anglestep\pgfmathresult%
387 }%
388 \savedmacro\calculateradii{%
389 %
390 % Get the node dimensions.
391 %
392 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
393 \advance\[email protected]\wd\pgfnodeparttextbox%
394 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
395 \advance\[email protected]\ht\pgfnodeparttextbox%
396 \advance\[email protected]\dp\pgfnodeparttextbox%
397 \ifdim\pgf@y>\pgf@x%
398 \pgf@x\pgf@y%
399 \fi%
400 %
401 % Calculate the incircle radius.
402 %
403 \[email protected]\pgf@x%
404 \edef\innerradius{\the\pgf@x}%
405 %
406 % Calculate the circumcircle radius.
407 %
408 % Use the star point height or the star point ratio?
409 %
410 \ifpgf@lib@shapes@starouterradiususesratio%
411 \pgfmathparse{\pgfkeysvalueof{/pgf/star point ratio}}%
412 \expandafter\pgf@x\pgfmathresult\pgf@x%
413 \else%
414 \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/star point height}}%
415 \fi%
416 \pgf@xc\pgf@x%
417 %
418 % Accommodate the larger of the minimum height/width.
419 %
420 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
421 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
422 \ifdim\pgf@ya>\pgf@xa%
423 \pgf@xa\pgf@ya%
424 \fi%
425 \ifdim\pgf@x<.5\pgf@xa%
426 \[email protected]\pgf@xa%
427 \fi%
428 \edef\outerradius{\the\pgf@x}%
429 %
430 % If the outer radius has been enlarged, adjust the inner radius...
431 %
432 \ifdim\pgf@x>\pgf@xc%
433 %
434 % ...using the star point ratio, or...
435 %
436 \ifpgf@lib@shapes@starouterradiususesratio%
437 \pgfmathreciprocal{\pgfkeysvalueof{/pgf/star point ratio}}%
438 \pgf@xa\pgfmathresult\pgf@x\relax%
439 \edef\innerradius{\the\pgf@xa}%
440 \else%
441 %
442 % The star point height.
443 %
444 \pgf@xa\pgf@x\relax%
445 \pgfmathaddtolength\pgf@xa{-\pgfkeysvalueof{/pgf/star point height}}%
446 \edef\innerradius{\the\pgf@xa}%
447 \fi%
448 \fi%
449 \edef\outerradius{\the\pgf@x}%
450 %
451 % Now calculate the anchor radii from the outer sep.
452 %
453 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}%
454 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}%
455 \ifdim\pgf@ya>\pgf@xa%
456 \pgf@xa\pgf@ya%
457 \fi
458 %
459 % Take into account the miter length...
460 %
461 \pgfmathdivide{180}{\pgfkeysvalueof{/pgf/star points}}%
462 \let\angletofirstpoint\pgfmathresult%
463 \pgfmathmultiply@{\angletofirstpoint}{2}%
464 \let\angletosecondpoint\pgfmathresult%
465 %
466 % ...for the outer radius...
467 %
468 \pgfmathanglebetweenlines%
469 {\pgfqpointpolar{\angletofirstpoint}{\outerradius}}%
470 {\pgfqpointpolar{\angletosecondpoint}{\innerradius}}%
471 {\pgfqpointpolar{\angletofirstpoint}{\outerradius}}%
472 {\pgfqpointpolar{0}{\innerradius}}%
473 \pgfmathdivide@{\pgfmathresult}{2}%
474 \pgfmathcosec@{\pgfmathresult}%
475 \pgf@x\outerradius\relax%
476 \advance\pgf@x\pgfmathresult\pgf@xa%
477 \edef\anchorouterradius{\the\pgf@x}%
478 %
479 % ...and for the inner radius.
480 %
481 \pgfmathanglebetweenlines%
482 {\pgfqpointpolar{\angletofirstpoint}{\innerradius}}%
483 {\pgfqpointpolar{0}{\outerradius}}%
484 {\pgfqpointpolar{\angletofirstpoint}{\innerradius}}%
485 {\pgfqpointpolar{\angletosecondpoint}{\outerradius}}%
486 \pgfmathdivide@{\pgfmathresult}{2}%
487 \pgfmathcosec@{\pgfmathresult}%
488 \pgf@x\innerradius\relax%
489 \advance\pgf@x\pgfmathresult\pgf@xa%
490 \edef\anchorinnerradius{\the\pgf@x}%
491 %
492 % Save all radii.
493 %
494 \addtosavedmacro{\innerradius}%
495 \addtosavedmacro{\outerradius}%
496 \addtosavedmacro{\anchorinnerradius}%
497 \addtosavedmacro{\anchorouterradius}%
498 }%
499 \savedmacro\startangle{%
500 \pgfmathadd{90}{\pgfkeysvalueof{/pgf/shape border rotate}}%
501 \let\startangle\pgfmathresult%
502 }%
503 %
504 % Saved anchors.
505 %
506 \savedanchor{\centerpoint}{%
507 \[email protected]\wd\pgfnodeparttextbox%
508 \[email protected]\ht\pgfnodeparttextbox%
509 \advance\[email protected]\dp\pgfnodeparttextbox%
510 }%
511 \savedanchor{\midpoint}{%
512 \[email protected]\wd\pgfnodeparttextbox%
513 \pgfmathsetlength\pgf@y{+.5ex}%
514 }%
515 %
516 %
517 % Other anchors.
518 %
519 \anchor{center}{\centerpoint}%
520 \anchor{mid}{\centerpoint\pgfmathsetlength\pgf@y{.5ex}}%
521 \anchor{base}{\centerpoint\pgf@y=0pt}%
522 \anchor{north}{%
523 \calculateradii%
524 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{0pt}{\anchorouterradius}}}%
525 \anchor{south}{%
526 \calculateradii%
527 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{0pt}{-\anchorouterradius}}}%
528 \anchor{east}{%
529 \calculateradii%
530 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{\anchorouterradius}{0pt}}}%
531 \anchor{west}{%
532 \calculateradii%
533 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{-\anchorouterradius}{0pt}}}%
534 \anchor{north east}{%
535 \calculateradii%
536 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{\anchorouterradius}{\anchorouterradius}}}%
537 \anchor{north west}{%
538 \calculateradii%
539 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{-\anchorouterradius}{\anchorouterradius}}}%
540 \anchor{south east}{%
541 \calculateradii%
542 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{\anchorouterradius}{-\anchorouterradius}}}%
543 \anchor{south west}{%
544 \calculateradii%
545 \csname pgf@anchor@star@border\endcsname{\pgfqpoint{-\anchorouterradius}{-\anchorouterradius}}}%
546 %
547 % Background path.
548 %
549 \backgroundpath{%
550 \calculateradii%
551 \let\angle\startangle%
552 \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpointpolar{\startangle}{\outerradius}}}%
553 \pgfmathloop%
554 \pgfmathadd@{\angle}{\anglestep}%
555 \let\angle\pgfmathresult%
556 \ifnum\pgfmathcounter=\totalstarpoints%
557 \pgfpathclose%
558 \else%
559 \ifodd\pgfmathcounter
560 \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpointpolar{\angle}{\innerradius}}}%
561 \else%
562 \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpointpolar{\angle}{\outerradius}}}%
563 \fi%
564 \repeatpgfmathloop%
565 }%
566 %
567 % Define points on the anchor border.
568 %
569 \anchorborder{%
570 %
571 % Save x and y.
572 %
573 \edef\externalx{\the\pgf@x}%
574 \edef\externaly{\the\pgf@y}%
575 %
576 % Adjust the location of the external
577 % point relative to \centerpoint.
578 %
579 \centerpoint%
580 \pgf@xa\externalx\relax%
581 \pgf@ya\externaly\relax%
582 \advance\pgf@xa\pgf@x%
583 \advance\pgf@ya\pgf@y%
584 \edef\externalx{\the\pgf@xa}%
585 \edef\externaly{\the\pgf@ya}%
586 %
587 % Get the angle of the external point to the \centerpoint.
588 %
589 \pgfmathanglebetweenpoints{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
590 %
591 % Locate the appropriate sides on the star border...
592 %
593 \pgfmathsubtract@{\pgfmathresult}{\startangle}%
594 \ifdim\pgfmathresult pt<0pt\relax%
595 \pgfmathadd@{\pgfmathresult}{360}%
596 \fi%
597 \pgfmathdivide@{\pgfmathresult}{\anglestep}%
598 \pgfmathfloor@{\pgfmathresult}%
599 \afterassignment\pgfmath@gobbletilpgfmath@
600 \c@pgf@counta\pgfmathresult\relax\pgfmath@
601 \pgfmathmultiply@{\pgfmathresult}{\anglestep}%
602 \pgfmathadd@{\pgfmathresult}{\startangle}%
603 \let\firstangle\pgfmathresult%
604 \pgfmathadd@{\pgfmathresult}{\anglestep}%
605 \let\secondangle\pgfmathresult%
606 \calculateradii%
607 %
608 % ...and thus, the point on the star border.
609 %
610 \ifodd\c@pgf@counta
611 \pgfpointintersectionoflines{\centerpoint}{\pgfpoint{+\externalx}{+\externaly}}%
612 {%
613 \pgfpointadd{\centerpoint}%
614 {\pgfqpointpolar{+\firstangle}{+\anchorinnerradius}}%
615 }%
616 {%
617 \pgfpointadd{\centerpoint}%
618 {\pgfqpointpolar{+\secondangle}{+\anchorouterradius}}%
619 }%
620 \else%
621 \pgfpointintersectionoflines{\centerpoint}{\pgfpoint{+\externalx}{+\externaly}}%
622 {%
623 \pgfpointadd{\centerpoint}%
624 {\pgfqpointpolar{+\firstangle}{+\anchorouterradius}}%
625 }%
626 {%
627 \pgfpointadd{\centerpoint}%
628 {\pgfqpointpolar{+\secondangle}{+\anchorinnerradius}}%
629 }%
630 \fi%
631 }%
632 %
633 % Some hackery. This is needed if a star is positioned using
634 % a `...point <n+1>' anchor, where n is the maximum number of
635 % points of any previously drawn star.
636 %
637 \pgfutil@g@addto@macro\pgf@sh@s@star{%
638 \c@pgf@counta\totalstarpoints\relax%
639 \divide\c@pgf@counta2\relax%
640 \pgfmathloop%
641 \ifnum\c@pgf@counta>0\relax%
642 \c@pgf@countb\c@pgf@counta\relax%
643 \advance\c@pgf@countb-1\relax%
644 \pgfutil@ifundefined{pgf@anchor@star@inner point\space\the\c@pgf@counta}{%
645 \expandafter\xdef\csname pgf@anchor@star@inner point\space\the\c@pgf@counta\endcsname{%
646 \noexpand\calculateradii%
647 \noexpand\pgfmathmultiply@{\the\c@pgf@countb}{\noexpand\anglestep}%
648 \noexpand\pgfmathmultiply@{\noexpand\pgfmathresult}{2}%
649 \noexpand\pgfmathadd@{\noexpand\pgfmathresult}{\noexpand\anglestep}%
650 \noexpand\pgfmathadd@{\noexpand\pgfmathresult}{\noexpand\startangle}%
651 \noexpand\let\noexpand\angle\noexpand\pgfmathresult%
652 \noexpand\pgfpointadd{\noexpand\centerpoint}%
653 {\noexpand\pgfqpointpolar{\noexpand\angle}{\noexpand\anchorinnerradius}}%
654 }%
655 \expandafter\xdef\csname pgf@anchor@star@outer point\space\the\c@pgf@counta\endcsname{%
656 \noexpand\calculateradii%
657 \noexpand\pgfmathmultiply@{\the\c@pgf@countb}{\noexpand\anglestep}%
658 \noexpand\pgfmathmultiply@{\noexpand\pgfmathresult}{2}%
659 \noexpand\pgfmathadd@{\noexpand\pgfmathresult}{\noexpand\startangle}%
660 \noexpand\let\noexpand\angle\noexpand\pgfmathresult%
661 \noexpand\pgfpointadd{\noexpand\centerpoint}%
662 {\noexpand\pgfqpointpolar{\noexpand\angle}{\noexpand\anchorouterradius}}%
663 }%
664 }{\c@pgf@counta0\relax}%
665 \advance\c@pgf@counta-1\relax%
666 \repeatpgfmathloop%
667 }%
668 }%
669
670
671
672
673 % Keys for shape regular polygon
674 %
675 % /pgf/regular polygon sides
676 %
677 \pgfkeys{/pgf/.cd,
678 regular polygon sides/.initial=5,
679 regular polygon rotate/.style={/pgf/shape border rotate={#1}}% For compatibility with 1.18
680 }%
681
682
683 % Shape Regular Polygon.
684 %
685 \pgfdeclareshape{regular polygon}{%
686 \savedmacro\sides{%
687 \pgfmathtruncatemacro\sides{\pgfkeysvalueof{/pgf/regular polygon sides}}%
688 }%
689 \savedmacro\anglestep{%
690 \pgfmathdivide{360}{\pgfkeysvalueof{/pgf/regular polygon sides}}%
691 \let\anglestep\pgfmathresult%
692 }%
693 \savedmacro\calculateradii{%
694 %
695 % Get the node dimensions.
696 %
697 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
698 \advance\[email protected]\wd\pgfnodeparttextbox%
699 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
700 \advance\[email protected]\ht\pgfnodeparttextbox%
701 \advance\[email protected]\dp\pgfnodeparttextbox%
702 \ifdim\pgf@y>\pgf@x%
703 \pgf@x\pgf@y%
704 \fi%
705 %
706 % Calculate i, the incircle radius
707 %
708 \[email protected]\pgf@x%
709 %
710 % Calculate r, the polygon radius
711 %
712 % r = i / cos(360 / s / 2)
713 %
714 % (s = polygon sides)
715 %
716 \pgfmathdivide{180}{\pgfkeysvalueof{/pgf/regular polygon sides}}%
717 \pgfmathsec@{\pgfmathresult}%
718 \pgf@x\pgfmathresult\pgf@x%
719 %
720 % Accommodate the minimum width/height.
721 %
722 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
723 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
724 \ifdim\pgf@ya>\pgf@xa%
725 \pgf@xa\pgf@ya%
726 \fi%
727 \ifdim\pgf@x<.5\pgf@xa%
728 \[email protected]\pgf@xa%
729 \fi%
730 \edef\radius{\the\pgf@x}%
731 %
732 % Now calculate the anchor radius from the outer sep.
733 %
734 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}%
735 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}%
736 \ifdim\pgf@ya>\pgf@xa%
737 \pgf@xa\pgf@ya%
738 \fi
739 %
740 % Take into account the miter length.
741 %
742 % m = o / sin (90 - (360 / s / 2))
743 %
744 % (o = outer sep, s = sides)
745 %
746 \pgfmathdivide{180}{\pgfkeysvalueof{/pgf/regular polygon sides}}%
747 \pgfmathsubtract@{90}{\pgfmathresult}%
748 \pgfmathcosec@{\pgfmathresult}%
749 \advance\pgf@x\pgfmathresult\pgf@xa%
750 \edef\anchorradius{\the\pgf@x}%
751 %
752 % Save both radii.
753 %
754 \addtosavedmacro{\radius}%
755 \addtosavedmacro{\anchorradius}%
756 }%
757 \savedmacro\startangle{%
758 \pgfmathdivide{360}{\pgfkeysvalueof{/pgf/regular polygon sides}}%
759 \let\anglestep\pgfmathresult%
760 \pgfmathtruncatemacro\sides{\pgfkeysvalueof{/pgf/regular polygon sides}}%
761 \expandafter\ifodd\sides\relax%
762 \edef\pgfmathresult{90}%
763 \else%
764 \pgfmathdivide@{\anglestep}{2}%
765 \pgfmathsubtract@{90}{\pgfmathresult}%
766 \fi%
767 \pgfmathadd{\pgfmathresult}{\pgfkeysvalueof{/pgf/shape border rotate}}%
768 \let\startangle\pgfmathresult%
769 }%
770 %
771 % Saved anchors.
772 %
773 \savedanchor{\centerpoint}{%
774 \[email protected]\wd\pgfnodeparttextbox%
775 \[email protected]\ht\pgfnodeparttextbox%
776 \advance\[email protected]\dp\pgfnodeparttextbox%
777 }%
778 \savedanchor{\midpoint}{%
779 \[email protected]\wd\pgfnodeparttextbox%
780 \pgfmathsetlength\pgf@y{+.5ex}%
781 }%
782 %
783 % Other anchors.
784 %
785 \anchor{center}{\centerpoint}%
786 \anchor{mid}{\midpoint}%
787 \anchor{base}{\centerpoint\pgf@y=0pt}%
788 \anchor{north}{%
789 \calculateradii%
790 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{0pt}{\anchorradius}}}%
791 \anchor{south}{%
792 \calculateradii%
793 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{0pt}{-\anchorradius}}}%
794 \anchor{east}{%
795 \calculateradii%
796 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{\anchorradius}{0pt}}}%
797 \anchor{west}{%
798 \calculateradii%
799 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{-\anchorradius}{0pt}}}%
800 \anchor{north east}{%
801 \calculateradii%
802 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{\anchorradius}{\anchorradius}}}%
803 \anchor{north west}{%
804 \calculateradii%
805 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{-\anchorradius}{\anchorradius}}}%
806 \anchor{south east}{%
807 \calculateradii%
808 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{\anchorradius}{-\anchorradius}}}%
809 \anchor{south west}{%
810 \calculateradii%
811 \csname pgf@anchor@regular polygon@border\endcsname{\pgfqpoint{-\anchorradius}{-\anchorradius}}}%
812 %
813 % Background path.
814 %
815 \backgroundpath{%
816 \calculateradii%
817 \pgfpathmoveto{%
818 \pgfpointadd{\centerpoint}{\pgfqpointpolar{\startangle}{\radius}}%
819 }%
820 \let\angle\startangle%
821 \pgfmathloop%
822 \ifnum\pgfmathcounter=\sides\relax%
823 \pgfpathclose%
824 \else%
825 \pgfmathadd@{\angle}{\anglestep}%
826 \let\angle\pgfmathresult%
827 \pgfpathlineto{%
828 \pgfpointadd{\centerpoint}{\pgfqpointpolar{\angle}{\radius}}%
829 }%
830 \repeatpgfmathloop%
831 }%
832 \anchorborder{%
833 %
834 % Save x and y.
835 %
836 \edef\externalx{\the\pgf@x}%
837 \edef\externaly{\the\pgf@y}%
838 %
839 % Adjust the location of the external
840 % point relative to \centerpoint.
841 %
842 \centerpoint%
843 \pgf@xa\externalx\relax%
844 \pgf@ya\externaly\relax%
845 \advance\pgf@xa\pgf@x%
846 \advance\pgf@ya\pgf@y%
847 \edef\externalx{\the\pgf@xa}%
848 \edef\externaly{\the\pgf@ya}%
849 %
850 % Get the angle of the external point to the \centerpoint.
851 %
852 \pgfmathanglebetweenpoints{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
853 %
854 % Locate the appropriate sides on the polygon border...
855 %
856 \pgfmathsubtract@{\pgfmathresult}{\startangle}%
857 \ifdim\pgfmathresult pt<0pt\relax%
858 \pgfmathadd@{\pgfmathresult}{360}%
859 \fi%
860 \pgfmathdivide@{\pgfmathresult}{\anglestep}%
861 \pgfmathfloor@{\pgfmathresult}%
862 \pgfmathmultiply@{\pgfmathresult}{\anglestep}%
863 \pgfmathadd@{\pgfmathresult}{\startangle}%
864 \let\firstangle\pgfmathresult%
865 \pgfmathadd@{\pgfmathresult}{\anglestep}%
866 \let\secondangle\pgfmathresult%
867 \calculateradii%
868 %
869 % ...and thus, the point on the polygon border.
870 %
871 \pgfpointintersectionoflines{\centerpoint}{\pgfpoint{+\externalx}{+\externaly}}%
872 {%
873 \pgfpointadd{\centerpoint}%
874 {\pgfqpointpolar{+\firstangle}{+\anchorradius}}%
875 }%
876 {%
877 \pgfpointadd{\centerpoint}%
878 {\pgfqpointpolar{+\secondangle}{+\anchorradius}}%
879 }%
880 }%
881 %
882 % More hackery for when the rectangular polygon is positioned using
883 % a `corner <n+1>' or `side <n+1>' anchor, where n is the maximum
884 % number of sides of any previously drawn regular polygon.
885 %
886 \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@regular polygon\endcsname{%
887 \c@pgf@counta\sides\relax%
888 \pgfmathloop%
889 \ifnum\c@pgf@counta>0\relax%
890 \pgfutil@ifundefined{pgf@anchor@regular polygon@corner\space\the\c@pgf@counta}{%
891 %
892 % ...(manually \xdef as \gdef is normally used by \anchor)...
893 %
894 \expandafter\xdef\csname pgf@anchor@regular polygon@corner\space\the\c@pgf@counta\endcsname{%
895 \noexpand\calculateradii%
896 \noexpand\pgfmathsubtract@{\the\c@pgf@counta}{1}%
897 \noexpand\pgfmathmultiply@{\noexpand\pgfmathresult}{\noexpand\anglestep}%
898 \noexpand\pgfmathadd@{\noexpand\pgfmathresult}{\noexpand\startangle}%
899 \noexpand\let\noexpand\angle\noexpand\pgfmathresult%
900 \noexpand\pgfpointadd{\noexpand\centerpoint}%
901 {\noexpand\pgfqpointpolar{\noexpand\angle}{\noexpand\anchorradius}}%
902 }%
903 \expandafter\xdef\csname pgf@anchor@regular polygon@side\space\the\c@pgf@counta\endcsname{%
904 \noexpand\calculateradii%
905 \noexpand\pgfmathsubtract@{\the\c@pgf@counta}{1}%
906 \noexpand\pgfmathmultiply@{\noexpand\pgfmathresult}{\noexpand\anglestep}%
907 \noexpand\pgfmathadd@{\noexpand\pgfmathresult}{\noexpand\startangle}%
908 \noexpand\let\noexpand\firstangle\noexpand\pgfmathresult%
909 \noexpand\pgfmathadd@{\noexpand\pgfmathresult}{\noexpand\anglestep}%
910 \noexpand\let\noexpand\secondangle\noexpand\pgfmathresult%
911 \noexpand\pgfpointlineattime{0.5}%
912 {\noexpand\pgfpointadd{\noexpand\centerpoint}%
913 {\noexpand\pgfqpointpolar{\noexpand\firstangle}{\noexpand\anchorradius}}}%
914 {\noexpand\pgfpointadd{\noexpand\centerpoint}%
915 {\noexpand\pgfqpointpolar{\noexpand\secondangle}{\noexpand\anchorradius}}}%
916 }%
917 }{\c@pgf@counta0\relax}%
918 \advance\c@pgf@counta-1\relax%
919 \repeatpgfmathloop%
920 }%
921 }%
922
923
924
925 % Keys for shape trapezium
926 %
927 % /pgf/trapezium left angle : angle of the left side.
928 % /pgf/trapezium right angle : angle of the right side.
929
930 \pgfkeys{/pgf/.cd,
931 trapezium left angle/.initial=60,
932 trapezium right angle/.initial=60,
933 trapezium angle/.style={
934 /pgf/trapezium left angle={#1},
935 /pgf/trapezium right angle={#1}
936 },%
937 trapezium stretches/.is if=pgf@lib@sh@trapeziumstretches,%
938 trapezium stretches body/.is if=pgf@lib@sh@trapeziumstretchesbody,%
939 }%
940
941 \newif\ifpgf@lib@sh@trapeziumstretchesbody
942 \newif\ifpgf@lib@sh@trapeziumstretches
943
944
945 % Shape trapezium.
946 %
947 \pgfdeclareshape{trapezium}{%
948 \savedmacro\installtrapeziumparameters{%
949 %
950 % Get the node dimensions.
951 %
952 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
953 \advance\[email protected]\wd\pgfnodeparttextbox%
954 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
955 \advance\[email protected]\ht\pgfnodeparttextbox%
956 \advance\[email protected]\dp\pgfnodeparttextbox%
957 \ifpgfshapeborderusesincircle%
958 %
959 % Get the rotation (no rounding).
960 %
961 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
962 %
963 % Use the radius of the incircle if required...
964 %
965 \ifdim\pgf@x<\pgf@y%
966 \pgf@x\pgf@y%
967 \fi%
968 \[email protected]\pgf@x%
969 \pgf@y\pgf@x%
970 \else%
971 %
972 % Get the rotation (with rounding).
973 %
974 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
975 \afterassignment\pgfmath@gobbletilpgfmath@%
976 \expandafter\c@pgf@counta\pgfmathresult\relax\pgfmath@%
977 \advance\c@pgf@counta45\relax%
978 \divide\c@pgf@counta90\relax%
979 \multiply\c@pgf@counta90\relax%
980 \ifnum\c@pgf@counta<0\relax%
981 \advance\c@pgf@counta360\relax%
982 \fi%
983 \edef\rotate{\the\c@pgf@counta}%
984 %
985 % Calculate the width and height of the node
986 % contents, according to any border rotation.
987 %
988 \ifnum\c@pgf@counta=90\relax%
989 \pgf@xc\pgf@x%
990 \pgf@x\pgf@y%
991 \pgf@y\pgf@xc%
992 \else%
993 \ifnum\c@pgf@counta=270\relax%
994 \pgf@xc\pgf@x%
995 \pgf@x\pgf@y%
996 \pgf@y\pgf@xc%
997 \fi%
998 \fi%
999 \fi%
1000 \pgfmathmod{\pgfkeysvalueof{/pgf/trapezium left angle}}{360}%
1001 \ifdim\pgfmathresult pt<0pt\relax%
1002 \pgfmathadd@{\pgfmathresult}{360}%
1003 \fi%
1004 \let\leftangle\pgfmathresult%
1005 \ifdim\leftangle pt=0pt\relax%
1006 \def\pgfmathresult{0}%
1007 \else%
1008 \pgfmathcot@{\leftangle}%
1009 \fi%
1010 \pgf@xa2\pgf@y%
1011 \pgf@xa\pgfmathresult\pgf@xa%
1012 \pgfmathmod{\pgfkeysvalueof{/pgf/trapezium right angle}}{360}%
1013 \ifdim\pgfmathresult pt<0pt\relax%
1014 \pgfmathadd@{\pgfmathresult}{360}%
1015 \fi%
1016 \let\rightangle\pgfmathresult%
1017 \ifdim\rightangle pt=0pt\relax%
1018 \def\pgfmathresult{0}%
1019 \else%
1020 \pgfmathcot@{\rightangle}%
1021 \fi%
1022 \pgf@xb2\pgf@y%
1023 \pgf@xb\pgfmathresult\pgf@xb%
1024 %
1025 % Take into account minimum height and width.
1026 %
1027 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
1028 \ifdim\pgf@y<.5\pgf@ya%
1029 \ifpgf@lib@sh@trapeziumstretches%
1030 \[email protected]\pgf@ya%
1031 \else%
1032 \ifpgf@lib@sh@trapeziumstretchesbody%
1033 \[email protected]\pgf@ya%
1034 \else%
1035 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@y}}%
1036 \[email protected]\pgf@ya%
1037 \pgf@yb\pgfmathresult\pgf@yb%
1038 \[email protected]\pgf@ya%
1039 \pgf@x\pgfmath@tonumber{\pgf@yb}\pgf@x%
1040 \pgf@xa\pgfmath@tonumber{\pgf@yb}\pgf@xa%
1041 \pgf@xb\pgfmath@tonumber{\pgf@yb}\pgf@xb%
1042 \fi%
1043 \fi%
1044 \fi%
1045 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum width}}%
1046 \pgf@xc2\pgf@x%
1047 \ifdim\pgf@xa<0pt\relax%
1048 \advance\pgf@xc-\pgf@xa%
1049 \else%
1050 \advance\pgf@xc\pgf@xa%
1051 \fi%
1052 \ifdim\pgf@xb<0pt\relax%
1053 \advance\pgf@xc-\pgf@xb%
1054 \else%
1055 \advance\pgf@xc\pgf@xb%
1056 \fi%
1057 \ifdim\pgf@xc<\pgf@ya%
1058 \ifpgf@lib@sh@trapeziumstretchesbody%
1059 \pgf@xc-\pgf@xc%
1060 \advance\pgf@xc\pgf@ya%
1061 \advance\[email protected]\pgf@xc%
1062 \else%
1063 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@xc}}%
1064 \pgf@ya\pgfmathresult\pgf@ya%
1065 \pgf@x\pgfmath@tonumber{\pgf@ya}\pgf@x%
1066 \pgf@xa\pgfmath@tonumber{\pgf@ya}\pgf@xa%
1067 \pgf@xb\pgfmath@tonumber{\pgf@ya}\pgf@xb%
1068 \ifpgf@lib@sh@trapeziumstretches%
1069 \else%
1070 \pgf@y\pgfmath@tonumber{\pgf@ya}\pgf@y%
1071 \fi%
1072 \fi%
1073 \fi%
1074 \edef\halfheight{\the\pgf@y}%
1075 \edef\halfwidth{\the\pgf@x}%
1076 \edef\leftextension{\the\pgf@xa}%
1077 \edef\rightextension{\the\pgf@xb}%
1078 \pgf@xc2\pgf@x%
1079 %
1080 % Take the larger of the outer sep.
1081 %
1082 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
1083 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
1084 \ifdim\pgf@y>\pgf@x%
1085 \pgf@x\pgf@y%
1086 \fi%
1087 \edef\outersep{\the\pgf@x}%
1088 %
1089 % The \externalradius is a length that is
1090 % guaranteed to produce a point outside the trapezium.
1091 %
1092 \advance\[email protected]\pgf@x%
1093 \pgf@yc\halfheight\relax%
1094 \multiply\pgf@yc2\relax%
1095 \advance\[email protected]\pgf@x%
1096 \ifdim\pgf@xc<\pgf@yc%
1097 \edef\externalradius{\the\pgf@yc}%
1098 \else%
1099 \edef\externalradius{\the\pgf@xc}%
1100 \fi%
1101 %
1102 % Calculate the centre base and mid points of the node.
1103 %
1104 \pgfextract@process\centerpoint{%
1105 \[email protected]\wd\pgfnodeparttextbox%
1106 \[email protected]\ht\pgfnodeparttextbox%
1107 \advance\[email protected]\dp\pgfnodeparttextbox%
1108 }%
1109 \pgfextract@process\basepoint{%
1110 \[email protected]\wd\pgfnodeparttextbox%
1111 \pgf@y0pt\relax%
1112 }%
1113 \pgfextract@process\midpoint{%
1114 \[email protected]\wd\pgfnodeparttextbox%
1115 \pgfmathsetlength\pgf@y{+.5ex}%
1116 }%
1117 %
1118 % Calculate each point on the trapezium (without rotation).
1119 %
1120 \pgfextract@process\lowerleftpoint{%
1121 \centerpoint%
1122 \advance\pgf@x-\halfwidth\relax%
1123 \ifdim\leftextension>0pt\relax%
1124 \advance\pgf@x-\leftextension\relax%
1125 \fi%
1126 \advance\pgf@y-\halfheight\relax%
1127 }%
1128 \pgfextract@process\upperleftpoint{%
1129 \centerpoint%
1130 \advance\pgf@x-\halfwidth\relax%
1131 \ifdim\leftextension<0pt\relax%
1132 \advance\pgf@x\leftextension\relax%
1133 \fi%
1134 \advance\pgf@y\halfheight\relax%
1135 }%
1136 \pgfextract@process\upperrightpoint{%
1137 \centerpoint%
1138 \advance\pgf@x\halfwidth\relax%
1139 \ifdim\rightextension<0pt\relax%
1140 \advance\pgf@x-\rightextension\relax%
1141 \fi%
1142 \advance\pgf@y\halfheight\relax%
1143 }%
1144 \pgfextract@process\lowerrightpoint{%
1145 \centerpoint%
1146 \advance\pgf@x\halfwidth\relax%
1147 \ifdim\rightextension>0pt\relax%
1148 \advance\pgf@x\rightextension\relax%
1149 \fi%
1150 \advance\pgf@y-\halfheight\relax%
1151 }%
1152 %
1153 % Now calculate the adjustment for the miter length at each corner
1154 % of the trapezium. This ensures more accurate anchor positioning
1155 % when the line width is particularly thick.
1156 %
1157 \pgfextract@process\lowerleftmiter{%
1158 \pgfmathanglebetweenlines{\lowerleftpoint}{\lowerrightpoint}{\lowerleftpoint}{\upperleftpoint}%
1159 \pgfmathmultiply@{\pgfmathresult}{.5}%
1160 \pgfmathtan@{\pgfmathresult}%
1161 \pgfmathreciprocal@{\pgfmathresult}%
1162 \pgf@x-\outersep\relax%
1163 \pgf@x\pgfmathresult\pgf@x%
1164 \pgf@y-\outersep\relax%
1165 }%
1166 \pgfextract@process\upperleftmiter{%
1167 \pgfmathanglebetweenlines{\upperleftpoint}{\lowerleftpoint}{\upperleftpoint}{\upperrightpoint}%
1168 \pgfmathmultiply@{\pgfmathresult}{.5}%
1169 \pgfmathtan@{\pgfmathresult}%
1170 \pgfmathreciprocal@{\pgfmathresult}%
1171 \pgf@x-\outersep\relax%
1172 \pgf@x\pgfmathresult\pgf@x%
1173 \pgf@y\outersep\relax%
1174 }%
1175 \pgfextract@process\upperrightmiter{%
1176 \pgfmathanglebetweenlines{\upperrightpoint}{\upperleftpoint}{\upperrightpoint}{\lowerrightpoint}%
1177 \pgfmathmultiply@{\pgfmathresult}{.5}%
1178 \pgfmathtan@{\pgfmathresult}%
1179 \pgfmathreciprocal@{\pgfmathresult}%
1180 \pgf@x\outersep\relax%
1181 \pgf@x\pgfmathresult\pgf@x%
1182 \pgf@y\outersep\relax%
1183 }%
1184 \pgfextract@process\lowerrightmiter{%
1185 \pgfmathanglebetweenlines{\lowerrightpoint}{\upperrightpoint}{\lowerrightpoint}{\lowerleftpoint}%
1186 \pgfmathmultiply@{\pgfmathresult}{.5}%
1187 \pgfmathtan@{\pgfmathresult}%
1188 \pgfmathreciprocal@{\pgfmathresult}%
1189 \pgf@x\outersep\relax%
1190 \pgf@x\pgfmathresult\pgf@x%
1191 \pgf@y-\outersep\relax%
1192 }%
1193 %
1194 % Now calculate the corners for determining anchor border
1195 % points, by adding the adjustment for the miter length.
1196 %
1197 \pgfextract@process\lowerleftborderpoint{%
1198 \pgfpointadd{\lowerleftpoint}{\lowerleftmiter}%
1199 }%
1200 \pgfextract@process\upperleftborderpoint{%
1201 \pgfpointadd{\upperleftpoint}{\upperleftmiter}%
1202 }%
1203 \pgfextract@process\upperrightborderpoint{%
1204 \pgfpointadd{\upperrightpoint}{\upperrightmiter}%
1205 }%
1206 \pgfextract@process\lowerrightborderpoint{%
1207 \pgfpointadd{\lowerrightpoint}{\lowerrightmiter}%
1208 }%
1209 %
1210 % Calculate the angle from the centerpoint to each corner.
1211 % Rotation is not important here (see \anchorborder code).
1212 %
1213 \pgfmathanglebetweenpoints{\centerpoint}{\lowerleftborderpoint}%
1214 \let\angletolowerleft\pgfmathresult%
1215 \pgfmathanglebetweenpoints{\centerpoint}{\upperleftborderpoint}%
1216 \let\angletoupperleft\pgfmathresult%
1217 \pgfmathanglebetweenpoints{\centerpoint}{\upperrightborderpoint}%
1218 \let\angletoupperright\pgfmathresult%
1219 \pgfmathanglebetweenpoints{\centerpoint}{\lowerrightborderpoint}%
1220 \let\angletolowerright\pgfmathresult%
1221 %
1222 % Do the same for the *inversely rotated* base point...
1223 %
1224 \pgfextract@process\rotatedbasepoint{%
1225 \pgfmathrotatepointaround{\basepoint}{\centerpoint}{-\rotate}%
1226 }%
1227 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\lowerleftborderpoint}%
1228 \let\baseangletolowerleft\pgfmathresult%
1229 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\upperleftborderpoint}%
1230 \let\baseangletoupperleft\pgfmathresult%
1231 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\upperrightborderpoint}%
1232 \let\baseangletoupperright\pgfmathresult%
1233 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\lowerrightborderpoint}%
1234 \let\baseangletolowerright\pgfmathresult%
1235 %
1236 % And the *inversely rotated* mid point...
1237 %
1238 \pgfextract@process\rotatedmidpoint{%
1239 \pgfmathrotatepointaround{\midpoint}{\centerpoint}{-\rotate}%
1240 }%
1241 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\lowerleftborderpoint}%
1242 \let\midangletolowerleft\pgfmathresult%
1243 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\upperleftborderpoint}%
1244 \let\midangletoupperleft\pgfmathresult%
1245 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\upperrightborderpoint}%
1246 \let\midangletoupperright\pgfmathresult%
1247 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\lowerrightborderpoint}%
1248 \let\midangletolowerright\pgfmathresult%
1249 %
1250 % Now rotate the border points around the centerpoint...
1251 %
1252 \pgfextract@process\lowerleftborderpoint{%
1253 \pgfmathrotatepointaround%
1254 {\lowerleftborderpoint}%
1255 {\centerpoint}%
1256 {\rotate}%
1257 }%
1258 \pgfextract@process\upperleftborderpoint{%
1259 \pgfmathrotatepointaround%
1260 {\upperleftborderpoint}%
1261 {\centerpoint}%
1262 {\rotate}%
1263 }%
1264 \pgfextract@process\upperrightborderpoint{%
1265 \pgfmathrotatepointaround%
1266 {\upperrightborderpoint}%
1267 {\centerpoint}%
1268 {\rotate}%
1269 }%
1270 \pgfextract@process\lowerrightborderpoint{%
1271 \pgfmathrotatepointaround%
1272 {\lowerrightborderpoint}%
1273 {\centerpoint}%
1274 {\rotate}%
1275 }%
1276 %
1277 % ...and the points for drawing the border (i.e. no outer sep).
1278 %
1279 \pgfextract@process\lowerleftpoint{%
1280 \pgfmathrotatepointaround{\lowerleftpoint}{\centerpoint}{\rotate}%
1281 }%
1282 \pgfextract@process\upperleftpoint{%
1283 \pgfmathrotatepointaround{\upperleftpoint}{\centerpoint}{\rotate}%
1284 }%
1285 \pgfextract@process\upperrightpoint{%
1286 \pgfmathrotatepointaround{\upperrightpoint}{\centerpoint}{\rotate}%
1287 }%
1288 \pgfextract@process\lowerrightpoint{%
1289 \pgfmathrotatepointaround{\lowerrightpoint}{\centerpoint}{\rotate}%
1290 }%
1291 %
1292 % And finally, save all the relevant stuff.
1293 %
1294 \addtosavedmacro{\lowerleftpoint}%
1295 \addtosavedmacro{\upperleftpoint}%
1296 \addtosavedmacro{\upperrightpoint}%
1297 \addtosavedmacro{\lowerrightpoint}%
1298 %
1299 \addtosavedmacro{\lowerleftborderpoint}%
1300 \addtosavedmacro{\upperleftborderpoint}%
1301 \addtosavedmacro{\upperrightborderpoint}%
1302 \addtosavedmacro{\lowerrightborderpoint}%
1303 %
1304 \addtosavedmacro{\angletolowerleft}%
1305 \addtosavedmacro{\angletoupperleft}%
1306 \addtosavedmacro{\angletoupperright}%
1307 \addtosavedmacro{\angletolowerright}%
1308 %
1309 \addtosavedmacro{\baseangletolowerleft}%
1310 \addtosavedmacro{\baseangletoupperleft}%
1311 \addtosavedmacro{\baseangletoupperright}%
1312 \addtosavedmacro{\baseangletolowerright}%
1313 %
1314 \addtosavedmacro{\midangletolowerleft}%
1315 \addtosavedmacro{\midangletoupperleft}%
1316 \addtosavedmacro{\midangletoupperright}%
1317 \addtosavedmacro{\midangletolowerright}%
1318 %
1319 \addtosavedmacro{\rotate}%
1320 \addtosavedmacro{\externalradius}%
1321 }%
1322 \savedanchor\centerpoint{%
1323 \[email protected]\wd\pgfnodeparttextbox%
1324 \[email protected]\ht\pgfnodeparttextbox%
1325 \advance\[email protected]\dp\pgfnodeparttextbox%
1326 }%
1327 \savedanchor\basepoint{%
1328 \[email protected]\wd\pgfnodeparttextbox%
1329 \pgf@y0pt\relax%
1330 }%
1331 \savedanchor\midpoint{%
1332 \[email protected]\wd\pgfnodeparttextbox%
1333 \pgfmathsetlength\pgf@y{+.5ex}%
1334 }%
1335 \anchor{center}{\centerpoint}%
1336 \anchor{base}{\basepoint}%
1337 \anchor{base east}{%
1338 \installtrapeziumparameters%
1339 \let\pgf@trapeziumanchorborderreferencepoint\basepoint%
1340 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
1341 }%
1342 \anchor{base west}{%
1343 \installtrapeziumparameters%
1344 \let\pgf@trapeziumanchorborderreferencepoint\basepoint%
1345 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
1346 }%
1347 \anchor{mid}{\midpoint}%
1348 \anchor{mid east}{%
1349 \installtrapeziumparameters%
1350 \let\pgf@trapeziumanchorborderreferencepoint\midpoint%
1351 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
1352 }%
1353 \anchor{mid west}{%
1354 \installtrapeziumparameters%
1355 \let\pgf@trapeziumanchorborderreferencepoint\midpoint%
1356 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
1357 }%
1358 \anchor{north}{%
1359 \installtrapeziumparameters%
1360 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{0pt}{\externalradius}}%
1361 }%
1362 \anchor{south}{%
1363 \installtrapeziumparameters%
1364 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{0pt}{-\externalradius}}%
1365 }%
1366 \anchor{east}{%
1367 \installtrapeziumparameters%
1368 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
1369 }%
1370 \anchor{west}{%
1371 \installtrapeziumparameters%
1372 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
1373 }%
1374 \anchor{north east}{%
1375 \installtrapeziumparameters%
1376 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{\externalradius}{\externalradius}}%
1377 }%
1378 \anchor{south west}{%
1379 \installtrapeziumparameters%
1380 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{-\externalradius}{-\externalradius}}%
1381 }%
1382 \anchor{south east}{%
1383 \installtrapeziumparameters%
1384 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{\externalradius}{-\externalradius}}%
1385 }%
1386 \anchor{north west}{%
1387 \installtrapeziumparameters%
1388 \csname pgf@anchor@trapezium@border\endcsname{\pgfqpoint{-\externalradius}{\externalradius}}%
1389 }%
1390 \anchor{bottom left corner}{%
1391 \installtrapeziumparameters%
1392 \lowerleftborderpoint%
1393 }%
1394 \anchor{top left corner}{%
1395 \installtrapeziumparameters%
1396 \upperleftborderpoint%
1397 }%
1398 \anchor{top right corner}{%
1399 \installtrapeziumparameters%
1400 \upperrightborderpoint%
1401 }%
1402 \anchor{bottom right corner}{%
1403 \installtrapeziumparameters%
1404 \lowerrightborderpoint%
1405 }%
1406 \anchor{left side}{%
1407 \installtrapeziumparameters%
1408 \pgfpointlineattime{0.5}{\lowerleftborderpoint}{\upperleftborderpoint}%
1409 }%
1410 \anchor{right side}{%
1411 \installtrapeziumparameters%
1412 \pgfpointlineattime{0.5}{\lowerrightborderpoint}{\upperrightborderpoint}%
1413 }%
1414 \anchor{top side}{%
1415 \installtrapeziumparameters%
1416 \pgfpointlineattime{0.5}{\upperleftborderpoint}{\upperrightborderpoint}%
1417 }%
1418 \anchor{bottom side}{%
1419 \installtrapeziumparameters%
1420 \pgfpointlineattime{0.5}{\lowerleftborderpoint}{\lowerrightborderpoint}%
1421 }%
1422 \backgroundpath{%
1423 \installtrapeziumparameters%
1424 \pgfpathmoveto{\lowerleftpoint}%
1425 \pgfpathlineto{\upperleftpoint}%
1426 \pgfpathlineto{\upperrightpoint}%
1427 \pgfpathlineto{\lowerrightpoint}%
1428 \pgfpathclose%
1429 }%
1430 \anchorborder{%
1431 %
1432 % Save x and y.
1433 %
1434 \edef\externalx{\the\pgf@x}%
1435 \edef\externaly{\the\pgf@y}%
1436 %
1437 % This allows anchors base east, base west, mid east and mid west,
1438 % to redefine the `center' of the node to correctly calculate the
1439 % border points.
1440 %
1441 \pgfutil@ifundefined{pgf@trapeziumanchorborderreferencepoint}%
1442 {\let\referencepoint\centerpoint}%
1443 {\let\referencepoint\pgf@trapeziumanchorborderreferencepoint}%
1444 %
1445 % Adjust the location of the external
1446 % point relative to the reference point.
1447 %
1448 \referencepoint%
1449 \pgf@xa\externalx\relax%
1450 \pgf@ya\externaly\relax%
1451 \advance\pgf@xa\pgf@x%
1452 \advance\pgf@ya\pgf@y%
1453 \edef\externalx{\the\pgf@xa}%
1454 \edef\externaly{\the\pgf@ya}%
1455 %
1456 % Install the required points and angles.
1457 %
1458 \installtrapeziumparameters%
1459 %
1460 % Get the angle of the external point to the \referencepoint.
1461 %
1462 \pgfmathanglebetweenpoints{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
1463 %
1464 % *Subtract* the rotation from the external angle. This is
1465 % why the border point angles do not need to be rotated.
1466 %
1467 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
1468 \ifdim\pgfmathresult pt<0pt\relax%
1469 \pgfmathadd@{\pgfmathresult}{360}%
1470 \fi%
1471 %
1472 % Get the relevant angles for the reference point.
1473 %
1474 \let\externalangle\pgfmathresult%
1475 \ifx\referencepoint\basepoint%
1476 \let\angletoupperright\baseangletoupperright%
1477 \let\angletoupperleft\baseangletoupperleft%
1478 \let\angletolowerright\baseangletolowerright%
1479 \let\angletolowerleft\baseangletolowerleft%
1480 \else%
1481 \ifx\referencepoint\midpoint%
1482 \let\angletoupperright\midangletoupperright%
1483 \let\angletoupperleft\midangletoupperleft%
1484 \let\angletolowerright\midangletolowerright%
1485 \let\angletolowerleft\midangletolowerleft%
1486 \fi\fi%
1487 %
1488 % Find the line on the border...
1489 %
1490 \ifdim\externalangle pt<\angletoupperright pt\relax%
1491 \let\firstpoint\upperrightborderpoint%
1492 \let\secondpoint\lowerrightborderpoint%
1493 \else%
1494 \ifdim\externalangle pt<\angletoupperleft pt\relax%
1495 \let\firstpoint\upperleftborderpoint%
1496 \let\secondpoint\upperrightborderpoint%
1497 \else%
1498 \ifdim\externalangle pt<\angletolowerleft pt\relax%
1499 \let\firstpoint\upperleftborderpoint%
1500 \let\secondpoint\lowerleftborderpoint%
1501 \else%
1502 \ifdim\externalangle pt<\angletolowerright pt\relax%
1503 \let\firstpoint\lowerleftborderpoint%
1504 \let\secondpoint\lowerrightborderpoint%
1505 \else%
1506 \let\firstpoint\upperrightborderpoint%
1507 \let\secondpoint\lowerrightborderpoint%
1508 \fi%
1509 \fi%
1510 \fi%
1511 \fi%
1512 %
1513 % ...and thus the point on the border.
1514 %
1515 \pgfpointintersectionoflines{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
1516 {\firstpoint}{\secondpoint}%
1517 }%
1518 }%
1519
1520
1521
1522
1523 % Shape semicircle.
1524 %
1525 \pgfdeclareshape{semicircle}{%
1526 \savedmacro\installsemicircleparameters{%
1527 %
1528 % Get the larger of the outer sep.
1529 %
1530 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
1531 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
1532 \ifdim\pgf@x<\pgf@y%
1533 \pgf@x\pgf@y%
1534 \fi%
1535 \edef\outersep{\the\pgf@x}%
1536 %
1537 % Get the node dimensions.
1538 %
1539 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
1540 \advance\pgf@x+.5\wd\pgfnodeparttextbox%
1541 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
1542 \advance\pgf@y+.5\ht\pgfnodeparttextbox%
1543 \advance\pgf@y+.5\dp\pgfnodeparttextbox%
1544 %
1545 % Use the radius of the incircle if required...
1546 %
1547 \ifpgfshapeborderusesincircle%
1548 %
1549 % Get the rotation (no rounding).
1550 %
1551 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
1552 \ifdim\pgf@x<\pgf@y%
1553 \pgf@x\pgf@y%
1554 \fi%
1555 \[email protected]\pgf@x%
1556 \edef\halfheight{\the\pgf@x}%
1557 \advance\pgf@x\pgf@x%
1558 \else%
1559 %
1560 % Get the rotation (with rounding).
1561 %
1562 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
1563 \afterassignment\pgfmath@gobbletilpgfmath@%
1564 \expandafter\c@pgf@counta\pgfmathresult\relax\pgfmath@%
1565 \advance\c@pgf@counta45\relax%
1566 \divide\c@pgf@counta90\relax%
1567 \multiply\c@pgf@counta90\relax%
1568 \ifnum\c@pgf@counta<0\relax%
1569 \advance\c@pgf@counta360\relax%
1570 \fi%
1571 \edef\rotate{\the\c@pgf@counta}%
1572 %
1573 % Calculate the width and height of the node
1574 % contents, according to any border rotation.
1575 %
1576 \ifnum\c@pgf@counta=90\relax%
1577 \pgf@xc\pgf@x%
1578 \pgf@x\pgf@y%
1579 \pgf@y\pgf@xc%
1580 \else%
1581 \ifnum\c@pgf@counta=270\relax%
1582 \pgf@xc\pgf@x%
1583 \pgf@x\pgf@y%
1584 \pgf@y\pgf@xc%
1585 \fi%
1586 \fi%
1587 \advance\pgf@y\pgf@y%
1588 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
1589 \pgf@x\pgfmathresult pt\relax%
1590 \[email protected]\pgf@y%
1591 \edef\halfheight{\the\pgf@y}%
1592 \fi%
1593 \edef\defaultradius{\the\pgf@x}%
1594 %
1595 % Take into account minimum height and width.
1596 %
1597 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
1598 \ifdim\pgf@x<.5\pgf@xa%
1599 \[email protected]\pgf@xa%
1600 \fi%
1601 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
1602 \ifdim\pgf@x<\pgf@ya%
1603 \pgf@x\pgf@ya%
1604 \fi%
1605 \edef\semicircleradius{\the\pgf@x}%
1606 %
1607 % Find the center/base/mid of the semi circle node.
1608 %
1609 \pgfextract@process\centerpoint{%
1610 \[email protected]\wd\pgfnodeparttextbox%
1611 \[email protected]\ht\pgfnodeparttextbox%
1612 \advance\pgf@y+-.5\dp\pgfnodeparttextbox%
1613 }%
1614 \pgfextract@process\basepoint{%
1615 \[email protected]\wd\pgfnodeparttextbox%
1616 \pgf@y0pt\relax%
1617 }%
1618 \pgfextract@process\midpoint{%
1619 \[email protected]\wd\pgfnodeparttextbox%
1620 \pgfmathsetlength\pgf@y{+.5ex}%
1621 }%
1622 \pgfextract@process\semicirclecenterpoint{%
1623 \centerpoint%
1624 \pgf@ya\semicircleradius\relax%
1625 \advance\pgf@ya-\defaultradius\relax%
1626 %
1627 % The point is adjusted to make the node contents
1628 % appear more centered if the node is enlarged to
1629 % some minimum size. The factor .4 just seems OK.
1630 %
1631 \[email protected]\pgf@ya%
1632 \advance\pgf@y-\pgf@ya%
1633 \pgf@ya\halfheight\relax%
1634 \advance\pgf@y-\pgf@ya%
1635 }%
1636 %
1637 % Add the outer sep to the radius here.
1638 %
1639 \pgf@x\semicircleradius\relax%
1640 \advance\pgf@x\outersep\relax%
1641 \edef\semicircleradius{\the\pgf@x}%
1642 \pgfpointdiff{\centerpoint}{\semicirclecenterpoint}%
1643 \ifdim\pgf@y<0pt\pgf@y-\pgf@y\fi%
1644 \edef\centerpointdiff{\the\pgf@y}%
1645 %
1646 % Calculate the start and end points on the border.
1647 %
1648 \pgfextract@process\arcstartborder{%
1649 \semicirclecenterpoint%
1650 \advance\pgf@x\semicircleradius\relax%
1651 }%
1652 \pgfextract@process\arcendborder{%
1653 \semicirclecenterpoint%
1654 \advance\pgf@x-\semicircleradius\relax%
1655 }%
1656 %
1657 % Calculate the start and end *corner* points on the border.
1658 % This is needed to accommodate the outer sep.
1659 %
1660 \pgfextract@process\arcstartcorner{%
1661 \arcstartborder%
1662 \advance\pgf@y-\outersep\relax%
1663 }%
1664 \pgfextract@process\arcendcorner{%
1665 \arcendborder%
1666 \advance\pgf@y-\outersep\relax%
1667 }
1668 %
1669 % Now calculate all the relevant angles.
1670 %
1671 % For the center point.
1672 %
1673 \pgfmathanglebetweenpoints{\centerpoint}{\arcstartborder}%
1674 \let\angletoarcstartborder\pgfmathresult%
1675 \pgfmathanglebetweenpoints{\centerpoint}{\arcendborder}%
1676 \let\angletoarcendborder\pgfmathresult%
1677 \pgfmathanglebetweenpoints{\centerpoint}{\arcstartcorner}%
1678 \let\angletoarcstartcorner\pgfmathresult%
1679 \pgfmathanglebetweenpoints{\centerpoint}{\arcendcorner}%
1680 \let\angletoarcendcorner\pgfmathresult%
1681 %
1682 % For the basepoint (rotated about the center point).
1683 %
1684 \pgfextract@process\rotatedbasepoint{%
1685 \pgfmathrotatepointaround{\basepoint}{\centerpoint}{-\rotate}%
1686 }%
1687 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\arcstartborder}%
1688 \let\baseangletoarcstartborder\pgfmathresult%
1689 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\arcendborder}%
1690 \let\baseangletoarcendborder\pgfmathresult%
1691 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\arcstartcorner}%
1692 \let\baseangletoarcstartcorner\pgfmathresult%
1693 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\arcendcorner}%
1694 \let\baseangletoarcendcorner\pgfmathresult%
1695 %
1696 % For the midpoint (rotated about the center point).
1697 %
1698 \pgfextract@process\rotatedmidpoint{%
1699 \pgfmathrotatepointaround{\midpoint}{\centerpoint}{-\rotate}%
1700 }%
1701 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\arcstartborder}%
1702 \let\midangletoarcstartborder\pgfmathresult%
1703 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\arcendborder}%
1704 \let\midangletoarcendborder\pgfmathresult%
1705 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\arcstartcorner}%
1706 \let\midangletoarcstartcorner\pgfmathresult%
1707 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\arcendcorner}%
1708 \let\midangletoarcendcorner\pgfmathresult%
1709 %
1710 % Now, rotate the semicircle points around the centerpoint.
1711 %
1712 \pgfextract@process\semicirclecenterpoint{%
1713 \pgfmathrotatepointaround{\semicirclecenterpoint}{\centerpoint}{\rotate}%
1714 }%
1715 \pgfextract@process\arcstartborder{%
1716 \pgfmathrotatepointaround{\arcstartborder}{\centerpoint}{\rotate}%
1717 }%
1718 \pgfextract@process\arcendborder{%
1719 \pgfmathrotatepointaround{\arcendborder}{\centerpoint}{\rotate}%
1720 }%
1721 \pgfextract@process\arcstartcorner{%
1722 \pgfmathrotatepointaround{\arcstartcorner}{\centerpoint}{\rotate}%
1723 }%
1724 \pgfextract@process\arcendcorner{%
1725 \pgfmathrotatepointaround{\arcendcorner}{\centerpoint}{\rotate}%
1726 }%
1727 %
1728 % Calculate the distance between the base point and the (rotated) semicircle center.
1729 %
1730 \pgfpointdiff{\basepoint}{\semicirclecenterpoint}%
1731 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
1732 \edef\basesemicirclecenterdiff{\pgfmathresult pt}%
1733 %
1734 % Calculate the distance between the base point and the (rotated) semicircle center.
1735 %
1736 \pgfpointdiff{\midpoint}{\semicirclecenterpoint}%
1737 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
1738 \edef\midsemicirclecenterdiff{\pgfmathresult pt}%
1739 %
1740 % And save all the stuff.
1741 %
1742 \addtosavedmacro{\rotate}%
1743 \addtosavedmacro{\outersep}%
1744 \addtosavedmacro{\semicircleradius}%
1745 %
1746 \addtosavedmacro{\arcstartborder}%
1747 \addtosavedmacro{\arcendborder}%
1748 \addtosavedmacro{\arcstartcorner}%
1749 \addtosavedmacro{\arcendcorner}%
1750 \addtosavedmacro{\semicirclecenterpoint}%
1751 %
1752 \addtosavedmacro{\angletoarcstartborder}%
1753 \addtosavedmacro{\angletoarcendborder}%
1754 \addtosavedmacro{\angletoarcstartcorner}%
1755 \addtosavedmacro{\angletoarcendcorner}%
1756 %
1757 \addtosavedmacro{\centerpointdiff}%
1758 \addtosavedmacro{\basesemicirclecenterdiff}%
1759 \addtosavedmacro{\midsemicirclecenterdiff}%
1760 %
1761 \addtosavedmacro{\baseangletoarcstartborder}%
1762 \addtosavedmacro{\baseangletoarcendborder}%
1763 \addtosavedmacro{\baseangletoarcstartcorner}%
1764 \addtosavedmacro{\baseangletoarcendcorner}%
1765 %
1766 \addtosavedmacro{\midangletoarcstartborder}%
1767 \addtosavedmacro{\midangletoarcendborder}%
1768 \addtosavedmacro{\midangletoarcstartcorner}%
1769 \addtosavedmacro{\midangletoarcendcorner}%
1770 }%
1771 \savedanchor{\centerpoint}{%
1772 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
1773 \pgfmathsetlength\pgf@y{+.5\ht\pgfnodeparttextbox}%
1774 \pgfmathaddtolength\pgf@y{-.5\dp\pgfnodeparttextbox}%
1775 }%
1776 \savedanchor{\basepoint}{%
1777 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
1778 \pgf@y0pt\relax%
1779 }%
1780 \savedanchor{\midpoint}{%
1781 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
1782 \pgfmathsetlength\pgf@y{+.5ex}%
1783 }%
1784 \anchor{center}{\centerpoint}%
1785 \anchor{base}{\basepoint}%
1786 \anchor{base west}{%
1787 \installsemicircleparameters%
1788 \let\pgf@semicirclereferencepoint\basepoint%
1789 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpoint{-\semicircleradius}{0pt}}%
1790 }%
1791 \anchor{base east}{%
1792 \installsemicircleparameters%
1793 \let\pgf@semicirclereferencepoint\basepoint%
1794 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpoint{\semicircleradius}{0pt}}%
1795 }%
1796 \anchor{mid}{\midpoint}%
1797 \anchor{mid west}{%
1798 \installsemicircleparameters%
1799 \let\pgf@semicirclereferencepoint\midpoint%
1800 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpoint{-\semicircleradius}{0pt}}%
1801 }%
1802 \anchor{mid east}{%
1803 \installsemicircleparameters%
1804 \let\pgf@semicirclereferencepoint\midpoint%
1805 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpoint{\semicircleradius}{0pt}}%
1806 }%
1807 \anchor{apex}{%
1808 \installsemicircleparameters%
1809 \pgfmathadd@{\rotate}{90}%
1810 \let\angle\pgfmathresult%
1811 \pgfpointadd{\semicirclecenterpoint}{\pgfqpointpolar{\angle}{\semicircleradius}}%
1812 }%
1813 \anchor{arc start}{%
1814 \installsemicircleparameters%
1815 \arcstartcorner%
1816 }%
1817 \anchor{arc end}{%
1818 \installsemicircleparameters%
1819 \arcendcorner%
1820 }%
1821 \anchor{chord center}{%
1822 \installsemicircleparameters%
1823 \pgfpointlineattime{0.5}{\arcstartcorner}{\arcendcorner}%
1824 }%
1825 \anchor{north}{%
1826 \installsemicircleparameters%
1827 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{90}{\semicircleradius}}%
1828 }%
1829 \anchor{south}{%
1830 \installsemicircleparameters%
1831 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{270}{\semicircleradius}}%
1832 }%
1833 \anchor{east}{%
1834 \installsemicircleparameters%
1835 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{0}{\semicircleradius}}%
1836 }%
1837 \anchor{west}{%
1838 \installsemicircleparameters%
1839 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{180}{\semicircleradius}}%
1840 }%
1841 \anchor{north west}{%
1842 \installsemicircleparameters%
1843 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{135}{\semicircleradius}}%
1844 }%
1845 \anchor{south west}{%
1846 \installsemicircleparameters%
1847 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{225}{\semicircleradius}}%
1848 }%
1849 \anchor{north east}{%
1850 \installsemicircleparameters%
1851 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{45}{\semicircleradius}}%
1852 }%
1853 \anchor{south east}{%
1854 \installsemicircleparameters%
1855 \csname pgf@anchor@semicircle@border\endcsname{\pgfqpointpolar{315}{\semicircleradius}}%
1856 }%
1857 \backgroundpath{%
1858 \installsemicircleparameters%
1859 \pgf@x\semicircleradius\relax%
1860 \advance\pgf@x-\outersep\relax%
1861 \edef\semicircleradius{\the\pgf@x}%
1862 \pgfpathmoveto{\pgfpointadd{\semicirclecenterpoint}{\pgfqpointpolar{\rotate}{\semicircleradius}}}%
1863 {%
1864 \pgftransformrotate{\rotate}%
1865 \pgfpatharc{0}{180}{\semicircleradius}%
1866 \pgfpathclose%
1867 }%
1868 }%
1869 \anchorborder{%
1870 %
1871 % Save x and y.
1872 %
1873 \edef\externalx{\the\pgf@x}%
1874 \edef\externaly{\the\pgf@y}%
1875 %
1876 % Check if a reference point has been defined (i.e. \midpoint or \basepoint).
1877 %
1878 \pgfutil@ifundefined{pgf@semicirclereferencepoint}%
1879 {\let\referencepoint\centerpoint}%
1880 {\let\referencepoint\pgf@semicirclereferencepoint}%
1881 %
1882 % Adjust the location of the external point relative to the reference point.
1883 %
1884 \referencepoint%
1885 \pgf@xa\externalx\relax%
1886 \pgf@ya\externaly\relax%
1887 \advance\pgf@xa\pgf@x%
1888 \advance\pgf@ya\pgf@y%
1889 \edef\externalx{\the\pgf@xa}%
1890 \edef\externaly{\the\pgf@ya}%
1891 %
1892 % Install the required points and angles.
1893 %
1894 \installsemicircleparameters%
1895 %
1896 % Get the angle of the external point to the \referencepoint.
1897 %
1898 \pgfmathanglebetweenpoints{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
1899 \let\externalangle\pgfmathresult%
1900 %
1901 % *Subtract* the rotation from the external angle.
1902 %
1903 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
1904 \ifdim\pgfmathresult pt<0pt\relax%
1905 \pgfmathadd@{\pgfmathresult}{360}%
1906 \fi%
1907 \let\angle\pgfmathresult%
1908 \ifx\referencepoint\basepoint%
1909 \let\angletoarcstartborder\baseangletoarcstartborder%
1910 \let\angletoarcendborder\baseangletoarcendborder%
1911 \let\angletoarcstartcorner\baseangletoarcstartcorner%
1912 \let\angletoarcendcorner\baseangletoarcendcorner%
1913 \let\centerpointdiff\basesemicirclecenterdiff%
1914 \else%
1915 \ifx\referencepoint\midpoint%
1916 \let\angletoarcstartborder\midangletoarcstartborder%
1917 \let\angletoarcendborder\midangletoarcendborder%
1918 \let\angletoarcstartcorner\midangletoarcstartcorner%
1919 \let\angletoarcendcorner\midangletoarcendcorner%
1920 \let\centerpointdiff\midsemicirclecenterdiff%
1921 \fi\fi%
1922 %
1923 % Determine if the line will cross the semicircle arc, or the chord.
1924 %
1925 \ifdim\angle pt>\angletoarcstartborder pt\relax%
1926 \let\firstpoint\pgfutil@empty%
1927 \let\secondpoint\pgfutil@empty%
1928 \else%
1929 \ifdim\angle pt>\angletoarcstartcorner pt\relax%
1930 \let\firstpoint\arcstartcorner%
1931 \let\secondpoint\arcstartborder%
1932 \else%
1933 \ifdim\angle pt>\angletoarcendcorner pt\relax%
1934 \let\firstpoint\arcendcorner%
1935 \let\secondpoint\arcstartcorner%
1936 \else%
1937 \ifdim\angle pt>\angletoarcendborder pt\relax%
1938 \let\firstpoint\arcendborder%
1939 \let\secondpoint\arcendcorner%
1940 \else%
1941 \let\firstpoint\pgfutil@empty%
1942 \let\secondpoint\pgfutil@empty%
1943 \fi%
1944 \fi%
1945 \fi%
1946 \fi%
1947 \ifx\firstpoint\pgfutil@empty
1948 %
1949 % Calculate the angle from the centre of the semicircle to the
1950 % point on the semicircle arc which intersects the line from
1951 % the external point to the reference point...
1952 %
1953 \pgfmathanglebetweenlines{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
1954 {\semicirclecenterpoint}{\referencepoint}%
1955 \pgfmathsin@{\pgfmathresult}%
1956 \let\sineangle\pgfmathresult%
1957 \pgf@x\semicircleradius\relax%
1958 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@x}}%
1959 \let\reciprocalradius\pgfmathresult%
1960 \pgf@x\centerpointdiff\relax%
1961 \pgf@x\sineangle\pgf@x%
1962 \pgf@x\reciprocalradius\pgf@x%
1963 \pgfmathasin@{\pgfmath@tonumber{\pgf@x}}%
1964 \pgf@x\pgfmathresult pt\relax%
1965 \advance\pgf@x\externalangle pt\relax%
1966 \edef\angle{\pgfmath@tonumber{\pgf@x}}%
1967 %
1968 % ...and thus the point on the border.
1969 %
1970 \pgfpointadd{\semicirclecenterpoint}{\pgfqpointpolar{\angle}{\semicircleradius}}%
1971 \else%
1972 %
1973 % Calculate the the point where the semicircle chord intersects
1974 % the line from the external point to the reference point.
1975 %
1976 \pgfpointintersectionoflines{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
1977 {\firstpoint}{\secondpoint}%
1978 \fi%
1979 }%
1980 }%
1981
1982
1983 % Keys for shape isosceles triangle
1984 %
1985 % /pgf/isosceles triangle apex angle : angle at the apex of the triangle.
1986 \pgfkeys{/pgf/.cd,
1987 isosceles triangle apex angle/.initial=45,
1988 isosceles triangle stretches/.is if=pgf@lib@sh@isosceslestrianglestretches
1989 }%
1990 \newif\ifpgf@lib@sh@isosceslestrianglestretches
1991
1992 \pgfdeclareshape{isosceles triangle}{%
1993 \savedmacro\trianglepoints{%
1994 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/isosceles triangle apex angle}}%
1995 \divide\pgf@x2\relax%
1996 \edef\halfapexangle{\pgfmath@tonumber{\pgf@x}}%
1997 \addtosavedmacro\halfapexangle%
1998 %
1999 \pgfmathtan@{\halfapexangle}%
2000 \let\tanhalfapexangle\pgfmathresult%
2001 %
2002 \pgfmathcot@{\halfapexangle}%
2003 \let\cothalfapexangle\pgfmathresult%
2004 %
2005 \pgfmathsin@{\halfapexangle}%
2006 \let\sinhalfapexangle\pgfmathresult%
2007 %
2008 \pgfmathreciprocal@{\pgfmathresult}%
2009 \let\cosechalfapexangle\pgfmathresult%
2010 %
2011 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
2012 \advance\[email protected]\wd\pgfnodeparttextbox%
2013 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
2014 \advance\[email protected]\ht\pgfnodeparttextbox%
2015 \advance\[email protected]\dp\pgfnodeparttextbox%
2016 %
2017 \ifpgfshapeborderusesincircle%
2018 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
2019 \ifdim\pgf@x<\pgf@y%
2020 \pgf@x\pgf@y%
2021 \else%
2022 \pgf@y\pgf@x%
2023 \fi%
2024 \[email protected]\pgf@x%
2025 \[email protected]\pgf@y%
2026 %
2027 \pgf@xa\pgf@x%
2028 \advance\pgf@xa\cosechalfapexangle\pgf@x%
2029 \pgf@ya\tanhalfapexangle\pgf@xa%
2030 \else%
2031 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
2032 \ifdim\pgfmathresult pt<0pt\relax%
2033 \pgfmathadd@{\pgfmathresult}{360}%
2034 \fi%
2035 \pgfmathsetcount\c@pgf@counta{+\pgfmathresult}%
2036 \advance\c@pgf@counta45\relax%
2037 \divide\c@pgf@counta90\relax%
2038 \multiply\c@pgf@counta90\relax%
2039 \edef\rotate{\the\c@pgf@counta}%
2040 \ifnum\c@pgf@counta=90\relax%
2041 \pgf@xa\pgf@x%
2042 \pgf@x\pgf@y%
2043 \pgf@y\pgf@xa%
2044 \else%
2045 \ifnum\c@pgf@counta=270\relax%
2046 \pgf@xa\pgf@x%
2047 \pgf@x\pgf@y%
2048 \pgf@y\pgf@xa%
2049 \fi%
2050 \fi%
2051 %
2052 \[email protected]\pgf@x%
2053 \pgf@ya\tanhalfapexangle\pgf@xa%
2054 \advance\pgf@xa\cothalfapexangle\pgf@y%
2055 \advance\pgf@ya\pgf@y%
2056 \fi%
2057 \addtosavedmacro\rotate%
2058 \ifdim\pgf@xa=0pt\relax%
2059 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum height}}%
2060 \fi%
2061 % Adjust for minimum height and width.
2062 %
2063 \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum width}}%
2064 \ifdim\pgf@ya<.5\pgf@yb%
2065 \ifpgf@lib@sh@isosceslestrianglestretches%
2066 \[email protected]\pgf@yb%
2067 %
2068 \pgfmathdivide@{\pgfmath@tonumber{\pgf@ya}}{\pgfmath@tonumber{\pgf@xa}}%
2069 \pgfmathatan@{\pgfmathresult}%
2070 \let\halfapexangle\pgfmathresult%
2071 %
2072 \else%
2073 \[email protected]\pgf@yb%
2074 \pgf@xa\cothalfapexangle\pgf@ya%
2075 \fi%
2076 \fi%
2077 %
2078 \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum height}}%
2079 \ifdim\pgf@xa<\pgf@xb%
2080 \ifpgf@lib@sh@isosceslestrianglestretches%
2081 \pgf@xa\pgf@xb%
2082 %
2083 \pgfmathdivide@{\pgfmath@tonumber{\pgf@ya}}{\pgfmath@tonumber{\pgf@xa}}%
2084 \pgfmathatan@{\pgfmathresult}%
2085 \let\halfapexangle\pgfmathresult%
2086 %
2087 \else%
2088 \pgf@xa\pgf@xb%
2089 \pgf@ya\tanhalfapexangle\pgf@xa%
2090 \fi%
2091 \fi%
2092 %
2093 %
2094 % Now find the ``offset height'' (h'). This is the distance from the
2095 % center of the node contents to the base of the triangle.
2096 %
2097 \ifpgfshapeborderusesincircle%
2098 %
2099 % h' = H*sin(a/2) / (1+sin(a/2))
2100 %
2101 % where:
2102 % H = the height of the triangle.
2103 % a = the apex angle.
2104 %
2105 \pgf@xc\pgf@xa%
2106 \pgfmathsin@{\halfapexangle}%
2107 \pgf@xc\pgfmathresult\pgf@xc%
2108 \pgf@yc1pt\relax%
2109 \advance\pgf@yc\pgfmathresult pt\relax%
2110 \pgfmathdivide@{\pgfmath@tonumber{\pgf@xc}}{\pgfmath@tonumber{\pgf@yc}}
2111 \pgfutil@tempdima\pgfmathresult pt\relax%
2112 \else%
2113 %
2114 % h' = 0.5*h + (0.5*(W-w)*cos(a/2) - h*sin(a/2))/(1+sin(a/2))
2115 %
2116 % where:
2117 % h = the height of the node contents.
2118 % w = the width of the node contents.
2119 % W = the width of the triangle.
2120 % a = the apex angle.
2121 %
2122 \pgf@xc\pgf@ya%
2123 \advance\pgf@xc-\pgf@y%
2124 \pgfmathcos@{\halfapexangle}%
2125 \pgf@xc\pgfmathresult\pgf@xc%
2126 \pgfmathsin@{\halfapexangle}%
2127 \advance\pgf@xc-\pgfmathresult\pgf@x%
2128 \advance\pgf@xc-\pgfmathresult\pgf@x%
2129 \pgf@yc\pgfmathresult pt\relax%
2130 \advance\pgf@yc1pt\relax%
2131 \pgfmathdivide@{\pgfmath@tonumber{\pgf@xc}}{\pgfmath@tonumber{\pgf@yc}}%
2132 \pgfutil@tempdima\pgfmathresult pt\relax%
2133 \advance\pgfutil@tempdima\pgf@x%
2134 \fi%
2135 \pgfextract@process\apex{%
2136 \pgf@y0pt%
2137 \pgf@x\pgf@xa%
2138 \advance\pgf@x-\pgfutil@tempdima%
2139 }%
2140 \addtosavedmacro\apex%
2141 %
2142 \pgfextract@process\lowerleft{%
2143 \pgf@y\pgf@ya%
2144 \pgf@x-\pgfutil@tempdima%
2145 }%
2146 \addtosavedmacro\lowerleft%
2147 %
2148 \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer xsep}}%
2149 \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/outer ysep}}%
2150 \ifdim\pgf@xb<\pgf@yb%
2151 \pgf@xb\pgf@yb%
2152 \fi%
2153 \pgfextract@process\apexanchor{%
2154 \apex%
2155 \advance\pgf@x\cosechalfapexangle\pgf@xb%
2156 }%
2157 \addtosavedmacro\apexanchor%
2158 %
2159 \pgf@yc-\halfapexangle pt\relax%
2160 \advance\pgf@yc90pt\relax%
2161 \divide\pgf@yc2\relax%
2162 \pgfmathcot@{\pgfmath@tonumber{\pgf@yc}}%
2163 \pgfextract@process\lowerleftanchor{%
2164 \lowerleft%
2165 \advance\pgf@y\pgfmathresult\pgf@xb%
2166 \advance\pgf@x-\pgf@xb%
2167 }%
2168 \addtosavedmacro\lowerleftanchor%
2169 %
2170 \pgfextract@process\lowerrightanchor{%
2171 \lowerleftanchor%
2172 \pgf@y-\pgf@y%
2173 }%
2174 \addtosavedmacro\lowerrightanchor%
2175 }%
2176 \anchor{apex}{%
2177 \trianglepoints%
2178 \pgfpointadd{\centerpoint}{%
2179 \pgfmathrotatepointaround{\apexanchor}{\pgfpointorigin}{\rotate}%
2180 }%
2181 }%
2182 \anchor{left corner}{%
2183 \trianglepoints%
2184 \pgfpointadd{\centerpoint}{%
2185 \pgfmathrotatepointaround{\lowerleftanchor}{\pgfpointorigin}{\rotate}%
2186 }%
2187 }%
2188 \anchor{right corner}{%
2189 \trianglepoints%
2190 \pgfpointadd{\centerpoint}{%
2191 \pgfmathrotatepointaround{\lowerrightanchor}{\pgfpointorigin}{\rotate}%
2192 }%
2193 }%
2194 \savedanchor\centerpoint{%
2195 \[email protected]\wd\pgfnodeparttextbox%
2196 \[email protected]\ht\pgfnodeparttextbox%
2197 \advance\[email protected]\dp\pgfnodeparttextbox%
2198 }%
2199 \savedanchor\midpoint{%
2200 \[email protected]\wd\pgfnodeparttextbox%
2201 \pgfmathsetlength\pgf@y{+.5ex}%
2202 }%
2203 \savedanchor\basepoint{%
2204 \[email protected]\wd\pgfnodeparttextbox%
2205 \pgf@y0pt%
2206 }%
2207 \anchor{center}{\centerpoint}%
2208 \anchor{mid}{\midpoint}%
2209 \anchor{mid west}{%
2210 \trianglepoints%
2211 \let\pgf@isoscelestriangle@referencepoint\midpoint%
2212 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{-1pt}{0pt}}%
2213 }%
2214 \anchor{mid east}{%
2215 \trianglepoints%
2216 \let\pgf@isoscelestriangle@referencepoint\midpoint%
2217 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{1pt}{0pt}}%
2218 }%
2219 \anchor{base}{\basepoint}%
2220 \anchor{base west}{%
2221 \trianglepoints%
2222 \let\pgf@isoscelestriangle@referencepoint\basepoint%
2223 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{-1pt}{0pt}}%
2224 }%
2225 \anchor{base east}{%
2226 \trianglepoints%
2227 \let\pgf@isoscelestriangle@referencepoint\basepoint%
2228 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{1pt}{0pt}}%
2229 }%
2230 \anchor{north}{%
2231 \trianglepoints%
2232 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{0pt}{1pt}}%
2233 }%
2234 \anchor{south}{%
2235 \trianglepoints%
2236 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{0pt}{-1pt}}%
2237 }%
2238 \anchor{east}{%
2239 \trianglepoints%
2240 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{1pt}{0pt}}%
2241 }%
2242 \anchor{west}{%
2243 \trianglepoints%
2244 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{-1pt}{0pt}}%
2245 }%
2246 \anchor{north east}{%
2247 \trianglepoints%
2248 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{1pt}{1pt}}%
2249 }%
2250 \anchor{south west}{%
2251 \trianglepoints%
2252 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{-1pt}{-1pt}}%
2253 }%
2254 \anchor{south east}{%
2255 \trianglepoints%
2256 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{1pt}{-1pt}}%
2257 }%
2258 \anchor{north west}{%
2259 \trianglepoints%
2260 \csname pgf@anchor@isosceles triangle@border\endcsname{\pgfqpoint{-1pt}{1pt}}%
2261 }%
2262 \anchor{left side}{%
2263 \trianglepoints%
2264 \pgfmathrotatepointaround{%
2265 \pgfpointadd{\pgfpointlineattime{0.5}{\lowerleftanchor}{\apexanchor}}{\centerpoint}}%
2266 {\centerpoint}{\rotate}%
2267 }%
2268 \anchor{right side}{%
2269 \trianglepoints%
2270 \pgfmathrotatepointaround{%
2271 \pgfpointadd{\pgfpointlineattime{0.5}{\lowerrightanchor}{\apexanchor}}{\centerpoint}}%
2272 {\centerpoint}{\rotate}%
2273 }%
2274 \anchor{lower side}{%
2275 \trianglepoints%
2276 \pgfmathrotatepointaround{%
2277 \pgfpointadd{\pgfpointlineattime{0.5}{\lowerleftanchor}{\lowerrightanchor}}{\centerpoint}}%
2278 {\centerpoint}{\rotate}%
2279 }%
2280 \backgroundpath{%
2281 \trianglepoints%
2282 {%
2283 \pgftransformshift{\centerpoint}%
2284 \pgftransformrotate{\rotate}%
2285 \pgfpathmoveto{\apex}%
2286 \pgfpathlineto{\lowerleft}%
2287 \pgfpathlineto{\lowerleft\pgf@y-\pgf@y}%
2288 \pgfpathclose%
2289 }%
2290 }%
2291 \anchorborder{%
2292 \pgfutil@ifundefined{pgf@isoscelestriangle@referencepoint}{\let\referencepoint\centerpoint}%
2293 {\let\referencepoint\pgf@isoscelestriangle@referencepoint}%
2294 \pgfextract@process\externalpoint{%
2295 \pgf@xa\pgf@x%
2296 \pgf@ya\pgf@y%
2297 \referencepoint%
2298 \advance\pgf@x\pgf@xa%
2299 \advance\pgf@y\pgf@ya%
2300 }%
2301 \trianglepoints%
2302 \pgfmathanglebetweenpoints{\referencepoint}{\externalpoint}%
2303 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
2304 \pgfmathmod@{\pgfmathresult}{360}%
2305 \ifdim\pgfmathresult pt<0pt\relax%
2306 \pgfmathadd@{\pgfmathresult}{360}%
2307 \fi%
2308 \let\externalangle\pgfmathresult%
2309 %
2310 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\centerpoint}{\lowerrightanchor}}%
2311 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2312 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\centerpoint}{\lowerleftanchor}}%
2313 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2314 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\centerpoint}{\apexanchor}}%
2315 \ifdim\externalangle pt>\pgfmathresult pt\relax%
2316 \let\firstpoint\apexanchor%
2317 \let\secondpoint\lowerleftanchor%
2318 \else%
2319 \let\firstpoint\apexanchor%
2320 \let\secondpoint\lowerrightanchor%
2321 \fi%
2322 \else%
2323 \let\firstpoint\lowerleftanchor%
2324 \let\secondpoint\lowerrightanchor%
2325 \fi%
2326 \else%
2327 \let\firstpoint\lowerrightanchor%
2328 \let\secondpoint\apexanchor%
2329 \fi%
2330 \pgfpointintersectionoflines{\referencepoint}{\externalpoint}%
2331 {\pgfmathrotatepointaround{\pgfpointadd{\centerpoint}{\firstpoint}}{\centerpoint}{\rotate}}%
2332 {\pgfmathrotatepointaround{\pgfpointadd{\centerpoint}{\secondpoint}}{\centerpoint}{\rotate}}%
2333 }%
2334 }%
2335
2336
2337
2338
2339 % Keys for shape kite
2340 %
2341 %
2342 \pgfkeys{/pgf/.cd,
2343 kite upper vertex angle/.initial=120,
2344 kite lower vertex angle/.initial=60,
2345 kite vertex angles/.code={%
2346 \pgfutil@in@{and}{#1}%
2347 \ifpgfutil@in@%
2348 \def\pgf@marshal##1and##2\@@{%
2349 \pgfkeys{/pgf/kite upper vertex angle={##1}}%
2350 \pgfkeys{/pgf/kite lower vertex angle={##2}}%
2351 }%
2352 \expandafter\pgf@marshal#1\@@%
2353 \else%
2354 \pgfkeys{/pgf/kite upper vertex angle={#1}}%
2355 \pgfkeys{/pgf/kite lower vertex angle={#1}}%
2356 \fi%
2357 }%
2358 }%
2359
2360 % Shape kite.
2361 %
2362 \pgfdeclareshape{kite}{%
2363 \savedmacro\installkiteparameters{%
2364 %
2365 % Get the larger of the outer sep.
2366 %
2367 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
2368 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
2369 \ifdim\pgf@x<\pgf@y%
2370 \pgf@x\pgf@y%
2371 \fi%
2372 \edef\outersep{\the\pgf@x}%
2373 %
2374 % Calculate the centre, base and mid points of the node.
2375 %
2376 \pgfextract@process\centerpoint{%
2377 \[email protected]\wd\pgfnodeparttextbox%
2378 \[email protected]\ht\pgfnodeparttextbox%
2379 \advance\[email protected]\dp\pgfnodeparttextbox%
2380 }%
2381 \pgfextract@process\basepoint{%
2382 \[email protected]\wd\pgfnodeparttextbox%
2383 \pgf@y0pt\relax%
2384 }%
2385 \pgfextract@process\midpoint{%
2386 \[email protected]\wd\pgfnodeparttextbox%
2387 \pgfmathsetlength\pgf@y{+.5ex}%
2388 }%
2389 %
2390 % Halve the vertex angles.
2391 %
2392 \pgfmathdivide{\pgfkeysvalueof{/pgf/kite upper vertex angle}}{2}%
2393 \let\halfuppervertexangle\pgfmathresult%
2394 \pgfmathdivide{\pgfkeysvalueof{/pgf/kite lower vertex angle}}{2}%
2395 \let\halflowervertexangle\pgfmathresult%
2396 %
2397 % Get the node dimensions.
2398 %
2399 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
2400 \advance\[email protected]\wd\pgfnodeparttextbox%
2401 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
2402 \advance\[email protected]\ht\pgfnodeparttextbox%
2403 \advance\[email protected]\dp\pgfnodeparttextbox%
2404 \ifpgfshapeborderusesincircle%
2405 %
2406 % Get the rotation.
2407 %
2408 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
2409 %
2410 % Get the radius of the incircle.
2411 %
2412 \ifdim\pgf@x<\pgf@y%
2413 \pgf@x\pgf@y%
2414 \fi%
2415 \[email protected]\pgf@x%
2416 %
2417 % Get the distances from the upper and lower vertices
2418 % to the center of the incircle.
2419 %
2420 \pgfmathsin@{\halfuppervertexangle}%
2421 \let\sinehalfuppervertexangle\pgfmathresult%
2422 \pgfmathreciprocal@{\pgfmathresult}%
2423 \let\cosechalfuppervertexangle\pgfmathresult%
2424 \pgf@ya\pgfmathresult\pgf@x%
2425 \pgfmathsin@{\halflowervertexangle}%
2426 \let\sinehalflowervertexangle\pgfmathresult%
2427 \pgfmathreciprocal@{\pgfmathresult}%
2428 \pgf@yb\pgfmathresult\pgf@x%
2429 %
2430 % Now calculate vertical offset (yc) between the center of
2431 % the incircle, and the intersection of the kite diagonals.
2432 %
2433 % yc = x * cosec(a/2) - x * cot(a/2) * (sin(a/2) + sin(b/2)) * cosec(a/2 + b/2)
2434 %
2435 % where:
2436 % x = the incircle radius.
2437 % a = the upper vertex angle.
2438 % b = the lower vertex angle.
2439 %
2440 \pgf@yc\pgf@x%
2441 \pgfmathadd@{\halfuppervertexangle}{\halflowervertexangle}%
2442 \pgfmathcosec@{\pgfmathresult}%
2443 \pgf@yc\pgfmathresult\pgf@yc%
2444 \pgfmathadd@{\sinehalfuppervertexangle}{\sinehalflowervertexangle}%
2445 \pgf@yc\pgfmathresult\pgf@yc%
2446 \pgfmathcos@{\halfuppervertexangle}%
2447 \pgf@yc\pgfmathresult\pgf@yc%
2448 \pgf@yc-\cosechalfuppervertexangle\pgf@yc%
2449 \advance\pgf@yc\cosechalfuppervertexangle\pgf@x%
2450 \edef\deltay{\the\pgf@yc}%
2451 %
2452 % Now calculate the height of the kite...
2453 %
2454 \advance\pgf@ya-\pgf@yc%
2455 %
2456 % ...and the depth.
2457 %
2458 \advance\pgf@yb\pgf@yc%
2459 %
2460 % Get the half width of the widest part of the kite.
2461 %
2462 \pgfmathtan@{\halfuppervertexangle}%
2463 \pgf@xa\pgfmathresult\pgf@ya%
2464 \else%
2465 \multiply\pgf@x2\relax%
2466 \multiply\pgf@y2\relax%
2467 %
2468 % Get the rotation (with rounding).
2469 %
2470 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
2471 \afterassignment\pgfmath@gobbletilpgfmath@%
2472 \expandafter\c@pgf@counta\pgfmathresult\relax\pgfmath@%
2473 \advance\c@pgf@counta45\relax%
2474 \divide\c@pgf@counta90\relax%
2475 \multiply\c@pgf@counta90\relax%
2476 \ifnum\c@pgf@counta<0\relax%
2477 \advance\c@pgf@counta360\relax%
2478 \fi%
2479 \edef\rotate{\the\c@pgf@counta}%
2480 %
2481 % Calculate the width and height of the node
2482 % contents, according to any border rotation.
2483 %
2484 \ifnum\c@pgf@counta=90\relax%
2485 \pgf@xc\pgf@x%
2486 \pgf@x\pgf@y%
2487 \pgf@y\pgf@xc%
2488 \else%
2489 \ifnum\c@pgf@counta=270\relax%
2490 \pgf@xc\pgf@x%
2491 \pgf@x\pgf@y%
2492 \pgf@y\pgf@xc%
2493 \fi%
2494 \fi%
2495 %
2496 % The node contents (total height y) extends a distance ya into the
2497 % upper isosceles triangle of the kite and a distance yb into the
2498 % lower isosceles triangle. Thus, the following relationships hold:
2499 %
2500 % ya/yb = tan(b/2)/tan(a/2)
2501 %
2502 % and y = ya + yb
2503 %
2504 % so ya = y * sin(a/2 + b/2) / (cos(a/2) * sin(b/2))
2505 %
2506 % where:
2507 % a = upper vertex angle.
2508 % b = lower vertex angle.
2509 %
2510 \pgfmathadd@{\halfuppervertexangle}{\halflowervertexangle}%
2511 \pgfmathsin@{\pgfmathresult}%
2512 \pgfmathreciprocal@{\pgfmathresult}%
2513 \pgf@ya\pgfmathresult\pgf@y%
2514 \pgfmathcos@{\halfuppervertexangle}%
2515 \pgf@ya\pgfmathresult\pgf@ya%
2516 \pgfmathsin@{\halflowervertexangle}%
2517 \pgf@ya\pgfmathresult\pgf@ya%
2518 \pgf@yb\pgf@y%
2519 \advance\pgf@yb-\pgf@ya%
2520 %
2521 % The vertical offset between the center of the node, and
2522 % the intersection of the kite diagonals is given by:
2523 %
2524 % yc = y/2 - ya
2525 %
2526 \[email protected]\pgf@y%
2527 \advance\pgf@yc-\pgf@ya%
2528 \edef\deltay{\the\pgf@yc}%
2529 %
2530 % Get the half width of the widest part of the kite.
2531 %
2532 \pgfmathtan@{\halfuppervertexangle}%
2533 \[email protected]\pgf@x%
2534 \advance\pgf@xa\pgfmathresult\pgf@ya%
2535 %
2536 % Now calculate the height of the kite...
2537 %
2538 \[email protected]\pgf@x%
2539 \pgfmathreciprocal@{\pgfmathresult}%
2540 \advance\pgf@ya\pgfmathresult\pgf@xb%
2541 %
2542 % ...and the depth.
2543 %
2544 \pgfmathtan@{\halflowervertexangle}%
2545 \pgfmathreciprocal@{\pgfmathresult}%
2546 \advance\pgf@yb\pgfmathresult\pgf@xb%
2547 \fi%
2548 %
2549 % Take into account minimum height and width.
2550 %
2551 % ya is the kite height.
2552 % yb is the kite depth.
2553 % xa is the kite (half) width.
2554 %
2555 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/minimum height}}%
2556 \pgf@y\pgf@ya%
2557 \advance\pgf@y\pgf@yb%
2558 \ifdim\pgf@y<\pgf@yc%
2559 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@y}}%
2560 \pgf@yc\pgfmathresult\pgf@yc%
2561 \pgf@xa\pgfmath@tonumber{\pgf@yc}\pgf@xa%
2562 \pgf@ya\pgfmath@tonumber{\pgf@yc}\pgf@ya%
2563 \pgf@yb\pgfmath@tonumber{\pgf@yc}\pgf@yb%
2564 \fi%
2565 \[email protected]\pgf@xa%
2566 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum width}}%
2567 \ifdim\pgf@x<\pgf@xc%
2568 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@x}}%
2569 \pgf@xc\pgfmathresult\pgf@xc%
2570 \pgf@xa\pgfmath@tonumber{\pgf@xc}\pgf@xa%
2571 \pgf@ya\pgfmath@tonumber{\pgf@xc}\pgf@ya%
2572 \pgf@yb\pgfmath@tonumber{\pgf@xc}\pgf@yb%
2573 \fi%
2574 \edef\kitehalfwidth{\the\pgf@xa}%
2575 \edef\kiteheight{\the\pgf@ya}%
2576 \edef\kitedepth{\the\pgf@yb}%
2577 %
2578 % Calculate the basic points on the kite (for the background path).
2579 %
2580 \pgfextract@process\toppoint{%
2581 \centerpoint%
2582 \advance\pgf@y\deltay\relax%
2583 \advance\pgf@y\kiteheight%
2584 }%
2585 \pgfextract@process\bottompoint{%
2586 \centerpoint%
2587 \advance\pgf@y\deltay\relax%
2588 \advance\pgf@y-\kitedepth%
2589 }%
2590 \pgfextract@process\leftpoint{%
2591 \centerpoint%
2592 \advance\pgf@y\deltay\relax%
2593 \advance\pgf@x-\kitehalfwidth%
2594 }%
2595 \pgfextract@process\rightpoint{%
2596 \centerpoint%
2597 \advance\pgf@y\deltay\relax%
2598 \advance\pgf@x\kitehalfwidth%
2599 }%
2600 %
2601 % Now calculate the miter length. At the top...
2602 %
2603 \pgfmathsin@{\halfuppervertexangle}%
2604 \pgfmathreciprocal@{\pgfmathresult}%
2605 \pgf@y\outersep\relax%
2606 \pgf@y\pgfmathresult\pgf@y%
2607 \edef\topmiter{\the\pgf@y}%
2608 %
2609 % ...at the bottom...
2610 %
2611 \pgfmathsin@{\halflowervertexangle}%
2612 \pgfmathreciprocal@{\pgfmathresult}%
2613 \pgf@y\outersep\relax%
2614 \pgf@y\pgfmathresult\pgf@y%
2615 \edef\bottommiter{\the\pgf@y}%
2616 %
2617 % ...to the right...
2618 %
2619 \pgfmathsubtract@{180}{\halflowervertexangle}%
2620 \pgfmathsubtract@{\pgfmathresult}{\halfuppervertexangle}%
2621 \pgfmathdivide@{\pgfmathresult}{2}%
2622 \pgfmathsin@{\pgfmathresult}%
2623 \pgfmathreciprocal@{\pgfmathresult}%
2624 \pgf@xa\outersep\relax%
2625 \pgf@xa\pgfmathresult\pgf@xa%
2626 \pgfmathsubtract@{\halfuppervertexangle}{\halflowervertexangle}%
2627 \pgfmathdivide@{\pgfmathresult}{2}%
2628 \let\angle\pgfmathresult%
2629 \pgfextract@process\rightmiter{%
2630 \pgfqpointpolar{\angle}{\the\pgf@xa}%
2631 }%
2632 %
2633 % ...and to the left.
2634 %
2635 \pgfmathsubtract@{180}{\angle}%
2636 \let\angle\pgfmathresult%
2637 \pgfextract@process\leftmiter{%
2638 \pgfqpointpolar{\angle}{\the\pgf@xa}%
2639 }%
2640 %
2641 % Create the border points.
2642 %
2643 \pgfextract@process\topborderpoint{%
2644 \toppoint%
2645 \advance\pgf@y\topmiter\relax%
2646 }%
2647 \pgfextract@process\bottomborderpoint{%
2648 \bottompoint%
2649 \advance\pgf@y-\bottommiter\relax%
2650 }%
2651 \pgfextract@process\leftborderpoint{%
2652 \leftpoint%
2653 \pgf@xa\pgf@x%
2654 \pgf@ya\pgf@y%
2655 \leftmiter%
2656 \advance\pgf@x\pgf@xa%
2657 \advance\pgf@y\pgf@ya%
2658 }%
2659 \pgfextract@process\rightborderpoint{%
2660 \rightpoint%
2661 \pgf@xa\pgf@x%
2662 \pgf@ya\pgf@y%
2663 \rightmiter%
2664 \advance\pgf@x\pgf@xa%
2665 \advance\pgf@y\pgf@ya%
2666 }%
2667 %
2668 % Get the angle from the \centerpoint to the *unrotated points*.
2669 %
2670 \pgfmathanglebetweenpoints{\centerpoint}{\topborderpoint}%
2671 \let\angletotoppoint\pgfmathresult%
2672 \pgfmathanglebetweenpoints{\centerpoint}{\leftborderpoint}%
2673 \let\angletoleftpoint\pgfmathresult%
2674 \pgfmathanglebetweenpoints{\centerpoint}{\bottomborderpoint}%
2675 \let\angletobottompoint\pgfmathresult%
2676 \pgfmathanglebetweenpoints{\centerpoint}{\rightborderpoint}%
2677 \let\angletorightpoint\pgfmathresult%
2678 %
2679 % ...from the *inversely rotated* \basepoint...
2680 %
2681 \pgfextract@process\rotatedbasepoint{%
2682 \pgfmathrotatepointaround{\basepoint}{\centerpoint}{-\rotate}%
2683 }%
2684 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\topborderpoint}%
2685 \let\baseangletotoppoint\pgfmathresult%
2686 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\leftborderpoint}%
2687 \let\baseangletoleftpoint\pgfmathresult%
2688 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\bottomborderpoint}%
2689 \let\baseangletobottompoint\pgfmathresult%
2690 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\rightborderpoint}%
2691 \let\baseangletorightpoint\pgfmathresult%
2692 %
2693 % ...and from the *inversely rotated* \midpoint.
2694 %
2695 \pgfextract@process\rotatedmidpoint{%
2696 \pgfmathrotatepointaround{\midpoint}{\centerpoint}{-\rotate}%
2697 }%
2698 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\topborderpoint}%
2699 \let\midangletotoppoint\pgfmathresult%
2700 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\leftborderpoint}%
2701 \let\midangletoleftpoint\pgfmathresult%
2702 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\bottomborderpoint}%
2703 \let\midangletobottompoint\pgfmathresult%
2704 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\rightborderpoint}%
2705 \let\midangletorightpoint\pgfmathresult%
2706 %
2707 % Calculate a radius guaranteed to be outside the kite.
2708 %
2709 \pgfextractx\pgf@xa{\pgfpointdiff{\leftborderpoint}{\rightborderpoint}}%
2710 \ifdim\pgf@xa<0pt\relax%
2711 \pgf@xa-\pgf@xa%
2712 \fi%
2713 \pgfextracty\pgf@ya{\pgfpointdiff{\topborderpoint}{\bottomborderpoint}}%
2714 \ifdim\pgf@ya<0pt\relax%
2715 \pgf@ya-\pgf@ya%
2716 \fi%
2717 \ifdim\pgf@ya>\pgf@xa%
2718 \edef\externalradius{\the\pgf@ya}%
2719 \else%
2720 \edef\externalradius{\the\pgf@xa}%
2721 \fi%
2722 %
2723 % Now rotate the points...
2724 %
2725 \pgfextract@process\toppoint{%
2726 \pgfmathrotatepointaround{\toppoint}{\centerpoint}{\rotate}%
2727 }%
2728 \pgfextract@process\bottompoint{%
2729 \pgfmathrotatepointaround{\bottompoint}{\centerpoint}{\rotate}%
2730 }%
2731 \pgfextract@process\leftpoint{%
2732 \pgfmathrotatepointaround{\leftpoint}{\centerpoint}{\rotate}%
2733 }%
2734 \pgfextract@process\rightpoint{%
2735 \pgfmathrotatepointaround{\rightpoint}{\centerpoint}{\rotate}%
2736 }%
2737 %
2738 % ...and the border points.
2739 %
2740 \pgfextract@process\topborderpoint{%
2741 \pgfmathrotatepointaround{\topborderpoint}{\centerpoint}{\rotate}%
2742 }%
2743 \pgfextract@process\bottomborderpoint{%
2744 \pgfmathrotatepointaround{\bottomborderpoint}{\centerpoint}{\rotate}%
2745 }%
2746 \pgfextract@process\leftborderpoint{%
2747 \pgfmathrotatepointaround{\leftborderpoint}{\centerpoint}{\rotate}%
2748 }%
2749 \pgfextract@process\rightborderpoint{%
2750 \pgfmathrotatepointaround{\rightborderpoint}{\centerpoint}{\rotate}%
2751 }%
2752 %
2753 % Now save it all.
2754 %
2755 \addtosavedmacro{\rotate}%
2756 \addtosavedmacro{\externalradius}%
2757 %
2758 \addtosavedmacro\toppoint%
2759 \addtosavedmacro\bottompoint%
2760 \addtosavedmacro\leftpoint%
2761 \addtosavedmacro\rightpoint%
2762 %
2763 \addtosavedmacro\topborderpoint%
2764 \addtosavedmacro\bottomborderpoint%
2765 \addtosavedmacro\leftborderpoint%
2766 \addtosavedmacro\rightborderpoint%
2767 %
2768 \addtosavedmacro\angletotoppoint%
2769 \addtosavedmacro\angletobottompoint%
2770 \addtosavedmacro\angletoleftpoint%
2771 \addtosavedmacro\angletorightpoint%
2772 %
2773 \addtosavedmacro\baseangletotoppoint%
2774 \addtosavedmacro\baseangletobottompoint%
2775 \addtosavedmacro\baseangletoleftpoint%
2776 \addtosavedmacro\baseangletorightpoint%
2777 %
2778 \addtosavedmacro\midangletotoppoint%
2779 \addtosavedmacro\midangletobottompoint%
2780 \addtosavedmacro\midangletoleftpoint%
2781 \addtosavedmacro\midangletorightpoint%
2782 }%
2783 \savedanchor\centerpoint{%
2784 \[email protected]\wd\pgfnodeparttextbox%
2785 \[email protected]\ht\pgfnodeparttextbox%
2786 \advance\[email protected]\dp\pgfnodeparttextbox%
2787 }%
2788 \savedanchor\basepoint{%
2789 \[email protected]\wd\pgfnodeparttextbox%
2790 \pgf@y0pt\relax%
2791 }%
2792 \savedanchor\midpoint{%
2793 \[email protected]\wd\pgfnodeparttextbox%
2794 \pgfmathsetlength\pgf@y{+.5ex}%
2795 }%
2796 \anchor{center}{\centerpoint}%
2797 \anchor{base}{\basepoint}%
2798 \anchor{base west}{%
2799 \installkiteparameters%
2800 \let\pgf@kiteanchorborderreferencepoint\basepoint%
2801 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
2802 }%
2803 \anchor{base east}{%
2804 \installkiteparameters%
2805 \let\pgf@kiteanchorborderreferencepoint\basepoint%
2806 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
2807 }%
2808 \anchor{mid}{\midpoint}%
2809 \anchor{mid west}{%
2810 \installkiteparameters%
2811 \let\pgf@kiteanchorborderreferencepoint\midpoint%
2812 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
2813 }%
2814 \anchor{mid east}{%
2815 \installkiteparameters%
2816 \let\pgf@kiteanchorborderreferencepoint\midpoint%
2817 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
2818 }%
2819 \anchor{north}{%
2820 \installkiteparameters%
2821 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{0pt}{\externalradius}}%
2822 }%
2823 \anchor{south}{%
2824 \installkiteparameters%
2825 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{0pt}{-\externalradius}}%
2826 }%
2827 \anchor{east}{%
2828 \installkiteparameters%
2829 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
2830 }%
2831 \anchor{west}{%
2832 \installkiteparameters%
2833 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
2834 }%
2835 \anchor{north east}{%
2836 \installkiteparameters%
2837 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{\externalradius}{\externalradius}}%
2838 }%
2839 \anchor{south west}{%
2840 \installkiteparameters%
2841 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{-\externalradius}{-\externalradius}}%
2842 }%
2843 \anchor{south east}{%
2844 \installkiteparameters%
2845 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{\externalradius}{-\externalradius}}%
2846 }%
2847 \anchor{north west}{%
2848 \installkiteparameters%
2849 \csname pgf@anchor@kite@border\endcsname{\pgfqpoint{-\externalradius}{\externalradius}}%
2850 }%
2851 \anchor{upper vertex}{%
2852 \installkiteparameters%
2853 \topborderpoint}%
2854 \anchor{lower vertex}{%
2855 \installkiteparameters%
2856 \bottomborderpoint}%
2857 \anchor{left vertex}{%
2858 \installkiteparameters%
2859 \leftborderpoint}%
2860 \anchor{right vertex}{%
2861 \installkiteparameters%
2862 \rightborderpoint}%
2863 \anchor{upper left side}{%
2864 \installkiteparameters%
2865 \pgfpointlineattime{0.5}{\topborderpoint}{\leftborderpoint}}%
2866 \anchor{lower left side}{%
2867 \installkiteparameters%
2868 \pgfpointlineattime{0.5}{\bottomborderpoint}{\leftborderpoint}}%
2869 \anchor{upper right side}{%
2870 \installkiteparameters%
2871 \pgfpointlineattime{0.5}{\topborderpoint}{\rightborderpoint}}%
2872 \anchor{lower right side}{%
2873 \installkiteparameters%
2874 \pgfpointlineattime{0.5}{\bottomborderpoint}{\rightborderpoint}}%
2875 \backgroundpath{%
2876 \installkiteparameters%
2877 \pgfpathmoveto{\toppoint}%
2878 \pgfpathlineto{\leftpoint}%
2879 \pgfpathlineto{\bottompoint}%
2880 \pgfpathlineto{\rightpoint}%
2881 \pgfpathclose%
2882 }%
2883 \anchorborder{%
2884 %
2885 % Save x and y.
2886 %
2887 \edef\externalx{\the\pgf@x}%
2888 \edef\externaly{\the\pgf@y}%
2889 %
2890 % This allows anchors base east, base west, mid east and mid west,
2891 % to redefine the `center' of the node to correctly calculate the
2892 % border points.
2893 %
2894 \pgfutil@ifundefined{pgf@kiteanchorborderreferencepoint}%
2895 {\let\referencepoint\centerpoint}%
2896 {\let\referencepoint\pgf@kiteanchorborderreferencepoint}%
2897 %
2898 % Adjust the location of the external
2899 % point relative to the reference point.
2900 %
2901 \referencepoint%
2902 \pgf@xa\externalx\relax%
2903 \pgf@ya\externaly\relax%
2904 \advance\pgf@xa\pgf@x%
2905 \advance\pgf@ya\pgf@y%
2906 \edef\externalx{\the\pgf@xa}%
2907 \edef\externaly{\the\pgf@ya}%
2908 %
2909 % Install the required points and angles.
2910 %
2911 \installkiteparameters%
2912 %
2913 % Get the angle of the external point relative to \referencepoint.
2914 %
2915 \pgfmathanglebetweenpoints{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
2916 %
2917 % *Subtract* the rotation from the external angle.
2918 %
2919 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
2920 \ifdim\pgfmathresult pt<0pt\relax%
2921 \pgfmathadd@{\pgfmathresult}{360}%
2922 \fi%
2923 \let\externalangle\pgfmathresult%
2924 \ifx\referencepoint\basepoint%
2925 \let\angletotoppoint\baseangletotoppoint%
2926 \let\angletobottompoint\baseangletobottompoint%
2927 \let\angletoleftpoint\baseangletoleftpoint%
2928 \let\angletorightpoint\baseangletorightpoint%
2929 \else%
2930 \ifx\referencepoint\midpoint%
2931 \let\angletotoppoint\midangletotoppoint%
2932 \let\angletobottompoint\midangletobottompoint%
2933 \let\angletoleftpoint\midangletoleftpoint%
2934 \let\angletorightpoint\midangletorightpoint%
2935 \fi\fi%
2936 %
2937 % Depending on the rotation, the angle to \rightborderpoint
2938 % may be smaller than the angle to \topborderpoint.
2939 %
2940 \ifdim\angletorightpoint pt<\angletotoppoint pt\relax%
2941 \ifdim\externalangle pt<\angletorightpoint pt\relax%
2942 \let\firstpoint\rightborderpoint%
2943 \let\secondpoint\bottomborderpoint%
2944 \else%
2945 \ifdim\externalangle pt<\angletotoppoint pt\relax%
2946 \let\firstpoint\rightborderpoint%
2947 \let\secondpoint\topborderpoint%
2948 \else%
2949 \ifdim\externalangle pt<\angletoleftpoint pt\relax%
2950 \let\firstpoint\topborderpoint%
2951 \let\secondpoint\leftborderpoint%
2952 \else%
2953 \ifdim\externalangle pt<\angletobottompoint pt\relax%
2954 \let\firstpoint\leftborderpoint%
2955 \let\secondpoint\bottomborderpoint%
2956 \else%
2957 \let\firstpoint\rightborderpoint%
2958 \let\secondpoint\bottomborderpoint%
2959 \fi%
2960 \fi%
2961 \fi%
2962 \fi%
2963 \else%
2964 \ifdim\externalangle pt<\angletotoppoint pt\relax%
2965 \let\firstpoint\rightborderpoint%
2966 \let\secondpoint\topborderpoint%
2967 \else%
2968 \ifdim\externalangle pt<\angletoleftpoint pt\relax%
2969 \let\firstpoint\leftborderpoint%
2970 \let\secondpoint\topborderpoint%
2971 \else%
2972 \ifdim\externalangle pt<\angletobottompoint pt\relax%
2973 \let\firstpoint\bottomborderpoint%
2974 \let\secondpoint\leftborderpoint%
2975 \else%
2976 \ifdim\externalangle pt<\angletorightpoint pt\relax%
2977 \let\firstpoint\rightborderpoint%
2978 \let\secondpoint\bottomborderpoint%
2979 \else%
2980 \let\firstpoint\rightborderpoint%
2981 \let\secondpoint\topborderpoint%
2982 \fi%
2983 \fi%
2984 \fi%
2985 \fi%
2986 \fi%
2987 \pgfpointintersectionoflines{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
2988 {\firstpoint}{\secondpoint}%
2989 }%
2990 }%
2991
2992
2993
2994
2995 % Keys for shape dart.
2996 %
2997 %
2998
2999 \pgfkeys{/pgf/.cd,
3000 dart tip angle/.initial=45,
3001 dart tail angle/.initial=135,
3002 }%
3003
3004 % Shape dart.
3005 %
3006 \pgfdeclareshape{dart}{%
3007 \savedmacro\installdartparameters{%
3008 %
3009 % Get the halved angles (more useful).
3010 %
3011 \pgfmathdivide{\pgfkeysvalueof{/pgf/dart tip angle}}{2}%
3012 \let\halftipangle\pgfmathresult%
3013 \pgfmathdivide{\pgfkeysvalueof{/pgf/dart tail angle}}{2}%
3014 \let\halftailangle\pgfmathresult%
3015 %
3016 % Calculate some common results.
3017 %
3018 \pgfmathcot@{\halftipangle}%
3019 \let\cothalftipangle\pgfmathresult%
3020 %
3021 % Get the larger of the outer sep.
3022 %
3023 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
3024 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
3025 \ifdim\pgf@x<\pgf@y%
3026 \pgf@x\pgf@y%
3027 \fi%
3028 \edef\outersep{\the\pgf@x}%
3029 %
3030 % Calculate the centre, base and mid points of the node.
3031 %
3032 \pgfextract@process\centerpoint{%
3033 \[email protected]\wd\pgfnodeparttextbox%
3034 \[email protected]\ht\pgfnodeparttextbox%
3035 \advance\[email protected]\dp\pgfnodeparttextbox%
3036 }%
3037 \pgfextract@process\basepoint{%
3038 \[email protected]\wd\pgfnodeparttextbox%
3039 \pgf@y0pt\relax%
3040 }%
3041 \pgfextract@process\midpoint{%
3042 \[email protected]\wd\pgfnodeparttextbox%
3043 \pgfmathsetlength\pgf@y{+.5ex}%
3044 }%
3045 %
3046 % Get the (halved) dimension of the node.
3047 %
3048 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
3049 \advance\[email protected]\wd\pgfnodeparttextbox%
3050 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
3051 \advance\[email protected]\ht\pgfnodeparttextbox%
3052 \advance\[email protected]\dp\pgfnodeparttextbox%
3053 %
3054 % Get the length of the dart tip.
3055 %
3056 \ifpgfshapeborderusesincircle%
3057 %
3058 % Get the (unrounded) rotation.
3059 %
3060 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
3061 %
3062 % Get the radius of the incircle.
3063 %
3064 \ifdim\pgf@x<\pgf@y%
3065 \pgf@x\pgf@y%
3066 \fi%
3067 \[email protected]\pgf@x%
3068 %
3069 % Calculate the length of the dart tip.
3070 %
3071 \pgf@xa\cothalftipangle\pgf@x%
3072 \advance\pgf@xa\pgf@x%
3073 \else%
3074 %
3075 % Get the rotation (with rounding).
3076 %
3077 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
3078 \afterassignment\pgfmath@gobbletilpgfmath@%
3079 \expandafter\c@pgf@counta\pgfmathresult\relax\pgfmath@%
3080 \advance\c@pgf@counta45\relax%
3081 \divide\c@pgf@counta90\relax%
3082 \multiply\c@pgf@counta90\relax%
3083 \ifnum\c@pgf@counta<0\relax%
3084 \advance\c@pgf@counta360\relax%
3085 \fi%
3086 \edef\rotate{\the\c@pgf@counta}%
3087 %
3088 % Flip the width and height of the node contents,
3089 % according to the appropriate border rotation.
3090 %
3091 \ifnum\c@pgf@counta=90\relax%
3092 \pgf@xc\pgf@x%
3093 \pgf@x\pgf@y%
3094 \pgf@y\pgf@xc%
3095 \else%
3096 \ifnum\c@pgf@counta=270\relax%
3097 \pgf@xc\pgf@x%
3098 \pgf@x\pgf@y%
3099 \pgf@y\pgf@xc%
3100 \fi%
3101 \fi%
3102 %
3103 % Calculate the length of the dart tip.
3104 %
3105 \pgf@xa\cothalftipangle\pgf@y%
3106 \advance\[email protected]\pgf@x%
3107 \fi%
3108 %
3109 % Get the (half) separation of the dart tails.
3110 %
3111 \pgfmathsubtract@{\halftailangle}{\halftipangle}%
3112 \pgfmathcosec@{\pgfmathresult}%
3113 \pgf@ya\pgfmathresult\pgf@xa%
3114 \pgfmathsin@{\halftipangle}%
3115 \pgf@ya\pgfmathresult\pgf@ya%
3116 \pgfmathcos@{\halftipangle}%
3117 \pgf@ya\pgfmathresult\pgf@ya%
3118 %
3119 % Get the total length of the dart...
3120 %
3121 \pgf@xb\cothalftipangle\pgf@ya%
3122 %
3123 % and hence the length of the tails.
3124 %
3125 \pgf@xc-\pgf@xa%
3126 \advance\pgf@xc\pgf@xb%
3127 %
3128 % Adjust for minimum height (length of the dart).
3129 %
3130 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum height}}%
3131 \ifdim\pgf@xb<\pgf@y%
3132 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@xb}}%
3133 \pgf@y\pgfmathresult\pgf@y%
3134 \pgf@xa\pgfmath@tonumber{\pgf@y}\pgf@xa%
3135 \pgf@xc\pgfmath@tonumber{\pgf@y}\pgf@xc%
3136 \pgf@ya\pgfmath@tonumber{\pgf@y}\pgf@ya%
3137 \pgf@x\pgfmath@tonumber{\pgf@y}\pgf@x%
3138 \fi%
3139 %
3140 % Adjust for minimum width (tail separation length).
3141 %
3142 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum width}}%
3143 \[email protected]\pgf@y%
3144 \ifdim\pgf@ya<\pgf@y%
3145 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@ya}}%
3146 \pgf@ya\pgf@y%
3147 \pgf@y\pgfmathresult\pgf@y%
3148 \pgf@xa\pgfmath@tonumber{\pgf@y}\pgf@xa%
3149 \pgf@xc\pgfmath@tonumber{\pgf@y}\pgf@xc%
3150 \pgf@x\pgfmath@tonumber{\pgf@y}\pgf@x%
3151 \fi%
3152 \edef\dartlength{\the\pgf@xa}%
3153 \edef\deltax{\the\pgf@x}%
3154 \edef\taillength{\the\pgf@xc}%
3155 \edef\halftailseparation{\the\pgf@ya}
3156 %
3157 % Create the basic points on the dart (for the background path).
3158 %
3159 \pgfextract@process\tippoint{%
3160 \centerpoint%
3161 \advance\pgf@x\dartlength\relax%
3162 \advance\pgf@x-\deltax\relax%
3163 }%
3164 \pgfextract@process\tailcenterpoint{%
3165 \centerpoint%
3166 \advance\pgf@x-\deltax\relax%
3167 }%
3168 \pgfextract@process\lefttailpoint{%
3169 \centerpoint%
3170 \advance\pgf@x-\deltax\relax%
3171 \advance\pgf@x-\taillength\relax%
3172 \advance\pgf@y\halftailseparation\relax%
3173 }%
3174 \pgfextract@process\righttailpoint{%
3175 \centerpoint%
3176 \advance\pgf@x-\deltax\relax%
3177 \advance\pgf@x-\taillength\relax%
3178 \advance\pgf@y-\halftailseparation\relax%
3179 }%
3180 %
3181 % Calculate the miter vectors. At the dart tip...
3182 %
3183 \pgfextract@process\tipmiter{%
3184 \pgfmathcosec@{\halftipangle}%
3185 \pgf@x\outersep\relax%
3186 \pgf@x\pgfmathresult\pgf@x%
3187 \pgf@y0pt\relax%
3188 }%
3189 %
3190 % ...at the tail center...
3191 %
3192 \pgfextract@process\tailcentermiter{%
3193 \pgfmathcosec@{\halftailangle}%
3194 \pgf@x-\outersep\relax%
3195 \pgf@x\pgfmathresult\pgf@x%
3196 \pgf@y0pt\relax%
3197 }%
3198 %
3199 % ...at the left tail...
3200 %
3201 \pgfmathsubtract@{\halftailangle}{\halftipangle}%
3202 \pgfmathdivide@{\pgfmathresult}{2}%
3203 \let\angle\pgfmathresult%
3204 \pgfmathcosec@{\pgfmathresult}%
3205 \pgf@x\outersep\relax%
3206 \pgf@x\pgfmathresult\pgf@x%
3207 \pgfmathadd@{\angle}{90}%
3208 \pgfmathsubtract{\pgfmathresult}{\halftailangle}%
3209 \pgfmathsincos@{\pgfmathresult}%
3210 \pgf@ya\pgfmathresultx\pgf@x%
3211 \pgf@xa\pgfmathresulty\pgf@x%
3212 \pgfextract@process\lefttailmiter{%
3213 \pgf@x-\pgf@xa%
3214 \pgf@y\pgf@ya%
3215 }%
3216 %
3217 % ...and the right tail.
3218 %
3219 \pgfextract@process\righttailmiter{%
3220 \pgf@x-\pgf@xa%
3221 \pgf@y-\pgf@ya%
3222 }%
3223 %
3224 % Create the border points.
3225 %
3226 \pgfextract@process\tipborderpoint{%
3227 \pgfpointadd{\tippoint}{\tipmiter}
3228 }%
3229 \pgfextract@process\tailcenterborderpoint{%
3230 \pgfpointadd{\tailcenterpoint}{\tailcentermiter}%
3231 }%
3232 \pgfextract@process\lefttailborderpoint{%
3233 \pgfpointadd{\lefttailpoint}{\lefttailmiter}%
3234 }%
3235 \pgfextract@process\righttailborderpoint{%
3236 \pgfpointadd{\righttailpoint}{\righttailmiter}%
3237 }%
3238 %
3239 % Calculate the angles between the centerpoint
3240 % and the *unrotated* borderpoints.
3241 %
3242 \pgfmathanglebetweenpoints{\centerpoint}{\tipborderpoint}%
3243 \let\angletotip\pgfmathresult%
3244 \pgfmathanglebetweenpoints{\centerpoint}{\tailcenterborderpoint}%
3245 \let\angletotailcenter\pgfmathresult%
3246 \pgfmathanglebetweenpoints{\centerpoint}{\lefttailborderpoint}%
3247 \let\angletolefttail\pgfmathresult%
3248 \pgfmathanglebetweenpoints{\centerpoint}{\righttailborderpoint}%
3249 \let\angletorighttail\pgfmathresult%
3250 %
3251 % Calculate the angles between the *inversely rotated*
3252 % basepoint and the *unrotated* borderpoints.
3253 %
3254 \pgfextract@process\rotatedbasepoint{%
3255 \pgfmathrotatepointaround{\basepoint}{\centerpoint}{-\rotate}%
3256 }%
3257 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\tipborderpoint}%
3258 \let\baseangletotip\pgfmathresult%
3259 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\tailcenterborderpoint}%
3260 \let\baseangletotailcenter\pgfmathresult%
3261 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\lefttailborderpoint}%
3262 \let\baseangletolefttail\pgfmathresult%
3263 \pgfmathanglebetweenpoints{\rotatedbasepoint}{\righttailborderpoint}%
3264 \let\baseangletorighttail\pgfmathresult%
3265 %
3266 % Calculate the angles between the *inversely rotated*
3267 % midpoint and the *unrotated* borderpoints.
3268 %
3269 \pgfextract@process\rotatedmidpoint{%
3270 \pgfmathrotatepointaround{\midpoint}{\centerpoint}{-\rotate}%
3271 }%
3272 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\tipborderpoint}%
3273 \let\midangletotip\pgfmathresult%
3274 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\tailcenterborderpoint}%
3275 \let\midangletotailcenter\pgfmathresult%
3276 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\lefttailborderpoint}%
3277 \let\midangletolefttail\pgfmathresult%
3278 \pgfmathanglebetweenpoints{\rotatedmidpoint}{\righttailborderpoint}%
3279 \let\midangletorighttail\pgfmathresult%
3280 %
3281 % Rotate the background path points.
3282 %
3283 \pgfextract@process\tippoint{%
3284 \pgfmathrotatepointaround{\tippoint}{\centerpoint}{\rotate}%
3285 }%
3286 \pgfextract@process\tailcenterpoint{%
3287 \pgfmathrotatepointaround{\tailcenterpoint}{\centerpoint}{\rotate}%
3288 }%
3289 \pgfextract@process\lefttailpoint{%
3290 \pgfmathrotatepointaround{\lefttailpoint}{\centerpoint}{\rotate}%
3291 }%
3292 \pgfextract@process\righttailpoint{%
3293 \pgfmathrotatepointaround{\righttailpoint}{\centerpoint}{\rotate}%
3294 }%
3295 %
3296 % Calculate a radius guaranteed to be outside the dart.
3297 %
3298 \pgfextractx\pgf@xa{\pgfpointdiff{\lefttailborderpoint}{\tipborderpoint}}%
3299 \pgfextracty\pgf@ya{\pgfpointdiff{\lefttailborderpoint}{\righttailborderpoint}}%
3300 \ifdim\pgf@xa<0pt\relax%
3301 \pgf@xa-\pgf@xa%
3302 \fi%
3303 \ifdim\pgf@ya<0pt\relax%
3304 \pgf@ya-\pgf@ya%
3305 \fi%
3306 \ifdim\pgf@xa>\pgf@ya%
3307 \edef\externalradius{\the\pgf@xa}%
3308 \else%
3309 \edef\externalradius{\the\pgf@ya}%
3310 \fi%
3311 %
3312 % Rotate the border anchor points.
3313 %
3314 \pgfextract@process\tipborderpoint{%
3315 \pgfmathrotatepointaround{\tipborderpoint}{\centerpoint}{\rotate}%
3316 }%
3317 \pgfextract@process\tailcenterborderpoint{%
3318 \pgfmathrotatepointaround{\tailcenterborderpoint}{\centerpoint}{\rotate}%
3319 }%
3320 \pgfextract@process\lefttailborderpoint{%
3321 \pgfmathrotatepointaround{\lefttailborderpoint}{\centerpoint}{\rotate}%
3322 }%
3323 \pgfextract@process\righttailborderpoint{%
3324 \pgfmathrotatepointaround{\righttailborderpoint}{\centerpoint}{\rotate}%
3325 }%
3326 %
3327 % Save everything.
3328 %
3329 \addtosavedmacro{\rotate}%
3330 \addtosavedmacro{\externalradius}%
3331 %
3332 \addtosavedmacro{\tippoint}%
3333 \addtosavedmacro{\tailcenterpoint}%
3334 \addtosavedmacro{\lefttailpoint}%
3335 \addtosavedmacro{\righttailpoint}%
3336 %
3337 \addtosavedmacro{\tipborderpoint}%
3338 \addtosavedmacro{\tailcenterborderpoint}%
3339 \addtosavedmacro{\lefttailborderpoint}%
3340 \addtosavedmacro{\righttailborderpoint}%
3341 %
3342 \addtosavedmacro{\angletotip}%
3343 \addtosavedmacro{\angletotailcenter}%
3344 \addtosavedmacro{\angletolefttail}%
3345 \addtosavedmacro{\angletorighttail}%
3346 %
3347 \addtosavedmacro{\baseangletotip}%
3348 \addtosavedmacro{\baseangletotailcenter}%
3349 \addtosavedmacro{\baseangletolefttail}%
3350 \addtosavedmacro{\baseangletorighttail}%
3351 %
3352 \addtosavedmacro{\midangletotip}%
3353 \addtosavedmacro{\midangletotailcenter}%
3354 \addtosavedmacro{\midangletolefttail}%
3355 \addtosavedmacro{\midangletorighttail}%
3356 }%
3357 \savedanchor\centerpoint{%
3358 \[email protected]\wd\pgfnodeparttextbox%
3359 \[email protected]\ht\pgfnodeparttextbox%
3360 \advance\[email protected]\dp\pgfnodeparttextbox%
3361 }%
3362 \savedanchor\basepoint{%
3363 \[email protected]\wd\pgfnodeparttextbox%
3364 \pgf@y0pt\relax%
3365 }%
3366 \savedanchor\midpoint{%
3367 \[email protected]\wd\pgfnodeparttextbox%
3368 \pgfmathsetlength\pgf@y{+.5ex}%
3369 }%
3370 \anchor{center}{\centerpoint}%
3371 \anchor{base}{\basepoint}%
3372 \anchor{base west}{%
3373 \installdartparameters%
3374 \let\pgf@dartanchorborderreferencepoint\basepoint%
3375 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
3376 }%
3377 \anchor{base east}{%
3378 \installdartparameters%
3379 \let\pgf@dartanchorborderreferencepoint\basepoint%
3380 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
3381 }%
3382 \anchor{mid}{\midpoint}%
3383 \anchor{mid west}{%
3384 \installdartparameters%
3385 \let\pgf@dartanchorborderreferencepoint\midpoint%
3386 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
3387 }%
3388 \anchor{mid east}{%
3389 \installdartparameters%
3390 \let\pgf@dartanchorborderreferencepoint\midpoint%
3391 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
3392 }%
3393 \anchor{north}{%
3394 \installdartparameters%
3395 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{0pt}{\externalradius}}%
3396 }%
3397 \anchor{south}{%
3398 \installdartparameters%
3399 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{0pt}{-\externalradius}}%
3400 }%
3401 \anchor{east}{%
3402 \installdartparameters%
3403 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
3404 }%
3405 \anchor{west}{%
3406 \installdartparameters%
3407 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
3408 }%
3409 \anchor{north east}{%
3410 \installdartparameters%
3411 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{\externalradius}{\externalradius}}%
3412 }%
3413 \anchor{south west}{%
3414 \installdartparameters%
3415 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{-\externalradius}{-\externalradius}}%
3416 }%
3417 \anchor{south east}{%
3418 \installdartparameters%
3419 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{\externalradius}{-\externalradius}}%
3420 }%
3421 \anchor{north west}{%
3422 \installdartparameters%
3423 \csname pgf@anchor@dart@border\endcsname{\pgfqpoint{-\externalradius}{\externalradius}}%
3424 }%
3425 \anchor{tip}{%
3426 \installdartparameters%
3427 \tipborderpoint}%
3428 \anchor{left tail}{%
3429 \installdartparameters%
3430 \lefttailborderpoint}%
3431 \anchor{right tail}{%
3432 \installdartparameters%
3433 \righttailborderpoint}%
3434 \anchor{tail center}{%
3435 \installdartparameters%
3436 \tailcenterborderpoint}%
3437 \anchor{left side}{%
3438 \installdartparameters%
3439 \pgfpointlineattime{0.5}{\tipborderpoint}{\lefttailborderpoint}}%
3440 \anchor{right side}{%
3441 \installdartparameters%
3442 \pgfpointlineattime{0.5}{\tipborderpoint}{\righttailborderpoint}}%
3443 \backgroundpath{%
3444 \installdartparameters%
3445 \pgfpathmoveto{\tippoint}%
3446 \pgfpathlineto{\lefttailpoint}%
3447 \pgfpathlineto{\tailcenterpoint}%
3448 \pgfpathlineto{\righttailpoint}%
3449 \pgfpathclose%
3450 }%
3451 \anchorborder{%
3452 %
3453 % Save x and y.
3454 %
3455 \edef\externalx{\the\pgf@x}%
3456 \edef\externaly{\the\pgf@y}%
3457 %
3458 % This allows anchors base east, base west, mid east and mid west,
3459 % to redefine the `center' of the node to correctly calculate the
3460 % border points.
3461 %
3462 \pgfutil@ifundefined{pgf@dartanchorborderreferencepoint}%
3463 {\let\referencepoint\centerpoint}%
3464 {\let\referencepoint\pgf@dartanchorborderreferencepoint}%
3465 %
3466 % Adjust the location of the external
3467 % point relative to the reference point.
3468 %
3469 \referencepoint%
3470 \pgf@xa\externalx\relax%
3471 \pgf@ya\externaly\relax%
3472 \advance\pgf@xa\pgf@x%
3473 \advance\pgf@ya\pgf@y%
3474 \edef\externalx{\the\pgf@xa}%
3475 \edef\externaly{\the\pgf@ya}%
3476 %
3477 % Install the required points and angles.
3478 %
3479 \installdartparameters%
3480 %
3481 % Get the angle of the external point relative to \referencepoint.
3482 %
3483 \pgfmathanglebetweenpoints{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
3484 %
3485 % *Subtract* the rotation from the external angle.
3486 %
3487 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
3488 \ifdim\pgfmathresult pt<0pt\relax%
3489 \pgfmathadd@{\pgfmathresult}{360}%
3490 \fi%
3491 \let\externalangle\pgfmathresult%
3492 %
3493 % Get the set of angles for the appropriate border point.
3494 %
3495 \ifx\referencepoint\basepoint%
3496 \let\angletotip\baseangletotip%
3497 \let\angletotailcenter\baseangletotailcenter%
3498 \let\angletolefttail\baseangletolefttail%
3499 \let\angletorighttail\baseangletorighttail%
3500 \else%
3501 \ifx\referencepoint\midpoint%
3502 \let\angletotip\midangletotip%
3503 \let\angletotailcenter\midangletotailcenter%
3504 \let\angletolefttail\midangletolefttail%
3505 \let\angletorighttail\midangletorighttail%
3506 \fi\fi%
3507 %
3508 % Locate the appropriate line on the border...
3509 %
3510 \ifdim\externalangle pt<\angletotip pt\relax%
3511 \let\firstpoint\tipborderpoint%
3512 \let\secondpoint\righttailborderpoint%
3513 \else%
3514 \ifdim\externalangle pt<\angletolefttail pt\relax%
3515 \let\firstpoint\lefttailborderpoint%
3516 \let\secondpoint\tipborderpoint%
3517 \else%
3518 \ifdim\externalangle pt<\angletotailcenter pt\relax%
3519 \let\firstpoint\lefttailborderpoint%
3520 \let\secondpoint\tailcenterborderpoint%
3521 \else%
3522 \ifdim\externalangle pt<\angletorighttail pt\relax%
3523 \let\firstpoint\righttailborderpoint%
3524 \let\secondpoint\tailcenterborderpoint%
3525 \else%
3526 \let\firstpoint\tipborderpoint%
3527 \let\secondpoint\righttailborderpoint%
3528 \fi%
3529 \fi%
3530 \fi%
3531 \fi%
3532 %
3533 % ...and thus the point on the border.
3534 %
3535 \pgfpointintersectionoflines{\referencepoint}{\pgfqpoint{\externalx}{\externaly}}%
3536 {\firstpoint}{\secondpoint}%
3537 }%
3538 }%
3539
3540
3541
3542 % Keys for shape circular sector:
3543 %
3544 % /pgf/circular sector angle : the angle at the center of the sector.
3545 %
3546 \pgfkeys{/pgf/circular sector angle/.initial=60}%
3547
3548 % Shape circular sector
3549 %
3550 \pgfdeclareshape{circular sector}{%
3551 \savedmacro\installcircularsectorparameters{%
3552 %
3553 % Define a \centerpoint, \basepoint and \midpoint.
3554 %
3555 \pgfextract@process\centerpoint{%
3556 \[email protected]\wd\pgfnodeparttextbox%
3557 \[email protected]\ht\pgfnodeparttextbox%
3558 \advance\[email protected]\dp\pgfnodeparttextbox%
3559 }%
3560 %
3561 % Get the larger of the outer sep.
3562 %
3563 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
3564 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
3565 \ifdim\pgf@x<\pgf@y%
3566 \pgf@x\pgf@y%
3567 \fi%
3568 \edef\outersep{\the\pgf@x}%
3569 %
3570 % Half of the sector angle is more useful.
3571 %
3572 \pgfmathmod{\pgfkeysvalueof{/pgf/circular sector angle}}{360}%
3573 \ifdim\pgfmathresult pt<0pt\relax%
3574 \pgfmathadd@{\pgfmathresult}{360}%
3575 \fi%
3576 \let\angle\pgfmathresult%
3577 \pgfmathdivide@{\pgfmathresult}{2}%
3578 \let\halfangle\pgfmathresult%
3579 %
3580 % Get some useful trigonometric stuff.
3581 %
3582 \pgfmathsin@{\halfangle}%
3583 \let\sinehalfangle\pgfmathresult%
3584 \pgfmathreciprocal@{\pgfmathresult}%
3585 \let\cosechalfangle\pgfmathresult%
3586 \pgfmathabs@{\halfangle}%
3587 \pgfmathcos@{\pgfmathresult}%
3588 \let\coshalfangle\pgfmathresult%
3589 \pgf@x\pgfmathresult pt\relax%
3590 \pgf@x\cosechalfangle\pgf@x%
3591 \edef\cothalfangle{\pgfmath@tonumber{\pgf@x}}%
3592 %
3593 % Calculate the miter length at the center,
3594 % according to the outer sep.
3595 %
3596 \pgf@x\outersep\relax%
3597 \pgf@x\cosechalfangle\pgf@x%
3598 \edef\centermiter{\the\pgf@x}%
3599 %
3600 % Get the start and end angles of the arc.
3601 %
3602 \pgfmathsubtract@{180}{\halfangle}%
3603 \let\startangle\pgfmathresult%
3604 \pgfmathadd@{180}{\halfangle}%
3605 \let\endangle\pgfmathresult%
3606 %
3607 % Get (half) the node dimensions.
3608 %
3609 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
3610 \advance\[email protected]\wd\pgfnodeparttextbox%
3611 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
3612 \advance\[email protected]\ht\pgfnodeparttextbox%
3613 \advance\[email protected]\dp\pgfnodeparttextbox%
3614 %
3615 % Calculate the radius of the sector and the `center offset',
3616 % which is the distance between the center of the node and the
3617 % center of the sector.
3618 %
3619 \ifpgfshapeborderusesincircle%
3620 %
3621 % Get the rotation.
3622 %
3623 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
3624 %
3625 % Calculate the incircle radius.
3626 %
3627 \ifdim\pgf@x<\pgf@y%
3628 \pgf@x\pgf@y%
3629 \fi%
3630 \[email protected]\pgf@x%
3631 \pgf@xa\cosechalfangle\pgf@x%
3632 %
3633 % xa is the radius, xb the offset.
3634 %
3635 \pgf@xb\pgf@xa%
3636 \advance\pgf@xa\pgf@x%
3637 \else%
3638 %
3639 % Get the rotation (with rounding).
3640 %
3641 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
3642 \afterassignment\pgfmath@gobbletilpgfmath@%
3643 \expandafter\c@pgf@counta\pgfmathresult\relax\pgfmath@%
3644 \advance\c@pgf@counta45\relax%
3645 \divide\c@pgf@counta90\relax%
3646 \multiply\c@pgf@counta90\relax%
3647 \ifnum\c@pgf@counta<0\relax%
3648 \advance\c@pgf@counta360\relax%
3649 \fi%
3650 \edef\rotate{\the\c@pgf@counta}%
3651 %
3652 % Swap the height and width for relevant angles.
3653 %
3654 \ifnum\c@pgf@counta=90\relax%
3655 \pgf@xc\pgf@x%
3656 \pgf@x\pgf@y%
3657 \pgf@y\pgf@xc%
3658 \else%
3659 \ifnum\c@pgf@counta=270\relax%
3660 \pgf@xc\pgf@x%
3661 \pgf@x\pgf@y%
3662 \pgf@y\pgf@xc%
3663 \fi%
3664 \fi%
3665 %
3666 % xa is the radius, xb the offset.
3667 %
3668 \pgf@xa\cosechalfangle\pgf@y%
3669 \pgf@xa\coshalfangle\pgf@xa%
3670 \advance\pgf@xa\pgf@x%
3671 \pgf@xb\pgf@xa%
3672 \advance\pgf@xa\pgf@x%
3673 \pgfmathveclen@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@y}}%
3674 \pgf@xa\pgfmathresult pt\relax%
3675 \fi%
3676 %
3677 % Adjust for minimum height and width.
3678 %
3679 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}%
3680 \[email protected]\pgf@x%
3681 \pgfmathsec@{\halfangle}%
3682 \pgf@xc\pgfmathresult\pgf@xb%
3683 \ifdim\pgf@xc<0pt\relax%
3684 \pgf@xc-\pgf@xc%
3685 \fi%
3686 \ifdim\pgf@xc<\pgf@x%
3687 \pgfmathreciprocal{\pgfmath@tonumber{\pgf@xc}}%
3688 \pgf@xc\pgfmathresult\pgf@x% Increase by ratio.
3689 \pgf@xa\pgfmath@tonumber{\pgf@xc}\pgf@xa%
3690 \pgf@xb\pgfmath@tonumber{\pgf@xc}\pgf@xb%
3691 \fi%
3692 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum height}}%
3693 \ifdim\pgf@xa<\pgf@y%
3694 \pgfmathreciprocal{\pgfmath@tonumber{\pgf@xa}}%
3695 \pgf@xc\pgfmathresult\pgf@y% Increase by ratio.
3696 \pgf@xa\pgf@y%
3697 \pgf@xb\pgfmath@tonumber{\pgf@xc}\pgf@xb%
3698 \fi%
3699 \edef\centeroffset{\the\pgf@xb}%
3700 \edef\radius{\the\pgf@xa}%
3701 %
3702 % Calculate the radius at sector border and the arc corners.
3703 %
3704 \advance\pgf@xa\outersep\relax%
3705 \edef\borderradius{\the\pgf@xa}%
3706 \pgf@x\outersep\relax%
3707 \pgf@x\cosechalfangle\pgf@x%
3708 \pgf@x\coshalfangle\pgf@x%
3709 \advance\pgf@xa\pgf@x%
3710 \edef\cornerradius{\the\pgf@xa}%
3711 %
3712 % Calculate the *unrotated* points for the background path.
3713 %
3714 \pgfextract@process\sectorcenter{%
3715 \centerpoint%
3716 \advance\pgf@x\centeroffset%
3717 }%
3718 \pgfextract@process\arcstart{%
3719 \pgfqpointpolar{\startangle}{\radius}%
3720 \pgf@xa\pgf@x%
3721 \pgf@ya\pgf@y%
3722 \sectorcenter%
3723 \advance\pgf@x\pgf@xa%
3724 \advance\pgf@y\pgf@ya%
3725 }%
3726 %
3727 % Calculate the *unrotated* points for the anchor border.
3728 %
3729 \pgfextract@process\sectorcenterborder{%
3730 \sectorcenter%
3731 \advance\pgf@x\centermiter\relax%
3732 }%
3733 \pgfextract@process\arcstartborder{%
3734 \pgfqpointpolar{\startangle}{\borderradius}%
3735 \pgf@xa\pgf@x%
3736 \pgf@ya\pgf@y%
3737 \sectorcenter%
3738 \advance\pgf@x\pgf@xa%
3739 \advance\pgf@y\pgf@ya%
3740 }%
3741 \pgfextract@process\arcendborder{%
3742 \pgfqpointpolar{\endangle}{\borderradius}%
3743 \pgf@xa\pgf@x%
3744 \pgf@ya\pgf@y%
3745 \sectorcenter%
3746 \advance\pgf@x\pgf@xa%
3747 \advance\pgf@y\pgf@ya%
3748 }%
3749 \pgfextract@process\arcstartcorner{%
3750 \pgfqpointpolar{\startangle}{\cornerradius}%
3751 \pgf@xa\pgf@x%
3752 \pgf@ya\pgf@y%
3753 \sectorcenterborder%
3754 \advance\pgf@x\pgf@xa%
3755 \advance\pgf@y\pgf@ya%
3756 }%
3757 \pgfextract@process\arcendcorner{%
3758 \pgfqpointpolar{\endangle}{\cornerradius}%
3759 \pgf@xa\pgf@x%
3760 \pgf@ya\pgf@y%
3761 \sectorcenterborder%
3762 \advance\pgf@x\pgf@xa%
3763 \advance\pgf@y\pgf@ya%
3764 }%
3765 %
3766 % Calculate the *unrotated* corner angles to the \centerpoint.
3767 %
3768 \pgfmathanglebetweenpoints{\centerpoint}{\sectorcenterborder}%
3769 \let\angletosectorcenterborder\pgfmathresult%
3770 \pgfmathanglebetweenpoints{\centerpoint}{\arcstartborder}%
3771 \let\angletoarcstartborder\pgfmathresult%
3772 \pgfmathanglebetweenpoints{\centerpoint}{\arcendborder}%
3773 \let\angletoarcendborder\pgfmathresult%
3774 \pgfmathanglebetweenpoints{\centerpoint}{\arcstartcorner}%
3775 \let\angletoarcstartcorner\pgfmathresult%
3776 \pgfmathanglebetweenpoints{\centerpoint}{\arcendcorner}%
3777 \let\angletoarcendcorner\pgfmathresult%
3778 %
3779 % Rotate the background path points around the note center.
3780 %
3781 \pgfextract@process\sectorcenter{%
3782 \pgfmathrotatepointaround{\sectorcenter}{\centerpoint}{\rotate}%
3783 }%
3784 \pgfextract@process\arcstart{%
3785 \pgfmathrotatepointaround{\arcstart}{\centerpoint}{\rotate}%
3786 }%
3787 %
3788 % Rotate the border points around the note center.
3789 %
3790 \pgfextract@process\sectorcenterborder{%
3791 \pgfmathrotatepointaround{\sectorcenterborder}{\centerpoint}{\rotate}%
3792 }%
3793 \pgfextract@process\arcstartborder{%
3794 \pgfmathrotatepointaround{\arcstartborder}{\centerpoint}{\rotate}%
3795 }%
3796 \pgfextract@process\arcendborder{%
3797 \pgfmathrotatepointaround{\arcendborder}{\centerpoint}{\rotate}%
3798 }%
3799 \pgfextract@process\arcstartcorner{%
3800 \pgfmathrotatepointaround{\arcstartcorner}{\centerpoint}{\rotate}%
3801 }%
3802 \pgfextract@process\arcendcorner{%
3803 \pgfmathrotatepointaround{\arcendcorner}{\centerpoint}{\rotate}%
3804 }%
3805 %
3806 % Add the rotation to the start and end angles.
3807 %
3808 \pgfmathadd@{\startangle}{\rotate}%
3809 \let\startangle\pgfmathresult%
3810 \pgfmathadd@{\endangle}{\rotate}%
3811 \let\endangle\pgfmathresult%
3812 %
3813 % Save everything.
3814 %
3815 % NB \addtosavedmacro is currently experimental. May get changed.
3816 %
3817 \addtosavedmacro{\rotate}%
3818 \addtosavedmacro{\centeroffset}%
3819 %
3820 \addtosavedmacro{\radius}%
3821 \addtosavedmacro{\borderradius}%
3822 \addtosavedmacro{\cornerradius}%
3823 %
3824 \addtosavedmacro{\endangle}%
3825 \addtosavedmacro{\startangle}%
3826 %
3827 \addtosavedmacro{\sectorcenter}%
3828 \addtosavedmacro{\arcstart}%
3829 %
3830 \addtosavedmacro{\sectorcenterborder}%
3831 \addtosavedmacro{\arcstartborder}%
3832 \addtosavedmacro{\arcendborder}%
3833 \addtosavedmacro{\arcstartcorner}%
3834 \addtosavedmacro{\arcendcorner}%
3835 %
3836 \addtosavedmacro{\angletosectorcenterborder}%
3837 \addtosavedmacro{\angletoarcstartborder}%
3838 \addtosavedmacro{\angletoarcendborder}%
3839 \addtosavedmacro{\angletoarcstartcorner}%
3840 \addtosavedmacro{\angletoarcendcorner}%
3841 }%
3842 \savedanchor\centerpoint{%
3843 \[email protected]\wd\pgfnodeparttextbox%
3844 \[email protected]\ht\pgfnodeparttextbox%
3845 \advance\[email protected]\dp\pgfnodeparttextbox%
3846 }%
3847 \savedanchor\basepoint{%
3848 \[email protected]\wd\pgfnodeparttextbox%
3849 \pgf@y0pt\relax%
3850 }%
3851 \savedanchor\midpoint{%
3852 \[email protected]\wd\pgfnodeparttextbox%
3853 \pgfmathsetlength\pgf@y{+.5ex}%
3854 }%
3855 \anchor{center}{\centerpoint}%
3856 \anchor{base}{\basepoint}%
3857 \anchor{mid}{\midpoint}%
3858 \anchor{arc start}{%
3859 \installcircularsectorparameters%
3860 \arcstartcorner%
3861 }%
3862 \anchor{arc end}{%
3863 \installcircularsectorparameters%
3864 \arcendcorner%
3865 }%
3866 \anchor{sector center}{%
3867 \installcircularsectorparameters%
3868 \sectorcenterborder%
3869 }%
3870 \anchor{arc center}{%
3871 \installcircularsectorparameters%
3872 \pgfmathadd@{\rotate}{180}%
3873 \let\angle\pgfmathresult%
3874 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpointpolar{\angle}{\cornerradius}}%
3875 }%
3876 \anchor{north}{%
3877 \installcircularsectorparameters%
3878 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{0pt}{\cornerradius}}%
3879 }%
3880 \anchor{south}{%
3881 \installcircularsectorparameters%
3882 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{0pt}{-\cornerradius}}%
3883 }%
3884 \anchor{east}{%
3885 \installcircularsectorparameters%
3886 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{\cornerradius}{0pt}}%
3887 }%
3888 \anchor{west}{%
3889 \installcircularsectorparameters%
3890 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{-\cornerradius}{0pt}}%
3891 }%
3892 \anchor{north west}{%
3893 \installcircularsectorparameters%
3894 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{-\cornerradius}{\cornerradius}}%
3895 }%
3896 \anchor{south west}{%
3897 \installcircularsectorparameters%
3898 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{-\cornerradius}{-\cornerradius}}%
3899 }%
3900 \anchor{north east}{%
3901 \installcircularsectorparameters%
3902 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{\cornerradius}{\cornerradius}}%
3903 }%
3904 \anchor{south east}{%
3905 \installcircularsectorparameters%
3906 \csname pgf@anchor@circular sector@border\endcsname{\pgfqpoint{\cornerradius}{-\cornerradius}}%
3907 }%
3908 \backgroundpath{%
3909 \installcircularsectorparameters%
3910 \pgfpathmoveto{\sectorcenter}%
3911 \pgfpathlineto{\arcstart}%
3912 \ifdim\endangle pt>360pt\relax%
3913 \ifdim\startangle pt>360pt\relax%
3914 \pgfpatharc{\startangle}{\endangle}{\radius}%
3915 \else%
3916 \pgfpatharc{\startangle}{360}{\radius}%
3917 \pgfpatharc{0}{\endangle}{\radius}%
3918 \fi%
3919 \else%
3920 \pgfpatharc{\startangle}{\endangle}{\radius}%
3921 \fi%
3922 \pgfpathclose%
3923 }%
3924 \anchorborder{%
3925 %
3926 % Save x and y.
3927 %
3928 \edef\externalx{\the\pgf@x}%
3929 \edef\externaly{\the\pgf@y}%
3930 %
3931 % Adjust the location of the external point relative to \centerpoint.
3932 %
3933 \centerpoint%
3934 \pgf@xa\externalx\relax%
3935 \pgf@ya\externaly\relax%
3936 \advance\pgf@xa\pgf@x%
3937 \advance\pgf@ya\pgf@y%
3938 \edef\externalx{\the\pgf@xa}%
3939 \edef\externaly{\the\pgf@ya}%
3940 %
3941 % Install the required points and angles.
3942 %
3943 \installcircularsectorparameters%
3944 %
3945 % Get the angle of the external point to the \centerpoint.
3946 %
3947 \pgfmathanglebetweenpoints{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
3948 \let\externalangle\pgfmathresult%
3949 %
3950 % *Subtract* the rotation from the external angle.
3951 %
3952 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
3953 \ifdim\pgfmathresult pt<0pt\relax%
3954 \pgfmathadd@{\pgfmathresult}{360}%
3955 \fi%
3956 \let\angle\pgfmathresult%
3957 %
3958 % Determine if the line will cross the sector arc.
3959 %
3960 \ifdim\angle pt>\angletoarcendcorner pt\relax%
3961 \let\firstpoint\arcendcorner%
3962 \let\secondpoint\sectorcenterborder%
3963 \else%
3964 \ifdim\angle pt>\angletoarcendborder pt\relax%
3965 \let\firstpoint\arcendborder%
3966 \let\secondpoint\arcendcorner%
3967 \else%
3968 \ifdim\angle pt>\angletoarcstartborder pt\relax%
3969 \let\firstpoint\pgfutil@empty%
3970 \let\secondpoint\pgfutil@empty%
3971 \else%
3972 \ifdim\angle pt>\angletoarcstartcorner pt\relax%
3973 \let\firstpoint\arcstartborder
3974 \let\secondpoint\arcstartcorner
3975 \else%
3976 \let\firstpoint\sectorcenterborder%
3977 \let\secondpoint\arcstartcorner%
3978 \fi%
3979 \fi%
3980 \fi%
3981 \fi%
3982 \ifx\firstpoint\pgfutil@empty
3983 %
3984 % Calculate the angle from the centre of the semicircle to the
3985 % point on the semicircle arc which intersects the line from
3986 % the external point to the reference point...
3987 %
3988 \pgfmathanglebetweenlines{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
3989 {\sectorcenter}{\centerpoint}%
3990 \pgfmathsin@{\pgfmathresult}%
3991 \let\sineangle\pgfmathresult%
3992 \pgf@x\borderradius\relax%
3993 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@x}}%
3994 \let\reciprocalradius\pgfmathresult%
3995 \pgf@x\centeroffset\relax%
3996 \pgf@x\sineangle\pgf@x%
3997 \pgf@x\reciprocalradius\pgf@x%
3998 \pgfmathasin@{\pgfmath@tonumber{\pgf@x}}%
3999 \pgf@x\pgfmathresult pt\relax%
4000 \advance\pgf@x\externalangle pt\relax%
4001 \edef\angle{\pgfmath@tonumber{\pgf@x}}%
4002 %
4003 % ...and thus the point on the border.
4004 %
4005 \pgfpointadd{\sectorcenter}{\pgfqpointpolar{\angle}{\borderradius}}%
4006 \else%
4007 %
4008 % Calculate the the point where the semicircle chord intersects
4009 % the line from the external point to the reference point.
4010 %
4011 \pgfpointintersectionoflines{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
4012 {\firstpoint}{\secondpoint}%
4013 \fi%
4014 }%
4015 }%
4016
4017
4018
4019 % Keys for shape cylinder
4020 %
4021 % /pgf/shape aspect : Ratio between the x and y radii of the cylinder end.
4022 % /pgf/cylinder uses custom fill : Use a custom fill for the cylinder.
4023 % /pgf/cylinder end fill : Custom color for the cylinder end.
4024 % /pgf/cylinder body fill : Custom color for the cylinder body.
4025 %
4026
4027 \newif\ifpgfcylinderusescustomfill
4028 \pgfkeys{/pgf/.cd,
4029 cylinder uses custom fill/.is if=pgfcylinderusescustomfill,
4030 cylinder end fill/.initial=white,
4031 cylinder body fill/.initial=white,
4032 }%
4033
4034
4035 \pgfdeclareshape{cylinder}{%
4036 \savedmacro\getcylinderpoints{%
4037 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}%
4038 \pgf@x\pgf@xc%
4039 \advance\[email protected]\wd\pgfnodeparttextbox%
4040 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}%
4041 \pgf@y\pgf@yc%
4042 \advance\[email protected]\ht\pgfnodeparttextbox%
4043 \advance\[email protected]\dp\pgfnodeparttextbox%
4044 \ifpgfshapeborderusesincircle%
4045 \pgfmathsetmacro\rotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
4046 \ifdim\pgf@x<\pgf@y%
4047 \pgf@x\pgf@y%
4048 \else%
4049 \pgf@y\pgf@x%
4050 \fi%
4051 \[email protected]\pgf@x%
4052 \[email protected]\pgf@y%
4053 \else%
4054 \pgfmathmod{\pgfkeysvalueof{/pgf/shape border rotate}}{360}%
4055 \ifdim\pgfmathresult pt<0pt\relax%
4056 \pgfmathadd@{\pgfmathresult}{360}%
4057 \fi%
4058 \pgfmathsetcount\c@pgf@counta{+\pgfmathresult}%
4059 \advance\c@pgf@counta45\relax%
4060 \divide\c@pgf@counta90\relax%
4061 \multiply\c@pgf@counta90\relax%
4062 \edef\rotate{\the\c@pgf@counta}%
4063 \ifnum\c@pgf@counta=90\relax%
4064 \pgf@xa\pgf@x%
4065 \pgf@x\pgf@y%
4066 \pgf@y\pgf@xa%
4067 \pgf@yc\pgf@xc%
4068 \else%
4069 \ifnum\c@pgf@counta=270\relax%
4070 \pgf@xa\pgf@x%
4071 \pgf@x\pgf@y%
4072 \pgf@y\pgf@xa%
4073 \pgf@yc\pgf@xc%
4074 \fi%
4075 \fi%
4076 \fi%
4077 \addtosavedmacro\rotate%
4078 \pgf@xa\pgf@x%
4079 \pgf@ya\pgf@y%
4080 \pgfutil@tempdima\pgfshapeaspect\pgf@ya%
4081 \pgfutil@tempdimb\pgf@ya%
4082 %
4083 % Adjust for minimum height.
4084 %
4085 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum width}}%
4086 \ifdim\pgfutil@tempdimb<.5\pgf@xc\relax%
4087 \[email protected]\pgf@xc%
4088 \pgf@ya\pgfutil@tempdimb%
4089 \fi%
4090 %
4091 % Calculate how far the node contents can extend into the cylinder bottom.
4092 %
4093 \pgf@yb\pgfutil@tempdimb%
4094 \advance\pgf@yb-\pgf@yc%
4095 \pgfmathdivide@{\pgfmath@tonumber{\pgf@yb}}{\pgfmath@tonumber{\pgfutil@tempdimb}}%
4096 \pgfmathasin@{\pgfmathresult}%
4097 \pgfmathcos@{\pgfmathresult}%
4098 \let\angle\pgfmathresult%
4099 \pgf@xb\pgfmathresult\pgfutil@tempdima%
4100 %
4101 % Adjust for minimum width.
4102 %
4103 \[email protected]\pgflinewidth%
4104 \advance\[email protected]\pgf@xa%
4105 \advance\[email protected]\pgfutil@tempdima%
4106 \advance\pgf@x-\pgf@xb%
4107 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/minimum height}}%
4108 \ifdim\pgf@x<\pgf@xc%
4109 \advance\pgf@xc-\pgf@x%
4110 \advance\[email protected]\pgf@xc%
4111 \fi%
4112 %
4113 % Add the larger of the outer sep to the radii.
4114 %
4115 \pgf@x\pgfutil@tempdima\relax%
4116 \pgf@y\pgfutil@tempdimb\relax%
4117 \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/outer xsep}}%
4118 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/outer ysep}}%
4119 \ifdim\pgf@xc>\pgf@yc%
4120 \advance\pgf@x\pgf@xc%
4121 \advance\pgf@y\pgf@xc%
4122 \edef\outersep{\the\pgf@xc}%
4123 \else%
4124 \advance\pgf@x\pgf@yc%
4125 \advance\pgf@y\pgf@yc%
4126 \edef\outersep{\the\pgf@yc}%
4127 \fi%
4128 \edef\xradius{\the\pgf@x}%
4129 \edef\yradius{\the\pgf@y}%
4130 \addtosavedmacro\xradius%
4131 \addtosavedmacro\yradius%
4132 \addtosavedmacro\outersep%
4133 %
4134 \pgfextract@process\cylindercenter{%
4135 \pgf@x\pgfutil@tempdima%
4136 \advance\[email protected]\pgflinewidth%
4137 \advance\pgf@x\pgf@xb%
4138 \[email protected]\pgf@x%
4139 \pgf@y0pt%
4140 }%
4141 \addtosavedmacro\cylindercenter%
4142 %
4143 \pgfextract@process\beforetop{%
4144 \pgf@x\pgf@xa%
4145 \advance\pgf@x\pgfutil@tempdima%
4146 \advance\[email protected]\pgflinewidth%
4147 \pgf@y\pgf@ya%
4148 }%
4149 \pgfextract@process\afterbottom{%
4150 \pgf@x-\pgf@xa%
4151 \advance\pgf@x\pgf@xb%
4152 \pgf@y\pgf@ya%
4153 }%
4154 \addtosavedmacro\beforetop%
4155 \addtosavedmacro\afterbottom%
4156 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/outer ysep}}%
4157 \pgfextract@process\beforetopanchor{%
4158 \beforetop%
4159 \advance\pgf@y\pgf@yc%
4160 }%
4161 \pgfextract@process\afterbottomanchor{%
4162 \afterbottom%
4163 \advance\pgf@y\pgf@yc%
4164 }%
4165 \addtosavedmacro\beforetopanchor%
4166 \addtosavedmacro\afterbottomanchor%
4167 %
4168 \beforetopanchor%
4169 \advance\pgf@x\xradius\relax%
4170 \ifdim\pgf@x>\pgf@y%
4171 \edef\externalradius{\the\pgf@x}%
4172 \else%
4173 \edef\externalradius{\the\pgf@y}%
4174 \fi%
4175 \addtosavedmacro\externalradius%
4176 }%
4177 \savedanchor\centerpoint{%
4178 \[email protected]\wd\pgfnodeparttextbox%
4179 \[email protected]\ht\pgfnodeparttextbox%
4180 \advance\[email protected]\dp\pgfnodeparttextbox%
4181 }%
4182 \savedanchor\midpoint{%
4183 \[email protected]\wd\pgfnodeparttextbox%
4184 \pgfmathsetlength\pgf@y{+0.5ex}%
4185 }%
4186 \savedanchor\basepoint{%
4187 \[email protected]\wd\pgfnodeparttextbox%
4188 \pgf@y0pt%
4189 }%
4190 \anchor{center}{\centerpoint}%
4191 \anchor{shape center}{%
4192 \getcylinderpoints%
4193 \pgfmathrotatepointaround{\pgfpointadd{\cylindercenter}{\centerpoint}}%
4194 {\centerpoint}{\rotate}%
4195 }%
4196 \anchor{mid}{\midpoint}%
4197 \anchor{mid east}{%
4198 \getcylinderpoints%
4199 \let\pgf@cylinder@referencepoint\midpoint%
4200 \pgf@anchor@cylinder@border{\pgfqpoint{\externalradius}{0pt}}%
4201 }%
4202 \anchor{mid west}{%
4203 \getcylinderpoints%
4204 \let\pgf@cylinder@referencepoint\midpoint%
4205 \pgf@anchor@cylinder@border{\pgfqpoint{-\externalradius}{0pt}}%
4206 }%
4207 \anchor{base}{\basepoint}%
4208 \anchor{base east}{%
4209 \getcylinderpoints%
4210 \let\pgf@cylinder@referencepoint\basepoint%
4211 \pgf@anchor@cylinder@border{\pgfqpoint{\externalradius}{0pt}}%
4212 }%
4213 \anchor{base west}{%
4214 \getcylinderpoints%
4215 \let\pgf@cylinder@referencepoint\basepoint%
4216 \pgf@anchor@cylinder@border{\pgfqpoint{-\externalradius}{0pt}}%
4217 }%
4218 \anchor{north}{%
4219 \getcylinderpoints%
4220 \pgf@anchor@cylinder@border{\pgfqpoint{0pt}{\externalradius}}%
4221 }%
4222 \anchor{south}{%
4223 \getcylinderpoints%
4224 \pgf@anchor@cylinder@border{\pgfqpoint{0pt}{-\externalradius}}%
4225 }%
4226 \anchor{east}{%
4227 \getcylinderpoints%
4228 \pgf@anchor@cylinder@border{\pgfqpoint{\externalradius}{0pt}}%
4229 }%
4230 \anchor{west}{%
4231 \getcylinderpoints%
4232 \pgf@anchor@cylinder@border{\pgfqpoint{-\externalradius}{0pt}}%
4233 }%
4234 \anchor{north east}{%
4235 \getcylinderpoints%
4236 \pgf@anchor@cylinder@border{\pgfqpoint{\externalradius}{\externalradius}}%
4237 }%
4238 \anchor{south west}{%
4239 \getcylinderpoints%
4240 \pgf@anchor@cylinder@border{\pgfqpoint{-\externalradius}{-\externalradius}}%
4241 }%
4242 \anchor{south east}{%
4243 \getcylinderpoints%
4244 \pgf@anchor@cylinder@border{\pgfqpoint{\externalradius}{-\externalradius}}%
4245 }%
4246 \anchor{north west}{%
4247 \getcylinderpoints%
4248 \pgf@anchor@cylinder@border{\pgfqpoint{-\externalradius}{\externalradius}}%
4249 }%
4250 \anchor{before top}{%
4251 \getcylinderpoints%
4252 \pgfmathrotatepointaround{\pgfpointadd{\beforetopanchor}{\centerpoint}}{\centerpoint}{\rotate}%
4253 }%
4254 \anchor{top}{%
4255 \getcylinderpoints%
4256 \pgfmathrotatepointaround{%
4257 \pgfpointadd{%
4258 \beforetop%
4259 \pgf@y0pt\relax%
4260 \advance\pgf@x\xradius\relax%
4261 }{\centerpoint}}{\centerpoint}{\rotate}%
4262 }%
4263 \anchor{after top}{%
4264 \getcylinderpoints%
4265 \pgfmathrotatepointaround{\pgfpointadd{\beforetopanchor\pgf@y-\pgf@y}{\centerpoint}}{\centerpoint}{\rotate}%
4266 }%
4267 \anchor{before bottom}{%
4268 \getcylinderpoints%
4269 \pgfmathrotatepointaround{\pgfpointadd{\afterbottomanchor\pgf@y-\pgf@y}{\centerpoint}}{\centerpoint}{\rotate}%
4270 }%
4271 \anchor{bottom}{%
4272 \getcylinderpoints%
4273 \pgfmathrotatepointaround{%
4274 \pgfpointadd{%
4275 \afterbottom%
4276 \pgf@y0pt\relax%
4277 \advance\pgf@x-\xradius\relax%
4278 }{\centerpoint}}{\centerpoint}{\rotate}%
4279 }%
4280 \anchor{after bottom}{%
4281 \getcylinderpoints%
4282 \pgfmathrotatepointaround{\pgfpointadd{\afterbottomanchor}{\centerpoint}}{\centerpoint}{\rotate}%
4283 }%
4284 \backgroundpath{%
4285 \getcylinderpoints%
4286 {%
4287 \pgf@x\xradius\relax%
4288 \advance\pgf@x-\outersep\relax%
4289 \edef\xradius{\the\pgf@x}%
4290 \pgf@y\yradius\relax%
4291 \advance\pgf@y-\outersep\relax%
4292 \edef\yradius{\the\pgf@y}%
4293 \pgftransformshift{\centerpoint}%
4294 \pgftransformrotate{\rotate}%
4295 \pgfpathmoveto{\afterbottom}%
4296 \pgfpatharc{90}{270}{\xradius and \yradius}%
4297 \pgfpathlineto{\beforetop\pgf@y-\pgf@y}%
4298 \pgfpatharc{-90}{90}{\xradius and \yradius}%
4299 \pgfpathclose%
4300 \pgfpathmoveto{\beforetop}%
4301 \pgfpatharc{90}{270}{\xradius and \yradius}%
4302 }%
4303 }%
4304 \behindbackgroundpath{%
4305 \ifpgfcylinderusescustomfill%
4306 \getcylinderpoints%
4307 \pgf@x\xradius\relax%
4308 \advance\pgf@x-\outersep\relax%
4309 \edef\xradius{\the\pgf@x}%
4310 \pgf@y\yradius\relax%
4311 \advance\pgf@y-\outersep\relax%
4312 \edef\yradius{\the\pgf@y}%
4313 {%
4314 \pgftransformshift{\centerpoint}%
4315 \pgftransformrotate{\rotate}%
4316 \pgfpathmoveto{\afterbottom}%
4317 \pgfpatharc{90}{270}{\xradius and \yradius}%
4318 \pgfpathlineto{\beforetop\pgf@y-\pgf@y}%
4319 \pgfpatharc{270}{90}{\xradius and \yradius}%
4320 \pgfpathclose%
4321 \expandafter\pgfsetfillcolor\expandafter{\pgfkeysvalueof{/pgf/cylinder body fill}}%
4322 \pgfusepath{fill}%
4323 %
4324 \pgfpathmoveto{\beforetop}%
4325 \pgfpatharc{90}{-270}{\xradius and \yradius}%
4326 \pgfpathclose
4327 \expandafter\pgfsetfillcolor\expandafter{\pgfkeysvalueof{/pgf/cylinder end fill}}%
4328 \pgfusepath{fill}%
4329 }%
4330 \fi%
4331 }%
4332 \anchorborder{%
4333 \pgfextract@process\externalpoint{}%
4334 \getcylinderpoints%
4335 \pgfutil@ifundefined{pgf@cylinder@referencepoint}{\let\referencepoint\centerpoint}{%
4336 \let\referencepoint\pgf@cylinder@referencepoint}%
4337 \pgfextract@process\externalpoint{%
4338 \externalpoint%
4339 \pgf@xa\pgf@x%
4340 \pgf@ya\pgf@y%
4341 \referencepoint%
4342 \advance\pgf@x\pgf@xa%
4343 \advance\pgf@y\pgf@ya%
4344 }%
4345 \pgfmathanglebetweenpoints{\centerpoint}{\externalpoint}%
4346 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
4347 \ifdim\pgfmathresult pt<0pt\relax%
4348 \pgfmathadd@{\pgfmathresult}{360}%
4349 \fi%
4350 \let\externalangle\pgfmathresult%
4351 %
4352 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\afterbottomanchor}{\centerpoint}}%
4353 \ifdim\externalangle pt<\pgfmathresult pt\relax%
4354 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\beforetopanchor}{\centerpoint}}%
4355 \ifdim\externalangle pt<\pgfmathresult pt\relax%
4356 \pgfmathrotatepointaround{%
4357 \pgfmathpointintersectionoflineandarc%
4358 {\pgfmathrotatepointaround{\externalpoint}{\centerpoint}{-\rotate}}%
4359 {\pgfmathrotatepointaround{\referencepoint}{\centerpoint}{-\rotate}}%
4360 {%
4361 \beforetop%
4362 \pgf@xa\pgf@x%
4363 \centerpoint%
4364 \advance\pgf@x\pgf@xa%
4365 }%
4366 {0}{90}{\xradius and \yradius}%
4367 }{\centerpoint}{\rotate}%
4368 \else%
4369 \pgfpointintersectionoflines{%
4370 \pgfmathrotatepointaround{\pgfpointadd{\afterbottomanchor}{\centerpoint}}%
4371 {\centerpoint}{\rotate}}{%
4372 \pgfmathrotatepointaround{\pgfpointadd{\beforetopanchor}{\centerpoint}}%
4373 {\centerpoint}{\rotate}}%
4374 {\referencepoint}{\externalpoint}%
4375 \fi%
4376 \else%
4377 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\afterbottomanchor\pgf@y-\pgf@y}{\centerpoint}}%
4378 \ifdim\externalangle pt>\pgfmathresult pt\relax%
4379 \pgfmathanglebetweenpoints{\referencepoint}{\pgfpointadd{\beforetopanchor\pgf@y-\pgf@y}{\centerpoint}}%
4380 \ifdim\externalangle pt>\pgfmathresult pt\relax%
4381 \pgfmathrotatepointaround{%
4382 \pgfmathpointintersectionoflineandarc%
4383 {\pgfmathrotatepointaround{\externalpoint}{\centerpoint}{-\rotate}}%
4384 {\pgfmathrotatepointaround{\referencepoint}{\centerpoint}{-\rotate}}%
4385 {%
4386 \beforetop%
4387 \pgf@xa\pgf@x%
4388 \centerpoint
4389 \advance\pgf@x\pgf@xa%
4390 }%
4391 {270}{360}{\xradius and \yradius}%
4392 }{\centerpoint}{\rotate}%
4393 \else%
4394 \pgfpointintersectionoflines{%
4395 \pgfmathrotatepointaround{\pgfpointadd{\afterbottomanchor\pgf@y-\pgf@y}{\centerpoint}}%
4396 {\centerpoint}{\rotate}}{%
4397 \pgfmathrotatepointaround{\pgfpointadd{\beforetopanchor\pgf@y-\pgf@y}{\centerpoint}}%
4398 {\centerpoint}{\rotate}}%
4399 {\referencepoint}{\externalpoint}%
4400 \fi%
4401 \else%
4402 \pgfmathrotatepointaround{%
4403 \pgfmathpointintersectionoflineandarc%
4404 {\pgfmathrotatepointaround{\externalpoint}{\centerpoint}{-\rotate}}%
4405 {\pgfmathrotatepointaround{\referencepoint}{\centerpoint}{-\rotate}}%
4406 {%
4407 \afterbottom%
4408 \pgf@xa\pgf@x%
4409 \centerpoint
4410 \advance\pgf@x\pgf@xa%
4411 }%
4412 {90}{270}{\xradius and \yradius}%
4413 }{\centerpoint}{\rotate}%
4414 \fi%
4415 \fi%
4416 }%
4417 }%