| 1 |
% Copyright 2019 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 Free Documentation License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
|
| 11 |
\section{Shape Library} |
| 12 |
\label{section-libs-shapes} |
| 13 |
|
| 14 |
\subsection{Overview} |
| 15 |
|
| 16 |
In addition to the standard shapes |rectangle|, |circle| and |coordinate|, |
| 17 |
there exist a number of additional shapes defined in different shape libraries. |
| 18 |
Most of these shapes have been contributed by Mark Wibrow. In the present |
| 19 |
section, these shapes are described. Note that the library |shapes| is provided |
| 20 |
for compatibility only. Please include sublibraries like |shapes.geometric| or |
| 21 |
|shapes.misc| directly. |
| 22 |
|
| 23 |
The appearance of shapes is influenced by numerous parameters like |
| 24 |
|minimum height| or |inner xsep|. These general parameters are documented in |
| 25 |
Section~\ref{section-shape-common-options} |
| 26 |
|
| 27 |
In all of the examples presented in this section, the following |shape example| |
| 28 |
style is used: |
| 29 |
% |
| 30 |
\begin{codeexample}[code only,setup code] |
| 31 |
\tikzset{ |
| 32 |
shape example/.style= {color = black!30, |
| 33 |
draw, |
| 34 |
fill = yellow!30, |
| 35 |
line width = .5cm, |
| 36 |
inner xsep = 2.5cm, |
| 37 |
inner ysep = 0.5cm} |
| 38 |
} |
| 39 |
\end{codeexample} |
| 40 |
|
| 41 |
|
| 42 |
\subsection{Predefined Shapes} |
| 43 |
\label{section-predefined-shapes} |
| 44 |
|
| 45 |
The three shapes |rectangle|, |circle|, and |coordinate| are always defined and |
| 46 |
no library needs to be loaded for them. While the |coordinate| shape defines |
| 47 |
only the |center| anchor, the other two shapes define a standard set of |
| 48 |
anchors. |
| 49 |
|
| 50 |
\begin{shape}{circle} |
| 51 |
This shape draws a tightly fitting circle around the text. The following |
| 52 |
figure shows the anchors this shape defines; the anchors |10| and |130| are |
| 53 |
example of border anchors. |
| 54 |
% |
| 55 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 56 |
\Huge |
| 57 |
\begin{tikzpicture} |
| 58 |
\node[name=s,shape=circle,shape example] {Circle\vrule width 1pt height 2cm}; |
| 59 |
\foreach \anchor/\placement in |
| 60 |
{north west/above left, north/above, north east/above right, |
| 61 |
west/left, center/above, east/right, |
| 62 |
mid west/right, mid/above, mid east/left, |
| 63 |
base west/left, base/below, base east/right, |
| 64 |
south west/below left, south/below, south east/below right, |
| 65 |
text/left, 10/right, 130/above} |
| 66 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 67 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 68 |
\end{tikzpicture} |
| 69 |
\end{codeexample} |
| 70 |
% |
| 71 |
\end{shape} |
| 72 |
|
| 73 |
\begin{shape}{rectangle} |
| 74 |
This shape, which is the standard, is a rectangle around the text. The |
| 75 |
inner and outer separations (see Section~\ref{section-shape-seps}) |
| 76 |
influence the white space around the text. The following figure shows the |
| 77 |
anchors this shape defines; the anchors |10| and |130| are example of |
| 78 |
border anchors. |
| 79 |
% |
| 80 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 81 |
\Huge |
| 82 |
\begin{tikzpicture} |
| 83 |
\node[name=s,shape=rectangle,shape example] {Rectangle\vrule width 1pt height 2cm}; |
| 84 |
\foreach \anchor/\placement in |
| 85 |
{north west/above left, north/above, north east/above right, |
| 86 |
west/left, center/above, east/right, |
| 87 |
mid west/right, mid/above, mid east/left, |
| 88 |
base west/left, base/below, base east/right, |
| 89 |
south west/below left, south/below, south east/below right, |
| 90 |
text/left, 10/right, 130/above} |
| 91 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 92 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 93 |
\end{tikzpicture} |
| 94 |
\end{codeexample} |
| 95 |
% |
| 96 |
\end{shape} |
| 97 |
|
| 98 |
|
| 99 |
\subsection{Geometric Shapes} |
| 100 |
|
| 101 |
\begin{pgflibrary}{shapes.geometric} |
| 102 |
This library defines different shapes that correspond to basic geometric |
| 103 |
objects like ellipses or polygons. |
| 104 |
\end{pgflibrary} |
| 105 |
|
| 106 |
\begin{shape}{diamond} |
| 107 |
This shape is a diamond tightly fitting the text box. The ratio between |
| 108 |
width and height is 1 by default, but can be changed by setting the shape |
| 109 |
aspect ratio using the following \pgfname{} key (to use this key in |
| 110 |
\tikzname{} simply remove the \declare{|/pgf/|} path). |
| 111 |
|
| 112 |
\begin{key}{/pgf/aspect=\meta{value} (initially 1.0)} |
| 113 |
The aspect is a recommendation for the quotient of the width and the |
| 114 |
height of a shape. This key calls the macro |\pgfsetshapeaspect|. |
| 115 |
\end{key} |
| 116 |
|
| 117 |
The following figure shows the anchors this shape defines; the anchors |10| |
| 118 |
and |130| are example of border anchors. |
| 119 |
% |
| 120 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 121 |
\Huge |
| 122 |
\begin{tikzpicture} |
| 123 |
\node[name=s,shape=diamond,shape example] {Diamond\vrule width 1pt height 2cm}; |
| 124 |
\foreach \anchor/\placement in |
| 125 |
{north west/above left, north/above, north east/above right, |
| 126 |
west/left, center/above, east/right, |
| 127 |
mid/above, |
| 128 |
base/below, |
| 129 |
south west/below left, south/below, south east/below right, |
| 130 |
text/left, 10/right, 130/above} |
| 131 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 132 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 133 |
\end{tikzpicture} |
| 134 |
\end{codeexample} |
| 135 |
% |
| 136 |
\end{shape} |
| 137 |
|
| 138 |
\begin{shape}{ellipse} |
| 139 |
This shape is an ellipse tightly fitting the text box, if no inner |
| 140 |
separation is given. The following figure shows the anchors this shape |
| 141 |
defines; the anchors |10| and |130| are example of border anchors. |
| 142 |
% |
| 143 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 144 |
\Huge |
| 145 |
\begin{tikzpicture} |
| 146 |
\node[name=s,shape=ellipse,shape example] {Ellipse\vrule width 1pt height 2cm}; |
| 147 |
\foreach \anchor/\placement in |
| 148 |
{north west/above left, north/above, north east/above right, |
| 149 |
west/left, center/above, east/right, |
| 150 |
mid west/right, mid/above, mid east/left, |
| 151 |
base west/left, base/below, base east/right, |
| 152 |
south west/below left, south/below, south east/below right, |
| 153 |
text/left, 10/right, 130/above} |
| 154 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 155 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 156 |
\end{tikzpicture} |
| 157 |
\end{codeexample} |
| 158 |
% |
| 159 |
\end{shape} |
| 160 |
|
| 161 |
\begin{shape}{trapezium} |
| 162 |
This shape is a trapezium, that is, a quadrilateral with a single pair of |
| 163 |
parallel lines (this can sometimes be known as a trapezoid). The trapezium |
| 164 |
shape supports the rotation of the shape border, as described in |
| 165 |
Section~\ref{section-rotating-shape-borders}. |
| 166 |
|
| 167 |
The lower internal angles at the lower corners of the trapezium can be |
| 168 |
specified independently, and the resulting extensions are in addition to |
| 169 |
the natural dimensions of the node contents (which includes any |
| 170 |
|inner sep|. |
| 171 |
% |
| 172 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 173 |
\begin{tikzpicture}[every node/.style={trapezium, draw}] |
| 174 |
\node at (0,2) {A}; |
| 175 |
\node[trapezium left angle=75, trapezium right angle=45] |
| 176 |
at (0,1) {B}; |
| 177 |
\node[trapezium left angle=120, trapezium right angle=60] |
| 178 |
at (0,0) {C}; |
| 179 |
\end{tikzpicture} |
| 180 |
\end{codeexample} |
| 181 |
|
| 182 |
The \pgfname{} keys to set the lower internal angles of the trapezium are |
| 183 |
shown below. To use these keys in \tikzname, simply remove the |
| 184 |
\declare{|/pgf/|} path. |
| 185 |
|
| 186 |
\begin{key}{/pgf/trapezium left angle=\meta{angle} (initially 60)} |
| 187 |
Sets the lower internal angle of the left side. |
| 188 |
\end{key} |
| 189 |
|
| 190 |
\begin{key}{/pgf/trapezium right angle=\meta{angle} (initially 60)} |
| 191 |
Sets the lower internal angle of the right side. |
| 192 |
\end{key} |
| 193 |
|
| 194 |
\begin{stylekey}{/pgf/trapezium angle=\meta{angle}} |
| 195 |
This key stores no value itself, but sets the value of the previous two |
| 196 |
keys to \meta{angle}. |
| 197 |
\end{stylekey} |
| 198 |
|
| 199 |
Regardless of the rotation of the shape border, the width and height of the |
| 200 |
trapezium are as follows: |
| 201 |
% |
| 202 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 203 |
\begin{tikzpicture}[>=stealth, every node/.style={text=black}, |
| 204 |
shape border uses incircle, shape border rotate=60] |
| 205 |
\node [trapezium, fill=gray!25, minimum width=2cm] (t) {}; |
| 206 |
\draw [red, <->] (t.bottom left corner) -- (t.bottom right corner) |
| 207 |
node [midway, below right] {width}; |
| 208 |
\draw [red, <->] (t.top side) -- (t.bottom side) |
| 209 |
node [at start, above] {height}; |
| 210 |
\end{tikzpicture} |
| 211 |
\end{codeexample} |
| 212 |
|
| 213 |
\begin{key}{/pgf/trapezium stretches=\meta{boolean} (default true)} |
| 214 |
This key controls whether \pgfname{} allows the width and the height of |
| 215 |
the trapezium to be enlarged independently, when considering any |
| 216 |
minimum size specification. This is initially |false|, ensuring that |
| 217 |
the shape ``looks the same but bigger'' when enlarged. |
| 218 |
% |
| 219 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 220 |
\tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}} |
| 221 |
\begin{tikzpicture} |
| 222 |
\draw [help lines] grid (3,2); |
| 223 |
\node [my node=red] {A}; |
| 224 |
\node [my node=green, minimum height=1.5cm] at (1, 1.25) {B}; |
| 225 |
\node [my node=blue, minimum width=1.5cm] at (2, 0) {C}; |
| 226 |
\end{tikzpicture} |
| 227 |
\end{codeexample} |
| 228 |
|
| 229 |
By setting \meta{boolean} to |true|, the trapezium can be stretched |
| 230 |
horizontally or vertically. |
| 231 |
% |
| 232 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 233 |
\tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}} |
| 234 |
\begin{tikzpicture} |
| 235 |
\tikzset{trapezium stretches=true} |
| 236 |
\draw [help lines] grid (3,2); |
| 237 |
\node [my node=red] {A}; |
| 238 |
\node [my node=green, minimum height=1.5cm] at (1, 1.25) {B}; |
| 239 |
\node [my node=blue, minimum width=1.5cm] at (2, 0) {C}; |
| 240 |
\end{tikzpicture} |
| 241 |
\end{codeexample} |
| 242 |
\end{key} |
| 243 |
|
| 244 |
\begin{key}{/pgf/trapezium stretches body=\meta{boolean} (default true)} |
| 245 |
This is similar to the |trapezium stretches| key except that when |
| 246 |
\meta{boolean} is |true|, \pgfname{} enlarges only the body of the |
| 247 |
trapezium when applying minimum width. |
| 248 |
% |
| 249 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 250 |
\tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}} |
| 251 |
\begin{tikzpicture} |
| 252 |
\draw [help lines] grid (3,2); |
| 253 |
\node [my node=red] at (1.5,.25) {A}; |
| 254 |
\node [my node=green, minimum width=3cm, trapezium stretches] |
| 255 |
at (1.5,1) {B}; |
| 256 |
\node [my node=blue, minimum width=3cm, trapezium stretches body] |
| 257 |
at (1.5,1.75) {C}; |
| 258 |
\end{tikzpicture} |
| 259 |
\end{codeexample} |
| 260 |
\end{key} |
| 261 |
|
| 262 |
The anchors for the trapezium are shown below. The anchor |160| is an |
| 263 |
example of a border anchor. |
| 264 |
% |
| 265 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 266 |
\Huge |
| 267 |
\begin{tikzpicture} |
| 268 |
\node[name=s, shape=trapezium, shape example, inner sep=1cm] |
| 269 |
{Trapezium\vrule width 1pt height 2cm}; |
| 270 |
\foreach \anchor/\placement in |
| 271 |
{bottom left corner/below, top right corner/right, |
| 272 |
top left corner/left, bottom right corner/below, |
| 273 |
bottom side/below, left side/left, |
| 274 |
right side/right, top side/above, |
| 275 |
center/above, text/below, mid/right, base/below, |
| 276 |
mid west/right, base west/below, mid east/left, base east/below, |
| 277 |
west/above, east/above, north/below, south/above, |
| 278 |
north west/above, north east/above, |
| 279 |
south west/below, south east/below, 160/above} |
| 280 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 281 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 282 |
\end{tikzpicture} |
| 283 |
\end{codeexample} |
| 284 |
% |
| 285 |
\end{shape} |
| 286 |
|
| 287 |
\begin{shape}{semicircle} |
| 288 |
This shape is a semicircle, which tightly fits the node contents. This |
| 289 |
shape supports the rotation of the shape border, as described in |
| 290 |
Section~\ref{section-rotating-shape-borders}. The anchors for the |
| 291 |
|semicircle| shape are shown below. Anchor |30| is an example of a border |
| 292 |
anchor. |
| 293 |
% |
| 294 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 295 |
\Huge |
| 296 |
\begin{tikzpicture} |
| 297 |
\node[name=s,shape=semicircle,shape border rotate=0,shape example, inner sep=1cm] |
| 298 |
{Semicircle\vrule width 1pt height 2cm}; |
| 299 |
\foreach \anchor/\placement in |
| 300 |
{apex/above, arc start/below, arc end/below, chord center/below, |
| 301 |
center/above, base/below, mid/right, text/left, |
| 302 |
base west/below, base east/below, mid west/left, mid east/right, |
| 303 |
north/below, south/above, east/above, west/above, |
| 304 |
north west/above left, north east/above right, |
| 305 |
south west/below, south east/below, 30/right} |
| 306 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 307 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 308 |
\end{tikzpicture} |
| 309 |
\end{codeexample} |
| 310 |
% |
| 311 |
\end{shape} |
| 312 |
|
| 313 |
\begin{shape}{regular polygon} |
| 314 |
This shape is a regular polygon, which, by default, is drawn so that a side |
| 315 |
(rather than a corner) is always at the bottom. This shape supports the |
| 316 |
rotation as described in Section~\ref{section-rotating-shape-borders}, but |
| 317 |
the border of the polygon is \emph{always} constructed using the incircle, |
| 318 |
whose radius is calculated to tightly fit the node contents (including any |
| 319 |
|inner sep|). |
| 320 |
% |
| 321 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 322 |
\begin{tikzpicture} |
| 323 |
\foreach \a in {3,...,7}{ |
| 324 |
\draw[red, dashed] (\a*2,0) circle(0.5cm); |
| 325 |
\node[regular polygon, regular polygon sides=\a, draw, |
| 326 |
inner sep=0.3535cm] at (\a*2,0) {}; |
| 327 |
} |
| 328 |
\end{tikzpicture} |
| 329 |
\end{codeexample} |
| 330 |
|
| 331 |
If the node is enlarged to any specified minimum size, this is interpreted |
| 332 |
as the diameter of the circumcircle, that is, the circle that passes |
| 333 |
through all the corners of the polygon border. |
| 334 |
% |
| 335 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 336 |
\begin{tikzpicture} |
| 337 |
\foreach \a in {3,...,7}{ |
| 338 |
\draw[blue, dashed] (\a*2,0) circle(0.5cm); |
| 339 |
\node[regular polygon, regular polygon sides=\a, minimum size=1cm, draw] at (\a*2,0) {}; |
| 340 |
} |
| 341 |
\end{tikzpicture} |
| 342 |
\end{codeexample} |
| 343 |
|
| 344 |
There is a \pgfname{} key to set the number of sides for the regular |
| 345 |
polygon. To use this key in \tikzname, simply remove the \declare{|/pgf/|} |
| 346 |
path. |
| 347 |
|
| 348 |
\begin{key}{/pgf/regular polygon sides=\meta{integer} (initially 5)} |
| 349 |
\end{key} |
| 350 |
|
| 351 |
The anchors for a regular polygon shape are shown below. The anchor |75| is |
| 352 |
an example of a border anchor. |
| 353 |
% |
| 354 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 355 |
\Huge |
| 356 |
\begin{tikzpicture} |
| 357 |
\node[name=s, shape=regular polygon, shape example, inner sep=.5cm] |
| 358 |
{Regular Polygon\vrule width 1pt height 2cm}; |
| 359 |
\foreach \anchor/\placement in |
| 360 |
{corner 1/above, corner 2/above, corner 3/left, corner 4/right, corner 5/above, |
| 361 |
side 1/above, side 2/left, side 3/below, side 4/right, side 5/above, |
| 362 |
center/above, text/left, mid/right, base/below, 75/above, |
| 363 |
west/above, east/above, north/below, south/above, |
| 364 |
north east/below, south east/above, north west/below, south west/above} |
| 365 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 366 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 367 |
\end{tikzpicture} |
| 368 |
\end{codeexample} |
| 369 |
% |
| 370 |
\end{shape} |
| 371 |
|
| 372 |
\begin{shape}{star} |
| 373 |
This shape is a star, which by default (minus any transformations) is drawn |
| 374 |
with the first point pointing upwards. This shape supports the rotation as |
| 375 |
described in Section~\ref{section-rotating-shape-borders}, but the border |
| 376 |
of the star is \emph{always} constructed using the incircle. |
| 377 |
|
| 378 |
A star should be thought of as having a set of ``inner points'' and ``outer |
| 379 |
points''. The inner points of the border are based on the radius of the |
| 380 |
circle which tightly fits the node contents, and the outer points are based |
| 381 |
on the circumcircle, the circle that passes through every outer point. Any |
| 382 |
specified minimum size, width or height, is interpreted as the diameter of |
| 383 |
the circumcircle. |
| 384 |
% |
| 385 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 386 |
\begin{tikzpicture} |
| 387 |
\draw [help lines] (0,0) grid (2,2); |
| 388 |
\draw [blue, dashed] (1,1) circle(1cm); |
| 389 |
\draw [red, dashed] (1,1) circle(.5cm); |
| 390 |
\node [star, star point height=.5cm, minimum size=2cm, draw] |
| 391 |
at (1,1) {S}; |
| 392 |
\end{tikzpicture} |
| 393 |
\end{codeexample} |
| 394 |
|
| 395 |
The \pgfname{} keys to set the number of star points, and the height of the |
| 396 |
star points, are shown below. To use these keys in \tikzname, simply remove |
| 397 |
the \declare{|/pgf/|} path. |
| 398 |
|
| 399 |
\begin{key}{/pgf/star points=\meta{integer} (initially 5)} |
| 400 |
Sets the number of points for the star. |
| 401 |
\end{key} |
| 402 |
|
| 403 |
\begin{key}{/pgf/star point height=\meta{distance} (initially .5cm)} |
| 404 |
Sets the height of the star points. This is the distance between the |
| 405 |
inner point and outer point radii. If the star is enlarged to some |
| 406 |
specified minimum size, the inner radius is increased to maintain the |
| 407 |
point height. |
| 408 |
\end{key} |
| 409 |
|
| 410 |
\begin{key}{/pgf/star point ratio=\meta{number} (initially 1.5)} |
| 411 |
Sets the ratio between the inner point and outer point radii. If the |
| 412 |
star is enlarged to some specified minimum size, the inner radius is |
| 413 |
increased to maintain the ratio. |
| 414 |
\end{key} |
| 415 |
|
| 416 |
The inner and outer points form the principal anchors for the star, as |
| 417 |
shown below (anchor |75| is an example of a border anchor). |
| 418 |
% |
| 419 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 420 |
\Huge |
| 421 |
\begin{tikzpicture} |
| 422 |
\node[name=s, shape=star, star points=5, star point ratio=1.65, shape example, inner sep=1.5cm] |
| 423 |
{Star\vrule width 1pt height 2cm}; |
| 424 |
\foreach \anchor/\placement in |
| 425 |
{inner point 1/above, inner point 2/above, inner point 3/below, inner point 4/right, |
| 426 |
inner point 5/above, outer point 1/above, outer point 2/above, outer point 3/left, |
| 427 |
outer point 4/right, outer point 5/above, |
| 428 |
center/above, text/left, mid/right, base/below, 75/above, |
| 429 |
west/above, east/above, north/below, south/above, |
| 430 |
north east/below, south east/above, north west/below, south west/above} |
| 431 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 432 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 433 |
\end{tikzpicture} |
| 434 |
\end{codeexample} |
| 435 |
% |
| 436 |
\end{shape} |
| 437 |
|
| 438 |
\begin{shape}{isosceles triangle} |
| 439 |
This shape is an isosceles triangle, which supports the rotation of the |
| 440 |
shape border, as described in Section~\ref{section-rotating-shape-borders}. |
| 441 |
The angle of rotation determines the direction in which the apex of the |
| 442 |
triangle points (provided no other transformations are applied). However, |
| 443 |
regardless of the rotation of the shape border, the width and height are |
| 444 |
always considered as follows: |
| 445 |
% |
| 446 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 447 |
\begin{tikzpicture}[>=stealth, every node/.style={text=black}, |
| 448 |
shape border uses incircle, shape border rotate=-30] |
| 449 |
\node [isosceles triangle, fill=gray!25, minimum width=1.5cm] (t) {}; |
| 450 |
\draw [red, <->] (t.left corner) -- (t.right corner) |
| 451 |
node [midway, above left] {width}; |
| 452 |
\draw [red, <->] (t.apex) -- (t.lower side) |
| 453 |
node [midway, above right] {height}; |
| 454 |
\end{tikzpicture} |
| 455 |
\end{codeexample} |
| 456 |
|
| 457 |
There are \pgfname{} keys to customize this shape. To use these keys in |
| 458 |
\tikzname, simply remove the \declare{|/pgf/|} path. |
| 459 |
|
| 460 |
\begin{key}{/pgf/isosceles triangle apex angle=\meta{angle} (initially 30)} |
| 461 |
Sets the angle of the apex of the isosceles triangle. |
| 462 |
\end{key} |
| 463 |
|
| 464 |
\begin{key}{/pgf/isosceles triangle stretches=\meta{boolean} (default false)} |
| 465 |
By default \meta{boolean} is |false|. This means, that when applying |
| 466 |
any minimum width or minimum height requirements, increasing the height |
| 467 |
will increase the width (and vice versa), in order to keep the apex |
| 468 |
angle the same. |
| 469 |
% |
| 470 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 471 |
\begin{tikzpicture}[paint/.style={draw=#1!75, fill=#1!20}] |
| 472 |
\tikzset{every node/.style={isosceles triangle, draw, inner sep=0pt, |
| 473 |
anchor=left corner, shape border rotate=90}} |
| 474 |
\draw[help lines] grid(4,2); |
| 475 |
\foreach \a/\c in {1.5/blue, 1/green, 0.5/red}{ |
| 476 |
\node[paint=\c, minimum height=\a cm] at (0,0) {}; |
| 477 |
\node[paint=\c, minimum width=\a cm] at (2,0) {}; |
| 478 |
} |
| 479 |
\end{tikzpicture} |
| 480 |
\end{codeexample} |
| 481 |
|
| 482 |
However, by setting \meta{boolean} to |true|, minimum width and height |
| 483 |
can be applied independently. |
| 484 |
% |
| 485 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 486 |
\begin{tikzpicture}[paint/.style={draw=#1!75, fill=#1!20}] |
| 487 |
\tikzset{every node/.style={isosceles triangle, draw, inner sep=0pt, |
| 488 |
anchor=south, shape border rotate=90, isosceles triangle stretches}} |
| 489 |
\draw[help lines] grid(4,2); |
| 490 |
\foreach \a/\c in {1.5/blue, 1/green, 0.5/red}{ |
| 491 |
\node[paint=\c, minimum height=\a cm, minimum width=1.5cm] at (0.75,0) {}; |
| 492 |
\node[paint=\c, minimum width=\a cm, minimum height=1.5cm] at (3,0) {}; |
| 493 |
} |
| 494 |
\end{tikzpicture} |
| 495 |
\end{codeexample} |
| 496 |
\end{key} |
| 497 |
|
| 498 |
The anchors for the |isosceles triangle| are shown below (anchor |150| is |
| 499 |
an example of a border anchor). Note that, somewhat confusingly, the anchor |
| 500 |
names such as |left side| and |right corner| are named as if the triangle |
| 501 |
is rotated to 90 degrees. Note also that the |center| anchor does not |
| 502 |
necessarily correspond to any kind of geometric center. |
| 503 |
% |
| 504 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 505 |
\Huge |
| 506 |
\begin{tikzpicture} |
| 507 |
\node[name=s, shape=isosceles triangle, shape example, inner xsep=1cm] |
| 508 |
{Isosceles Triangle\vrule width 1pt height 2cm}; |
| 509 |
\foreach \anchor/\placement in |
| 510 |
{apex/above, left corner/right, right corner/right, |
| 511 |
left side/above, right side/below, lower side/right, |
| 512 |
center/above, text/right, 150/above, |
| 513 |
mid/right, mid west/above, mid east/right, |
| 514 |
base/below, base west/below, base east/below, |
| 515 |
west/above, east/below, north/below, south/above, |
| 516 |
north west/below, north east/below, |
| 517 |
south west/above, south east/above} |
| 518 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 519 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 520 |
\end{tikzpicture} |
| 521 |
\end{codeexample} |
| 522 |
% |
| 523 |
\end{shape} |
| 524 |
|
| 525 |
\par\leavevmode |
| 526 |
\begin{shape}{kite} |
| 527 |
This shape is a kite, which supports the rotation of the shape border, as |
| 528 |
described in Section~\ref{section-rotating-shape-borders}. There are |
| 529 |
\pgfname{} keys to specify the upper and lower vertex angles of the kite. |
| 530 |
To use these keys in \tikzname, simply remove the \declare{|/pgf/|} path. |
| 531 |
|
| 532 |
\begin{key}{/pgf/kite upper vertex angle=\meta{angle} (initially 120)} |
| 533 |
Sets the upper internal angle of the kite. |
| 534 |
\end{key} |
| 535 |
|
| 536 |
\begin{key}{/pgf/kite lower vertex angle=\meta{angle} (initially 60)} |
| 537 |
Sets the lower internal angle of the kite. |
| 538 |
\end{key} |
| 539 |
|
| 540 |
\begin{key}{/pgf/kite vertex angles=\meta{angle specification}} |
| 541 |
This key sets the keys for both the upper and lower vertex angles (it |
| 542 |
stores no value itself). \meta{angle specification} can be pair of |
| 543 |
angles in the form \meta{upper angle} |and| \meta{lower angle}, or a |
| 544 |
single angle. In this latter case, both the upper and lower vertex |
| 545 |
angles will be the same. |
| 546 |
\end{key} |
| 547 |
% |
| 548 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 549 |
\begin{tikzpicture}[every node/.style={kite, draw}] |
| 550 |
\node[kite upper vertex angle=135, kite lower vertex angle=70] at (0,0) {A}; |
| 551 |
\node[kite vertex angles=90 and 45] at (1,0) {B}; |
| 552 |
\node[kite vertex angles=60] at (2,0) {C}; |
| 553 |
\end{tikzpicture} |
| 554 |
\end{codeexample} |
| 555 |
|
| 556 |
The anchors for the |kite| are shown below. Anchor |110| is an example of a |
| 557 |
border anchor. |
| 558 |
% |
| 559 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 560 |
\Huge |
| 561 |
\begin{tikzpicture} |
| 562 |
\node[name=s, shape=kite, shape example, inner sep=1.5cm] |
| 563 |
{Kite\vrule width 1pt height 2cm}; |
| 564 |
\foreach \anchor/\placement in |
| 565 |
{upper vertex/above, left vertex/above, lower vertex/below, |
| 566 |
right vertex/above, upper left side/above, upper right side/above, |
| 567 |
lower left side/below, lower right side/below, |
| 568 |
center/above, text/left, mid/right, base/below, |
| 569 |
mid west/left, base west/below, mid east/right, base east/below, |
| 570 |
west/above, east/above, north/below, south/above, |
| 571 |
north west/left, north east/right, |
| 572 |
south west/above, south east/above, 110/above} |
| 573 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 574 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 575 |
\end{tikzpicture} |
| 576 |
\end{codeexample} |
| 577 |
% |
| 578 |
\end{shape} |
| 579 |
|
| 580 |
\begin{shape}{dart} |
| 581 |
This shape is a dart (which can also be known as an arrowhead or concave |
| 582 |
kite). This shape supports the rotation of the shape border, as described |
| 583 |
in Section~\ref{section-rotating-shape-borders}. The angle of the border |
| 584 |
rotation determines the direction in which the dart points (unless other |
| 585 |
transformations have been applied). |
| 586 |
|
| 587 |
There are \pgfname{} keys to set the angle for the `tip' of the dart and |
| 588 |
the angle between the `tails' of the dart. To use these keys in \tikzname, |
| 589 |
simply remove the \declare{|/pgf/|} path. |
| 590 |
% |
| 591 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 592 |
\begin{tikzpicture} |
| 593 |
\node[dart, draw, gray, shape border uses incircle, shape border rotate=45] |
| 594 |
(d) {dart}; |
| 595 |
\draw [<->] (d.tip)++(202.5:.5cm) arc(202.5:247.5:.5cm); |
| 596 |
\node [left=.5cm] at (d.tip) {tip angle}; |
| 597 |
\draw [<->] (d.tail center)++(157.5:.5cm) arc(157.5:292.5:.5cm); |
| 598 |
\node [right] at (d.tail center) {tail angle}; |
| 599 |
\end{tikzpicture} |
| 600 |
\end{codeexample} |
| 601 |
|
| 602 |
\begin{key}{/pgf/dart tip angle=\meta{angle} (initially 45)} |
| 603 |
Sets the angle at the tip of the dart. |
| 604 |
\end{key} |
| 605 |
|
| 606 |
\begin{key}{/pgf/dart tail angle=\meta{angle} (initially 135)} |
| 607 |
Sets the angle between the tails of the dart. |
| 608 |
\end{key} |
| 609 |
|
| 610 |
The anchors for the |dart| shape are shown below (note that the shape is |
| 611 |
rotated 90 degrees anti-clockwise). Anchor |110| is an example of a border |
| 612 |
anchor. |
| 613 |
% |
| 614 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 615 |
\Huge |
| 616 |
\begin{tikzpicture} |
| 617 |
\node[name=s, shape=dart, shape border rotate=90, shape example, inner sep=1.25cm] |
| 618 |
{Dart\vrule width 1pt height 2cm}; |
| 619 |
\foreach \anchor/\placement in |
| 620 |
{tip/above, tail center/below, right tail/below, |
| 621 |
left tail/below, right tail/below, left side/left, right side/right, |
| 622 |
center/above, text/left, mid/right, base/below, |
| 623 |
mid west/left, base west/below, mid east/right, base east/below, |
| 624 |
west/above, east/above, north/below, south/above, |
| 625 |
north west/left, north east/right, south west/above, south east/above, |
| 626 |
110/above} |
| 627 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 628 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 629 |
\end{tikzpicture} |
| 630 |
\end{codeexample} |
| 631 |
% |
| 632 |
\end{shape} |
| 633 |
|
| 634 |
\begin{shape}{circular sector} |
| 635 |
This shape is a circular sector (which can also be known as a wedge). This |
| 636 |
shape supports the rotation of the shape border, as described in |
| 637 |
Section~\ref{section-rotating-shape-borders}. The angle of the border |
| 638 |
rotation determines the direction in which the `apex' of the sector points |
| 639 |
(unless other transformations have been applied). |
| 640 |
% |
| 641 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 642 |
\begin{tikzpicture}[ |
| 643 |
every node/.style={circular sector, shape border uses incircle, draw}, |
| 644 |
] |
| 645 |
\node at (0,0) {A}; |
| 646 |
\node [shape border rotate=30] at (1.5,0) {A}; |
| 647 |
\end{tikzpicture} |
| 648 |
\end{codeexample} |
| 649 |
|
| 650 |
There is a \pgfname{} key to set the central angle of the sector, which is |
| 651 |
expected to be less than 180 degrees. To use this key in \tikzname, simply |
| 652 |
remove the \declare{|/pgf/|} path. |
| 653 |
|
| 654 |
\begin{key}{/pgf/circular sector angle=\meta{angle} (initially 60)} |
| 655 |
Sets the central angle of the sector. |
| 656 |
\end{key} |
| 657 |
|
| 658 |
The anchors for the circular sector shape are shown below. Anchor |30| is |
| 659 |
an example of a border anchor. |
| 660 |
% |
| 661 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 662 |
\Huge |
| 663 |
\begin{tikzpicture} |
| 664 |
\node[name=s,shape=circular sector, style=shape example, inner sep=1cm] |
| 665 |
{Circular Sector\vrule width 1pt height 2cm}; |
| 666 |
\foreach \anchor/\placement in |
| 667 |
{sector center/above, arc start/below, arc end/below, arc center/below, |
| 668 |
center/above, base/below, mid/right, text/below, |
| 669 |
north/below, south/above, east/below, west/above, |
| 670 |
north west/above left, north east/above right, |
| 671 |
south west/below, south east/below, 30/right} |
| 672 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 673 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 674 |
\end{tikzpicture} |
| 675 |
\end{codeexample} |
| 676 |
% |
| 677 |
\end{shape} |
| 678 |
|
| 679 |
\begin{shape}{cylinder} |
| 680 |
This shape is a 2-dimensional representation of a cylinder, which supports |
| 681 |
the rotation of the shape border as described in |
| 682 |
Section~\ref{section-rotating-shape-borders}. |
| 683 |
% |
| 684 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 685 |
\begin{tikzpicture} |
| 686 |
\node[cylinder, draw, shape aspect=.5] {ABC}; |
| 687 |
\end{tikzpicture} |
| 688 |
\end{codeexample} |
| 689 |
|
| 690 |
Regardless the rotation of the shape border, the height is always the |
| 691 |
distance between the curved ends, and the width is always the distance |
| 692 |
between the straight sides. |
| 693 |
% |
| 694 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 695 |
\begin{tikzpicture}[>=stealth] |
| 696 |
\node [cylinder, gray!50, rotate=30, draw, |
| 697 |
minimum height=2cm, minimum width=1cm] (c) {Cylinder}; |
| 698 |
\draw[red, <->] (c.top) -- (c.bottom) |
| 699 |
node [at end, below, black] {height}; |
| 700 |
\draw[red, <->] (c.north) -- (c.south) |
| 701 |
node [at start, above, black] {width}; |
| 702 |
\end{tikzpicture} |
| 703 |
\end{codeexample} |
| 704 |
|
| 705 |
Enlarging the shape to some minimum height will stretch only the body of |
| 706 |
the cylinder. By contrast, enlarging the shape to some minimum width will |
| 707 |
stretch the curved ends. |
| 708 |
% |
| 709 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 710 |
\begin{tikzpicture}[shape aspect=.5] |
| 711 |
\tikzset{every node/.style={cylinder, shape border rotate=90, draw}} |
| 712 |
\node [minimum height=1.5cm] {A}; |
| 713 |
\node [minimum width=1.5cm] at (1.5,0) {B}; |
| 714 |
\end{tikzpicture} |
| 715 |
\end{codeexample} |
| 716 |
|
| 717 |
There are various keys to customize this shape (to use \pgfname{} keys in |
| 718 |
\tikzname{}, simply remove the \declare{|/pgf/|} path). |
| 719 |
|
| 720 |
\begin{key}{/pgf/aspect=\meta{value} (initially 1.0)} |
| 721 |
The aspect is a recommendation for the quotient of the radii of the |
| 722 |
cylinder end. This may be ignored if the shape is enlarged to some |
| 723 |
minimum width. |
| 724 |
% |
| 725 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 726 |
\begin{tikzpicture}[] |
| 727 |
\tikzset{every node/.style={cylinder, shape border rotate=90, draw}} |
| 728 |
\node [aspect=1.0] {A}; |
| 729 |
\node [aspect=0.5] at (1,0) {B}; |
| 730 |
\node [aspect=0.25] at (2,0) {C}; |
| 731 |
\end{tikzpicture} |
| 732 |
\end{codeexample} |
| 733 |
\end{key} |
| 734 |
|
| 735 |
\begin{key}{/pgf/cylinder uses custom fill=\meta{boolean} (default true)} |
| 736 |
This enables the use of a custom fill for the body and the end of the |
| 737 |
cylinder. The background path for the shape should not be filled (e.g., |
| 738 |
in \tikzname{}, the |fill| option for the node must be implicitly or |
| 739 |
explicitly set to |none|). Internally, this key sets the \TeX-if |
| 740 |
|\ifpgfcylinderusescustomfill| appropriately. |
| 741 |
\end{key} |
| 742 |
% |
| 743 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 744 |
\begin{tikzpicture}[aspect=0.5] |
| 745 |
\node [cylinder, cylinder uses custom fill, cylinder end fill=red!50, |
| 746 |
cylinder body fill=red!25] {Cylinder}; |
| 747 |
\end{tikzpicture} |
| 748 |
\end{codeexample} |
| 749 |
|
| 750 |
\begin{key}{/pgf/cylinder end fill=\meta{color} (initially white)} |
| 751 |
Sets the color for the end of the cylinder. |
| 752 |
\end{key} |
| 753 |
|
| 754 |
\begin{key}{/pgf/cylinder body fill=\meta{color} (initially white)} |
| 755 |
Sets the color for the body of the cylinder. |
| 756 |
\end{key} |
| 757 |
|
| 758 |
The anchors of this shape are shown below (anchor |160| is an example of a |
| 759 |
border anchor). Note that the cylinder shape does not distinguish between |
| 760 |
|outer xsep| and |outer ysep|. Only the larger of the two values is used |
| 761 |
for the shape. Note also the difference between the |center| and |
| 762 |
|shape center| anchors: |center| is the center of the cylinder body and |
| 763 |
also the center of rotation. The |shape center| is the center of the shape |
| 764 |
which includes the 2-dimensional representation of the cylinder top. |
| 765 |
% |
| 766 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] |
| 767 |
\Huge |
| 768 |
\begin{tikzpicture} |
| 769 |
\node[name=s, shape=cylinder, shape example, aspect=.5, inner xsep=3cm, |
| 770 |
inner ysep=1cm] {Cylinder\vrule width 1pt height 2cm}; |
| 771 |
\foreach \anchor/\placement in |
| 772 |
{before top/above, top/above, after top/below, |
| 773 |
before bottom/below, bottom/above, after bottom/above, |
| 774 |
mid/right, mid west/right, mid east/left, |
| 775 |
base/below, base west/below, base east/below, |
| 776 |
center/above, text/above, shape center/right, |
| 777 |
west/right, east/left, north/above, south/below, |
| 778 |
north west/below, north east/above, |
| 779 |
south west/above, south east/below, 160/above} |
| 780 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 781 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 782 |
\end{tikzpicture} |
| 783 |
\end{codeexample} |
| 784 |
% |
| 785 |
\end{shape} |
| 786 |
|
| 787 |
|
| 788 |
\subsection{Symbol Shapes} |
| 789 |
|
| 790 |
\begin{pgflibrary}{shapes.symbols} |
| 791 |
This library defines shapes that can be used for drawing symbols like a |
| 792 |
forbidden sign or a cloud. |
| 793 |
\end{pgflibrary} |
| 794 |
|
| 795 |
\begin{shape}{correct forbidden sign} |
| 796 |
This shape places the node inside a circle with a diagonal from the upper |
| 797 |
left to the lower right added. The circle is part of the background, the |
| 798 |
diagonal line part of the foreground path; thus, the diagonal line is on |
| 799 |
top of the text. |
| 800 |
% |
| 801 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 802 |
\begin{tikzpicture} |
| 803 |
\node [correct forbidden sign,line width=1ex,draw=red,fill=white] {Smoking}; |
| 804 |
\end{tikzpicture} |
| 805 |
\end{codeexample} |
| 806 |
|
| 807 |
The shape inherits all anchors from the |circle| shape. |
| 808 |
\end{shape} |
| 809 |
|
| 810 |
\begin{shape}{forbidden sign} |
| 811 |
This shape is like |correct forbidden sign|, only the line goes from the |
| 812 |
lower left to the upper right. The strange naming of these shapes is for |
| 813 |
historical reasons. |
| 814 |
% |
| 815 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 816 |
\begin{tikzpicture} |
| 817 |
\node [forbidden sign,line width=1ex,draw=red,fill=white] {Smoking}; |
| 818 |
\end{tikzpicture} |
| 819 |
\end{codeexample} |
| 820 |
|
| 821 |
The shape inherits all anchors from the |circle| shape. |
| 822 |
\end{shape} |
| 823 |
|
| 824 |
\begin{shape}{magnifying glass} |
| 825 |
This shape places the node inside a circle with a handle attached to the |
| 826 |
node. The angle of the handle and its length can be adjusted using two |
| 827 |
keys: |
| 828 |
|
| 829 |
\begin{key}{/pgf/magnifying glass handle angle fill=\meta{degree} (default -45)} |
| 830 |
The angle of the handle. |
| 831 |
\end{key} |
| 832 |
|
| 833 |
\begin{key}{/pgf/magnifying glass handle angle aspect=\meta{factor} (default 1.5)} |
| 834 |
The length of the handle as a multiple of the circle radius. |
| 835 |
\end{key} |
| 836 |
% |
| 837 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 838 |
\begin{tikzpicture} |
| 839 |
\node [magnifying glass,line width=1ex,draw] {huge}; |
| 840 |
\end{tikzpicture} |
| 841 |
\end{codeexample} |
| 842 |
% |
| 843 |
The shape inherits all anchors from the |circle| shape. |
| 844 |
\end{shape} |
| 845 |
|
| 846 |
\begin{shape}{cloud} |
| 847 |
This shape is a cloud, drawn to tightly fit the node contents (strictly |
| 848 |
speaking, using an ellipse which tightly fits the node contents -- |
| 849 |
including any |inner sep|). |
| 850 |
% |
| 851 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 852 |
\begin{tikzpicture} |
| 853 |
\node[cloud, draw, fill=gray!20, aspect=2] {ABC}; |
| 854 |
\node[cloud, draw, fill=gray!20] at (1.5,0) {D}; |
| 855 |
\end{tikzpicture} |
| 856 |
\end{codeexample} |
| 857 |
|
| 858 |
A cloud should be thought of as having a number of ``puffs'', which are the |
| 859 |
individual arcs drawn around the border. There are \pgfname{} keys to |
| 860 |
specify how the cloud is drawn (to use these keys in \tikzname{}, simply |
| 861 |
remove the \declare{|/pgf/|} path). |
| 862 |
|
| 863 |
\begin{key}{/pgf/cloud puffs=\meta{integer} (initially 10)} |
| 864 |
Sets the number of puffs for the cloud. |
| 865 |
\end{key} |
| 866 |
|
| 867 |
\begin{key}{/pgf/cloud puff arc=\meta{angle} (initially 135)} |
| 868 |
Sets the length of the puff arc (in degrees). A shorter arc can produce |
| 869 |
better looking joins between puffs for larger line widths. |
| 870 |
\end{key} |
| 871 |
|
| 872 |
Like the diamond shape, the cloud shape also uses the \declare{|aspect|} |
| 873 |
key to determine the ratio of the width and the height of the cloud. |
| 874 |
However, there may be circumstances where it may be undesirable to |
| 875 |
continually specify the |aspect| for the cloud. Therefore, the following |
| 876 |
key is implemented: |
| 877 |
|
| 878 |
\begin{key}{/pgf/cloud ignores aspect=\meta{boolean} (default true)} |
| 879 |
Instruct \pgfname{} to ignore the |aspect| key. Internally, the \TeX-if |
| 880 |
|\ifpgfcloudignoresaspect| is set appropriately. The initial value is |
| 881 |
|false|. |
| 882 |
% |
| 883 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 884 |
\begin{tikzpicture}[aspect=1, every node/.style={cloud, cloud puffs=11, draw}] |
| 885 |
\node [fill=gray!20] {rain}; |
| 886 |
\node [cloud ignores aspect, fill=white] at (1.5,0) {snow}; |
| 887 |
\end{tikzpicture} |
| 888 |
\end{codeexample} |
| 889 |
\end{key} |
| 890 |
|
| 891 |
Any minimum size requirements are applied to the ``circum-ellipse'', which |
| 892 |
is the ellipse which passes through all the midpoints of the puff arcs. |
| 893 |
These requirements are considered \emph{after} any aspect specification is |
| 894 |
applied. |
| 895 |
% |
| 896 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 897 |
\begin{tikzpicture} |
| 898 |
\draw [help lines] grid (3,2); |
| 899 |
\draw [blue, dashed] (1.5, 1) ellipse (1.5cm and 1cm); |
| 900 |
\node [cloud, cloud puffs=9, draw, minimum width=3cm, minimum height=2cm] |
| 901 |
at (1.5, 1) {}; |
| 902 |
\end{tikzpicture} |
| 903 |
\end{codeexample} |
| 904 |
|
| 905 |
The anchors for the cloud shape are shown below for a cloud with eleven |
| 906 |
puffs. Anchor 70 is an example of a border anchor. |
| 907 |
% |
| 908 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 909 |
\Huge |
| 910 |
\begin{tikzpicture} |
| 911 |
\node[name=s, shape=cloud, style=shape example, cloud puffs=11, aspect=1.5, |
| 912 |
cloud puff arc=120,inner ysep=1cm] {Cloud\vrule width 1pt height 2cm}; |
| 913 |
\foreach \anchor/\placement in |
| 914 |
{puff 1/above, puff 2/above, puff 3/above, puff 4/below, |
| 915 |
puff 5/left, puff 6/below, puff 7/below, puff 8/right, |
| 916 |
puff 9/below, puff 10/above, puff 11/above, 70/right, |
| 917 |
center/above, base/below, mid/right, text/left, |
| 918 |
north/below, south/below, east/above, west/above, |
| 919 |
north west/left, north east/right, |
| 920 |
south west/below, south east/below} |
| 921 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 922 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 923 |
\end{tikzpicture} |
| 924 |
\end{codeexample} |
| 925 |
% |
| 926 |
\end{shape} |
| 927 |
|
| 928 |
\begin{shape}{starburst} |
| 929 |
This shape is a randomly generated elliptical star, which supports the |
| 930 |
rotation of the shape border as described in |
| 931 |
Section~\ref{section-rotating-shape-borders}. |
| 932 |
% |
| 933 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 934 |
\begin{tikzpicture} |
| 935 |
\node[starburst, fill=yellow, draw=red, line width=2pt] {\bf BANG!}; |
| 936 |
\end{tikzpicture} |
| 937 |
\end{codeexample} |
| 938 |
% |
| 939 |
Like the |star| shape, the starburst should be thought of as having a set |
| 940 |
of inner points and outer points. The inner points lie on the ellipse which |
| 941 |
tightly fits the node contents (including any |inner sep|). |
| 942 |
|
| 943 |
Using a specified `starburst point height' value, the outer points are |
| 944 |
generated randomly between this value and one quarter of this value. For a |
| 945 |
given starburst shape, the angle between each point is fixed, and is |
| 946 |
determined by the number of points specified for the starburst. |
| 947 |
|
| 948 |
It is important to note that, whilst the maximum possible point height is |
| 949 |
used to calculate minimum width or height requirements, the outer points |
| 950 |
are randomly generated, so there is (unfortunately) no guarantee that any |
| 951 |
such requirements will be fully met. |
| 952 |
% |
| 953 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 954 |
\begin{tikzpicture} |
| 955 |
\draw[help lines] grid(3,2); |
| 956 |
\node[starburst, draw, minimum width=3cm, minimum height=2cm] |
| 957 |
at (1.5, 1) {\bf BOOM!}; |
| 958 |
\end{tikzpicture} |
| 959 |
\end{codeexample} |
| 960 |
|
| 961 |
There are \pgfname{} keys to control the drawing of the starburst shape. To |
| 962 |
use these keys in \tikzname, simply remove the \declare{|/pgf/|} path. |
| 963 |
|
| 964 |
\begin{key}{/pgf/starburst points=\meta{integer} (initially 17)} |
| 965 |
Sets the number of outer points for the starburst. |
| 966 |
\end{key} |
| 967 |
% |
| 968 |
\begin{key}{/pgf/starburst point height=\meta{length} (initially .5cm)} |
| 969 |
Sets the \emph{maximum} distance between the inner point radius and the |
| 970 |
outer point radius. |
| 971 |
\end{key} |
| 972 |
|
| 973 |
\begin{key}{/pgf/random starburst=\meta{integer} (initially 100)} |
| 974 |
Sets the seed for the random number generator for creating the |
| 975 |
starburst. The maximum value for \meta{integer} is |16383|. If |
| 976 |
\meta{integer}|=0|, the random number generator will not be used, and |
| 977 |
the maximum point height will be used for all outer points. If |
| 978 |
\meta{integer} is omitted, a seed will be randomly chosen. |
| 979 |
\end{key} |
| 980 |
|
| 981 |
The basic anchors for a nine point |starburst| shape are shown below. |
| 982 |
Anchor |80| is an example of a border anchor. |
| 983 |
% |
| 984 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 985 |
\Huge |
| 986 |
\begin{tikzpicture} |
| 987 |
\node[name=s, shape=starburst, starburst points=9, starburst point height=3.5cm, |
| 988 |
style=shape example,inner sep=1cm] |
| 989 |
{Starburst\vrule width 1pt height 2cm}; |
| 990 |
\foreach \anchor/\placement in |
| 991 |
{outer point 1/above, outer point 2/above, outer point 3/right, |
| 992 |
outer point 4/above, outer point 5/below, outer point 6/above, |
| 993 |
outer point 7/left, outer point 8/above, outer point 9/above, |
| 994 |
inner point 1/below, inner point 2/above, inner point 3/left, |
| 995 |
inner point 4/above, inner point 5/above, inner point 6/above, |
| 996 |
inner point 7/below, inner point 8/above, inner point 9/below, |
| 997 |
center/above, text/left, mid/right, base/below, 80/above, |
| 998 |
north/below, south/below, east/left, west/right, |
| 999 |
north east/below, south west/below, south east/below, north west/below} |
| 1000 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1001 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1002 |
\end{tikzpicture} |
| 1003 |
\end{codeexample} |
| 1004 |
% |
| 1005 |
\end{shape} |
| 1006 |
|
| 1007 |
\begin{shape}{signal} |
| 1008 |
This shape is a ``signal'' or sign shape, that is, a rectangle, with |
| 1009 |
optionally pointed sides. A signal can point ``to'' somewhere, with outward |
| 1010 |
points in that direction. It can also be ``from'' somewhere, with inward |
| 1011 |
points from that direction. The resulting points extend the node contents |
| 1012 |
(which include the |inner sep|). |
| 1013 |
% |
| 1014 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1015 |
\begin{tikzpicture} |
| 1016 |
[every node/.style={signal, draw, text=white, signal to=nowhere}] |
| 1017 |
\node[fill=green!65!black, signal to=east] at (0,1) {To East}; |
| 1018 |
\node[fill=red!65!black, signal from=east] at (0,0) {From East}; |
| 1019 |
\end{tikzpicture} |
| 1020 |
\end{codeexample} |
| 1021 |
|
| 1022 |
There are \pgfname{} keys for drawing the signal shape (to use these keys |
| 1023 |
in \tikzname{}, simply remove the \declare{|/pgf/|} path): |
| 1024 |
|
| 1025 |
\begin{key}{/pgf/signal pointer angle=\meta{angle} (initially 90)} |
| 1026 |
Sets the angle for the pointed sides of the shape. This angle is |
| 1027 |
maintained when enforcing any minimum size requirements, so |
| 1028 |
any adjustment to the width will affect the height, and vice versa. |
| 1029 |
\end{key} |
| 1030 |
|
| 1031 |
\begin{key}{/pgf/signal from=\meta{direction}\space\opt{and \meta{opposite direction}} (initially nowhere)} |
| 1032 |
Sets which sides take an inward pointer (i.e., that points towards the |
| 1033 |
center of the shape). The possible values for \meta{direction} and |
| 1034 |
\meta{opposite direction} are the compass point directions |north|, |
| 1035 |
|south|, |east| and |west| (or |above|, |below|, |right| and |left|). |
| 1036 |
An additional keyword |nowhere| can be used to reset the sides so they |
| 1037 |
have no pointers. When used with |signal from| key, this only resets |
| 1038 |
inward pointers; used with the |signal to| key, it only resets outward |
| 1039 |
pointers. |
| 1040 |
\end{key} |
| 1041 |
|
| 1042 |
\begin{key}{/pgf/signal to=\meta{direction}\space\opt{and \meta{opposite direction}} (initially east)} |
| 1043 |
Sets which sides take an outward pointer (i.e., that points away from |
| 1044 |
the shape). |
| 1045 |
\end{key} |
| 1046 |
|
| 1047 |
Note that \pgfname{} will ignore any instruction to use directions that are |
| 1048 |
not opposites (so using the value |east and north|, will result in only |
| 1049 |
|north| being assigned a pointer). This is also the case if non-opposite |
| 1050 |
values are used in the |signal to| and |signal from| keys at the same time. |
| 1051 |
So, for example, it is not possible for a signal to have an outward point |
| 1052 |
to the left, and also have an inward point from below. |
| 1053 |
|
| 1054 |
The anchors for the signal shape are shown below. Anchor |70| is an example |
| 1055 |
of a border anchor. |
| 1056 |
% |
| 1057 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1058 |
\Huge |
| 1059 |
\begin{tikzpicture} |
| 1060 |
\node[name=s, shape=signal, signal from=west, shape example, inner sep=2cm] |
| 1061 |
{Signal\vrule width1pt height2cm}; |
| 1062 |
\foreach \anchor/\placement in |
| 1063 |
{text/left, center/above, 70/above, |
| 1064 |
base/below, base east/below, base west/below, |
| 1065 |
mid/right, mid east/above left, mid west/above left, |
| 1066 |
north/above, south/below, |
| 1067 |
east/above, west/above, |
| 1068 |
north west/above, north east/above, |
| 1069 |
south west/below, south east/below} |
| 1070 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1071 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1072 |
\end{tikzpicture} |
| 1073 |
\end{codeexample} |
| 1074 |
% |
| 1075 |
\end{shape} |
| 1076 |
|
| 1077 |
\begin{shape}{tape} |
| 1078 |
This shape is a rectangle with optional, ``bendy'' top and bottom sides, |
| 1079 |
which tightly fits the node contents (including the |inner sep|). |
| 1080 |
% |
| 1081 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1082 |
\begin{tikzpicture} |
| 1083 |
\node[tape, draw]{ABCD}; |
| 1084 |
\node[tape, draw, tape bend top=none] at (1.5, 0) {EFGH}; |
| 1085 |
\end{tikzpicture} |
| 1086 |
\end{codeexample} |
| 1087 |
|
| 1088 |
There are \pgfname{} keys to specify which sides bend and how high the |
| 1089 |
bends are (to use these keys in \tikzname{}, simply remove the |
| 1090 |
\declare{|/pgf/|} path): |
| 1091 |
|
| 1092 |
\begin{key}{/pgf/tape bend top=\meta{bend style} (initially in and out)} |
| 1093 |
Specifies how the top side bends. The \meta{bend style} is either |
| 1094 |
|in and out|, |out and in| or |none| (i.e., a straight line). The |
| 1095 |
bending sides are drawn in a clockwise direction, and using the bend |
| 1096 |
style |in and out| will mean the side will first bend inwards and then |
| 1097 |
bend outwards. The opposite holds true for |out and in|. |
| 1098 |
% |
| 1099 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1100 |
\begin{tikzpicture}[-stealth] |
| 1101 |
\node[tape, draw, gray, minimum width=2cm](t){Tape}; |
| 1102 |
\draw [blue]([yshift=5pt] t.north west) -- ([yshift=5pt]t.north east) |
| 1103 |
node[midway, above, black]{in and out}; |
| 1104 |
\draw [blue]([yshift=-5pt]t.south east) -- ([yshift=-5pt]t.south west) |
| 1105 |
node[sloped, allow upside down, midway, above, black]{in and out}; |
| 1106 |
\end{tikzpicture} |
| 1107 |
\end{codeexample} |
| 1108 |
|
| 1109 |
This might take a bit of getting used to, but just remember that when |
| 1110 |
you want the bendy sides to be parallel, the sides take the same bend |
| 1111 |
style. It is possible for the top and bottom sides to take opposite |
| 1112 |
bend styles, but the author of this shape cannot think of a single use |
| 1113 |
for such a combination. |
| 1114 |
% |
| 1115 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1116 |
\begin{tikzpicture}[every node/.style={tape, draw}] |
| 1117 |
\node [tape bend top=out and in, tape bend bottom=out and in] {Parallel}; |
| 1118 |
\node at (2,0) [tape bend bottom=out and in] {Why?}; |
| 1119 |
\end{tikzpicture} |
| 1120 |
\end{codeexample} |
| 1121 |
\end{key} |
| 1122 |
|
| 1123 |
\begin{key}{/pgf/tape bend bottom=\meta{bend style} (initially in and out)} |
| 1124 |
Specifies how the bottom side bends. |
| 1125 |
\end{key}% |
| 1126 |
|
| 1127 |
\begin{key}{/pgf/tape bend height=\meta{length} (initially 5pt)} |
| 1128 |
Sets the total height for a side with a bend. |
| 1129 |
% |
| 1130 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1131 |
\begin{tikzpicture}[>=stealth] |
| 1132 |
\draw [help lines] grid(3,2); |
| 1133 |
\node [tape, fill, minimum size=2cm, red!50, tape bend top=none, |
| 1134 |
tape bend height=1cm] at (1.5,1.5) (t) {}; |
| 1135 |
\draw [|<->|, blue] (1.5,0) -- (1.5,1) |
| 1136 |
node [at end, above, black]{tape bend height}; |
| 1137 |
\end{tikzpicture} |
| 1138 |
\end{codeexample} |
| 1139 |
\end{key} |
| 1140 |
|
| 1141 |
The anchors for the tape shape are shown below. Anchor |60| is an example |
| 1142 |
of a border anchor. Note that border anchors will snap to the center of |
| 1143 |
convex curves (i.e.\ when bending in). |
| 1144 |
% |
| 1145 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1146 |
\Huge |
| 1147 |
\begin{tikzpicture} |
| 1148 |
\node[name=s, shape=tape, tape bend height=1cm, shape example, inner xsep=3cm] |
| 1149 |
{Tape\vrule width1pt height2cm}; |
| 1150 |
\foreach \anchor/\placement in |
| 1151 |
{text/left, center/above, 60/above, |
| 1152 |
base/below, base east/below, base west/below, |
| 1153 |
mid/right, mid east/left, mid west/right, |
| 1154 |
north/above, south/below, east/above, west/above, |
| 1155 |
north west/above, north east/above, |
| 1156 |
south west/below, south east/below} |
| 1157 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1158 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1159 |
\end{tikzpicture} |
| 1160 |
\end{codeexample} |
| 1161 |
% |
| 1162 |
\end{shape} |
| 1163 |
|
| 1164 |
\begin{shape}{magnetic tape} |
| 1165 |
This shape represents a `magnetic tape' or any sequential data store that |
| 1166 |
is sometimes used in flowcharts. It is essentially a circle with a little |
| 1167 |
tail: |
| 1168 |
% |
| 1169 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1170 |
\tikz\node [magnetic tape, draw] (A) {A}; |
| 1171 |
\end{codeexample} |
| 1172 |
|
| 1173 |
The following keys can be used to customise the |magnetic tape| shape: |
| 1174 |
|
| 1175 |
\begin{key}{/pgf/magnetic tape tail extend=\meta{distance} (initially 0cm)} |
| 1176 |
This key sets how far the tail extends beyond the radius of the tape. |
| 1177 |
Negative values will be ignored. |
| 1178 |
% |
| 1179 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1180 |
\begin{tikzpicture}[every node/.style={magnetic tape, draw}] |
| 1181 |
\node [magnetic tape tail extend=0cm] at (0,0) {A}; |
| 1182 |
\node [magnetic tape tail extend=0.25cm] at (0,1) {B}; |
| 1183 |
\end{tikzpicture} |
| 1184 |
\end{codeexample} |
| 1185 |
\end{key} |
| 1186 |
|
| 1187 |
\begin{key}{/pgf/magnetic tape tail=\meta{proportion} (initially 0.15)} |
| 1188 |
This key sets the thickness of the `tail' to be \meta{proportion} times |
| 1189 |
the radius of the shape. The \meta{proportion} should be between |0.0| |
| 1190 |
and |1.0|. |
| 1191 |
% |
| 1192 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1193 |
\begin{tikzpicture}[every node/.style={magnetic tape, draw}] |
| 1194 |
\node [magnetic tape tail=0.5, magnetic tape tail extend=0.5cm] {A}; |
| 1195 |
\node [magnetic tape tail=0.25] at (0,1) {B}; |
| 1196 |
\end{tikzpicture} |
| 1197 |
\end{codeexample} |
| 1198 |
\end{key} |
| 1199 |
|
| 1200 |
The following figure shows the anchors this shape defines; the anchors 10 |
| 1201 |
and 130 are example of border anchors. |
| 1202 |
% |
| 1203 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] |
| 1204 |
\Huge |
| 1205 |
\begin{tikzpicture} |
| 1206 |
\node[name=s,shape=magnetic tape,shape example,inner sep=0.75cm, |
| 1207 |
magnetic tape tail extend=0.5cm] |
| 1208 |
{Magnetic Tape\vrule width 1pt height 2cm}; |
| 1209 |
\foreach \anchor/\placement in |
| 1210 |
{north west/above left, north/above, north east/above right, |
| 1211 |
west/left, center/above, east/right, |
| 1212 |
mid west/right, mid/right, mid east/left, |
| 1213 |
base west/below, base/below, base east/right, |
| 1214 |
south west/below left, south/below, south east/left, |
| 1215 |
text/left, 10/right, 130/above, |
| 1216 |
tail east/right, tail south east/below, tail north east/above} |
| 1217 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1218 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1219 |
\end{tikzpicture} |
| 1220 |
\end{codeexample} |
| 1221 |
% |
| 1222 |
\end{shape} |
| 1223 |
|
| 1224 |
|
| 1225 |
\subsection{Arrow Shapes} |
| 1226 |
|
| 1227 |
\begin{pgflibrary}{shapes.arrows} |
| 1228 |
This library defines arrow shapes. Note that an arrow shape is something |
| 1229 |
quite different from a (normal) arrow tip: It is a shape that just |
| 1230 |
``happens'' to ``look like'' an arrow. In particular, you cannot use these |
| 1231 |
shapes as arrow tips. |
| 1232 |
\end{pgflibrary} |
| 1233 |
|
| 1234 |
\begin{shape}{single arrow} |
| 1235 |
This shape is an arrow, which tightly fits the node contents (including any |
| 1236 |
|inner sep|). This shape supports the rotation of the shape border, as |
| 1237 |
described in Section~\ref{section-rotating-shape-borders}. The angle of |
| 1238 |
rotation determines in which direction the arrow points (provided no other |
| 1239 |
rotational transformations are applied). |
| 1240 |
% |
| 1241 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1242 |
\begin{tikzpicture}[every node/.style={single arrow, draw}, |
| 1243 |
rotate border/.style={shape border uses incircle, shape border rotate=#1}] |
| 1244 |
\node {right}; |
| 1245 |
\node at (2,0) [shape border rotate=90]{up}; |
| 1246 |
\node at (1,1) [rotate border=37, inner sep=0pt]{$37^\circ$}; |
| 1247 |
\end{tikzpicture} |
| 1248 |
\end{codeexample} |
| 1249 |
|
| 1250 |
Regardless of the rotation of the arrow border, the width is measured |
| 1251 |
between the back ends of the arrow head, and the height is measured from |
| 1252 |
the arrow tip to the end of the arrow tail. |
| 1253 |
% |
| 1254 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1255 |
\begin{tikzpicture}[>=stealth, |
| 1256 |
rotate border/.style={shape border uses incircle, shape border rotate=#1}] |
| 1257 |
\node[rotate border=-30, fill=gray!25, minimum height=3cm, single arrow, |
| 1258 |
single arrow head extend=.5cm, single arrow head indent=.25cm] (arrow) {}; |
| 1259 |
\draw[red, <->] (arrow.before tip) -- (arrow.after tip) |
| 1260 |
node [near end, left, black] {width}; |
| 1261 |
\draw[red, <->] (arrow.tip) -- (arrow.tail) |
| 1262 |
node [near end, below left, black] {height}; |
| 1263 |
\end{tikzpicture} |
| 1264 |
\end{codeexample} |
| 1265 |
|
| 1266 |
There are \pgfname{} keys that can be used to customize this shape (to use |
| 1267 |
these keys in \tikzname{}, simply remove the \declare{|/pgf/|} path). |
| 1268 |
|
| 1269 |
\begin{key}{/pgf/single arrow tip angle=\meta{angle} (initially 90)} |
| 1270 |
Sets the angle for the arrow tip. Enlarging the arrow to some minimum |
| 1271 |
width may increase the height of the shape to maintain this angle. |
| 1272 |
\end{key} |
| 1273 |
|
| 1274 |
\begin{key}{/pgf/single arrow head extend=\meta{length} (initially .5cm)} |
| 1275 |
This sets the distance between the tail of the arrow and the outer end |
| 1276 |
of the arrow head. This may change if the shape is enlarged to some |
| 1277 |
minimum width. |
| 1278 |
% |
| 1279 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1280 |
\begin{tikzpicture} |
| 1281 |
\node[single arrow, draw, single arrow head extend=.5cm, gray!50, rotate=60] |
| 1282 |
(a) {Arrow}; |
| 1283 |
\draw[red, |<->|] (a.before tip) -- (a.before head) |
| 1284 |
node [midway, below, sloped, black] {head extend}; |
| 1285 |
\end{tikzpicture} |
| 1286 |
\end{codeexample} |
| 1287 |
\end{key} |
| 1288 |
|
| 1289 |
\begin{key}{/pgf/single arrow head indent=\meta{length} (initially 0cm)} |
| 1290 |
This moves the point where the arrow head joins the shaft of the arrow |
| 1291 |
\emph{towards} the arrow tip, by \meta{length}. |
| 1292 |
% |
| 1293 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1294 |
\begin{tikzpicture}[every node/.style={single arrow, draw=none, rotate=60}] |
| 1295 |
\node [fill=red!50] {arrow 1}; |
| 1296 |
\node [fill=blue!50, single arrow head indent=1ex] at (1.5,0) {arrow 2}; |
| 1297 |
\end{tikzpicture} |
| 1298 |
\end{codeexample} |
| 1299 |
\end{key} |
| 1300 |
|
| 1301 |
The anchors for this shape are shown below (anchor |20| is an example of a |
| 1302 |
border anchor). |
| 1303 |
% |
| 1304 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1305 |
\Huge |
| 1306 |
\begin{tikzpicture} |
| 1307 |
\node[name=s,shape=single arrow, shape example, single arrow head extend=1.5cm] |
| 1308 |
{Single Arrow\vrule width1pt height2cm}; |
| 1309 |
\foreach \anchor/\placement in |
| 1310 |
{text/above, center/above, 20/above, |
| 1311 |
mid west/left, mid/above, mid east/above left, |
| 1312 |
base west/below, base/below, base east/below, |
| 1313 |
tip/above, before tip/above, after tip/below, before head/above, |
| 1314 |
after head/below, after tail/above, before tail/below, tail/right, |
| 1315 |
north/above, south/below, east/below, west/above, |
| 1316 |
north west/above, north east/below, south west/below, south east/above} |
| 1317 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1318 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1319 |
\end{tikzpicture} |
| 1320 |
\end{codeexample} |
| 1321 |
% |
| 1322 |
\end{shape} |
| 1323 |
|
| 1324 |
\begin{shape}{double arrow} |
| 1325 |
This shape is a double arrow, which tightly fits the node contents |
| 1326 |
(including any |inner sep|), and supports the rotation of the shape border, |
| 1327 |
as described in Section~\ref{section-rotating-shape-borders}. |
| 1328 |
% |
| 1329 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1330 |
\begin{tikzpicture}[every node/.style={double arrow, draw}] |
| 1331 |
\node [double arrow, draw] {Left or Right}; |
| 1332 |
\end{tikzpicture} |
| 1333 |
\end{codeexample} |
| 1334 |
|
| 1335 |
The double arrow behaves exactly like the single arrow, so you need to |
| 1336 |
remember that the width is \emph{always} the distance between the back ends |
| 1337 |
of the arrow heads, and the height is \emph{always} the tip-to-tip |
| 1338 |
distance. |
| 1339 |
% |
| 1340 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1341 |
\begin{tikzpicture}[>=stealth, |
| 1342 |
rotate border/.style={shape border uses incircle, shape border rotate=#1}] |
| 1343 |
\node[rotate border=210, fill=gray!25, minimum height=3cm, double arrow, |
| 1344 |
double arrow head extend=.5cm, double arrow head indent=.25cm] (arrow) {}; |
| 1345 |
\draw[red, <->] (arrow.before tip 1) -- (arrow.after tip 1) |
| 1346 |
node [near start, right, black] {width}; |
| 1347 |
\draw[red, <->] (arrow.tip 1) -- (arrow.tip 2) |
| 1348 |
node [near end, above left, black] {height}; |
| 1349 |
\end{tikzpicture} |
| 1350 |
\end{codeexample} |
| 1351 |
|
| 1352 |
The \pgfname{} keys that can be used to customize the double arrow behave |
| 1353 |
similarly to the keys for the single arrow (to use these keys in |
| 1354 |
\tikzname{}, simply remove the \declare{|/pgf/|} path). |
| 1355 |
|
| 1356 |
\begin{key}{/pgf/double arrow tip angle=\meta{angle} (initially 90)} |
| 1357 |
Sets the angle for the arrow tip. Enlarging the arrow to some minimum |
| 1358 |
width may increase the height of the shape to maintain this angle. |
| 1359 |
\end{key} |
| 1360 |
|
| 1361 |
\begin{key}{/pgf/double arrow head extend=\meta{length} (initially .5cm)} |
| 1362 |
This sets the distance between the shaft of the arrow and the outer end |
| 1363 |
of the arrow heads. This may change if the shape is enlarged to some |
| 1364 |
minimum width. |
| 1365 |
\end{key} |
| 1366 |
|
| 1367 |
\begin{key}{/pgf/double arrow head indent=\meta{length} (initially 0cm)} |
| 1368 |
This moves the point where the arrow heads join the shaft of the arrow |
| 1369 |
\emph{towards} the arrow tips, by \meta{length}. |
| 1370 |
% |
| 1371 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1372 |
\begin{tikzpicture}[every node/.style={double arrow, draw=none, rotate=-60}] |
| 1373 |
\node [fill=red!50] {arrow 1}; |
| 1374 |
\node [fill=blue!50, double arrow head indent=1ex] at (1.5,0) {arrow 2}; |
| 1375 |
\end{tikzpicture} |
| 1376 |
\end{codeexample} |
| 1377 |
\end{key} |
| 1378 |
|
| 1379 |
The anchors for this shape are shown below (anchor |20| is an example of a |
| 1380 |
border anchor). |
| 1381 |
% |
| 1382 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1383 |
\Huge |
| 1384 |
\begin{tikzpicture} |
| 1385 |
\node[name=s,shape=double arrow, double arrow head extend=1.5cm, shape example, inner xsep=2cm] |
| 1386 |
{Double Arrow\vrule width1pt height2cm}; |
| 1387 |
\foreach \anchor/\placement in |
| 1388 |
{text/above, center/above, 20/above, |
| 1389 |
mid west/above right, mid/above, mid east/above left, |
| 1390 |
base west/below, base/below, base east/below, |
| 1391 |
before head 1/above, before tip 1/above, tip 1/above, after tip 1/below, after head 1/below, |
| 1392 |
before head 2/above, before tip 2/below, tip 2/above, after tip 2/above, after head 2/below, |
| 1393 |
north/above, south/below, east/below, west/below, |
| 1394 |
north west/below, north east/below, south west/above, south east/above} |
| 1395 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1396 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1397 |
\end{tikzpicture} |
| 1398 |
\end{codeexample} |
| 1399 |
% |
| 1400 |
\end{shape} |
| 1401 |
|
| 1402 |
\begin{shape}{arrow box} |
| 1403 |
This shape is a rectangle with optional arrows which extend from the four |
| 1404 |
sides. |
| 1405 |
% |
| 1406 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1407 |
\begin{tikzpicture} |
| 1408 |
\node[arrow box, draw] {A}; |
| 1409 |
\node[arrow box, draw, arrow box arrows={north:.5cm, west:0.75cm}] |
| 1410 |
at (2,0) {B}; |
| 1411 |
\end{tikzpicture} |
| 1412 |
\end{codeexample} |
| 1413 |
|
| 1414 |
Any minimum size requirements are applied to the main rectangle |
| 1415 |
\emph{only}. This does not pose too many problems if you wish to |
| 1416 |
accommodate the length of the arrows, as it is possible to specify the |
| 1417 |
length of each arrow independently, from either the border of the rectangle |
| 1418 |
(the default) or the center of the rectangle. |
| 1419 |
% |
| 1420 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1421 |
\begin{tikzpicture} |
| 1422 |
\tikzset{box/.style={arrow box, fill=#1}} |
| 1423 |
\draw [help lines] grid(3,2); |
| 1424 |
\node[box=blue!50, arrow box arrows={east:2cm}] at (1,1.5){One}; |
| 1425 |
\node[box=red!50, arrow box arrows={east:2cm from center}] at (1,0.5){Two}; |
| 1426 |
\end{tikzpicture} |
| 1427 |
\end{codeexample} |
| 1428 |
|
| 1429 |
There are various \pgfname{} keys for drawing this shape (to use these keys |
| 1430 |
in \tikzname, simply remove the \declare{/pgf/} path). |
| 1431 |
|
| 1432 |
\begin{key}{/pgf/arrow box tip angle=\meta{angle} (initially 90)} |
| 1433 |
Sets the angle at the arrow tip for all four arrows. |
| 1434 |
\end{key} |
| 1435 |
|
| 1436 |
\begin{key}{/pgf/arrow box head extend=\meta{length} (initially .125cm)} |
| 1437 |
Sets the distance the arrow head extends away from the shaft of the arrow. |
| 1438 |
This applies to all arrows. |
| 1439 |
\end{key} |
| 1440 |
|
| 1441 |
\begin{key}{/pgf/arrow box head indent=\meta{length} (initially 0cm)} |
| 1442 |
Moves the point where the arrow head joins the shaft of the arrow |
| 1443 |
\emph{towards} the arrow tip. This applies to all arrows. |
| 1444 |
\end{key} |
| 1445 |
|
| 1446 |
\begin{key}{/pgf/arrow box shaft width=\meta{length} (initially .125cm)} |
| 1447 |
Sets the width of the shaft of all arrows. |
| 1448 |
\end{key} |
| 1449 |
|
| 1450 |
\begin{key}{/pgf/arrow box north arrow=\meta{distance} (initially .5cm)} |
| 1451 |
Sets the distance the north arrow extends from the node. By default this is |
| 1452 |
from the border of the shape, but by using the additional keyword |
| 1453 |
|from center|, the distance will be measured from the center of the shape. |
| 1454 |
If \meta{distance} is |0pt| or a negative distance, the arrow will not be |
| 1455 |
drawn. |
| 1456 |
\end{key} |
| 1457 |
|
| 1458 |
\begin{key}{/pgf/arrow box south arrow=\meta{distance} (initially .5cm)} |
| 1459 |
Sets the distance the south arrow extends from the node. |
| 1460 |
\end{key} |
| 1461 |
|
| 1462 |
\begin{key}{/pgf/arrow box east arrow=\meta{distance} (initially .5cm)} |
| 1463 |
Sets the distance the east arrow extends from the node. |
| 1464 |
\end{key} |
| 1465 |
|
| 1466 |
\begin{key}{/pgf/arrow box west arrow=\meta{distance} (initially .5cm)} |
| 1467 |
Sets the distance the west arrow extends from the node. |
| 1468 |
\end{key} |
| 1469 |
|
| 1470 |
\begin{key}{/pgf/arrow box arrows={\ttfamily\char`\{}\meta{list}{\ttfamily\char`\}}} |
| 1471 |
Sets the distance that all arrows extend from the node. The specification |
| 1472 |
in \meta{list} consists of the four compass points |north|, |south|, |east| |
| 1473 |
or |west|, separated by commas (so the list must be contained within |
| 1474 |
braces). The distances can be specified after each side separated by a |
| 1475 |
colon (e.g., |north:1cm|, or |west:5cm from center|). If an item specifies |
| 1476 |
no distance, the most recently specified distance will be used (at the |
| 1477 |
start of the list this is |0cm|, so the first item in the list should |
| 1478 |
specify a distance). Any sides not specified will not be drawn with an |
| 1479 |
arrow. |
| 1480 |
\end{key} |
| 1481 |
|
| 1482 |
The anchors for this shape are shown below (unfortunately, due to its size, |
| 1483 |
this example must be rotated). Anchor |75| is an example of a border anchor. If |
| 1484 |
a side is drawn without an arrow, the anchors for that arrow should be |
| 1485 |
considered unavailable. They are (unavoidably) defined, but default to the |
| 1486 |
center of the appropriate side. |
| 1487 |
% |
| 1488 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] |
| 1489 |
\Huge |
| 1490 |
\begin{tikzpicture} |
| 1491 |
\node[shape=arrow box, shape example, inner xsep=1cm, inner ysep=1.5cm, arrow box shaft width=2cm, |
| 1492 |
arrow box arrows={north:3.5cm from border, south, east:5cm from border, west}, |
| 1493 |
arrow box head extend=0.75cm, rotate=-90](s) {Arrow Box\vrule width1pt height2cm}; |
| 1494 |
\foreach \anchor/\placement in |
| 1495 |
{center/above, text/above, mid/right, base/below, 75/above, |
| 1496 |
mid east/right, mid west/left, base east/right, base west/left, |
| 1497 |
north/below, south/below, east/below, west/below, |
| 1498 |
north east/above, south east/above, south west/below, north west/below, |
| 1499 |
north arrow tip/above,south arrow tip/above, east arrow tip/above, west arrow tip/above, |
| 1500 |
before north arrow/above, before north arrow head/below left, before north arrow tip/above left, |
| 1501 |
after north arrow tip/above right, after north arrow head/below right, after north arrow/below, |
| 1502 |
before south arrow/below, before south arrow head/above right, before south arrow tip/below right, |
| 1503 |
after south arrow tip/below left, after south arrow head/above left, after south arrow/above, |
| 1504 |
before east arrow/above, before east arrow head/above right, before east arrow tip/above, |
| 1505 |
after east arrow tip/below, after east arrow head/below right, after east arrow/below, |
| 1506 |
before west arrow/below, before west arrow head/below left, before west arrow tip/below, |
| 1507 |
after west arrow tip/above, after west arrow head/above left, after west arrow/below} |
| 1508 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1509 |
node[\placement, rotate=-90] {\scriptsize\texttt{(s.\anchor)}}; |
| 1510 |
\end{tikzpicture} |
| 1511 |
\end{codeexample} |
| 1512 |
% |
| 1513 |
\end{shape} |
| 1514 |
|
| 1515 |
|
| 1516 |
\subsection{Shapes with Multiple Text Parts} |
| 1517 |
|
| 1518 |
\begin{pgflibrary}{shapes.multipart} |
| 1519 |
This library defines general-purpose shapes that are composed of multiple |
| 1520 |
(text) parts. |
| 1521 |
\end{pgflibrary} |
| 1522 |
|
| 1523 |
|
| 1524 |
\begin{shape}{circle split} |
| 1525 |
This shape is a multi-part shape consisting of a circle with a line in the |
| 1526 |
middle. The upper part is the main part (the |text| part), the lower part |
| 1527 |
is the |lower| part. |
| 1528 |
% |
| 1529 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1530 |
\begin{tikzpicture} |
| 1531 |
\node [circle split,draw,double,fill=red!20] |
| 1532 |
{ |
| 1533 |
$q_1$ |
| 1534 |
\nodepart{lower} |
| 1535 |
$00$ |
| 1536 |
}; |
| 1537 |
\end{tikzpicture} |
| 1538 |
\end{codeexample} |
| 1539 |
|
| 1540 |
The shape inherits all anchors from the |circle| shape and defines the |
| 1541 |
|lower| anchor in addition. See also the following figure: |
| 1542 |
% |
| 1543 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1544 |
\Huge |
| 1545 |
\begin{tikzpicture} |
| 1546 |
\node[name=s,shape=circle split,shape example] {text\nodepart{lower}lower}; |
| 1547 |
\foreach \anchor/\placement in |
| 1548 |
{north west/above left, north/above, north east/above right, |
| 1549 |
west/left, center/below, east/right, |
| 1550 |
mid west/right, mid/above, mid east/left, |
| 1551 |
base west/left, base/below, base east/right, |
| 1552 |
south west/below left, south/below, south east/below right, |
| 1553 |
text/left, lower/left, 130/above} |
| 1554 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1555 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1556 |
\end{tikzpicture} |
| 1557 |
\end{codeexample} |
| 1558 |
% |
| 1559 |
\end{shape} |
| 1560 |
|
| 1561 |
\begin{shape}{circle solidus} |
| 1562 |
This shape (due to Manuel Lacruz) is similar to the split circle, but the |
| 1563 |
two text parts are arranged diagonally. |
| 1564 |
% |
| 1565 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1566 |
\begin{tikzpicture} |
| 1567 |
\node [circle solidus,draw,double,fill=red!20] |
| 1568 |
{ |
| 1569 |
$q_1$ |
| 1570 |
\nodepart{lower} |
| 1571 |
$00$ |
| 1572 |
}; |
| 1573 |
\end{tikzpicture} |
| 1574 |
\end{codeexample} |
| 1575 |
|
| 1576 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1577 |
\Huge |
| 1578 |
\begin{tikzpicture} |
| 1579 |
\node[name=s,shape=circle solidus,shape example,inner xsep=1cm] {text\nodepart{lower}lower}; |
| 1580 |
\foreach \anchor/\placement in |
| 1581 |
{north west/above left, north/above, north east/above right, |
| 1582 |
west/left, center/below, east/right, |
| 1583 |
mid west/right, mid/above, mid east/left, |
| 1584 |
base west/left, base/below, base east/right, |
| 1585 |
south west/below left, south/below, south east/below right, |
| 1586 |
text/left, lower/left, 130/above} |
| 1587 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1588 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1589 |
\end{tikzpicture} |
| 1590 |
\end{codeexample} |
| 1591 |
% |
| 1592 |
\end{shape} |
| 1593 |
|
| 1594 |
\begin{shape}{ellipse split} |
| 1595 |
This shape is a multi-part shape consisting of an ellipse with a line in |
| 1596 |
the middle. The upper part is the main part (the |text| part), the lower |
| 1597 |
part is the |lower| part. The anchors for this shape are shown below. |
| 1598 |
Anchor |60| is a border anchor. |
| 1599 |
% |
| 1600 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1601 |
\Huge |
| 1602 |
\begin{tikzpicture} |
| 1603 |
\node[name=s,shape=ellipse split,shape example] {text\nodepart{lower}lower}; |
| 1604 |
\foreach \anchor/\placement in |
| 1605 |
{center/below, text/left, lower/left, 60/above right, |
| 1606 |
mid/above, mid east/above, mid west/above, |
| 1607 |
base/right, base east/left, base west/right, |
| 1608 |
north/above, south/below, east/below, west/below, |
| 1609 |
north east/above, south east/below, south west/below, north west/above} |
| 1610 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1611 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1612 |
\end{tikzpicture} |
| 1613 |
\end{codeexample} |
| 1614 |
% |
| 1615 |
\end{shape} |
| 1616 |
|
| 1617 |
\begin{shape}{diamond split} |
| 1618 |
This shape is a multi-part shape consisting of a diamond with a line |
| 1619 |
in the middle. The upper part is the main part (the |text| part); the |
| 1620 |
lower part is the |lower| part. |
| 1621 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1622 |
\Huge |
| 1623 |
\begin{tikzpicture} |
| 1624 |
\node[name=s,shape=diamond split,shape example,inner xsep=1cm] {text\nodepart{lower}lower}; |
| 1625 |
\foreach \anchor/\placement in |
| 1626 |
{north west/above left, north/above, north east/above right, |
| 1627 |
west/left, center/below, east/right, mid/above, base/below, |
| 1628 |
south west/below left, south/below, south east/below right, |
| 1629 |
text/left, lower/left, 130/above} |
| 1630 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1631 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1632 |
\end{tikzpicture} |
| 1633 |
\end{codeexample} |
| 1634 |
\end{shape} |
| 1635 |
|
| 1636 |
\begin{shape}{rectangle split} |
| 1637 |
This shape is a rectangle, which can be split either horizontally or |
| 1638 |
vertically into several parts. |
| 1639 |
% |
| 1640 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1641 |
\begin{tikzpicture}[my shape/.style={ |
| 1642 |
rectangle split, rectangle split parts=#1, draw, anchor=center}] |
| 1643 |
\node [my shape=5] at (0,1) |
| 1644 |
{a\nodepart{two}b\nodepart{three}c\nodepart{four}d\nodepart{five}e}; |
| 1645 |
\node [my shape=5, rectangle split horizontal] at (2,2) |
| 1646 |
{1\nodepart{two}2\nodepart{three}3\nodepart{four}4\nodepart{five}5}; |
| 1647 |
\node [my shape=3] at (3,0.5) |
| 1648 |
{A\nodepart{two}B\nodepart{three}C}; |
| 1649 |
\node [my shape=4, rectangle split horizontal] at (1.5,0.5) |
| 1650 |
{1\nodepart{two}2\nodepart{three}3\nodepart{four}4}; |
| 1651 |
\end{tikzpicture} |
| 1652 |
\end{codeexample} |
| 1653 |
|
| 1654 |
The shape can be split into a maximum of twenty parts. However, to avoid |
| 1655 |
allocating a lot of unnecessary boxes, \pgfname{} only allocates four boxes |
| 1656 |
by default. To use the |rectangle| |split| shape with more than four boxes, |
| 1657 |
the extra boxes must be allocated manually in advance (perhaps using |
| 1658 |
|\newbox| or |\let|). The boxes take the form |
| 1659 |
|\pgfnodepart|\meta{number}|box|, where \meta{number} is from the cardinal |
| 1660 |
numbers |one|, |two|, |three|, \ldots{} and so on. |\pgfnodepartonebox| is |
| 1661 |
special in that it is synonymous with |\pgfnodeparttextbox|. For |
| 1662 |
compatibility with earlier versions of this shape, the boxes |
| 1663 |
|\pgfnodeparttwobox|, |\pgfnodepartthreebox| and |\pgfnodepartfourbox|, can |
| 1664 |
be referred to using the ordinal numbers: |\pgfnodepartsecondbox|, |
| 1665 |
|\pgfnodepartthirdbox| and |\pgfnodepartfourthbox|. In order to facilitate |
| 1666 |
the allocation of these extra boxes, the following key is provided: |
| 1667 |
|
| 1668 |
\begin{key}{/pgf/rectangle split allocate boxes=\meta{number}} |
| 1669 |
This key checks if \meta{number} boxes have been allocated, and if not, |
| 1670 |
it allocates the required boxes using |\newbox| (some ``magic'' is |
| 1671 |
performed to get around the fact that |\newbox| is declared |\outer| in |
| 1672 |
plain \TeX). |
| 1673 |
\end{key} |
| 1674 |
|
| 1675 |
When split vertically, the rectangle split will meet any |minimum width| |
| 1676 |
requirements, but any |minimum height| will be ignored. Conversely when |
| 1677 |
split horizontally, |minimum height| requirements will be met, but any |
| 1678 |
|minimum width| will be ignored. In addition, |inner sep| is applied to |
| 1679 |
every part that is used, so it cannot be specified independently for a |
| 1680 |
particular part. |
| 1681 |
|
| 1682 |
There are several \pgfname{} keys to specify how the shape is drawn. To use |
| 1683 |
these keys in \tikzname, simply remove the \declare{|/pgf/|} path: |
| 1684 |
|
| 1685 |
\begin{key}{/pgf/rectangle split parts=\meta{number} (initially 4)} |
| 1686 |
Split the rectangle into \meta{number} parts, which should be in the |
| 1687 |
range |1| to |20|. If more than four parts are needed, the boxes should |
| 1688 |
be allocated in advance as described above. |
| 1689 |
% |
| 1690 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1691 |
\begin{tikzpicture}[every text node part/.style={align=center}] |
| 1692 |
\node[rectangle split, rectangle split parts=3, draw, text width=2.75cm] |
| 1693 |
{Student |
| 1694 |
\nodepart{two} |
| 1695 |
age:int \\ |
| 1696 |
name:String |
| 1697 |
\nodepart{three} |
| 1698 |
getAge():int \\ |
| 1699 |
getName():String}; |
| 1700 |
\end{tikzpicture} |
| 1701 |
\end{codeexample} |
| 1702 |
\end{key} |
| 1703 |
|
| 1704 |
\begin{key}{/pgf/rectangle split horizontal=\opt{\meta{boolean}} (default true)} |
| 1705 |
This key determines whether the rectangle is split horizontally or |
| 1706 |
vertically |
| 1707 |
\end{key} |
| 1708 |
|
| 1709 |
\begin{key}{/pgf/rectangle split ignore empty parts=\opt{\meta{boolean}} (default true)} |
| 1710 |
When \meta{boolean} is true, \pgfname{} will ignore any part that is |
| 1711 |
empty \emph{except the text part}. This effectively overrides the |
| 1712 |
|rectangle split parts| key in that, if 3 parts (for example) are |
| 1713 |
specified, but one is empty, only two will be shown. |
| 1714 |
% |
| 1715 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1716 |
\begin{tikzpicture}[every node/.style={draw, anchor=text, rectangle split, |
| 1717 |
rectangle split parts=3}] |
| 1718 |
\node {text \nodepart{second} \nodepart{third}third}; |
| 1719 |
\node [rectangle split ignore empty parts] at (2,0) |
| 1720 |
{text \nodepart{second} \nodepart{third}third}; |
| 1721 |
\end{tikzpicture} |
| 1722 |
\end{codeexample} |
| 1723 |
\end{key} |
| 1724 |
% |
| 1725 |
\begin{key}{/pgf/rectangle split empty part width=\meta{length} (initially 1ex)} |
| 1726 |
Sets the default width for a node part box if it is empty and empty |
| 1727 |
parts are not ignored. |
| 1728 |
\end{key} |
| 1729 |
|
| 1730 |
\begin{key}{/pgf/rectangle split empty part height=\meta{length} (initially 1ex)} |
| 1731 |
Sets the default height for a node part box if it is empty and empty |
| 1732 |
parts are not ignored. |
| 1733 |
\end{key} |
| 1734 |
|
| 1735 |
\begin{key}{/pgf/rectangle split empty part depth=\meta{length} (initially 0ex)} |
| 1736 |
Sets the default depth for a node part box if it is empty and empty |
| 1737 |
parts are not ignored. |
| 1738 |
\end{key} |
| 1739 |
|
| 1740 |
\begin{key}{/pgf/rectangle split part align={\ttfamily\char`\{}\meta{list}{\ttfamily\char`\}} (initially center)} |
| 1741 |
Sets the alignment of the boxes inside the node parts. Each item in |
| 1742 |
\meta{list} should be separated by commas (so if there is more than one |
| 1743 |
item in \meta{list}, it must be surrounded by braces). |
| 1744 |
|
| 1745 |
When the rectangle is split vertically, the entries in \meta{list} must |
| 1746 |
be one of |left|, |right|, or |center|. If \meta{list} has less entries |
| 1747 |
than node parts then the remaining boxes are aligned according to the |
| 1748 |
last entry in the list. Note that this only aligns the boxes in each |
| 1749 |
part and \emph{does not} affect the alignment of the contents of the |
| 1750 |
boxes. |
| 1751 |
% |
| 1752 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1753 |
\def\x{one \nodepart{two} 2 \nodepart{three} three \nodepart{four} 4} |
| 1754 |
\begin{tikzpicture}[ |
| 1755 |
every node/.style={rectangle split, rectangle split parts=4, |
| 1756 |
draw} |
| 1757 |
] |
| 1758 |
\node[rectangle split part align={center, left, right}] at (0,0) {\x}; |
| 1759 |
\node[rectangle split part align={center, left}] at (1.25,0) {\x}; |
| 1760 |
\node[rectangle split part align={center}] at (2.5,0) {\x}; |
| 1761 |
\end{tikzpicture} |
| 1762 |
\end{codeexample} |
| 1763 |
|
| 1764 |
When the rectangle is split horizontally, the entries in \meta{list} |
| 1765 |
must be one of |top|, |bottom|, |center| or |base|. Note that using the |
| 1766 |
value |base| will only make sense if all the node part boxes are being |
| 1767 |
aligned in this way. This is because the |base| value aligns the boxes |
| 1768 |
in relation to each other, whereas the other values align the boxes in |
| 1769 |
relation to the part of the shape they occupy. |
| 1770 |
% |
| 1771 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1772 |
\def\x{\Large w\nodepart{two}x\nodepart{three}\Huge y\nodepart{four}\tiny z} |
| 1773 |
\begin{tikzpicture}[ |
| 1774 |
every node/.style={rectangle split, rectangle split parts=4, |
| 1775 |
draw, rectangle split horizontal} |
| 1776 |
] |
| 1777 |
\node[rectangle split part align={center, top, bottom}] at (0,0) {\x}; |
| 1778 |
\node[rectangle split part align={center, top}] at (0,-1.25) {\x}; |
| 1779 |
\node[rectangle split part align={center}] at (0,-2.5) {\x}; |
| 1780 |
\node[rectangle split part align=base] at (0,-3.75) {\x}; |
| 1781 |
\end{tikzpicture} |
| 1782 |
\end{codeexample} |
| 1783 |
\end{key} |
| 1784 |
|
| 1785 |
\begin{key}{/pgf/rectangle split draw splits=\opt{\meta{boolean}} (default true)} |
| 1786 |
Sets whether the line or lines between node parts will be drawn. |
| 1787 |
Internally, this sets the \TeX-if |\ifpgfrectanglesplitdrawsplits| |
| 1788 |
appropriately. |
| 1789 |
\end{key} |
| 1790 |
|
| 1791 |
\begin{key}{/pgf/rectangle split use custom fill=\opt{\meta{boolean}} (default true)} |
| 1792 |
This enables the use of a custom fill for each of the node parts |
| 1793 |
(including the area covered by the |inner sep|). The background path |
| 1794 |
for the shape should not be filled (e.g., in \tikzname{}, the |fill| |
| 1795 |
option for the node must be implicitly or explicitly set to |none|). |
| 1796 |
Internally, this key sets the \TeX-if |
| 1797 |
|\ifpgfrectanglesplitusecustomfill| appropriately. |
| 1798 |
\end{key} |
| 1799 |
|
| 1800 |
\begin{key}{/pgf/rectangle split part fill={\ttfamily\char`\{}\meta{list}{\ttfamily\char`\}} (initially white)} |
| 1801 |
Sets the custom fill color for each node part shape. The items in |
| 1802 |
\meta{list} should be separated by commas (so if there is more than one |
| 1803 |
item in \meta{list}, it must be surrounded by braces). If \meta{list} |
| 1804 |
has less entries than node parts, then the remaining node parts use the |
| 1805 |
color from the last entry in the list. This key will automatically set |
| 1806 |
|/pgf/rectangle split use custom fill|. |
| 1807 |
% |
| 1808 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1809 |
\begin{tikzpicture} |
| 1810 |
\tikzset{every node/.style={rectangle split, draw, minimum width=.5cm}} |
| 1811 |
\node[rectangle split part fill={red!50, green!50, blue!50, yellow!50}] {}; |
| 1812 |
\node[rectangle split part fill={red!50, green!50, blue!50}] at (0.75,0) {}; |
| 1813 |
\node[rectangle split part fill={red!50, green!50}] at (1.5,0) {}; |
| 1814 |
\node[rectangle split part fill={red!50}] at (2.25,0) {}; |
| 1815 |
\end{tikzpicture} |
| 1816 |
\end{codeexample} |
| 1817 |
\end{key} |
| 1818 |
|
| 1819 |
The anchors for the |rectangle split| shape split vertically into four, are |
| 1820 |
shown below (anchor |70| is an example of a border angle). When a node part |
| 1821 |
is missing, the anchors prefixed with the name of that node part should be |
| 1822 |
considered unavailable. They are (unavoidably) defined, but default to |
| 1823 |
other anchor positions. |
| 1824 |
% |
| 1825 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] |
| 1826 |
\Huge |
| 1827 |
\begin{tikzpicture} |
| 1828 |
\node[name=s,shape=rectangle split, rectangle split parts=4, shape example, |
| 1829 |
inner ysep=0.75cm] |
| 1830 |
{\nodepart{text}text\nodepart{two}two |
| 1831 |
\nodepart{three}three\nodepart{four}four}; |
| 1832 |
\foreach \anchor/\placement in |
| 1833 |
{text/left, text east/above, text west/above, |
| 1834 |
two/left, two east/above, two west/above, |
| 1835 |
three/left, three east/below, three west/below, |
| 1836 |
four/left, four east/below, four west/below, |
| 1837 |
text split/left, text split east/above, text split west/above, |
| 1838 |
two split/left, two split east/above, two split west/above, |
| 1839 |
three split/left, three split east/below, three split west/below, |
| 1840 |
north/above, south/below, east/below, west/below, |
| 1841 |
north west/above, north east/above, south west/below, south east/below, |
| 1842 |
center/above, 70/above, mid/above, base/below} |
| 1843 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1844 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1845 |
\end{tikzpicture} |
| 1846 |
\end{codeexample} |
| 1847 |
% |
| 1848 |
\end{shape} |
| 1849 |
|
| 1850 |
|
| 1851 |
\subsection{Callout Shapes} |
| 1852 |
|
| 1853 |
\begin{pgflibrary}{shapes.callouts} |
| 1854 |
Producing basic callouts can be done quite easily in \pgfname{} and |
| 1855 |
\tikzname{} by creating a node and then subsequently drawing a path from |
| 1856 |
the border of the node to the required point. This library provides more |
| 1857 |
fancy, `balloon'-style callouts. |
| 1858 |
\end{pgflibrary} |
| 1859 |
|
| 1860 |
Callouts consist of a main shape and a pointer (which is part of the shape) |
| 1861 |
which points to something in (or outside) the picture. The position on the |
| 1862 |
border of the main shape to which the pointer is connected is determined |
| 1863 |
automatically. However, the pointer is ignored when calculating the minimum |
| 1864 |
size of the shape, and also when positioning anchors. |
| 1865 |
% |
| 1866 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 1867 |
\begin{tikzpicture}[remember picture] |
| 1868 |
\node[ellipse callout, draw] (hallo) {Hallo!}; |
| 1869 |
\end{tikzpicture} |
| 1870 |
\end{codeexample} |
| 1871 |
|
| 1872 |
There are two kinds of pointer: the ``relative'' pointer and the ``absolute'' |
| 1873 |
pointer. The relative pointer calculates the angle of a specified coordinate |
| 1874 |
relative to the center of the main shape, locates the point on the border to |
| 1875 |
which this angle corresponds, and then adds the coordinate to this point. This |
| 1876 |
seemingly over-complex approach means than you do not have to guess the size of |
| 1877 |
the main shape: the relative pointer will always be outside. The absolute |
| 1878 |
pointer, on the other hand, is much simpler: it points to the specified |
| 1879 |
coordinate absolutely (and can even point to named coordinates in different |
| 1880 |
pictures). |
| 1881 |
% |
| 1882 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 1883 |
\begin{tikzpicture}[remember picture, note/.style={rectangle callout, fill=#1}] |
| 1884 |
\draw [help lines] grid(3,2); |
| 1885 |
\node [note=red!50, callout relative pointer={(0,1)}] at (3,1) {Relative}; |
| 1886 |
\node [note=blue!50, callout absolute pointer={(0,1)}] at (1,0) {Absolute}; |
| 1887 |
\node [note=green!50, opacity=.5, overlay, |
| 1888 |
callout absolute pointer={(hallo.south)}] at (1,2) {Outside}; |
| 1889 |
\end{tikzpicture} |
| 1890 |
\end{codeexample} |
| 1891 |
|
| 1892 |
The following keys are common to all callouts. Please remember that the |
| 1893 |
|callout| |relative| |pointer|, and |callout| |absolute| |pointer| keys take a |
| 1894 |
different format for their value depending on whether they are being used in |
| 1895 |
\pgfname{} or \tikzname{}. |
| 1896 |
|
| 1897 |
\begin{key}{/pgf/callout relative pointer=\meta{coordinate} (initially {\ttfamily\char`\\pgfpointpolar\char`\{315\char`\}\char`\{.5cm\char`\}})} |
| 1898 |
Sets the vector of the callout pointer `relative' to the callout shape. |
| 1899 |
\end{key} |
| 1900 |
|
| 1901 |
\begin{key}{/pgf/callout absolute pointer=\meta{coordinate}} |
| 1902 |
Sets the vector of the callout pointer absolutely within the picture. |
| 1903 |
\end{key} |
| 1904 |
|
| 1905 |
\begin{key}{/tikz/callout relative pointer=\meta{coordinate} (initially {(315:.5cm)})} |
| 1906 |
The \tikzname{} version of the |callout relative pointer| key. Here, |
| 1907 |
\meta{coordinate} can be specified using the \tikzname{} format for |
| 1908 |
coordinates. |
| 1909 |
\end{key} |
| 1910 |
|
| 1911 |
\begin{key}{/tikz/callout absolute pointer=\meta{coordinate}} |
| 1912 |
The \tikzname{} version of the |callout absolute pointer| key. Here, |
| 1913 |
\meta{coordinate} can be specified using the \tikzname{} format for |
| 1914 |
coordinates. |
| 1915 |
\end{key} |
| 1916 |
|
| 1917 |
It is also possible to shorten the pointer by some distance, using the |
| 1918 |
following key: |
| 1919 |
|
| 1920 |
\begin{key}{/pgf/callout pointer shorten=\meta{distance} (initially 0cm)} |
| 1921 |
Moves the callout pointer towards the center of the callout's main shape by |
| 1922 |
\meta{distance}. |
| 1923 |
% |
| 1924 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 1925 |
\begin{tikzpicture} |
| 1926 |
\tikzset{callout/.style={ellipse callout, callout pointer arc=30, |
| 1927 |
callout absolute pointer={#1}}} |
| 1928 |
\draw (0,0) grid (3,2); |
| 1929 |
\node[callout={(3,1.5)}, fill=red!50] at (0,1.5) {A}; |
| 1930 |
\node[callout={(3,.5)}, fill=green!50, callout pointer shorten=1cm] |
| 1931 |
at (0,.5) {B}; |
| 1932 |
\end{tikzpicture} |
| 1933 |
\end{codeexample} |
| 1934 |
% |
| 1935 |
\end{key} |
| 1936 |
|
| 1937 |
\begin{shape}{rectangle callout} |
| 1938 |
This shape is a callout whose main shape is a rectangle, which tightly fits |
| 1939 |
the node contents (including any |inner sep|). It supports the keys |
| 1940 |
described above and also the following key: |
| 1941 |
|
| 1942 |
\begin{key}{/pgf/callout pointer width=\meta{length} (initially .25cm)} |
| 1943 |
Sets the width of the pointer at the border of the rectangle. |
| 1944 |
\end{key} |
| 1945 |
|
| 1946 |
The anchors for this shape are shown below (anchor |60| is an example of a |
| 1947 |
border anchor). The pointer direction is ignored when placing anchors. |
| 1948 |
Additionally, when using an absolute pointer, the |pointer| anchor should |
| 1949 |
not to be used to used to position the shape as it is calculated whilst the |
| 1950 |
shape is being drawn. |
| 1951 |
% |
| 1952 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 1953 |
\Huge |
| 1954 |
\begin{tikzpicture} |
| 1955 |
\node[name=s,shape=rectangle callout, callout relative pointer={(1.25cm,-1cm)}, |
| 1956 |
callout pointer width=2cm, shape example, inner xsep=2cm, inner ysep=1cm] |
| 1957 |
{Rectangle Callout\vrule width 1pt height 2cm}; |
| 1958 |
\foreach \anchor/\placement in |
| 1959 |
{center/above, text/below, 60/above, |
| 1960 |
mid/right, mid west/left, mid east/right, |
| 1961 |
base/below, base west/below, base east/below, |
| 1962 |
north/above, south/below, east/above, west/above, |
| 1963 |
north west/above, north east/above, |
| 1964 |
south west/below, south east/below, |
| 1965 |
pointer/below} |
| 1966 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 1967 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 1968 |
\end{tikzpicture} |
| 1969 |
\end{codeexample} |
| 1970 |
% |
| 1971 |
\end{shape} |
| 1972 |
|
| 1973 |
\begin{shape}{ellipse callout} |
| 1974 |
This shape is a callout whose main shape is an ellipse, which tightly fits |
| 1975 |
the node contents (including any |inner sep|). It uses the |
| 1976 |
|absolute callout pointer|, |relative callout pointer| and |
| 1977 |
|callout pointer shorten| keys, and also the following key: |
| 1978 |
|
| 1979 |
\begin{key}{/pgf/callout pointer arc=\meta{angle} (initially 15)} |
| 1980 |
Sets the width of the pointer at the border of the ellipse according to |
| 1981 |
an arc of length \meta{angle}. |
| 1982 |
\end{key} |
| 1983 |
|
| 1984 |
The anchors for this shape are shown below (anchor |60| is an example of a |
| 1985 |
border anchor). The pointer direction is ignored when placing anchors and |
| 1986 |
the |pointer| anchor can only be used to position the shape when the |
| 1987 |
relative anchor is specified. |
| 1988 |
% |
| 1989 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 1990 |
\Huge |
| 1991 |
\begin{tikzpicture} |
| 1992 |
\node[name=s,shape=ellipse callout, callout relative pointer={(1.25cm,-1cm)}, |
| 1993 |
callout pointer width=2cm, shape example, inner xsep=1cm, inner ysep=.5cm] |
| 1994 |
{Ellipse Callout\vrule width 1pt height 2cm}; |
| 1995 |
\foreach \anchor/\placement in |
| 1996 |
{center/above, text/below, 60/above, |
| 1997 |
mid/above, mid west/right, mid east/left, |
| 1998 |
base/below, base west/below, base east/below, |
| 1999 |
north/above, south/below, east/above, west/above, |
| 2000 |
north west/above left, north east/above right, |
| 2001 |
south west/below left, south east/below right, |
| 2002 |
pointer/below} |
| 2003 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 2004 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 2005 |
\end{tikzpicture} |
| 2006 |
\end{codeexample} |
| 2007 |
% |
| 2008 |
\end{shape} |
| 2009 |
|
| 2010 |
\begin{shape}{cloud callout} |
| 2011 |
This shape is a callout whose main shape is a cloud which fits the node |
| 2012 |
contents. The pointer is segmented, consisting of a series of shrinking |
| 2013 |
ellipses. This callout requires the |shapes.callouts| library (for the cloud |
| 2014 |
shape). If this library is not loaded an error will result. |
| 2015 |
% |
| 2016 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 2017 |
\begin{tikzpicture} |
| 2018 |
\node[cloud callout, cloud puffs=15, aspect=2.5, cloud puff arc=120, |
| 2019 |
shading=ball,text=white] {\bf Imagine...}; |
| 2020 |
\end{tikzpicture} |
| 2021 |
\end{codeexample} |
| 2022 |
|
| 2023 |
The |cloud callout| supports the |absolute callout pointer|, |
| 2024 |
|relative callout pointer| and |callout pointer shorten| keys, as described |
| 2025 |
above. The main shape can be modified using the same keys as the |cloud| |
| 2026 |
shape. The following keys are also supported: |
| 2027 |
|
| 2028 |
\begin{key}{/pgf/callout pointer start size=\meta{value} (initially .2 of callout)} |
| 2029 |
Sets the size of the first segment in the pointer (i.e., the segment |
| 2030 |
nearest the main cloud shape). There are three possible forms for |
| 2031 |
\meta{value}: |
| 2032 |
% |
| 2033 |
\begin{itemize} |
| 2034 |
\item A single dimension (e.g., |5pt|), in which case the first |
| 2035 |
ellipse will have equal diameters of 5pt. |
| 2036 |
\item Two dimensions (e.g., |10pt and 2.5pt|), which sets the $x$ |
| 2037 |
and $y$ diameters of the first ellipse. |
| 2038 |
\item A decimal fraction (e.g., |.2 of callout|), in which case the |
| 2039 |
$x$ and $y$ diameters of the first ellipse will be set as |
| 2040 |
fractions of the width and height of the main shape. The |
| 2041 |
keyword |of callout| cannot be omitted. |
| 2042 |
\end{itemize} |
| 2043 |
\end{key} |
| 2044 |
|
| 2045 |
\begin{key}{/pgf/callout pointer end size=\meta{value} (initially .1 of callout)} |
| 2046 |
Sets the size of the last ellipse in the pointer. |
| 2047 |
\end{key} |
| 2048 |
|
| 2049 |
\begin{key}{/pgf/callout pointer segments=\meta{number} (initially 2)} |
| 2050 |
Sets the number of segments in the pointer. Note that \pgfname{} will |
| 2051 |
happily overlap segments if too many are specified. |
| 2052 |
\end{key} |
| 2053 |
|
| 2054 |
The anchors for this shape are shown below (anchor |70| is an example of a |
| 2055 |
border anchor). The pointer direction is ignored when placing anchors and |
| 2056 |
the pointer anchor can only be used to position the shape when the relative |
| 2057 |
anchor is specified. Note that the center of the last segment is drawn at |
| 2058 |
the |pointer| anchor. |
| 2059 |
% |
| 2060 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] |
| 2061 |
\Huge |
| 2062 |
\begin{tikzpicture} |
| 2063 |
\node[name=s, shape=cloud callout, style=shape example, cloud puffs=11, aspect=1.5, |
| 2064 |
cloud puff arc=120,inner xsep=.5cm, callout pointer start size=.25 of callout, |
| 2065 |
callout pointer end size=.15 of callout, callout relative pointer={(315:4cm)}, |
| 2066 |
callout pointer segments=2] {Cloud Callout\vrule width 1pt height 2cm}; |
| 2067 |
\foreach \anchor/\placement in |
| 2068 |
{puff 1/above, puff 2/above, puff 3/above, puff 4/below, |
| 2069 |
puff 5/left, puff 6/below, puff 7/below, puff 8/right, |
| 2070 |
puff 9/below, puff 10/above, puff 11/above, 70/right, |
| 2071 |
center/above, base/below, mid/right, text/left, |
| 2072 |
north/below, south/below, east/above, west/above, |
| 2073 |
north west/left, north east/right, |
| 2074 |
south west/below, south east/below,pointer/above} |
| 2075 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 2076 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 2077 |
\end{tikzpicture} |
| 2078 |
\end{codeexample} |
| 2079 |
% |
| 2080 |
\end{shape} |
| 2081 |
|
| 2082 |
|
| 2083 |
\subsection{Miscellaneous Shapes} |
| 2084 |
|
| 2085 |
\begin{pgflibrary}{shapes.misc} |
| 2086 |
This library defines general-purpose shapes that do not fit into the |
| 2087 |
previous categories. |
| 2088 |
\end{pgflibrary} |
| 2089 |
|
| 2090 |
\begin{shape}{cross out} |
| 2091 |
This shape ``crosses out'' the node. Its foreground path are simply two |
| 2092 |
diagonal lines between the corners of the node's bounding box. Here is an |
| 2093 |
example: |
| 2094 |
% |
| 2095 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2096 |
\begin{tikzpicture} |
| 2097 |
\draw [help lines] (0,0) grid (3,2); |
| 2098 |
\node [cross out,draw=red] at (1.5,1) {cross out}; |
| 2099 |
\end{tikzpicture} |
| 2100 |
\end{codeexample} |
| 2101 |
|
| 2102 |
A useful application is inside text as in the following example: |
| 2103 |
% |
| 2104 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2105 |
Cross \tikz[baseline] \node [cross out,draw,anchor=text] {me}; out! |
| 2106 |
\end{codeexample} |
| 2107 |
|
| 2108 |
This shape inherits all anchors from the |rectangle| shape, see also the |
| 2109 |
following figure: |
| 2110 |
% |
| 2111 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2112 |
\Huge |
| 2113 |
\begin{tikzpicture} |
| 2114 |
\node[name=s,shape=cross out,shape example] {cross out\vrule width 1pt height 2cm}; |
| 2115 |
\foreach \anchor/\placement in |
| 2116 |
{north west/above left, north/above, north east/above right, |
| 2117 |
west/left, center/above, east/right, |
| 2118 |
mid west/right, mid/above, mid east/left, |
| 2119 |
base west/left, base/below, base east/right, |
| 2120 |
south west/below left, south/below, south east/below right, |
| 2121 |
text/left, 10/right, 130/above} |
| 2122 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 2123 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 2124 |
\end{tikzpicture} |
| 2125 |
\end{codeexample} |
| 2126 |
% |
| 2127 |
\end{shape} |
| 2128 |
|
| 2129 |
\begin{shape}{strike out} |
| 2130 |
This shape is identical to the |cross out| shape, only its foreground path |
| 2131 |
consists of a single line from the lower left to the upper right. |
| 2132 |
% |
| 2133 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2134 |
Strike \tikz[baseline] \node [strike out,draw,anchor=text] {me}; out! |
| 2135 |
\end{codeexample} |
| 2136 |
|
| 2137 |
See the |cross out| shape for the anchors. |
| 2138 |
\end{shape} |
| 2139 |
|
| 2140 |
\begin{shape}{rounded rectangle} |
| 2141 |
This shape is a rectangle which can have optionally rounded sides. |
| 2142 |
% |
| 2143 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2144 |
\begin{tikzpicture} |
| 2145 |
\node[rounded rectangle, draw, fill=red!20]{Hallo}; |
| 2146 |
\end{tikzpicture} |
| 2147 |
\end{codeexample} |
| 2148 |
|
| 2149 |
There are keys to specify how the sides are rounded (to use these keys in |
| 2150 |
\tikzname, simply remove the \declare{|/pgf/|} path). |
| 2151 |
|
| 2152 |
\begin{key}{/pgf/rounded rectangle arc length=\meta{angle} (initially 180)} |
| 2153 |
Sets the length of the arcs for the rounded ends. Recommended values |
| 2154 |
for \meta{angle} are between |90| and |180|. |
| 2155 |
% |
| 2156 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2157 |
\begin{tikzpicture} |
| 2158 |
\matrix[row sep=5pt, every node/.style={draw, rounded rectangle}]{ |
| 2159 |
\node[rounded rectangle arc length=180] {180}; \\ |
| 2160 |
\node[rounded rectangle arc length=120] {120}; \\ |
| 2161 |
\node[rounded rectangle arc length=90] {90}; \\}; |
| 2162 |
\end{tikzpicture} |
| 2163 |
\end{codeexample} |
| 2164 |
\end{key} |
| 2165 |
|
| 2166 |
\begin{key}{/pgf/rounded rectangle west arc=\meta{arc type} (initially convex)} |
| 2167 |
Sets the style of the rounding for the left side. The permitted values |
| 2168 |
for \meta{arc type} are |concave|, |convex|, or |none|. |
| 2169 |
% |
| 2170 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2171 |
\begin{tikzpicture} |
| 2172 |
\matrix[row sep=5pt, every node/.style={draw, rounded rectangle}]{ |
| 2173 |
\node[rounded rectangle west arc=concave] {Concave}; \\ |
| 2174 |
\node[rounded rectangle west arc=convex] {Convex}; \\ |
| 2175 |
\node[rounded rectangle left arc=none] {None}; \\}; |
| 2176 |
\end{tikzpicture} |
| 2177 |
\end{codeexample} |
| 2178 |
\end{key} |
| 2179 |
|
| 2180 |
\begin{stylekey}{/pgf/rounded rectangle left arc=\meta{arc type}} |
| 2181 |
Alternative key for specifying the west arc. |
| 2182 |
\end{stylekey} |
| 2183 |
|
| 2184 |
\begin{key}{/pgf/rounded rectangle east arc=\meta{arc type} (initially convex)} |
| 2185 |
Sets the style of the rounding for the east side. |
| 2186 |
\end{key} |
| 2187 |
|
| 2188 |
\begin{stylekey}{/pgf/rounded rectangle right arc=\meta{arc type}} |
| 2189 |
Alternative key for specifying the east arc. |
| 2190 |
\end{stylekey} |
| 2191 |
|
| 2192 |
The anchors for this shape are shown below (anchor |10| is an example of a |
| 2193 |
border angle). Note that if only one side is rounded, the |center| anchor |
| 2194 |
will not be the precise center of the shape. |
| 2195 |
% |
| 2196 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2197 |
\Huge |
| 2198 |
\begin{tikzpicture} |
| 2199 |
\node[name=s,shape=rounded rectangle, shape example, inner xsep=1.5cm, inner ysep=1cm] |
| 2200 |
{Rounded Rectangle\vrule width 1pt height 2cm}; |
| 2201 |
\foreach \anchor/\placement in |
| 2202 |
{center/above, text/below, 10/above, |
| 2203 |
mid/above, mid west/right, mid east/left, |
| 2204 |
base/below, base west/below, base east/below, |
| 2205 |
north/above, south/below, east/above, west/above, |
| 2206 |
north west/above left, north east/above right, |
| 2207 |
south west/below left, south east/below right} |
| 2208 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 2209 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 2210 |
\end{tikzpicture} |
| 2211 |
\end{codeexample} |
| 2212 |
% |
| 2213 |
\end{shape} |
| 2214 |
|
| 2215 |
\begin{shape}{chamfered rectangle} |
| 2216 |
This shape is a rectangle with optionally chamfered corners. |
| 2217 |
% |
| 2218 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2219 |
\begin{tikzpicture} |
| 2220 |
\node[chamfered rectangle, white, fill=red, double=red, draw, very thick] |
| 2221 |
{\bf STOP!}; |
| 2222 |
\end{tikzpicture} |
| 2223 |
\end{codeexample} |
| 2224 |
|
| 2225 |
There are \pgfname{} keys to specify how this shape is drawn (to use these |
| 2226 |
keys in \tikzname{} simply remove the \declare{|/pgf/|} path). |
| 2227 |
|
| 2228 |
\begin{key}{/pgf/chamfered rectangle angle=\meta{angle} (initially 45)} |
| 2229 |
Sets the angle \emph{from the vertical} for the chamfer. |
| 2230 |
% |
| 2231 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2232 |
\begin{tikzpicture} |
| 2233 |
\tikzset{every node/.style={chamfered rectangle, draw}} |
| 2234 |
\node[chamfered rectangle angle=30] {abc}; |
| 2235 |
\node[chamfered rectangle angle=60] at (1.5,0) {123}; |
| 2236 |
\end{tikzpicture} |
| 2237 |
\end{codeexample} |
| 2238 |
\end{key} |
| 2239 |
|
| 2240 |
\begin{key}{/pgf/chamfered rectangle xsep=\meta{length} (initially .666ex)} |
| 2241 |
Sets the distance that the chamfer extends horizontally beyond the node |
| 2242 |
contents (which includes the |inner sep|). If \meta{length} is large, |
| 2243 |
such that the top and bottom chamfered edges would cross, then |
| 2244 |
\meta{length} is ignored and the chamfered edges are drawn so that they |
| 2245 |
meet in the middle. |
| 2246 |
% |
| 2247 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2248 |
\begin{tikzpicture} |
| 2249 |
\tikzset{every node/.style={chamfered rectangle, draw}} |
| 2250 |
\node[chamfered rectangle xsep=2pt] {def}; |
| 2251 |
\node[chamfered rectangle xsep=2cm] at (1.5,0) {456}; |
| 2252 |
\end{tikzpicture} |
| 2253 |
\end{codeexample} |
| 2254 |
\end{key} |
| 2255 |
|
| 2256 |
\begin{key}{/pgf/chamfered rectangle ysep=\meta{length} (initially .666ex)} |
| 2257 |
Sets the distance that the chamfer extends vertically beyond the node |
| 2258 |
contents. If \meta{length} is large, such that the left and right |
| 2259 |
chamfered edges would cross, then \meta{length} is ignored and the |
| 2260 |
chamfered edges are drawn so that they meet in the middle. |
| 2261 |
\end{key} |
| 2262 |
|
| 2263 |
\begin{key}{/pgf/chamfered rectangle sep=\meta{length} (initially .666ex)} |
| 2264 |
Sets both the |xsep| and |ysep| simultaneously. |
| 2265 |
\end{key} |
| 2266 |
|
| 2267 |
\begin{key}{/pgf/chamfered rectangle corners=\meta{list} (initially chamfer all)} |
| 2268 |
Specifies which corners are chamfered. The corners are identified by |
| 2269 |
their ``compass point'' directions (i.e.\ |north east|, |north west|, |
| 2270 |
|south west|, and |south east|), and must be separated by commas (so if |
| 2271 |
there is more than one corner in the list, it must be surrounded by |
| 2272 |
braces). Any corners not mentioned in \meta{list} are automatically not |
| 2273 |
chamfered. Two additional values |chamfer all| and |chamfer none|, are |
| 2274 |
also permitted. |
| 2275 |
% |
| 2276 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2277 |
\begin{tikzpicture} |
| 2278 |
\tikzset{every node/.style={chamfered rectangle, draw}} |
| 2279 |
\node[chamfered rectangle corners=north west] {ghi}; |
| 2280 |
\node[chamfered rectangle corners={north east, south east}] at (1.5,0) {789}; |
| 2281 |
\end{tikzpicture} |
| 2282 |
\end{codeexample} |
| 2283 |
\end{key} |
| 2284 |
|
| 2285 |
The anchors for this shape are shown below (anchor |60| is an example of a |
| 2286 |
border angle. |
| 2287 |
% |
| 2288 |
\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] |
| 2289 |
\Huge |
| 2290 |
\begin{tikzpicture} |
| 2291 |
\node[name=s,shape=chamfered rectangle, chamfered rectangle sep=1cm, |
| 2292 |
shape example, inner ysep=1cm, inner xsep=.75cm] |
| 2293 |
{Chamfered Rectangle\vrule width1pt height2cm}; |
| 2294 |
\foreach \anchor/\placement in |
| 2295 |
{text/right, center/above, 70/above, |
| 2296 |
base/below, base east/left, base west/right, |
| 2297 |
mid/right, mid east/above, mid west/above, |
| 2298 |
north/above, south/below, east/above, west/above, |
| 2299 |
before north east/above, north east/above, after north east/above, |
| 2300 |
before north west/above, north west/above, after north west/above, |
| 2301 |
before south west/below, south west/below, after south west/below, |
| 2302 |
before south east/below, south east/below, after south east/below} |
| 2303 |
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)} |
| 2304 |
node[\placement] {\scriptsize\texttt{(s.\anchor)}}; |
| 2305 |
\end{tikzpicture} |
| 2306 |
\end{codeexample} |
| 2307 |
% |
| 2308 |
\end{shape} |
| 2309 |
|
| 2310 |
|
| 2311 |
%%% Local Variables: |
| 2312 |
%%% mode: latex |
| 2313 |
%%% TeX-master: "pgfmanual-pdftex-version" |
| 2314 |
%%% End: |