Debian Codegraph @

texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.symbols.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.symbols.code.tex}
11
12 \pgfdeclareshape{forbidden sign}
13 {%
14 \inheritsavedanchors[from=circle]% this is nearly a circle
15 \inheritanchorborder[from=circle]%
16 \inheritanchor[from=circle]{north}%
17 \inheritanchor[from=circle]{north west}%
18 \inheritanchor[from=circle]{north east}%
19 \inheritanchor[from=circle]{center}%
20 \inheritanchor[from=circle]{west}%
21 \inheritanchor[from=circle]{east}%
22 \inheritanchor[from=circle]{mid}%
23 \inheritanchor[from=circle]{mid west}%
24 \inheritanchor[from=circle]{mid east}%
25 \inheritanchor[from=circle]{base}%
26 \inheritanchor[from=circle]{base west}%
27 \inheritanchor[from=circle]{base east}%
28 \inheritanchor[from=circle]{south}%
29 \inheritanchor[from=circle]{south west}%
30 \inheritanchor[from=circle]{south east}%
31 \inheritbackgroundpath[from=circle]%
32 \foregroundpath{
33 \centerpoint%
34 \pgf@xc=\pgf@x%
35 \pgf@yc=\pgf@y%
36 \pgfutil@tempdima=\radius%
37 \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
38 \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
39 \ifdim\pgf@xb<\pgf@yb%
40 \advance\pgfutil@tempdima by-\pgf@yb%
41 \else%
42 \advance\pgfutil@tempdima by-\pgf@xb%
43 \fi%
44 \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{-0.707107\pgfutil@tempdima}{-0.707107\pgfutil@tempdima}}}
45 \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0.707107\pgfutil@tempdima}{0.707107\pgfutil@tempdima}}}
46 \pgfsetarrowsstart{}
47 \pgfsetarrowsend{}
48 }%
49 }%
50
51
52 \pgfdeclareshape{correct forbidden sign}
53 {%
54 \inheritsavedanchors[from=circle]% this is nearly a circle
55 \inheritanchorborder[from=circle]%
56 \inheritanchor[from=circle]{north}%
57 \inheritanchor[from=circle]{north west}%
58 \inheritanchor[from=circle]{north east}%
59 \inheritanchor[from=circle]{center}%
60 \inheritanchor[from=circle]{west}%
61 \inheritanchor[from=circle]{east}%
62 \inheritanchor[from=circle]{mid}%
63 \inheritanchor[from=circle]{mid west}%
64 \inheritanchor[from=circle]{mid east}%
65 \inheritanchor[from=circle]{base}%
66 \inheritanchor[from=circle]{base west}%
67 \inheritanchor[from=circle]{base east}%
68 \inheritanchor[from=circle]{south}%
69 \inheritanchor[from=circle]{south west}%
70 \inheritanchor[from=circle]{south east}%
71 \inheritbackgroundpath[from=circle]%
72 \foregroundpath{
73 \centerpoint%
74 \pgf@xc=\pgf@x%
75 \pgf@yc=\pgf@y%
76 \pgfutil@tempdima=\radius%
77 \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
78 \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
79 \ifdim\pgf@xb<\pgf@yb%
80 \advance\pgfutil@tempdima by-\pgf@yb%
81 \else%
82 \advance\pgfutil@tempdima by-\pgf@xb%
83 \fi%
84 \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0.707107\pgfutil@tempdima}{-0.707107\pgfutil@tempdima}}}
85 \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{-0.707107\pgfutil@tempdima}{0.707107\pgfutil@tempdima}}}
86 \pgfsetarrowsstart{}
87 \pgfsetarrowsend{}
88 }%
89 }%
90
91
92
93
94
95 % Keys for starburst shape
96 %
97 % /pgf/starburst point height : The maximum height of the outer points.
98 % /pgf/starburst points : The number of points.
99 % /pgf/random starburst : The seed for the random number generator.
100 %
101 \pgfkeys{/pgf/random starburst/%
102 .code={%
103 \ifx\pgfkeysnovalue#1%
104 \pgfmathgeneratepseudorandomnumber%
105 \else%
106 \pgfmathtruncatemacro\pgfmathresult{#1}%
107 \fi%
108 \pgfkeyslet{/pgf/random starburst}{\pgfmathresult}%
109 }%
110 }%
111 \pgfkeys{/pgf/random starburst=100}%
112
113 \pgfkeys{/pgf/starburst point height/.value required}%
114 \pgfkeys{/pgf/starburst point height/.code={%
115 \pgfmathparse{#1}%
116 \edef\pgfmathresult{\pgfmathresult pt}%
117 \pgfkeyslet{/pgf/starburst point height}{\pgfmathresult}%
118 }%
119 }%
120 \pgfkeys{/pgf/starburst point height=.5cm}%
121
122 \pgfkeys{/pgf/starburst points/.value required}%
123 \pgfkeys{/pgf/starburst points/.code={%
124 \pgfmathtruncatemacro\pgfmathresult{#1}%
125 \pgfkeyslet{/pgf/starburst points}{\pgfmathresult}%
126 }%
127 }%
128 \pgfkeys{/pgf/starburst points=17}%
129
130 \pgfdeclareshape{starburst}{%
131 \savedmacro\anglestep{%
132 \pgfmathdivide@{180}{\pgfkeysvalueof{/pgf/starburst points}}%
133 \let\anglestep\pgfmathresult%
134 }%
135 \savedmacro\calculatestarburstpoints{%
136 %
137 % Get the angle step.
138 %
139 \pgfmathdivide@{180}{\pgfkeysvalueof{/pgf/starburst points}}%
140 \let\anglestep\pgfmathresult%
141 %
142 % Get the total number of points.
143 %
144 \pgfmathsetcounter{pgf@counta}{\pgfkeysvalueof{/pgf/starburst points}}%
145 \multiply\c@pgf@counta2\relax%
146 \edef\totalpoints{\the\c@pgf@counta}%
147 \addtosavedmacro{\totalpoints}%
148 %
149 % Calculate the centerpoint.
150 %
151 \pgfextract@process\centerpoint{%
152 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
153 \pgfmathsetlength\pgf@y{+.5\ht\pgfnodeparttextbox}%
154 \pgfmathaddtolength\pgf@y{+-.5\dp\pgfnodeparttextbox}%
155 }%
156 %
157 % Get the larger of the outer sep.
158 %
159 \pgfmathsetlength\pgf@x{+\pgfkeysvalueof{/pgf/outer xsep}}%
160 \pgfmathsetlength\pgf@y{+\pgfkeysvalueof{/pgf/outer ysep}}%
161 \ifdim\pgf@x<\pgf@y%
162 \pgf@x\pgf@y%
163 \fi%
164 \edef\outersep{\the\pgf@x}%
165 %
166 % Get the node dimensions.
167 %
168 \pgfmathsetlength\pgf@x{+\pgfkeysvalueof{/pgf/inner xsep}}%
169 \pgfmathaddtolength\pgf@x{+.5\wd\pgfnodeparttextbox}%
170 \pgfmathsetlength\pgf@y{+\pgfkeysvalueof{/pgf/inner ysep}}%
171 \pgfmathaddtolength\pgf@y{+.5\ht\pgfnodeparttextbox}%
172 \pgfmathaddtolength\pgf@y{+.5\dp\pgfnodeparttextbox}%
173 %
174 % Calculate the inner radii.
175 %
176 \ifpgfshapeborderusesincircle%
177 \pgfkeysgetvalue{/pgf/shape border rotate}{\rotate}%
178 %
179 % Use the incircle...
180 %
181 \ifdim\pgf@y>\pgf@x%
182 \pgf@x\pgf@y%
183 \fi%
184 \[email protected]\pgf@x%
185 \pgf@y\pgf@x%
186 \else%
187 %
188 % Get the rotation (with rounding).
189 %
190 \pgfkeysgetvalue{/pgf/shape border rotate}{\rotate}%
191 \pgfmathmod@{\rotate}{360}%
192 \afterassignment\pgfmath@gobbletilpgfmath@%
193 \expandafter\c@pgf@counta\pgfmathresult\relax\pgfmath@%
194 \advance\c@pgf@counta45\relax%
195 \divide\c@pgf@counta90\relax%
196 \multiply\c@pgf@counta90\relax%
197 \ifnum\c@pgf@counta<0\relax%
198 \advance\c@pgf@counta360\relax%
199 \fi%
200 %
201 % Calculate the width and height of the node
202 % contents, according to any border rotation.
203 %
204 \ifnum\c@pgf@counta=90\relax%
205 \pgf@xc\pgf@x%
206 \pgf@x\pgf@y%
207 \pgf@y\pgf@xc%
208 \else%
209 \ifnum\c@pgf@counta=270\relax%
210 \pgf@xc\pgf@x%
211 \pgf@x\pgf@y%
212 \pgf@y\pgf@xc%
213 \fi%
214 \fi%
215 \edef\rotate{\the\c@pgf@counta}%
216 %
217 % ...or not.
218 %
219 \pgf@x=1.41421\pgf@x%
220 \pgf@y=1.41421\pgf@y%
221 \fi%
222 \addtosavedmacro{\rotate}%
223 %
224 % Adjust innerradius for minimum width and height.
225 %
226 \pgf@xa\pgf@x%
227 \pgfmathsetlength\pgf@xb{+\pgfkeysvalueof{/pgf/starburst point height}}%
228 \advance\pgf@xa\pgf@xb%
229 \pgfmathsetlength\pgf@xc{+\pgfkeysvalueof{/pgf/minimum width}}%
230 \ifdim\pgf@xa<.5\pgf@xc%
231 \[email protected]\pgf@xc%
232 \advance\pgf@x-\pgf@xb%
233 \fi%
234 \pgf@ya\pgf@y%
235 \pgfmathsetlength\pgf@yb{+\pgfkeysvalueof{/pgf/starburst point height}}%
236 \advance\pgf@ya\pgf@yb%
237 \pgfmathsetlength\pgf@yc{+\pgfkeysvalueof{/pgf/minimum height}}%
238 \ifdim\pgf@ya<.5\pgf@yc%
239 \[email protected]\pgf@yc%
240 \advance\pgf@y-\pgf@yb%
241 \fi%
242 \edef\xinnerradius{\the\pgf@x}%
243 \edef\yinnerradius{\the\pgf@y}%
244 \addtosavedmacro{\xinnerradius}%
245 \addtosavedmacro{\yinnerradius}%
246 %
247 % Calculate a radius outside the starburst.
248 %
249 \ifdim\pgf@y>\pgf@x%
250 \pgf@x\pgf@y%
251 \fi%
252 \pgfmathaddtolength\pgf@x{+\pgfkeysvalueof{/pgf/starburst point height}}%
253 \edef\externalradius{\the\pgf@x}%
254 \addtosavedmacro{\externalradius}%
255 %
256 % Set the seed for the random number generator.
257 %
258 \pgfmathsetseed{\pgfkeysvalueof{/pgf/random starburst}}%
259 %
260 % Now create the points on the shape and also
261 % the miter length and angle for each point.
262 %
263 \def\angle{90}% Start at the top.
264 %
265 % At point a, the miter length and angle are calculated for point b = a - 1.
266 %
267 \c@pgf@counta1\relax%
268 \c@pgf@countb0\relax%
269 %
270 % As 3 consecutive points are required to be defined for miter
271 % calculations, it is necessary to go over the first two points
272 % again.
273 %
274 \c@pgf@countc\totalpoints\relax%
275 \advance\c@pgf@countc2\relax%
276 \edef\looppoints{\the\c@pgf@countc}%
277 \let\secondpoint\pgfutil@empty%
278 \let\thirdpoint\pgfutil@empty%
279 \pgfmathloop%
280 %
281 % Cycle the point definitions.
282 %
283 \let\firstpoint\secondpoint%
284 \let\secondpoint\thirdpoint%
285 \ifnum\pgfmathcounter>\looppoints%
286 \else%
287 \ifnum\pgfmathcounter>\totalpoints%
288 \expandafter\let\expandafter\thirdpoint\csname point@\the\c@pgf@counta @\endcsname%
289 \else%
290 \ifodd\pgfmathcounter%
291 %
292 % An outer point.
293 %
294 \ifnum\pgfkeysvalueof{/pgf/random starburst}=0\relax%
295 \pgf@xa\pgfkeysvalueof{/pgf/starburst point height}\relax%
296 \else%
297 \pgf@x\pgfkeysvalueof{/pgf/starburst point height}\relax%
298 \[email protected]\pgf@x%
299 \[email protected]\pgf@x%
300 \pgfmathrnd%
301 \pgf@xa\pgfmathresult\pgf@xa%
302 \advance\pgf@xa\pgf@xb%
303 \fi%
304 \pgf@x\xinnerradius\relax%
305 \advance\pgf@x\pgf@xa%
306 \pgf@y\yinnerradius\relax%
307 \advance\pgf@y\pgf@xa%
308 \expandafter\pgfextract@process\csname point@\the\c@pgf@counta @\endcsname{%
309 \pgfpointpolar{\angle}{\the\pgf@x and \the\pgf@y}%
310 \pgf@xa\pgf@x%
311 \pgf@ya\pgf@y%
312 \centerpoint%
313 \advance\pgf@x\pgf@xa%
314 \advance\pgf@y\pgf@ya%
315 }%
316 \else%
317 %
318 % An inner point.
319 %
320 \expandafter\pgfextract@process\csname point@\the\c@pgf@counta @\endcsname{%
321 \pgfpointpolar{\angle}{\xinnerradius and \yinnerradius}%
322 \pgf@xa\pgf@x%
323 \pgf@ya\pgf@y%
324 \centerpoint%
325 \advance\pgf@x\pgf@xa%
326 \advance\pgf@y\pgf@ya%
327 }%
328 \fi%
329 %
330 % Add the points to the saved macro.
331 %
332 \expandafter\let\expandafter\thirdpoint\csname point@\the\c@pgf@counta @\endcsname%
333 \expandafter\addtosavedmacro\expandafter{\csname point@\the\c@pgf@counta @\endcsname}%
334 \fi%
335 %
336 % It is only possible to do the miter calculations if three points are defined.
337 %
338 \ifx\firstpoint\pgfutil@empty%
339 \else%
340 %
341 % Calculate the miter length...
342 %
343 \pgfmathanglebetweenlines{\secondpoint}{\thirdpoint}{\secondpoint}{\firstpoint}%
344 \pgfmathdivide@{\pgfmathresult}{2}%
345 \let\defaultmiterangle\pgfmathresult%
346 \pgfmathcosec@{\pgfmathresult}%
347 \pgf@x\outersep\relax%
348 \pgf@x\pgfmathresult\pgf@x%
349 \edef\miterlength{\the\pgf@x}%
350 %
351 % ...the miter angle...
352 %
353 \pgfmathanglebetweenlines{\firstpoint}{\secondpoint}{\firstpoint}{\thirdpoint}%
354 \pgfmathadd@{\pgfmathresult}{\defaultmiterangle}%
355 \pgfmathsubtract@{180}{\pgfmathresult}%
356 \let\angletemp\pgfmathresult%
357 \pgfmathanglebetweenpoints{\firstpoint}{\thirdpoint}%
358 \pgfmathsubtract@{180}{\pgfmathresult}%
359 \pgfmathsubtract@{\angletemp}{\pgfmathresult}%
360 \edef\miterangle{\pgfmathresult}%
361 %
362 % ...and thus the border point.
363 %
364 \pgfextract@process\borderpoint{%
365 \secondpoint%
366 \pgf@xa\pgf@x
367 \pgf@ya\pgf@y%
368 \pgfpointpolar{\miterangle}{\miterlength}%
369 \advance\pgf@x\pgf@xa%
370 \advance\pgf@y\pgf@ya%
371 }%
372 %
373 % Get the angle from the centerpoint to the *unrotated* border points.
374 %
375 \pgfmathanglebetweenpoints{\centerpoint}{\borderpoint}%
376 \expandafter\edef\csname angletoborderpoint@\the\c@pgf@countb @\endcsname{\pgfmathresult}%
377 \expandafter\addtosavedmacro\expandafter{\csname angletoborderpoint@\the\c@pgf@countb @\endcsname}%
378 %
379 % Rotate the border points and save.
380 %
381 \expandafter\pgfextract@process\csname borderpoint@\the\c@pgf@countb @\endcsname{%
382 \pgfmathrotatepointaround{\borderpoint}{\centerpoint}{\rotate}%
383 }%
384 \expandafter\addtosavedmacro\expandafter{\csname borderpoint@\the\c@pgf@countb @\endcsname}%
385 %
386 % Now create the anchors.
387 %
388 \c@pgf@countc\c@pgf@countb%
389 \advance\c@pgf@countc1\relax%
390 \divide\c@pgf@countc2\relax%
391 \ifodd\c@pgf@countb\relax%
392 \pgfutil@ifundefined{pgf@anchor@starburst@outer point\space\the\c@pgf@countc}{%
393 \expandafter\xdef\csname pgf@anchor@starburst@outer point\space\the\c@pgf@countc\endcsname{%
394 \noexpand\calculatestarburstpoints%
395 \noexpand\csname borderpoint@\the\c@pgf@countb @\noexpand\endcsname%
396 }%
397 }{}%
398 \else%
399 \pgfutil@ifundefined{pgf@anchor@starburst@inner point\space\the\c@pgf@countc}{%
400 \expandafter\xdef\csname pgf@anchor@starburst@inner point\space\the\c@pgf@countc\endcsname{%
401 \noexpand\calculatestarburstpoints%
402 \noexpand\csname borderpoint@\the\c@pgf@countb @\noexpand\endcsname%
403 }%
404 }{}%
405 \fi%
406 \fi%
407 \pgfmathadd@{\angle}{\anglestep}%
408 \pgfmathmod@{\pgfmathresult}{360}%
409 \let\angle\pgfmathresult%
410 \advance\c@pgf@counta1\relax%
411 \ifnum\c@pgf@counta>\totalpoints%
412 \c@pgf@counta1\relax%
413 \fi%
414 \advance\c@pgf@countb1\relax%
415 \ifnum\c@pgf@countb>\totalpoints%
416 \c@pgf@countb1\relax%
417 \fi%
418 \repeatpgfmathloop%
419 }%
420 \savedanchor\centerpoint{%
421 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
422 \pgfmathsetlength\pgf@y{+.5\ht\pgfnodeparttextbox}%
423 \pgfmathaddtolength\pgf@y{+-.5\dp\pgfnodeparttextbox}%
424 }%
425 \savedanchor\midpoint{%
426 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
427 \pgfmathsetlength\pgf@y{+.5ex}%
428 }%
429 \savedanchor\basepoint{%
430 \pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
431 \pgf@y0pt\relax%
432 }%
433 \anchor{center}{\centerpoint}%
434 \anchor{base}{\basepoint}%
435 \anchor{mid}{\midpoint}%
436 \anchor{north}{%
437 \calculatestarburstpoints%
438 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{0pt}{\externalradius}}%
439 }%
440 \anchor{south}{%
441 \calculatestarburstpoints%
442 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{0pt}{-\externalradius}}%
443 }%
444 \anchor{east}{%
445 \calculatestarburstpoints%
446 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{\externalradius}{0pt}}%
447 }%
448 \anchor{west}{%
449 \calculatestarburstpoints%
450 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{-\externalradius}{0pt}}%
451 }%
452 \anchor{north west}{%
453 \calculatestarburstpoints%
454 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{-\externalradius}{\externalradius}}%
455 }%
456 \anchor{south west}{%
457 \calculatestarburstpoints%
458 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{-\externalradius}{-\externalradius}}%
459 }%
460 \anchor{north east}{%
461 \calculatestarburstpoints%
462 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{\externalradius}{\externalradius}}%
463 }%
464 \anchor{south east}{%
465 \calculatestarburstpoints%
466 \csname pgf@anchor@starburst@border\endcsname{\pgfqpoint{\externalradius}{-\externalradius}}%
467 }%
468 \backgroundpath{%
469 \calculatestarburstpoints%
470 \pgfmathloop%
471 \ifnum\pgfmathcounter>\totalpoints%
472 \else%
473 \ifnum\pgfmathcounter=1\relax%
474 \let\starburstaction\pgfpathmoveto%
475 \else%
476 \let\starburstaction\pgfpathlineto%
477 \fi%
478 \starburstaction{%
479 %\pgfmathrotatepointaround{\csname point@\pgfmathcounter @\endcsname}{\centerpoint}{\rotate}}%
480 \csname point@\pgfmathcounter @\endcsname}
481 \repeatpgfmathloop%
482 \pgfpathclose%
483 }%
484 \anchorborder{%
485 %
486 % Save x and y.
487 %
488 \edef\externalx{\the\pgf@x}%
489 \edef\externaly{\the\pgf@y}%
490 %
491 % Adjust the location of the external
492 % point relative to \centerpoint.
493 %
494 \centerpoint%
495 \pgf@xa\externalx\relax%
496 \pgf@ya\externaly\relax%
497 \advance\pgf@xa\pgf@x%
498 \advance\pgf@ya\pgf@y%
499 \edef\externalx{\the\pgf@xa}%
500 \edef\externaly{\the\pgf@ya}%
501 %
502 % Get the starburst points.
503 %
504 \calculatestarburstpoints%
505 %
506 % Get the angle of the external point to the \centerpoint.
507 %
508 \pgfmathanglebetweenpoints{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
509 \pgfmathsubtract@{\pgfmathresult}{\rotate}%
510 \ifdim\pgfmathresult pt<0pt\relax%
511 \pgfmathadd@{\pgfmathresult}{360}%
512 \fi%
513 \let\externalangle\pgfmathresult%
514 %
515 % Locate the appropriate sides on the starburst border...
516 %
517 \ifdim\externalangle pt<90pt\relax%
518 \c@pgf@counta0\relax%
519 \c@pgf@countb\totalpoints\relax%
520 \pgfmathloop%
521 \ifnum\c@pgf@counta>0\relax%
522 \else%
523 \ifdim\csname angletoborderpoint@\the\c@pgf@countb @\endcsname pt>90pt\relax%
524 \c@pgf@counta\c@pgf@countb%
525 \else%
526 \ifdim\externalangle pt>\csname angletoborderpoint@\the\c@pgf@countb @\endcsname pt\relax%
527 \c@pgf@counta\c@pgf@countb%
528 \fi%
529 \fi%
530 \advance\c@pgf@countb-1\relax%
531 \repeatpgfmathloop%
532 \edef\first{\the\c@pgf@counta}%
533 \advance\c@pgf@counta1\relax%
534 \ifnum\c@pgf@counta>\totalpoints\relax%
535 \c@pgf@counta1\relax%
536 \fi%
537 \edef\second{\the\c@pgf@counta}%
538 \else%
539 \c@pgf@counta0\relax%
540 \pgfmathloop%
541 \ifnum\c@pgf@counta>0\relax%
542 \else%
543 \ifdim\csname angletoborderpoint@\pgfmathcounter @\endcsname pt<90pt\relax%
544 \c@pgf@counta\pgfmathcounter%
545 \else%
546 \ifdim\externalangle pt<\csname angletoborderpoint@\pgfmathcounter @\endcsname pt\relax%
547 \c@pgf@counta\pgfmathcounter%
548 \fi%
549 \fi%
550 \repeatpgfmathloop%
551 \edef\first{\the\c@pgf@counta}%
552 \advance\c@pgf@counta-1\relax%
553 \ifnum\c@pgf@counta=0\relax%
554 \c@pgf@counta\totalpoints\relax%
555 \fi%
556 \edef\second{\the\c@pgf@counta}%
557 \fi%
558 %
559 % ...and thus, the point on the star border.
560 %
561 \pgfpointintersectionoflines{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
562 {\csname borderpoint@\first @\endcsname}{\csname borderpoint@\second @\endcsname}%
563 }%
564 }%
565
566
567
568
569 % Keys for shape cloud.
570 %
571 % /pgf/cloud puffs : the number of cloud puffs.
572 % /pgf/cloud puff arc : the length of the cloud puff arc.
573
574 \newif\ifpgfcloudanchorsuseellipse%
575 \newif\ifpgfcloudignoresaspect%
576 \pgfcloudignoresaspectfalse%
577 \pgfkeys{/pgf/.cd,
578 cloud puffs/.initial=10,
579 cloud puff arc/.initial=150,
580 cloud ignores aspect/.is if=pgfcloudignoresaspect,
581 cloud anchors use ellipse/.is if=pgfcloudanchorsuseellipse,
582 }%
583
584
585 % If symbol library is loaded separately these need to be defined.
586 %
587 \pgfkeys{/pgf/.cd,
588 aspect/.code={\pgfsetshapeaspect{#1}},% this for tikz...
589 shape aspect/.initial=1,% but this is consistent with other pgfset stuff.
590 shape aspect/.code={%
591 \pgfkeys{/pgf/aspect={#1}}%
592 \pgfkeyssetvalue{/pgf/shape aspect}{#1}
593 }%
594 }%
595
596 \def\pgfsetshapeaspect#1{%
597 \def\pgfshapeaspect{#1}%
598 % Invert
599 \pgfutil@tempdima=#1pt%
600 \pgfutil@tempdima=.125\pgfutil@tempdima%
601 \c@pgf@counta=\pgfutil@tempdima\relax% 8192*determinant
602 \pgfutil@tempdima=8192pt%
603 \divide\pgfutil@tempdima by\c@pgf@counta%
604 \edef\pgfshapeaspectinverse{\pgf@sys@tonumber{\pgfutil@tempdima}}%
605 }%
606
607 \pgfsetshapeaspect{1}%
608
609
610 % Shape cloud.
611 %
612 \pgfdeclareshape{cloud}{%
613 \savedmacro\getradii{%
614 \pgfmathtruncatemacro\puffs{\pgfkeysvalueof{/pgf/cloud puffs}}%
615 \addtosavedmacro\puffs%
616 \pgfmathdivide{360}{\pgfkeysvalueof{/pgf/cloud puffs}}%
617 \let\anglestep\pgfmathresult%
618 \addtosavedmacro\anglestep%
619 \pgfmathsetmacro\arc{\pgfkeysvalueof{/pgf/cloud puff arc}}%
620 \addtosavedmacro\arc%
621 %
622 % x radius.
623 %
624 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
625 \advance\[email protected]\wd\pgfnodeparttextbox%
626 \[email protected]\pgf@x%
627 %
628 % y radius.
629 %
630 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
631 \advance\[email protected]\ht\pgfnodeparttextbox%
632 \advance\[email protected]\dp\pgfnodeparttextbox%
633 \[email protected]\pgf@y%
634 %
635 % Adjust for shape aspect.
636 %
637 \ifpgfcloudignoresaspect%
638 \pgf@xc\pgf@x%
639 \pgf@yc\pgf@y%
640 \else%
641 \pgf@xc\pgfshapeaspect\pgf@y%
642 \ifdim\pgf@xc<\pgf@x%
643 \pgf@xc\pgf@x%
644 \fi%
645 \pgf@yc\pgfshapeaspectinverse\pgf@xc%
646 \ifdim\pgf@yc<\pgf@y%
647 \pgf@yc\pgf@y%
648 \pgf@xc\pgfshapeaspect\pgf@y%
649 \fi%
650 \fi%
651 %
652 \edef\xinnerradius{\the\pgf@xc}%
653 \edef\yinnerradius{\the\pgf@yc}%
654 %
655 % Get the larger of the outer sep.
656 %
657 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
658 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
659 \ifdim\pgf@x<\pgf@y%
660 \pgf@x\pgf@y%
661 \fi%
662 \edef\outersep{\the\pgf@x}%
663 \addtosavedmacro\outersep%
664 %
665 % For a given cloud, with puff arc length a, the quotient of the
666 % distance between the start and end point of a puffs circular arc
667 % and the radius of that arc, is constant:
668 %
669 % g = .5 * sec((180-a)/2)
670 %
671 \pgfmathsubtract{180}{\arc}%
672 \pgfmathdivide@{\pgfmathresult}{2}%
673 \let\tempangle\pgfmathresult%
674 \pgfmathsec@{\pgfmathresult}%
675 \pgfmathdivide@{\pgfmathresult}{2}%
676 \let\arcradiusquotient\pgfmathresult%
677 \addtosavedmacro\arcradiusquotient%
678 %
679 % In addition, the quotient of the distance between the start and
680 % end point of a puffs circular arc and the height of that arc
681 % (ignoring rotation), is also constant:
682 %
683 % h = .5 * (1-sin((180-a)/2))/cos((180-a)/2)
684 % = g * (1 - sin((180-a)/2))
685 \pgfmathsin@{\tempangle}%
686 \pgfmathsubtract@{1}{\pgfmathresult}%
687 \pgfmathmultiply@{\pgfmathresult}{\arcradiusquotient}%
688 \let\archeightquotient\pgfmathresult%
689 \addtosavedmacro\archeightquotient%
690 %
691 % Minimum size is applied to the circum-ellipse (i.e. the ellipse
692 % that passes through the extremities of each puff). Thus, the
693 % relationship between the radii of the elliptical incircle ("inellipse"?)
694 % of the cloud (x and y) and the radii of the circum-ellipse (X and Y),
695 % is given by
696 %
697 % X = 2(x*cos(p/2) + ky)
698 % Y = 2(y*cos(p/2) + kx)
699 %
700 % where:
701 % k = sin(p/2)*((1-cos(a/2))/sin(a/2))
702 % p = the angle between each puff (i.e. 360/<puffs>)
703 % a = the length of arc of the puff.
704 %
705 \pgfmathdivide{\arc}{2}%
706 \let\halfarcangle\pgfmathresult%
707 \pgfmathcos@{\pgfmathresult}%
708 \pgfmathsubtract@{1}{\pgfmathresult}%
709 \let\pgf@temp\pgfmathresult%
710 \pgfmathsin@{\halfarcangle}%
711 \pgfmathdivide@{\pgf@temp}{\pgfmathresult}%
712 \let\pgf@temp\pgfmathresult%
713 \pgfmathdivide@{\anglestep}{2}%
714 \pgfmathsin@{\pgfmathresult}%
715 \pgfmathmultiply@{\pgfmathresult}{\pgf@temp}%
716 \let\k\pgfmathresult%
717 %
718 \pgfmathdivide@{\anglestep}{2}%
719 \pgfmathcos@{\pgfmathresult}%
720 \let\coshalfanglestep\pgfmathresult%
721 %
722 % Calculate the actual radii of the circum-ellipse.
723 %
724 \pgf@x\xinnerradius\relax%
725 \pgf@y\yinnerradius\relax%
726 \pgf@xa\coshalfanglestep\pgf@x%
727 \advance\pgf@xa\k\pgf@y%
728 \pgf@ya\coshalfanglestep\pgf@y%
729 \advance\pgf@ya\k\pgf@x%
730 %
731 % Adjust for minimum height (Y').
732 %
733 \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}%
734 \ifdim\pgf@ya<.5\pgf@yb%
735 \[email protected]\pgf@yb%
736 \fi%
737 %
738 % Adjust for minimum width (X').
739 %
740 \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}%
741 \ifdim\pgf@xa<.5\pgf@xb%
742 \[email protected]\pgf@xb%
743 \fi%
744 %
745 \edef\xouterradius{\the\pgf@xa}%
746 \addtosavedmacro\xouterradius%
747 \edef\youterradius{\the\pgf@ya}%
748 \addtosavedmacro\youterradius%
749 %
750 % Now recalculate `in-ellipse' radii:
751 %
752 % x = (X'cos(p/2)-kY')/cos^2(p/2)-k^2,
753 % y = (Y'cos(p/2)-kX')/cos^2(p/2)-k^2,
754 %
755 \pgf@xc\k pt\relax%
756 \pgf@xc-\k\pgf@xc%
757 \pgf@yc\coshalfanglestep pt\relax%
758 \pgf@yc\coshalfanglestep\pgf@yc%
759 \advance\pgf@xc\pgf@yc\relax%
760 \pgfmathreciprocal@{\pgfmath@tonumber{\pgf@xc}}% cos^2(p/2)-k^2
761 %
762 \pgf@x\coshalfanglestep\pgf@xa%
763 \advance\pgf@x-\k\pgf@ya%
764 \pgf@x\pgfmathresult\pgf@x%
765 \pgf@y\coshalfanglestep\pgf@ya%
766 \advance\pgf@y-\k\pgf@xa%
767 \pgf@y\pgfmathresult\pgf@y%
768 %
769 \edef\xinnerradius{\the\pgf@x}%
770 \edef\yinnerradius{\the\pgf@y}%
771 \addtosavedmacro\xinnerradius%
772 \addtosavedmacro\yinnerradius%
773 %
774 % Get some useful trig. constants.
775 %
776 \pgfmathdivide@{\arc}{4}%
777 \let\quarterarc\pgfmathresult%
778 \pgfmathsubtract@{180}{\arc}%
779 \pgfmathdivide@{\pgfmathresult}{2}%
780 \let\halfcomplementarc\pgfmathresult%
781 %
782 \addtosavedmacro\arc%
783 \addtosavedmacro\quarterarc%
784 \addtosavedmacro\halfcomplementarc%
785 %
786 \pgfmathsec@{\halfcomplementarc}% 1/cos((180-a)/2)
787 \let\sechalfcomplementarc\pgfmathresult%
788 \pgfmathsin@{\halfcomplementarc}% sin((180-a)/2)
789 \let\sinhalfcomplementarc\pgfmathresult%
790 %
791 \addtosavedmacro\sechalfcomplementarc%
792 \addtosavedmacro\sinhalfcomplementarc%
793 %
794 \pgfmathsin@{\quarterarc}% sin(a/4)
795 \let\sinquarterarc\pgfmathresult%
796 \pgfmathcos@{\quarterarc}% cos(a/4)
797 \let\cosquarterarc\pgfmathresult%
798 \pgfmathreciprocal@{\cosquarterarc}%
799 \pgfmathmultiply@{\pgfmathresult}{\sinquarterarc}% tan(a/4)
800 \let\tanquarterarc\pgfmathresult%
801 %
802 \addtosavedmacro\sinquarterarc%
803 \addtosavedmacro\cosquarterarc%
804 \addtosavedmacro\tanquarterarc%
805 %
806 }%
807 \savedanchor\centerpoint{%
808 \[email protected]\wd\pgfnodeparttextbox%
809 \[email protected]\ht\pgfnodeparttextbox%
810 \advance\[email protected]\dp\pgfnodeparttextbox%
811 }%
812 \savedanchor\midpoint{%
813 \[email protected]\wd\pgfnodeparttextbox%
814 \pgfmathsetlength\pgf@y{+.5ex}%
815 }%
816 \savedanchor\basepoint{%
817 \[email protected]\wd\pgfnodeparttextbox%
818 \pgf@y0pt%
819 }%
820 \anchor{center}{\centerpoint}%
821 \anchor{mid}{\midpoint}%
822 \anchor{base}{\basepoint}%
823 \anchor{north}{%
824 \getradii%
825 \csname pgf@anchor@cloud@border\endcsname{\pgfqpoint{0pt}{\youterradius}}%
826 }%
827 \anchor{south}{%
828 \getradii%
829 \csname pgf@anchor@cloud@border\endcsname{\pgfqpoint{0pt}{-\youterradius}}%
830 }%
831 \anchor{east}{%
832 \getradii%
833 \csname pgf@anchor@cloud@border\endcsname{\pgfqpoint{\xouterradius}{0pt}}%
834 }%
835 \anchor{west}{%
836 \getradii%
837 \csname pgf@anchor@cloud@border\endcsname{\pgfqpoint{-\xouterradius}{0pt}}%
838 }%
839 \anchor{north west}{%
840 \getradii%
841 \pgfextract@process\pgf@sh{%
842 \pgf@x\xouterradius\relax%
843 \[email protected]\pgf@x%
844 \pgf@y\youterradius\relax%
845 \[email protected]\pgf@y%
846 }%
847 \csname pgf@anchor@cloud@border\endcsname{\pgf@sh}%
848 }%
849 \anchor{north east}{%
850 \getradii%
851 \pgfextract@process\pgf@sh{%
852 \pgf@x\xouterradius\relax%
853 \[email protected]\pgf@x%
854 \pgf@y\youterradius\relax%
855 \[email protected]\pgf@y%
856 }%
857 \csname pgf@anchor@cloud@border\endcsname{\pgf@sh}%
858 }%
859 \anchor{south west}{%
860 \getradii%
861 \pgfextract@process\pgf@sh{%
862 \pgf@x\xouterradius\relax%
863 \[email protected]\pgf@x%
864 \pgf@y\youterradius\relax%
865 \[email protected]\pgf@y%
866 }%
867 \csname pgf@anchor@cloud@border\endcsname{\pgf@sh}%
868 }%
869 \anchor{south east}{%
870 \getradii%
871 \pgfextract@process\pgf@sh{%
872 \pgf@x\xouterradius\relax%
873 \[email protected]\pgf@x%
874 \pgf@y\youterradius\relax%
875 \[email protected]\pgf@y%
876 }%
877 \csname pgf@anchor@cloud@border\endcsname{\pgf@sh}%
878 }%
879 %
880 % Each `puff' is a circular arc of length a, drawn using two a/2
881 % arcs (a < 180), approximated by Bezier curves.
882 % Due to TeX rounding errors, it is sometimes necessary to `force'
883 % the arc to end at a specific point. So...
884 %
885 % @article{riskus2006,
886 % author = {Aleskus Ri\v{s}kus},
887 % title = {Approximation of a cubic Bezier curve by circular arcs and vice versa},
888 % journal = {Information Technology and Control},
889 % year = {2006},
890 % volume = {35},
891 % number = {4}
892 % }
893 %
894 \backgroundpath{%
895 {%
896 \getradii%
897 %
898 % Get the start angle.
899 %
900 \pgfmathdivide@{\anglestep}{2}%
901 \pgfmathsubtract@{90}{\pgfmathresult}%
902 \let\angle\pgfmathresult%
903 %
904 % Calculate the first arc point.
905 %
906 \pgfextract@process\arcfirstpoint{%
907 \pgfpointadd{\centerpoint}{%
908 \pgfpointpolar{+\angle}{+\xinnerradius and +\yinnerradius}%
909 }%
910 }%
911 \pgfpathmoveto{\arcfirstpoint}%
912 \let\arcendpoint\arcfirstpoint%
913 %
914 \pgfmathloop%
915 \ifnum\pgfmathcounter>\puffs\relax%
916 \else
917 \let\arcstartpoint\arcendpoint%
918 %
919 % Make sure beginning and end of path are exactly the same.
920 %
921 \ifnum\pgfmathcounter=\puffs\relax%
922 \let\arcendpoint\arcfirstpoint%
923 \else%
924 \pgfmathadd@{\angle}{\anglestep}%
925 \let\angle\pgfmathresult%
926 \pgfextract@process\arcendpoint{%
927 \pgfpointadd{\centerpoint}{%
928 \pgfpointpolar{+\angle}{+\xinnerradius and +\yinnerradius}%
929 }%
930 }%
931 \fi%
932 %
933 % Get some useful cloud parameters from \arcstartpoint and \arcendpoint.
934 %
935 \pgf@sh@getcloudpuffparameters%
936 %
937 % Get the rotation for the Bezier curve.
938 %
939 \pgfmathsubtract@{90}{\quarterarc}%
940 \pgfmathadd@{\pgfmathresult}{\arcslope}%
941 \let\arcrotate\pgfmathresult%
942 \pgfmathsin@{\arcrotate}%
943 \let\sinarcrotate\pgfmathresult%
944 \pgfmathcos@{\arcrotate}%
945 \let\cosarcrotate\pgfmathresult%
946 %
947 % Calculate the amount by which to scale the control
948 % points, in order to approximate an a/2 arc with radius x.
949 %
950 \pgf@x\arcradius\relax%
951 \pgf@x\tanquarterarc\pgf@x% tan(a/4)
952 \edef\controlscale{\pgfmath@tonumber{\pgf@x}}%
953 %
954 % Get the first control point for the first arc (length a/2)...
955 %
956 \pgfextract@process\controlone{%
957 %
958 % k = 0.552284745 (a `magic' number)...
959 %
960 \[email protected]\relax%
961 \pgf@x\sinquarterarc\pgf@x% k * sin(a/2)
962 \[email protected]\relax%
963 \pgf@y\cosquarterarc\pgf@y% k * cos(a/2)
964 %
965 % ...scale the control points up...
966 %
967 \pgf@x\controlscale\pgf@x%
968 \pgf@y\controlscale\pgf@y%
969 %
970 % ...rotate...
971 %
972 \pgf@xa\cosarcrotate\pgf@x%
973 \advance\pgf@xa-\sinarcrotate\pgf@y%
974 \pgf@ya\cosarcrotate\pgf@y%
975 \advance\pgf@ya\sinarcrotate\pgf@x%
976 %
977 % ...and shift.
978 %
979 \arcstartpoint%
980 \advance\pgf@x\pgf@xa%
981 \advance\pgf@y\pgf@ya%
982 }%
983 %
984 % Get the midpoint of the 150� arc.
985 %
986 \pgfextract@process\arcmidpoint{%
987 \pgfextract@process\arcmidpoint{%
988 \pgf@x-\halfchordlength\relax%
989 \pgf@y\segmentheight\relax%
990 }%
991 \pgfpointadd{\arcstartpoint}{%
992 \pgfmathrotatepointaround{\arcmidpoint}{\pgfpointorigin}{\arcslope}%
993 }%
994 }%
995 %
996 % Get the second control point for the first arc (length a/2)...
997 %
998 \pgfextract@process\controltwo{%
999 \[email protected]\relax%
1000 \pgf@x\sinquarterarc\pgf@x% k * sin(a/2)
1001 \[email protected]\relax%
1002 \pgf@y\cosquarterarc\pgf@y% -k * cos(a/2)
1003 %
1004 % ...scale, rotate and shift.
1005 %
1006 \pgf@x\controlscale\pgf@x%
1007 \pgf@y\controlscale\pgf@y%
1008 %
1009 \pgf@xa\cosarcrotate\pgf@x%
1010 \advance\pgf@xa-\sinarcrotate\pgf@y%
1011 \pgf@ya\cosarcrotate\pgf@y%
1012 \advance\pgf@ya\sinarcrotate\pgf@x%
1013 %
1014 \arcmidpoint%
1015 \advance\pgf@x\pgf@xa%
1016 \advance\pgf@y\pgf@ya%
1017 }%
1018 {%
1019 \pgfsetcornersarced{\pgfpointorigin}%
1020 \pgfpathcurveto{\controlone}{\controltwo}{\arcmidpoint}%
1021 }%
1022 %
1023 % Do the same for the second arc...
1024 %
1025 \pgfmathadd@{\quarterarc}{90}%
1026 \pgfmathadd@{\pgfmathresult}{\arcslope}%
1027 \let\arcrotate\pgfmathresult%
1028 \pgfmathsin@{\arcrotate}%
1029 \let\sinarcrotate\pgfmathresult%
1030 \pgfmathcos@{\arcrotate}%
1031 \let\cosarcrotate\pgfmathresult%
1032 %
1033 % First control point for the second arc...
1034 %
1035 \pgfextract@process\controlone{%
1036 \[email protected]\relax%
1037 \pgf@x\sinquarterarc\pgf@x% k * sin(a/2)
1038 \[email protected]\relax%
1039 \pgf@y\cosquarterarc\pgf@y% k * cos(a/2)
1040 %
1041 % ...scale, rotate and shift.
1042 %
1043 \pgf@x\controlscale\pgf@x%
1044 \pgf@y\controlscale\pgf@y%
1045 %
1046 \pgf@xa\cosarcrotate\pgf@x%
1047 \advance\pgf@xa-\sinarcrotate\pgf@y%
1048 \pgf@ya\cosarcrotate\pgf@y%
1049 \advance\pgf@ya\sinarcrotate\pgf@x%
1050 %
1051 \arcmidpoint%
1052 \advance\pgf@x\pgf@xa%
1053 \advance\pgf@y\pgf@ya%
1054 }%
1055 %
1056 % Second control point for the second arc.
1057 %
1058 \pgfextract@process\controltwo{%
1059 \[email protected]\relax%
1060 \pgf@x\sinquarterarc\pgf@x% k * sin(a/2)
1061 \[email protected]\relax%
1062 \pgf@y\cosquarterarc\pgf@y% -k * cos(a/2)
1063 %
1064 % ...scale, rotate and shift.
1065 %
1066 \pgf@x\controlscale\pgf@x%
1067 \pgf@y\controlscale\pgf@y%
1068 %
1069 \pgf@xa\cosarcrotate\pgf@x%
1070 \advance\pgf@xa-\sinarcrotate\pgf@y%
1071 \pgf@ya\cosarcrotate\pgf@y%
1072 \advance\pgf@ya\sinarcrotate\pgf@x%
1073 %
1074 \arcendpoint%
1075 \advance\pgf@x\pgf@xa%
1076 \advance\pgf@y\pgf@ya%
1077 }%
1078 \pgfpathcurveto{\controlone}{\controltwo}{\arcendpoint}%
1079 \repeatpgfmathloop%
1080 \pgfpathclose% Phew!
1081 }%
1082 }%
1083 %
1084 % Calculate a point on the border of the cloud. This is a two-stage process:
1085 %
1086 % 1. Locate the correct puff.
1087 % 2. Locate the angle on the circular arc which forms the puff.
1088 %
1089 \anchorborder{%
1090 %
1091 % Save x and y.
1092 %
1093 \edef\externalx{\the\pgf@x}%
1094 \edef\externaly{\the\pgf@y}%
1095 %
1096 % Get the inner radii and trig. constants.
1097 %
1098 \getradii%
1099 %
1100 %
1101 %
1102 \ifpgfcloudanchorsuseellipse%
1103 \pgfpointadd{\centerpoint}{%
1104 \pgfpointborderellipse{%
1105 \pgfpoint{\externalx}{\externaly}
1106 }{%
1107 \pgfpoint{\xouterradius}{\youterradius}
1108 }%
1109 }%
1110 \else%
1111 \pgfextract@process\externalpoint{%
1112 \centerpoint%
1113 \advance\pgf@x\externalx\relax%
1114 \advance\pgf@y\externaly\relax%
1115 }%
1116 \pgfmathanglebetweenpoints{\centerpoint}{\externalpoint}%
1117 \let\externalangle\pgfmathresult%
1118 %
1119 % 1. Locate the correct puff:
1120 %
1121 % Get end angle of the relevant puff arc.
1122 %
1123 \pgfmathdivide@{\anglestep}{2}%
1124 \let\halfanglestep\pgfmathresult%
1125 \pgfmathsubtract@{90}{\halfanglestep}%
1126 \let\endangle\pgfmathresult%
1127 \pgfmathloop%
1128 \pgfmathsubtract@{\endangle}{\anglestep}%
1129 \ifdim\pgfmathresult pt<-\anglestep pt\relax%
1130 \else%
1131 \let\endangle\pgfmathresult%
1132 \repeatpgfmathloop%
1133 \def\angle{0}%
1134 \let\lastangle\angle%
1135 \pgfmathloop%
1136 \pgfmathadd@{\endangle}{\anglestep}%
1137 \let\endangle\pgfmathresult%
1138 %
1139 % Calculate the `miter point'. This is the point between
1140 % each puff, and takes into account the outer sep.
1141 %
1142 \pgfextract@process\miterpoint{%
1143 %
1144 \pgfextract@process\secondpoint{%
1145 \pgfpointpolar{+\endangle}{+\xinnerradius and +\yinnerradius}%
1146 }%
1147 %
1148 \pgfmathadd@{\endangle}{\anglestep}%
1149 \let\angletemp\pgfmathresult%
1150 \pgfextract@process\thirdpoint{%
1151 \pgfpointpolar{+\angletemp}{+\xinnerradius and +\yinnerradius}%
1152 }%
1153 %
1154 \pgfmathsubtract@{\endangle}{\anglestep}%
1155 \let\angletemp\pgfmathresult%
1156 \pgfextract@process\firstpoint{%
1157 \pgfpointpolar{+\angletemp}{+\xinnerradius and +\yinnerradius}%
1158 }%
1159 %
1160 \pgfmathanglebetweenpoints{\firstpoint}{\secondpoint}%
1161 \let\anglealpha\pgfmathresult%
1162 \pgfmathanglebetweenpoints{\secondpoint}{\thirdpoint}%
1163 \let\anglebeta\pgfmathresult%
1164 %
1165 \pgfmathsubtract@{\anglebeta}{\anglealpha}%
1166 \pgfmathdivide@{\pgfmathresult}{2}%
1167 \pgfmathadd@{\pgfmathresult}{\halfcomplementarc}%
1168 \pgfmathcosec@{\pgfmathresult}%
1169 \pgf@x\outersep\relax%
1170 \pgf@x\pgfmathresult\pgf@x%
1171 \edef\miterradius{\the\pgf@x}%
1172 %
1173 \pgfmathadd@{\anglealpha}{\anglebeta}%
1174 \pgfmathsubtract@{\pgfmathresult}{180}%
1175 \pgfmathdivide@{\pgfmathresult}{2}%
1176 \let\miterangle\pgfmathresult%
1177 \pgfpointadd{\secondpoint}{%
1178 \pgfqpointpolar{\miterangle}{\miterradius}%
1179 }%
1180 }%
1181 %
1182 % Get the angle of the miter point...
1183 %
1184 \pgfmathanglebetweenpoints{\pgfpointorigin}{\miterpoint}%
1185 \let\angle\pgfmathresult%
1186 \ifdim\angle pt<\lastangle pt\relax% Guard against 360� = 0�
1187 \pgfmathadd@{\angle}{360}%
1188 \let\angle\pgfmathresult%
1189 \fi%
1190 \let\lastangle\angle%
1191 %
1192 % ...and see if it is greater than the external point.
1193 %
1194 \ifdim\externalangle pt>\angle pt\relax%
1195 \repeatpgfmathloop%
1196 %
1197 % Get the start angle of the relevant arc and ensure angles are in the range.
1198 %
1199 \pgfmathmod@{\endangle}{360}%
1200 \let\endangle\pgfmathresult%
1201 \pgfmathsubtract@{\endangle}{\anglestep}%
1202 \ifdim\pgfmathresult pt<0pt\relax%
1203 \pgfmathadd@{\pgfmathresult}{360}%
1204 \fi%
1205 \let\startangle\pgfmathresult%
1206 %
1207 % Now, get the start and end points of the arc.
1208 %
1209 \pgfextract@process\arcstartpoint{%
1210 \pgfpointadd{\centerpoint}{%
1211 \pgfpointpolar{+\startangle}{+\xinnerradius and +\yinnerradius}%
1212 }%
1213 }%
1214 \pgfextract@process\arcendpoint{%
1215 \pgfpointadd{\centerpoint}{%
1216 \pgfpointpolar{+\endangle}{+\xinnerradius and +\yinnerradius}%
1217 }%
1218 }%
1219 %
1220 % Get some useful cloud parameters from \arcstartpoint and \arcendpoint.
1221 %
1222 \pgf@sh@getcloudpuffparameters%
1223 %
1224 % Hackery, for when an arc straddles 0�.
1225 %
1226 \ifdim\endangle pt<\startangle pt\relax%
1227 \pgfmathadd@{\externalangle}{180}%
1228 \pgfmathmod@{\pgfmathresult}{360}%
1229 \let\x\pgfmathresult%
1230 \else%
1231 \let\x\externalangle%
1232 \fi%
1233 %
1234 % 2. Locate the angle on the circular arc which forms the puff.
1235 %
1236 % Essentially a binary search to find the angle on the circular
1237 % arc, which provides the nearest estimate to the border point.
1238 %
1239 \let\s\halfcomplementarc% The start of the arc.
1240 \pgfmathadd@{\s}{\arc}%
1241 \let\e\pgfmathresult% The end of the arc.
1242 \pgfmathadd@{\e}{\s}%
1243 \pgfmathdivide@{\pgfmathresult}{2}%
1244 \let\n\pgfmathresult% The nearest estimate (default to middle of arc).
1245 \def\m{360}% Measure of `nearness'.
1246 \pgfmathloop%
1247 \pgfmathadd@{\e}{\s}%
1248 \pgfmathdivide@{\pgfmathresult}{2}%
1249 \let\p\pgfmathresult% The point halfway between \s and \e.
1250 \ifdim\p pt=\s pt\relax%
1251 \else%
1252 %
1253 % Get the point on the circular arc.
1254 %
1255 \pgfmathadd@{\p}{\arcslope}%
1256 \let\a\pgfmathresult%
1257 \pgfextract@process\arcpoint{%
1258 \pgfpointadd{\circlecenterpoint}{%
1259 \pgfqpointpolar{\a}{\outerarcradius}%
1260 }%
1261 }%
1262 %
1263 % Find the angle between the node centre and the point on the arc.
1264 %
1265 \pgfmathanglebetweenpoints{\centerpoint}{\arcpoint}%
1266 %
1267 % Hackery, for when an arc straddles 0�.
1268 %
1269 \ifdim\endangle pt<\startangle pt\relax%
1270 \pgfmathadd@{\pgfmathresult}{180}%
1271 \pgfmathmod@{\pgfmathresult}{360}%
1272 \fi%
1273 \let\q\pgfmathresult%
1274 \ifdim\x pt=\q pt% Found it!
1275 \pgfmathbreakloop% Breaks after current iteration is complete.
1276 \else
1277 \ifdim\x pt<\q pt\relax%
1278 \let\e\p%
1279 \else%
1280 \let\s\p%
1281 \fi%
1282 \fi%
1283 \pgfmathsubtract@{\x}{\q}%
1284 \pgfmathabs@{\pgfmathresult}%
1285 %
1286 % Save the estimate if it is better than any previous estimate.
1287 %
1288 \ifdim\pgfmathresult pt<\m pt\relax%
1289 \let\m\pgfmathresult%
1290 \let\n\p%
1291 \fi%
1292 \repeatpgfmathloop%
1293 %
1294 % Use the nearest estimate as the anchor angle.
1295 %
1296 \pgfmathadd@{\n}{\arcslope}%
1297 \let\anchorangle\pgfmathresult%
1298 %
1299 % Finally, the required point.
1300 %
1301 \pgfpointadd{\circlecenterpoint}{%
1302 \pgfqpointpolar{\anchorangle}{\outerarcradius}%
1303 }%
1304 \fi%
1305 }% Again, Phew!
1306 %
1307 % Now, a sneaky hack. This means an arbitrary `puff' anchors
1308 % can be used for positioning the cloud shape. This is needed
1309 % if a cloud is positioned using the `puff <n+1>' anchor, where
1310 % n is the number of puffs of any previously drawn cloud.
1311 %
1312 \pgfutil@g@addto@macro\pgf@sh@s@cloud{%
1313 \c@pgf@counta\puffs\relax%
1314 \pgfmathloop%
1315 \ifnum\c@pgf@counta>0\relax%
1316 \pgfutil@ifundefined{pgf@anchor@cloud@puff\space\the\c@pgf@counta}{%
1317 \expandafter\xdef\csname pgf@anchor@cloud@puff\space\the\c@pgf@counta\endcsname{%
1318 \noexpand\pgf@sh@@cloudpuffanchor{\the\c@pgf@counta}%
1319 }%
1320 }{\c@pgf@counta0\relax}%
1321 \advance\c@pgf@counta-1\relax%
1322 \repeatpgfmathloop%
1323 }%
1324 }%
1325
1326 % \pgf@sh@@cloudpuffanchor
1327 %
1328 % Internal macro for calculating the anchors puff 1, puff 2, ... etc.
1329 %
1330 \def\pgf@sh@@cloudpuffanchor#1{%
1331 \getradii%
1332 \pgfmathdivide@{\anglestep}{2}%
1333 \let\halfanglestep\pgfmathresult%
1334 \c@pgf@counta#1\relax%
1335 \advance\c@pgf@counta-1\relax%
1336 \pgfmathmultiply@{\anglestep}{\the\c@pgf@counta}%
1337 \pgfmathadd@{\pgfmathresult}{90}%
1338 \pgfmathsubtract@{\pgfmathresult}{\halfanglestep}%
1339 \let\angle\pgfmathresult%
1340 %
1341 % Calculate the first arc point.
1342 %
1343 \pgfextract@process\arcstartpoint{%
1344 \pgfpointadd{\centerpoint}{%
1345 \pgfpointpolar{+\angle}{+\xinnerradius and +\yinnerradius}%
1346 }%
1347 }%
1348 %
1349 \pgfmathadd@{\angle}{\anglestep}%
1350 \let\angle\pgfmathresult%
1351 \pgfextract@process\arcendpoint{%
1352 \pgfpointadd{\centerpoint}{%
1353 \pgfpointpolar{+\angle}{+\xinnerradius and +\yinnerradius}%
1354 }%
1355 }%
1356 %
1357 % Get some useful cloud parameters from \arcstartpoint and \arcendpoint.
1358 %
1359 \pgf@sh@getcloudpuffparameters%
1360 %
1361 % Calculate the point.
1362 %
1363 \pgfmathadd@{\arcslope}{90}%
1364 \let\anchorangle\pgfmathresult%
1365 \pgfpointadd{\circlecenterpoint}{%
1366 \pgfqpointpolar{\anchorangle}{\outerarcradius}%
1367 }%
1368 }%
1369
1370 % \pgf@sh@cloudpuffparameters
1371 %
1372 % Internal macro to calculate some common arc parameters which
1373 % are required when calculating radii, drawing the background
1374 % path and calculating border anchors.
1375 %
1376 \def\pgf@sh@getcloudpuffparameters{%
1377 %
1378 % Calculate the angle to which the entire arc is sloped.
1379 %
1380 \pgfmathanglebetweenpoints{\arcendpoint}{\arcstartpoint}%
1381 \let\arcslope\pgfmathresult%
1382 %
1383 % Calculate the chord length and arc radius.
1384 %
1385 \pgfpointdiff{\arcendpoint}{\arcstartpoint}%
1386 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}
1387 \pgf@x\pgfmathresult pt\relax%
1388 \[email protected]\pgf@x%
1389 \edef\halfchordlength{\the\pgf@xa}%
1390 \pgf@x\arcradiusquotient\pgf@x%
1391 \edef\arcradius{\the\pgf@x}%
1392 \pgf@xa\outersep\relax%
1393 \advance\pgf@xa\pgf@x%
1394 \edef\outerarcradius{\the\pgf@xa}%
1395 %
1396 % Calculate the height of the resulting segment.
1397 %
1398 \pgf@y-\sinhalfcomplementarc\pgf@x% sin((180-a)/2)
1399 \advance\pgf@y\pgf@x%
1400 \edef\segmentheight{\the\pgf@y}%
1401 %
1402 % Calculate the center of the circle of which the arc is a part.
1403 %
1404 \pgfextract@process\circlecenterpoint{%
1405 \pgfextract@process\circlecenterpoint{%
1406 \pgf@x-\halfchordlength\relax%
1407 \pgf@y\segmentheight\relax%
1408 \advance\pgf@y-\arcradius
1409 }%
1410 \pgfpointadd{\arcstartpoint}{%
1411 \pgfmathrotatepointaround{\circlecenterpoint}{\pgfpointorigin}{\arcslope}%
1412 }%
1413 }%
1414 }%
1415
1416
1417
1418
1419
1420 % Internal macros for signal shape.
1421 %
1422 \def\pgf@lib@sh@signal@nowhere{nowhere}%
1423 \def\pgf@lib@sh@signal@from{from}%
1424 \def\pgf@lib@sh@signal@to{to}%
1425
1426 \def\pgf@lib@sh@signal@parsedirection#1#2{%
1427 %
1428 \let\pgf@lib@sh@signal@direction=#2%
1429 \edef\pgf@lib@sh@temp{#1}%
1430 \expandafter\pgf@lib@sh@signal@@parsedirection\pgf@lib@sh@temp\pgf@stop}%
1431
1432 \def\pgf@lib@sh@signal@@parsedirection#1\pgf@stop{%
1433 \pgfutil@in@{and}{#1}%
1434 \ifpgfutil@in@%
1435 \pgf@lib@sh@signal@@@parsedirection#1\pgf@lib%
1436 \else%
1437 \pgf@lib@sh@signal@@@parsedirection#1 and #1\pgf@lib%
1438 \fi
1439 }%
1440 \def\pgf@lib@sh@signal@@@parsedirection#1 and #2\pgf@lib{%
1441 \pgfutil@in@{nowhere}{#1}%
1442 \ifpgfutil@in@
1443 \else%
1444 \pgf@lib@sh@signal@@@@parsedirection{#1}%
1445 \pgf@lib@sh@signal@@@@parsedirection{#2}%
1446 \fi%
1447 }%
1448 \def\pgf@lib@sh@signal@@@@parsedirection#1{%
1449 \pgfutil@in@{ #1 }{ east right }%
1450 \ifpgfutil@in@%
1451 \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@direction%
1452 \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@nowhere%
1453 \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@nowhere%
1454 \fi%
1455 \pgfutil@in@{ #1 }{ left west }%
1456 \ifpgfutil@in@%
1457 \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@direction%
1458 \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@nowhere%
1459 \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@nowhere%
1460 \fi%
1461 \pgfutil@in@{ #1 }{ above up north }%
1462 \ifpgfutil@in@%
1463 \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@direction%
1464 \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@nowhere%
1465 \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@nowhere%
1466 \fi%
1467 \pgfutil@in@{ #1 }{ below down south }%
1468 \ifpgfutil@in@%
1469 \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@direction%
1470 \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@nowhere%
1471 \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@nowhere%
1472 \fi%
1473 }%
1474
1475
1476 % Keys for signal shape:
1477 %
1478 \pgfkeys{/pgf/.cd,
1479 signal pointer angle/.initial=90,
1480 signal to/.initial=east,
1481 signal from/.initial=nowhere,
1482 }%
1483
1484 \pgfdeclareshape{signal}{%
1485 \savedmacro\installsignalparameters{%
1486 %
1487 \let\pgf@lib@sh@signal@north=\pgf@lib@sh@signal@nowhere%
1488 \let\pgf@lib@sh@signal@south=\pgf@lib@sh@signal@nowhere%
1489 \let\pgf@lib@sh@signal@east=\pgf@lib@sh@signal@nowhere%
1490 \let\pgf@lib@sh@signal@west=\pgf@lib@sh@signal@nowhere%
1491 %
1492 \pgf@lib@sh@signal@parsedirection{\pgfkeysvalueof{/pgf/signal from}}{\pgf@lib@sh@signal@from}%
1493 \pgf@lib@sh@signal@parsedirection{\pgfkeysvalueof{/pgf/signal to}}{\pgf@lib@sh@signal@to}%
1494 %
1495 % Define a centerpoint.
1496 %
1497 \pgfextract@process\centerpoint{%
1498 \[email protected]\wd\pgfnodeparttextbox%
1499 \[email protected]\ht\pgfnodeparttextbox%
1500 \advance\[email protected]\dp\pgfnodeparttextbox%
1501 }%
1502 %
1503 % Get some useful trig. stuff
1504 %
1505 \pgfmathsetmacro\pointerangle{\pgfkeysvalueof{/pgf/signal pointer angle}}%
1506 %
1507 \pgfmathdivide@{\pointerangle}{2}%
1508 \let\halfpointerangle=\pgfmathresult%
1509 %
1510 \pgfmathcosec@{\halfpointerangle}%
1511 \let\cosechalfpointerangle=\pgfmathresult%
1512 %
1513 \pgfmathdivide@{\halfpointerangle}{2}%
1514 \let\quarterpointerangle=\pgfmathresult%
1515 %
1516 \pgfmathcosec@{\quarterpointerangle}%
1517 \let\cosecquarterpointerangle=\pgfmathresult%
1518 %
1519 \pgfmathsec@{\quarterpointerangle}%
1520 \let\secquarterpointerangle=\pgfmathresult%
1521 %
1522 \pgfmathsubtract@{90}{\quarterpointerangle}%
1523 \let\complementquarterpointerangle\pgfmathresult%
1524 %
1525 % Get the larger of the outer sep.
1526 %
1527 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
1528 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
1529 \ifdim\pgf@x>\pgf@y%
1530 \pgf@y\pgf@x%
1531 \fi%
1532 \pgf@yc=\pgf@y%
1533 %
1534 % Calculate the miter due to the line width, at the pointer apex...
1535 %
1536 \pgf@x=\cosechalfpointerangle\pgf@y%
1537 \edef\pointerapexmiter{\the\pgf@x}%
1538 %
1539 % ...at a corner by a `to' pointer (i.e. sticks out)...
1540 %
1541 \pgf@x=\secquarterpointerangle\pgf@y%
1542 \edef\tocornermiter{\the\pgf@x}%
1543 %
1544 % ...at a corner by a `from' pointer (i.e. sticks in).
1545 %
1546 \pgf@x=\cosecquarterpointerangle\pgf@y
1547 \edef\fromcornermiter{\the\pgf@x}%
1548 %
1549 % Get the (half) dimensions of the node.
1550 %
1551 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
1552 \advance\[email protected]\wd\pgfnodeparttextbox%
1553 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/inner ysep}}%
1554 \advance\[email protected]\ht\pgfnodeparttextbox%
1555 \advance\[email protected]\dp\pgfnodeparttextbox%
1556 %
1557 % Get the distance a pointer sticks out to the side...
1558 %
1559 \pgfmathsubtract@{90}{\halfpointerangle}%
1560 \pgfmathtan@{\pgfmathresult}%
1561 \pgf@xb=\pgfmathresult\pgf@ya%
1562 %
1563 % ...and up.
1564 %
1565 \pgf@yb=\pgfmathresult\pgf@xa%
1566 %
1567 % Adjust for minimum height.
1568 %
1569 \pgfutil@tempdima=2.0\pgf@ya%
1570 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@nowhere%
1571 \else%
1572 \advance\pgfutil@tempdima by\pgf@yb%
1573 \fi%
1574 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@nowhere%
1575 \else%
1576 \advance\pgfutil@tempdima by\pgf@yb%
1577 \fi%
1578 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum height}}%
1579 \ifdim\pgfutil@tempdima<\pgf@y%
1580 \pgfutil@tempdima=\pgf@y%
1581 %
1582 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@nowhere%
1583 \else%
1584 \advance\pgfutil@tempdima by-\pgf@yb%
1585 \fi%
1586 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@nowhere%
1587 \else%
1588 \advance\pgfutil@tempdima by-\pgf@yb%
1589 \fi%
1590 \pgf@ya=0.5\pgfutil@tempdima%
1591 \pgfmathsubtract@{90}{\halfpointerangle}%
1592 \pgfmathtan@{\pgfmathresult}%
1593 \pgf@xb=\pgfmathresult\pgf@ya%
1594 \fi%
1595 %
1596 % Adjust for minimum width.
1597 %
1598 \pgfutil@tempdima=2.0\pgf@xa%
1599 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere%
1600 \else%
1601 \advance\pgfutil@tempdima by\pgf@xb%
1602 \fi%
1603 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere%
1604 \else%
1605 \advance\pgfutil@tempdima by\pgf@xb%
1606 \fi%
1607 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}%
1608 \ifdim\pgfutil@tempdima<\pgf@x%
1609 \pgfutil@tempdima=\pgf@x%
1610 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere%
1611 \else%
1612 \advance\pgfutil@tempdima by-\pgf@xb%
1613 \fi%
1614 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere%
1615 \else%
1616 \advance\pgfutil@tempdima by-\pgf@xb%
1617 \fi%
1618 \pgf@xa=0.5\pgfutil@tempdima%
1619 \pgfmathsubtract@{90}{\halfpointerangle}%
1620 \pgfmathtan@{\pgfmathresult}%
1621 \pgf@yb=\pgfmathresult\pgf@xa%
1622 \fi%
1623 %
1624 % So, define the points for the background path.
1625 %
1626 \pgfextract@process\north{%
1627 \centerpoint%
1628 \advance\pgf@y\pgf@ya%
1629 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@to%
1630 \advance\pgf@y\pgf@yb%
1631 \fi%
1632 }%
1633 \pgfextract@process\south{%
1634 \centerpoint%
1635 \advance\pgf@y-\pgf@ya%
1636 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@to%
1637 \advance\pgf@y-\pgf@yb%
1638 \fi%
1639 }%
1640 \pgfextract@process\east{%
1641 \centerpoint%
1642 \advance\pgf@x\pgf@xa%
1643 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@to%
1644 \advance\pgf@x\pgf@xb%
1645 \fi%
1646 }%
1647 \pgfextract@process\west{%
1648 \centerpoint%
1649 \advance\pgf@x-\pgf@xa%
1650 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to%
1651 \advance\pgf@x-\pgf@xb%
1652 \fi%
1653 }%
1654 \pgfextract@process\northeast{%
1655 \centerpoint%
1656 \advance\pgf@y\pgf@ya%
1657 \advance\pgf@x\pgf@xa%
1658 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from%
1659 \advance\pgf@y\pgf@yb%
1660 \fi%
1661 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from%
1662 \advance\pgf@x\pgf@xb%
1663 \fi%
1664 }%
1665 \pgfextract@process\southeast{%
1666 \centerpoint%
1667 \advance\pgf@y-\pgf@ya%
1668 \advance\pgf@x\pgf@xa%
1669 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from%
1670 \advance\pgf@y-\pgf@yb%
1671 \fi%
1672 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from%
1673 \advance\pgf@x\pgf@xb%
1674 \fi%
1675 }%
1676 \pgfextract@process\southwest{%
1677 \centerpoint%
1678 \advance\pgf@y-\pgf@ya%
1679 \advance\pgf@x-\pgf@xa%
1680 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from%
1681 \advance\pgf@y-\pgf@yb%
1682 \fi%
1683 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from%
1684 \advance\pgf@x-\pgf@xb%
1685 \fi%
1686 }%
1687 \pgfextract@process\northwest{%
1688 \centerpoint%
1689 \advance\pgf@y\pgf@ya%
1690 \advance\pgf@x-\pgf@xa%
1691 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from%
1692 \advance\pgf@y\pgf@yb%
1693 \fi%
1694 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from%
1695 \advance\pgf@x-\pgf@xb%
1696 \fi%
1697 }%
1698 \addtosavedmacro{\north}%
1699 \addtosavedmacro{\south}%
1700 \addtosavedmacro{\east}%
1701 \addtosavedmacro{\west}%
1702 \addtosavedmacro{\northeast}%
1703 \addtosavedmacro{\southwest}%
1704 \addtosavedmacro{\southeast}%
1705 \addtosavedmacro{\northwest}%
1706 %
1707 % Calculate the `miter vectors' (i.e. +outer sep).
1708 %
1709 \pgfextract@process\northmiter{%
1710 \pgf@x0pt%
1711 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@nowhere%
1712 \pgf@y\pgf@yc%
1713 \else%
1714 \pgf@y\pointerapexmiter\relax%
1715 \fi%
1716 }%
1717 \pgfextract@process\southmiter{%
1718 \pgf@x0pt%
1719 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@nowhere%
1720 \pgf@y-\pgf@yc%
1721 \else%
1722 \pgf@y-\pointerapexmiter\relax%
1723 \fi%
1724 }%
1725 \pgfextract@process\eastmiter{%
1726 \pgf@y0pt%
1727 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere%
1728 \pgf@x\pgf@yc%
1729 \else%
1730 \pgf@x\pointerapexmiter\relax%
1731 \fi%
1732 }%
1733 \pgfextract@process\westmiter{%
1734 \pgf@y0pt%
1735 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere%
1736 \pgf@x-\pgf@yc%
1737 \else%
1738 \pgf@x-\pointerapexmiter\relax%
1739 \fi%
1740 }%
1741 \pgfextract@process\northeastmiter{%
1742 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere%
1743 \pgf@x\pgf@yc
1744 \pgf@y\pgf@yc%
1745 \else
1746 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from%
1747 \pgfqpointpolar{\quarterpointerangle}{\fromcornermiter}
1748 \else%
1749 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@to%
1750 \pgfqpointpolar{\complementquarterpointerangle}{\tocornermiter}%
1751 \fi%
1752 \fi%
1753 \fi%
1754 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from%
1755 \pgfqpointpolar{\complementquarterpointerangle}{\fromcornermiter}%
1756 \else%
1757 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@to%
1758 \pgfqpointpolar{\quarterpointerangle}{\tocornermiter}%
1759 \fi%
1760 \fi%
1761 }%
1762 \pgfextract@process\southeastmiter{%
1763 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@nowhere%
1764 \pgf@x\pgf@yc%
1765 \pgf@y\pgf@yc%
1766 \else
1767 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@from%
1768 \pgfqpointpolar{-\quarterpointerangle}{\fromcornermiter}
1769 \else%
1770 \ifx\pgf@lib@sh@signal@east\pgf@lib@sh@signal@to%
1771 \pgfqpointpolar{-\complementquarterpointerangle}{\tocornermiter}%
1772 \fi%
1773 \fi%
1774 \fi%
1775 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from%
1776 \pgfqpointpolar{-\complementquarterpointerangle}{\fromcornermiter}
1777 \else%
1778 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@to%
1779 \pgfqpointpolar{-\quarterpointerangle}{\tocornermiter}%
1780 \fi%
1781 \fi%
1782 }%
1783 \pgfextract@process\southwestmiter{%
1784 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere%
1785 \pgf@x-\pgf@yc
1786 \pgf@y-\pgf@yc%
1787 \else
1788 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from%
1789 \pgfmathadd@{\quarterpointerangle}{180}%
1790 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter}
1791 \else%
1792 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to%
1793 \pgfmathadd@{\complementquarterpointerangle}{180}%
1794 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}%
1795 \fi%
1796 \fi%
1797 \fi%
1798 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@from%
1799 \pgfmathadd@{\complementquarterpointerangle}{180}%
1800 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter}%
1801 \else%
1802 \ifx\pgf@lib@sh@signal@south\pgf@lib@sh@signal@to%
1803 \pgfmathadd@{\quarterpointerangle}{180}%
1804 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}%
1805 \fi%
1806 \fi%
1807 }%
1808 \pgfextract@process\northwestmiter{%
1809 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@nowhere%
1810 \pgf@x-\pgf@yc%
1811 \pgf@y\pgf@yc%
1812 \else
1813 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@from%
1814 \pgfmathsubtract@{180}{\quarterpointerangle}%
1815 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter}
1816 \else%
1817 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to%
1818 \pgfmathsubtract@{180}{\complementquarterpointerangle}%
1819 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}%
1820 \fi%
1821 \fi%
1822 \fi%
1823 \ifx\pgf@lib@sh@signal@north\pgf@lib@sh@signal@from%
1824 \pgfmathsubtract@{180}{\complementquarterpointerangle}%
1825 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\fromcornermiter}%
1826 \else%
1827 \ifx\pgf@lib@sh@signal@west\pgf@lib@sh@signal@to%
1828 \pgfmathsubtract@{180}{\quarterpointerangle}%
1829 \expandafter\pgfqpointpolar\expandafter{\pgfmathresult}{\tocornermiter}%
1830 \fi%
1831 \fi%
1832 }%
1833 \addtosavedmacro{\northmiter}%
1834 \addtosavedmacro{\southmiter}%
1835 \addtosavedmacro{\eastmiter}%
1836 \addtosavedmacro{\westmiter}%
1837 \addtosavedmacro{\northeastmiter}%
1838 \addtosavedmacro{\southeastmiter}%
1839 \addtosavedmacro{\southwestmiter}%
1840 \addtosavedmacro{\northwestmiter}%
1841 %
1842 % Now calculate the anchor points
1843 %
1844 \pgfextract@process\anchornorth{%
1845 \pgfpointadd{\north}{\northmiter}%
1846 }%
1847 \pgfextract@process\anchorsouth{%
1848 \pgfpointadd{\south}{\southmiter}%
1849 }%
1850 \pgfextract@process\anchoreast{%
1851 \pgfpointadd{\east}{\eastmiter}%
1852 }%
1853 \pgfextract@process\anchorwest{%
1854 \pgfpointadd{\west}{\westmiter}%
1855 }%
1856 \pgfextract@process\anchornortheast{%
1857 \pgfpointadd{\northeast}{\northeastmiter}%
1858 }%
1859 \pgfextract@process\anchorsoutheast{%
1860 \pgfpointadd{\southeast}{\southeastmiter}%
1861 }%
1862 \pgfextract@process\anchorsouthwest{%
1863 \pgfpointadd{\southwest}{\southwestmiter}%
1864 }%
1865 \pgfextract@process\anchornorthwest{%
1866 \pgfpointadd{\northwest}{\northwestmiter}%
1867 }%
1868 \addtosavedmacro{\anchornorth}%
1869 \addtosavedmacro{\anchorsouth}%
1870 \addtosavedmacro{\anchoreast}%
1871 \addtosavedmacro{\anchorwest}%
1872 \addtosavedmacro{\anchornortheast}%
1873 \addtosavedmacro{\anchorsouthwest}%
1874 \addtosavedmacro{\anchorsoutheast}%
1875 \addtosavedmacro{\anchornorthwest}%
1876 }%
1877 \savedanchor\centerpoint{%
1878 \[email protected]\wd\pgfnodeparttextbox%
1879 \[email protected]\ht\pgfnodeparttextbox%
1880 \advance\[email protected]\dp\pgfnodeparttextbox%
1881 }%
1882 \savedanchor\basepoint{%
1883 \[email protected]\wd\pgfnodeparttextbox%
1884 \pgf@y0pt%
1885 }%
1886 \savedanchor\midpoint{%
1887 \[email protected]\wd\pgfnodeparttextbox%
1888 \pgfmathsetlength\pgf@y{+.5ex}%
1889 }%
1890 \anchor{center}{\centerpoint}%
1891 \anchor{base}{\basepoint}%
1892 \anchor{base east}{%
1893 \installsignalparameters%
1894 \anchoreast%
1895 \pgf@xa\pgf@x%
1896 \pgf@ya\pgf@y%
1897 \anchorsoutheast%
1898 \ifdim\pgf@xa>\pgf@x%
1899 \pgfutil@tempdima\pgf@xa%
1900 \else%
1901 \pgfutil@tempdima\pgf@x%
1902 \fi%
1903 \pgfextract@process\externalpoint{%
1904 \basepoint%
1905 \pgf@x\pgfutil@tempdima%
1906 }
1907 \basepoint%
1908 \let\firstpoint\anchoreast%
1909 \ifdim\pgf@y<\pgf@ya%
1910 \let\secondpoint\anchorsoutheast%
1911 \else%
1912 \let\secondpoint\anchornortheast%
1913 \fi%
1914 \pgfpointintersectionoflines{\basepoint}{\externalpoint}%
1915 {\firstpoint}{\secondpoint}%
1916 }%
1917 \anchor{base west}{%
1918 \installsignalparameters%
1919 \anchorwest%
1920 \pgf@xa\pgf@x%
1921 \pgf@ya\pgf@y%
1922 \anchorsouthwest%
1923 \ifdim\pgf@xa<\pgf@x%
1924 \pgfutil@tempdima\pgf@xa%
1925 \else%
1926 \pgfutil@tempdima\pgf@x%
1927 \fi%
1928 \pgfextract@process\externalpoint{%
1929 \basepoint%
1930 \pgf@x\pgfutil@tempdima%
1931 }
1932 \basepoint%
1933 \let\firstpoint\anchorwest%
1934 \ifdim\pgf@y<\pgf@ya%
1935 \let\secondpoint\anchorsouthwest%
1936 \else%
1937 \let\secondpoint\anchornorthwest%
1938 \fi%
1939 \pgfpointintersectionoflines{\basepoint}{\externalpoint}%
1940 {\firstpoint}{\secondpoint}%
1941 }%
1942 \anchor{mid}{\midpoint}%
1943 \anchor{mid east}{%
1944 \installsignalparameters%
1945 \anchoreast%
1946 \pgf@xa\pgf@x%
1947 \pgf@ya\pgf@y%
1948 \anchorsoutheast%
1949 \ifdim\pgf@xa>\pgf@x%
1950 \pgfutil@tempdima\pgf@xa%
1951 \else%
1952 \pgfutil@tempdima\pgf@x%
1953 \fi%
1954 \pgfextract@process\externalpoint{%
1955 \midpoint%
1956 \pgf@x\pgfutil@tempdima%
1957 }
1958 \midpoint%
1959 \let\firstpoint\anchoreast%
1960 \ifdim\pgf@y<\pgf@ya%
1961 \let\secondpoint\anchorsoutheast%
1962 \else%
1963 \let\secondpoint\anchornortheast%
1964 \fi%
1965 \pgfpointintersectionoflines{\midpoint}{\externalpoint}%
1966 {\firstpoint}{\secondpoint}%
1967 }%
1968 \anchor{mid west}{%
1969 \installsignalparameters%
1970 \anchorwest%
1971 \pgf@xa\pgf@x%
1972 \pgf@ya\pgf@y%
1973 \anchorsouthwest%
1974 \ifdim\pgf@xa<\pgf@x%
1975 \pgfutil@tempdima\pgf@xa%
1976 \else%
1977 \pgfutil@tempdima\pgf@x%
1978 \fi%
1979 \pgfextract@process\externalpoint{%
1980 \midpoint%
1981 \pgf@x\pgfutil@tempdima%
1982 }
1983 \midpoint%
1984 \let\firstpoint\anchorwest%
1985 \ifdim\pgf@y<\pgf@ya%
1986 \let\secondpoint\anchorsouthwest%
1987 \else%
1988 \let\secondpoint\anchornorthwest%
1989 \fi%
1990 \pgfpointintersectionoflines{\midpoint}{\externalpoint}%
1991 {\firstpoint}{\secondpoint}%
1992 }%
1993 \anchor{north}{\installsignalparameters\anchornorth}%
1994 \anchor{south}{\installsignalparameters\anchorsouth}%
1995 \anchor{east}{\installsignalparameters\anchoreast}%
1996 \anchor{west}{\installsignalparameters\anchorwest}%
1997 \anchor{north east}{\installsignalparameters\anchornortheast}%
1998 \anchor{south east}{\installsignalparameters\anchorsoutheast}%
1999 \anchor{south west}{\installsignalparameters\anchorsouthwest}%
2000 \anchor{north west}{\installsignalparameters\anchornorthwest}%
2001 \backgroundpath{%
2002 \installsignalparameters%
2003 \pgfpathmoveto{\north}%
2004 \pgfpathlineto{\northeast}%
2005 \pgfpathlineto{\east}%
2006 \pgfpathlineto{\southeast}%
2007 \pgfpathlineto{\south}%
2008 \pgfpathlineto{\southwest}%
2009 \pgfpathlineto{\west}%
2010 \pgfpathlineto{\northwest}%
2011 \pgfpathclose%
2012 }%
2013 \anchorborder{%
2014 %
2015 % Save x and y.
2016 %
2017 \edef\externalx{\the\pgf@x}%
2018 \edef\externaly{\the\pgf@y}%
2019 %
2020 % Adjust the location of the external
2021 % point relative to \centerpoint.
2022 %
2023 \centerpoint%
2024 \pgf@xa\externalx\relax%
2025 \pgf@ya\externaly\relax%
2026 \advance\pgf@xa\pgf@x%
2027 \advance\pgf@ya\pgf@y%
2028 \edef\externalx{\the\pgf@xa}%
2029 \edef\externaly{\the\pgf@ya}%
2030 %
2031 % Get the shape parameters.
2032 %
2033 \installsignalparameters%
2034 %
2035 % Get the angle of the external point to the \centerpoint.
2036 %
2037 \pgfmathanglebetweenpoints{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
2038 \let\externalangle\pgfmathresult%
2039 %
2040 %
2041 %
2042 \pgfmathanglebetweenpoints{\centerpoint}{\anchorwest}%
2043 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2044 \pgfmathanglebetweenpoints{\centerpoint}{\anchornorth}%
2045 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2046 \pgfmathanglebetweenpoints{\centerpoint}{\anchornortheast}%
2047 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2048 \let\firstpoint\anchoreast%
2049 \let\secondpoint\anchornortheast%
2050 \else%
2051 \let\secondpoint\anchornortheast%
2052 \let\firstpoint\anchornorth%
2053 \fi%
2054 \else%
2055 \pgfmathanglebetweenpoints{\centerpoint}{\anchornorthwest}%
2056 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2057 \let\firstpoint\anchornorth%
2058 \let\secondpoint\anchornorthwest%
2059 \else%
2060 \let\secondpoint\anchornorthwest%
2061 \let\firstpoint\anchorwest%
2062 \fi%
2063 \fi%
2064 \else%
2065 \pgfmathanglebetweenpoints{\centerpoint}{\anchorsouth}%
2066 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2067 \pgfmathanglebetweenpoints{\centerpoint}{\anchorsouthwest}%
2068 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2069 \let\firstpoint\anchorwest%
2070 \let\secondpoint\anchorsouthwest%
2071 \else%
2072 \let\secondpoint\anchorsouthwest%
2073 \let\firstpoint\anchorsouth%
2074 \fi%
2075 \else%
2076 \pgfmathanglebetweenpoints{\centerpoint}{\anchorsoutheast}%
2077 \ifdim\externalangle pt<\pgfmathresult pt\relax%
2078 \let\firstpoint\anchorsouth%
2079 \let\secondpoint\anchorsoutheast%
2080 \else%
2081 \let\secondpoint\anchorsoutheast%
2082 \let\firstpoint\anchoreast%
2083 \fi%
2084 \fi%
2085 \fi%
2086 %
2087 % Now locate the point.
2088 %
2089 \pgfpointintersectionoflines{\centerpoint}{\pgfqpoint{\externalx}{\externaly}}%
2090 {\firstpoint}{\secondpoint}%
2091 }%
2092 }%
2093
2094
2095
2096
2097
2098
2099 % Keys for shape tape
2100 %
2101 % /pgf/tape bend top : Type of bend for north side.
2102 % /pgf/tape bend bottom : Type of bend for south side.
2103 % /pgf/tape bend height : The height of the bends.
2104 \pgfkeys{/pgf/.cd,
2105 tape bend top/.initial=in and out,
2106 tape bend bottom/.initial=in and out,
2107 tape bend/.style={/pgf/tape bend top={#1}, /pgf/tape bend bottom={#1}},
2108 tape bend height/.initial=5pt,
2109 }%
2110
2111 \def\pgf@lib@sh@inandouttext{in and out}%
2112 \def\pgf@lib@sh@outandintext{out and in}%
2113 \def\pgf@lib@sh@nonetext{none}%
2114
2115 \pgfdeclareshape{tape}{%
2116 \savedmacro\tapedimensions{%
2117 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
2118 \advance\[email protected]\wd\pgfnodeparttextbox%
2119 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
2120 \advance\[email protected]\ht\pgfnodeparttextbox%
2121 \advance\[email protected]\dp\pgfnodeparttextbox%
2122 %
2123 \pgfmathsetlengthmacro\outerxsep{\pgfkeysvalueof{/pgf/outer xsep}}%
2124 \pgfmathsetlengthmacro\outerysep{\pgfkeysvalueof{/pgf/outer ysep}}%
2125 \addtosavedmacro\outerxsep%
2126 \addtosavedmacro\outerysep%
2127 %
2128 \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/tape bend height}}%
2129 \[email protected]\pgfutil@tempdima%
2130 \edef\halfbendheight{\the\pgfutil@tempdima}%
2131 \addtosavedmacro\halfbendheight%
2132 %
2133 \pgfkeysgetvalue{/pgf/tape bend top}{\topbendstyle}%
2134 \pgfkeysgetvalue{/pgf/tape bend bottom}{\bottombendstyle}%
2135 \addtosavedmacro\topbendstyle%
2136 \addtosavedmacro\bottombendstyle%
2137 %
2138 \ifx\topbendstyle\pgf@lib@sh@nonetext%
2139 \else%
2140 \advance\pgf@y\pgfutil@tempdima%
2141 \fi%
2142 \ifx\bottombendstyle\pgf@lib@sh@none%
2143 \else%
2144 \advance\pgf@y\pgfutil@tempdima%
2145 \fi%
2146 %
2147 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
2148 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
2149 \ifdim\pgf@x<.5\pgf@xa%
2150 \[email protected]\pgf@xa%
2151 \fi%
2152 \ifdim\pgf@y<.5\pgf@ya%
2153 \[email protected]\pgf@ya%
2154 \fi%
2155 \ifx\topbendstyle\pgf@lib@sh@nonetext%
2156 \else%
2157 \advance\pgf@y-\pgfutil@tempdima%
2158 \fi%
2159 \ifx\bottombendstyle\pgf@lib@sh@nonetext%
2160 \else%
2161 \advance\pgf@y-\pgfutil@tempdima%
2162 \fi%
2163 %
2164 \[email protected]\pgfutil@tempdima% 1 / (1-sin(45))
2165 \edef\bendyradius{\the\pgfutil@tempdima}%
2166 \addtosavedmacro\bendyradius%
2167 \advance\pgfutil@tempdima\outerysep%
2168 \edef\outerbendyradius{\the\pgfutil@tempdima}%
2169 \addtosavedmacro\outerbendyradius%
2170 \advance\pgfutil@tempdima-\outerysep%
2171 \advance\pgfutil@tempdima-\outerysep%
2172 \edef\innerbendyradius{\the\pgfutil@tempdima}%
2173 \addtosavedmacro\innerbendyradius%
2174 %
2175 \[email protected]\pgf@x% cos(45)
2176 \edef\bendxradius{\the\pgfutil@tempdima}%
2177 \addtosavedmacro\bendxradius%
2178 \advance\pgfutil@tempdima\outerxsep%
2179 \edef\outerbendxradius{\the\pgfutil@tempdima}%
2180 \addtosavedmacro\outerbendxradius%
2181 \advance\pgfutil@tempdima-\outerxsep%
2182 \advance\pgfutil@tempdima-\outerxsep%
2183 \edef\innerbendxradius{\the\pgfutil@tempdima}%
2184 \addtosavedmacro\innerbendxradius%
2185 %
2186 \edef\halfwidth{\the\pgf@x}%
2187 \edef\halfheight{\the\pgf@y}%
2188 \addtosavedmacro\halfwidth%
2189 \addtosavedmacro\halfheight%
2190 %
2191 \advance\pgf@x\outerxsep%
2192 \edef\outerhalfwidth{\the\pgf@x}%
2193 \addtosavedmacro\outerhalfwidth%
2194 %
2195 \pgf@xc\bendxradius%
2196 \pgf@yc\bendyradius%
2197 \pgfmathdivide@{\pgfmath@tonumber{\pgf@yc}}{\pgfmath@tonumber{\pgf@xc}}%
2198 \pgfmathatan{\pgfmathresult}%
2199 \pgf@xc\pgfmathresult pt\relax%
2200 \[email protected]\pgf@xc%
2201 \edef\halfangle{\pgfmath@tonumber{\pgf@xc}}%
2202 \addtosavedmacro\halfangle%
2203 %
2204 \pgf@xc45pt\relax%
2205 \advance\pgf@xc-\halfangle pt%
2206 \pgfmathcot@{\pgfmath@tonumber{\pgf@xc}}%
2207 \let\cothalfanglein\pgfmathresult%
2208 \addtosavedmacro\cothalfanglein%
2209 %
2210 \pgf@xc90pt\relax%
2211 \advance\pgf@xc-\halfangle pt%
2212 \pgfmathcot@{\pgfmath@tonumber{\pgf@xc}}%
2213 \let\cothalfangleout\pgfmathresult%
2214 \addtosavedmacro\cothalfangleout%
2215 %
2216 }%
2217 \savedanchor{\centerpoint}{%
2218 \[email protected]\wd\pgfnodeparttextbox%
2219 \[email protected]\ht\pgfnodeparttextbox%
2220 \advance\[email protected]\dp\pgfnodeparttextbox%
2221 }%
2222 \savedanchor{\midpoint}{%
2223 \[email protected]\wd\pgfnodeparttextbox%
2224 \pgfmathsetlength\pgf@y{+0.5ex}%
2225 }%
2226 \savedanchor{\basepoint}{%
2227 \[email protected]\wd\pgfnodeparttextbox%
2228 \pgf@y0pt%
2229 }%
2230 \anchor{center}{\centerpoint}%
2231 \anchor{mid}{\midpoint}%
2232 \anchor{mid east}{\tapedimensions\midpoint\advance\pgf@x\outerhalfwidth}%
2233 \anchor{mid west}{\tapedimensions\midpoint\advance\pgf@x-\outerhalfwidth}%
2234 \anchor{base}{\basepoint}%
2235 \anchor{base east}{\tapedimensions\basepoint\advance\pgf@x\outerhalfwidth}%
2236 \anchor{base west}{\tapedimensions\basepoint\advance\pgf@x-\outerhalfwidth}%
2237 \anchor{north}{%
2238 \csname pgf@anchor@tape@north east\endcsname%
2239 \pgf@ya\pgf@y%
2240 \csname pgf@anchor@tape@north west\endcsname%
2241 \advance\pgf@ya\pgf@y%
2242 \centerpoint%
2243 \[email protected]\pgf@ya%
2244 }%
2245 \anchor{south}{%
2246 \csname pgf@anchor@tape@south east\endcsname%
2247 \pgf@ya\pgf@y%
2248 \csname pgf@anchor@tape@south west\endcsname%
2249 \advance\pgf@ya\pgf@y%
2250 \centerpoint%
2251 \[email protected]\pgf@ya%
2252 }%
2253 \anchor{east}{%
2254 \tapedimensions%
2255 \centerpoint%
2256 \advance\pgf@x\outerhalfwidth%
2257 }%
2258 \anchor{west}{%
2259 \tapedimensions%
2260 \centerpoint%
2261 \advance\pgf@x-\outerhalfwidth%
2262 }%
2263 \anchor{north east}{%
2264 \tapedimensions%
2265 \centerpoint%
2266 \advance\pgf@x\outerhalfwidth%
2267 \advance\pgf@y\halfheight%
2268 \pgf@yc\outerysep%
2269 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2270 \advance\pgf@y\halfbendheight%
2271 \advance\pgf@y\cothalfangleout\pgf@yc%
2272 \else%
2273 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2274 \advance\pgf@y\halfbendheight%
2275 \advance\pgf@y\cothalfanglein\pgf@yc%
2276 \else%
2277 \advance\pgf@y\pgf@yc%
2278 \fi%
2279 \fi%
2280 }%
2281 \anchor{north west}{%
2282 \tapedimensions%
2283 \centerpoint%
2284 \advance\pgf@x-\outerhalfwidth%
2285 \advance\pgf@y\halfheight%
2286 \pgf@yc\outerysep%
2287 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2288 \advance\pgf@y\halfbendheight%
2289 \advance\pgf@y\cothalfanglein\pgf@yc%
2290 \else%
2291 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2292 \advance\pgf@y\halfbendheight%
2293 \advance\pgf@y\cothalfangleout\pgf@yc%
2294 \else%
2295 \advance\pgf@y\pgf@yc%
2296 \fi%
2297 \fi%
2298 }%
2299 \anchor{south east}{%
2300 \tapedimensions%
2301 \centerpoint%
2302 \advance\pgf@x\outerhalfwidth%
2303 \advance\pgf@y-\halfheight%
2304 \pgf@yc\outerysep%
2305 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2306 \advance\pgf@y-\halfbendheight%
2307 \advance\pgf@y-\cothalfangleout\pgf@yc%
2308 \else%
2309 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2310 \advance\pgf@y-\halfbendheight%
2311 \advance\pgf@y-\cothalfanglein\pgf@yc%
2312 \else%
2313 \advance\pgf@y-\pgf@yc%
2314 \fi%
2315 \fi%
2316 }%
2317 \anchor{south west}{%
2318 \tapedimensions%
2319 \centerpoint%
2320 \advance\pgf@x-\outerhalfwidth%
2321 \advance\pgf@y-\halfheight%
2322 \pgf@yc\outerysep%
2323 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2324 \advance\pgf@y-\halfbendheight%
2325 \advance\pgf@y-\cothalfanglein\pgf@yc%
2326 \else%
2327 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2328 \advance\pgf@y-\halfbendheight%
2329 \advance\pgf@y-\cothalfangleout\pgf@yc%
2330 \else%
2331 \advance\pgf@y-\pgf@yc%
2332 \fi%
2333 \fi%
2334 }%
2335 \backgroundpath{%
2336 \tapedimensions%
2337 %
2338 \pgf@xc\halfwidth%
2339 \pgf@yc\halfheight%
2340 %
2341 \pgf@xc\bendxradius%
2342 \pgf@yc\bendyradius%
2343 {%
2344 \pgftransformshift{\centerpoint}%
2345 \pgfpathmoveto{\pgfqpoint{-\halfwidth}{0pt}}%
2346 \pgfpathlineto{\pgfqpoint{-\halfwidth}{\halfheight}}%
2347 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2348 \pgfpathlineto{\pgf@x-\halfwidth\pgf@y\halfheight\advance\pgf@y\halfbendheight}%
2349 \pgfpatharc{225}{315}{\bendxradius and \bendyradius}%
2350 \pgfpatharc{135}{45}{\bendxradius and \bendyradius}%
2351 \else%
2352 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2353 \pgfpathlineto{\pgf@x-\halfwidth\pgf@y\halfheight\advance\pgf@y\halfbendheight}%
2354 \pgfpatharc{135}{45}{\bendxradius and \bendyradius}%
2355 \pgfpatharc{225}{315}{\bendxradius and \bendyradius}%
2356 \else%
2357 \pgfpathlineto{\pgfqpoint{\halfwidth}{\halfheight}}%
2358 \fi%
2359 \fi%
2360 \pgfpathlineto{\pgfqpoint{\halfwidth}{-\halfheight}}%
2361 \ifx\bottombendstyle\pgf@lib@sh@inandouttext%
2362 \pgfpathlineto{\pgf@x\halfwidth\pgf@y-\halfheight\advance\pgf@y-\halfbendheight}%
2363 \pgfpatharc{45}{135}{\bendxradius and \bendyradius}%
2364 \pgfpatharc{315}{225}{\bendxradius and \bendyradius}%
2365 \else%
2366 \ifx\bottombendstyle\pgf@lib@sh@outandintext%
2367 \pgfpathlineto{\pgf@x\halfwidth\pgf@y-\halfheight\advance\pgf@y-\halfbendheight}%
2368 \pgfpatharc{315}{225}{\bendxradius and \bendyradius}%
2369 \pgfpatharc{45}{135}{\bendxradius and \bendyradius}%
2370 \else%
2371 \pgfpathlineto{\pgfqpoint{-\halfwidth}{-\halfheight}}%
2372 \fi%
2373 \fi%
2374 \pgfpathclose%
2375 }%
2376 }%
2377 \anchorborder{%
2378 \pgf@xa\pgf@x%
2379 \pgf@ya\pgf@y%
2380 \pgfextract@process\externalpoint{%
2381 \centerpoint%
2382 \advance\pgf@x\pgf@xa%
2383 \advance\pgf@y\pgf@ya%
2384 }%
2385 \pgfmathanglebetweenpoints{\centerpoint}{\externalpoint}%
2386 \let\externalangle\pgfmathresult%
2387 \tapedimensions%
2388 %
2389 \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@tape@north west\endcsname}%
2390 \ifdim\externalangle pt<\pgfmathresult pt%
2391 \ifdim\externalangle pt<90pt%
2392 \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@tape@north east\endcsname}%
2393 \ifdim\externalangle pt<\pgfmathresult pt%
2394 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2395 {\csname pgf@anchor@tape@north east\endcsname}%
2396 {\csname pgf@anchor@tape@south east\endcsname}%
2397 \else%
2398 % Between north and north east.
2399 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2400 % in and out.
2401 \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}%
2402 {%
2403 \centerpoint%
2404 \pgf@xc\halfwidth%
2405 \advance\[email protected]\pgf@xc%
2406 \advance\pgf@y\halfheight%
2407 \advance\pgf@y\halfbendheight%
2408 \pgf@yc\bendyradius%
2409 \advance\[email protected]\pgf@yc%
2410 }%
2411 {5}{175}{\outerbendxradius and \outerbendyradius}%
2412 \else%
2413 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2414 % out and in.
2415 \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}%
2416 {%
2417 \centerpoint%
2418 \pgf@xc\halfwidth%
2419 \advance\[email protected]\pgf@xc%
2420 \advance\pgf@y\halfheight%
2421 \advance\pgf@y\halfbendheight%
2422 \pgf@yc\bendyradius%
2423 \advance\[email protected]\pgf@yc%
2424 }%
2425 {185}{355}{\innerbendxradius and \innerbendyradius}%
2426 \else%
2427 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2428 {\csname pgf@anchor@tape@north east\endcsname}%
2429 {\csname pgf@anchor@tape@north west\endcsname}%
2430 \fi%
2431 \fi%
2432 \fi%
2433 \else%
2434 % Between north and north west.
2435 \ifx\topbendstyle\pgf@lib@sh@inandouttext%
2436 % in and out.
2437 \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}%
2438 {%
2439 \centerpoint%
2440 \pgf@xc\halfwidth%
2441 \advance\[email protected]\pgf@xc%
2442 \advance\pgf@y\halfheight%
2443 \advance\pgf@y\halfbendheight%
2444 \pgf@yc\bendyradius%
2445 \advance\[email protected]\pgf@yc%
2446 }%
2447 {185}{355}{\innerbendxradius and \innerbendyradius}%
2448 \else%
2449 \ifx\topbendstyle\pgf@lib@sh@outandintext%
2450 % out and in.
2451 \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}%
2452 {%
2453 \centerpoint%
2454 \pgf@xc\halfwidth%
2455 \advance\[email protected]\pgf@xc%
2456 \advance\pgf@y\halfheight%
2457 \advance\pgf@y\halfbendheight%
2458 \pgf@yc\bendyradius%
2459 \advance\[email protected]\pgf@yc%
2460 }%
2461 {5}{175}{\outerbendxradius and \outerbendyradius}%
2462 \else%
2463 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2464 {\csname pgf@anchor@tape@north east\endcsname}%
2465 {\csname pgf@anchor@tape@north west\endcsname}%
2466 \fi%
2467 \fi%
2468 \fi%
2469 \else%
2470 \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@tape@south west\endcsname}%
2471 \ifdim\externalangle pt>\pgfmathresult pt%
2472 \ifdim\externalangle pt>270pt%
2473 \pgfmathanglebetweenpoints{\centerpoint}{\csname pgf@anchor@tape@south east\endcsname}%
2474 \ifdim\externalangle pt>\pgfmathresult pt%
2475 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2476 {\csname pgf@anchor@tape@north east\endcsname}%
2477 {\csname pgf@anchor@tape@south east\endcsname}%
2478 \else%
2479 % Between south and south east.
2480 \ifx\bottombendstyle\pgf@lib@sh@inandouttext%
2481 % in and out.
2482 \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}%
2483 {%
2484 \centerpoint%
2485 \pgf@xc\halfwidth%
2486 \advance\[email protected]\pgf@xc%
2487 \advance\pgf@y-\halfheight%
2488 \advance\pgf@y-\halfbendheight%
2489 \pgf@yc\bendyradius%
2490 \advance\[email protected]\pgf@yc%
2491 }%
2492 {5}{175}{\innerbendxradius and \innerbendyradius}%
2493 \else%
2494 \ifx\bottombendstyle\pgf@lib@sh@outandintext%
2495 % out and in.
2496 \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}%
2497 {%
2498 \centerpoint%
2499 \pgf@xc\halfwidth%
2500 \advance\[email protected]\pgf@xc%
2501 \advance\pgf@y-\halfheight%
2502 \advance\pgf@y-\halfbendheight%
2503 \pgf@yc\bendyradius%
2504 \advance\[email protected]\pgf@yc%
2505 }%
2506 {185}{355}{\outerbendxradius and \outerbendyradius}%
2507 \else%
2508 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2509 {\csname pgf@anchor@tape@south east\endcsname}%
2510 {\csname pgf@anchor@tape@south west\endcsname}%
2511 \fi%
2512 \fi%
2513 \fi%
2514 \else%
2515 % Between south and south west.
2516 \ifx\bottombendstyle\pgf@lib@sh@inandouttext%
2517 % in and out.
2518 \pgfmathpointintersectionoflineandarc{\externalpoint}{\centerpoint}%
2519 {%
2520 \centerpoint%
2521 \pgf@xc\halfwidth%
2522 \advance\[email protected]\pgf@xc%
2523 \advance\pgf@y-\halfheight%
2524 \advance\pgf@y-\halfbendheight%
2525 \pgf@yc\bendyradius%
2526 \advance\[email protected]\pgf@yc%
2527 }%
2528 {185}{355}{\outerbendxradius and \outerbendyradius}%
2529 \else%
2530 \ifx\bottombendstyle\pgf@lib@sh@outandintext%
2531 % out and in.
2532 \pgfmathpointintersectionoflineandarc{\centerpoint}{\externalpoint}%
2533 {%
2534 \centerpoint%
2535 \pgf@xc\halfwidth%
2536 \advance\[email protected]\pgf@xc%
2537 \advance\pgf@y-\halfheight%
2538 \advance\pgf@y-\halfbendheight%
2539 \pgf@yc\bendyradius%
2540 \advance\[email protected]\pgf@yc%
2541 }%
2542 {5}{175}{\innerbendxradius and \innerbendyradius}%
2543 \else%
2544 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2545 {\csname pgf@anchor@tape@south east\endcsname}%
2546 {\csname pgf@anchor@tape@south west\endcsname}%
2547 \fi%
2548 \fi%
2549 \fi%
2550 \else%
2551 \pgfpointintersectionoflines{\externalpoint}{\centerpoint}%
2552 {\csname pgf@anchor@tape@north west\endcsname}%
2553 {\csname pgf@anchor@tape@south west\endcsname}%
2554 \fi%
2555 \fi%
2556 }%
2557 }%
2558
2559
2560
2561
2562 % Keys for magnifying glass shape
2563 %
2564 % /pgf/magnifying glass handle angle : The angle of handle
2565 % /pgf/magnifying glass handle aspect : The length of the handle as a multiple
2566 % of the radius of the circle
2567 %
2568
2569 \pgfkeys{/pgf/.cd,
2570 magnifying glass handle angle/.initial=-45,
2571 magnifying glass handle aspect/.initial=1.5,
2572 }%
2573
2574 \pgfdeclareshape{magnifying glass}
2575 {%
2576 \inheritsavedanchors[from=circle]% this is nearly a circle
2577 \inheritanchorborder[from=circle]%
2578 \inheritanchor[from=circle]{north}%
2579 \inheritanchor[from=circle]{north west}%
2580 \inheritanchor[from=circle]{north east}%
2581 \inheritanchor[from=circle]{center}%
2582 \inheritanchor[from=circle]{west}%
2583 \inheritanchor[from=circle]{east}%
2584 \inheritanchor[from=circle]{mid}%
2585 \inheritanchor[from=circle]{mid west}%
2586 \inheritanchor[from=circle]{mid east}%
2587 \inheritanchor[from=circle]{base}%
2588 \inheritanchor[from=circle]{base west}%
2589 \inheritanchor[from=circle]{base east}%
2590 \inheritanchor[from=circle]{south}%
2591 \inheritanchor[from=circle]{south west}%
2592 \inheritanchor[from=circle]{south east}%
2593 \inheritbackgroundpath[from=circle]%
2594 \foregroundpath{
2595 \centerpoint%
2596 \pgf@xc=\pgf@x%
2597 \pgf@yc=\pgf@y%
2598 \pgfutil@tempdima=\radius%
2599 \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
2600 \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
2601 \ifdim\pgf@xb<\pgf@yb%
2602 \advance\pgfutil@tempdima by-\pgf@yb%
2603 \else%
2604 \advance\pgfutil@tempdima by-\pgf@xb%
2605 \fi%
2606 \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}
2607 {\pgfpointpolar{\pgfkeysvalueof{/pgf/magnifying glass handle angle}}{\pgfutil@tempdima}}}
2608 \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}
2609 {\pgfpointpolar{\pgfkeysvalueof{/pgf/magnifying glass handle angle}}{\pgfutil@tempdima+\pgfutil@tempdima*(\pgfkeysvalueof{/pgf/magnifying glass handle aspect})}}}
2610 \pgfsetarrowsstart{}
2611 \pgfsetarrowsend{}
2612 }%
2613 }%
2614
2615
2616 \pgfkeys{%
2617 /pgf/magnetic tape tail/.initial=0.15,
2618 /pgf/magnetic tape tail extend/.initial=0cm,
2619 }%
2620 \pgfdeclareshape{magnetic tape}{%
2621 \nodeparts{text}%
2622 \savedmacro\installparameters{%
2623 %
2624 \pgf@x=0.5\wd\pgfnodeparttextbox%
2625 \pgf@y=0.5\ht\pgfnodeparttextbox%
2626 \advance\pgf@y by-0.5\dp\pgfnodeparttextbox%
2627 \edef\centerpoint{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
2628 %
2629 \pgf@x=\wd\pgfnodeparttextbox%
2630 \pgf@y=\ht\pgfnodeparttextbox%
2631 \advance\pgf@y by\dp\pgfnodeparttextbox%
2632 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
2633 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/inner ysep}}%
2634 \advance\pgf@x by2.0\pgf@xa%
2635 \advance\pgf@y by2.0\pgf@ya%
2636 \ifdim\pgf@y>\pgf@x%
2637 \pgf@x=\pgf@y%
2638 \fi%
2639 \pgf@x=1.414213\pgf@x%
2640 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
2641 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
2642 \ifdim\pgf@x<\pgf@xa%
2643 \pgf@x=\pgf@xa%
2644 \fi%
2645 \ifdim\pgf@x<\pgf@ya%
2646 \pgf@x=\pgf@ya%
2647 \fi%
2648 \pgf@x=0.5\pgf@x%
2649 \edef\radius{\the\pgf@x}%
2650 %
2651 \pgfmathparse{max(\pgfkeysvalueof{/pgf/magnetic tape tail extend},0)}%
2652 \edef\tailextend{\pgfmathresult pt}%
2653 %
2654 \pgfmathparse{min(max(\pgfkeysvalueof{/pgf/magnetic tape tail},0),1)}%
2655 \pgf@xa=\pgfmathresult\pgf@x%
2656 \edef\tailheight{\the\pgf@xa}%
2657 %
2658 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}%
2659 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}%
2660 \ifdim\pgf@xa<\pgf@ya%
2661 \pgf@xa=\pgf@ya%
2662 \fi%
2663 \edef\outersep{\the\pgf@xa}%
2664 %
2665 \pgfmathparse{\outersep+\radius}%
2666 \edef\outerradius{\pgfmathresult pt}%
2667 %
2668 \pgfmathparse{(\radius-\tailheight)/\radius}%
2669 \pgfmathasin@{\pgfmathresult}%
2670 \pgfmathadd@{-\pgfmathresult}{360}%
2671 \let\tailangle=\pgfmathresult%
2672 %
2673 \pgfmathparse{\outerradius/(\outerradius+\tailextend)}%
2674 \pgfmathatan@{\pgfmathresult}%
2675 \pgfmathadd@{-\pgfmathresult}{360}%
2676 \let\tailbottomangle=\pgfmathresult%
2677 %
2678 \pgfmathparse{(\outerradius-\outersep-\tailheight-\outersep)/(\outerradius+\tailextend)}%
2679 \pgfmathatan@{\pgfmathresult}%
2680 \pgfmathadd@{-\pgfmathresult}{360}%
2681 \let\tailtopangle=\pgfmathresult%
2682 %
2683 \addtosavedmacro\radius%
2684 \addtosavedmacro\outerradius%
2685 \addtosavedmacro\outersep%
2686 \addtosavedmacro\tailheight%
2687 \addtosavedmacro\tailextend
2688 \addtosavedmacro\tailangle%
2689 \addtosavedmacro\tailtopangle%
2690 \addtosavedmacro\tailbottomangle%
2691 \addtosavedmacro\centerpoint%
2692 }%
2693 \savedanchor{\base}{\pgfqpoint{0.5\wd\pgfnodeparttextbox}{0pt}}%
2694 \savedanchor{\mid}{\pgfqpoint{0.5\wd\pgfnodeparttextbox}{0pt}\pgfmathsetlength\pgf@y{.5ex}}%
2695 \anchor{center}{\installparameters\centerpoint}% \addtosavedmacro\outerradius%
2696 \anchor{base}{\base}%
2697 \anchor{mid}{\mid}%
2698 \anchor{base west}{\installparameters\pgfpointadd{\base}{\pgfqpoint{-\outerradius}{0pt}}}%
2699 \anchor{base east}{\installparameters\pgfpointadd{\base}{\pgfqpoint{\outerradius}{0pt}}}%
2700 \anchor{mid west}{\installparameters\pgfpointadd{\mid}{\pgfqpoint{-\outerradius}{0pt}}}%
2701 \anchor{mid east}{\installparameters\pgfpointadd{\mid}{\pgfqpoint{\outerradius}{0pt}}}%
2702 \anchor{north}{\installparameters%
2703 \pgfpointadd{\centerpoint}{\pgfqpoint{0pt}{\outerradius}}}%
2704 \anchor{north east}{\installparameters%
2705 \pgfpointadd{\centerpoint}{\pgfqpointpolar{45}{\outerradius}}}%
2706 \anchor{south}{\installparameters%
2707 \pgfpointadd{\centerpoint}{\pgfqpoint{0pt}{-\outerradius}}}%
2708 \anchor{south east}{\installparameters%
2709 \pgfpointadd{\centerpoint}{\pgfqpoint{\outerradius}{-\outerradius}}}%
2710 \anchor{east}{\installparameters%
2711 \pgfpointadd{\centerpoint}{\pgfqpoint{\outerradius}{0pt}}}%
2712 \anchor{south west}{\installparameters%
2713 \pgfpointadd{\centerpoint}{\pgfqpointpolar{225}{\outerradius}}}%
2714 \anchor{west}{\installparameters%
2715 \pgfpointadd{\centerpoint}{\pgfqpoint{-\outerradius}{0pt}}}%
2716 \anchor{north west}{\installparameters%
2717 \pgfpointadd{\centerpoint}{\pgfqpointpolar{135}{\outerradius}}}%
2718 \anchor{tail east}{\installparameters%
2719 \pgfpointadd{\centerpoint}{\pgfpoint{\radius+\tailextend+\outersep}{-\outerradius+\outersep+\tailheight/2}}}%
2720 \anchor{tail south east}{\installparameters%
2721 \pgfpointadd{\centerpoint}{\pgfpoint{\radius+\tailextend+\outersep}{-\outerradius}}}%
2722 \anchor{tail north east}{\installparameters%
2723 \pgfpointadd{\centerpoint}{\pgfpoint{\radius+\tailextend+\outersep}{-\outerradius+\outersep+\tailheight+\outersep}}}%
2724 \backgroundpath{
2725 %
2726 \installparameters%
2727 {%
2728 \pgftransformshift{\centerpoint}%
2729 \pgfpathmoveto{\pgfpointpolar{\tailangle}{\radius}}%
2730 \pgfpatharc{\tailangle}{360}{\radius}%
2731 \pgfpatharc{0}{270}{\radius}%
2732 \pgfpathlineto{\pgfpoint{\radius+\tailextend}{-\radius}}%
2733 \pgfpathlineto{\pgfpoint{\radius+\tailextend}{-\radius+\tailheight}}%
2734 \pgfpathclose%
2735 }%
2736 }%
2737 \anchorborder{%
2738 \pgfextract@process\externalpoint{}%
2739 \installparameters%
2740 \pgfmathanglebetweenpoints{\pgfpointorigin}{\externalpoint}
2741 \ifdim\pgfmathresult pt<270pt\relax%
2742 \pgfpointadd{\centerpoint}{%
2743 \pgfpointborderellipse%
2744 {\externalpoint}%
2745 {\pgfqpoint{\outerradius}{\outerradius}}%
2746 }%
2747 \else%
2748 \ifdim\pgfmathresult pt<\tailbottomangle pt\relax%
2749 \pgfpointadd{\centerpoint}{%
2750 \pgfpointintersectionoflines%
2751 {\externalpoint}{\pgfpointorigin}%
2752 {\pgfqpoint{0pt}{-\outerradius}}{\pgfqpoint{\outerradius}{-\outerradius}}%
2753 }%
2754 \else%
2755 \ifdim\pgfmathresult pt<\tailtopangle pt\relax%
2756 \pgfpointadd{\centerpoint}{%
2757 \pgfpointintersectionoflines%
2758 {\externalpoint}{\pgfpointorigin}%
2759 {\pgfqpoint{\outerradius}{\outerradius}}{\pgfqpoint{\outerradius}{-\outerradius}}%
2760 }%
2761 \else%
2762 \pgfpointadd{\centerpoint}{%
2763 \pgfpointborderellipse%
2764 {\externalpoint}%
2765 {\pgfqpoint{\outerradius}{\outerradius}}%
2766 }%
2767 \fi%
2768 \fi%
2769 \fi%
2770 }%
2771 }%
2772
2773 % Local Variables:
2774 % tab-width: 2
2775 % End: