summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex
blob: affa75dd8b414403f3ec3fd6d7afad17dd8f6934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
% Copyright 2007 by Till Tantau and Mark Wibrow
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.


\section{Shape Library}
\label{section-libs-shapes}


\subsection{Overview}

In addition to the standard shapes |rectangle|, |circle| and
|coordinate|, there exist a number of additional shapes defined in
different shape libraries. Most of these shapes have been 
contributed by Mark Wibrow. In the present section, these shapes are
described. Note that the library |shapes| is provided for
compatibility only. Please include sublibraries like
|shapes.geometric| or |shapes.misc| directly.

The appearance of shapes is influenced by numerous parameters like
|minimum height| or |inner xsep|. These general parameters are documented in
Section~\ref{section-shape-common-options} 


\subsection{Predefined Shapes}
\label{section-predefined-shapes}

The three shapes |rectangle|, |circle|, and |coordiante| are always
defined and no library needs to be loaded for them. While the
|coordinate| shape defines only the |center| anchor, the other two
shapes define a standard set of anchors.

\begin{shape}{circle}
  This shape draws a tightly fitting circle around the text. The
  following figure shows the anchors this shape defines; the anchors
  |10| and |130| are example of border anchors. 
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=circle,shape example] {Circle\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{rectangle}
  This shape, which is the standard, is a rectangle around the
  text. The inner   and outer separations (see
  Section~\ref{section-shape-seps}) influence the white space around
  the text. The following figure shows the anchors this
  shape defines; the anchors |10| and |130| are example of border anchors.
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=rectangle,shape example] {Rectangle\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}



\subsection{Geometric Shapes}

\begin{pgflibrary}{shapes.geometric}
  This library defines different shapes that correspond to basic
  geometric objects like ellipses or polygons.
\end{pgflibrary}


\begin{shape}{diamond}
  This shape is a diamond tightly fitting the text box. The ratio
  between width and height is 1 by default, but can be changed by
  setting the shape aspect ratio using the following \pgfname{}
  key (to use this key in \tikzname{} simply remove the 
  \declare{|/pgf/|} path). 

  \begin{key}{/pgf/aspect=\meta{value} (initially 1.0)}
    The aspect is a recommendation for the quotient of the width and 
    the height of a shape. This key calls the macro
    |\pgfsetshapeaspect|.
  \end{key}
  
  The following figure shows the anchors this
  shape defines; the anchors |10| and |130| are example of border
  anchors.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=diamond,shape example] {Diamond\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid/above, 
     base/below,  
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{ellipse}
  This shape is an ellipse tightly fitting the text box, if no inner
  separation is given. The following figure shows the anchors this
  shape defines; the anchors |10| and |130| are example of border anchors.
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=ellipse,shape example] {Ellipse\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}





\begin{shape}{trapezium}
  This shape is a trapezium, that is, a quadrilateral with a single
  pair of parallel lines (this can sometimes be known as a trapezoid).
  The trapezium shape supports the rotation of the shape border, as 
  described in Section~\ref{section-rotating-shape-borders}. 
  
  The lower internal angles at the lower corners of the trapezium can 
  be specified independently, and the resulting extensions are in 
  addition to the natural dimensions of the node contents (which
  includes any |inner sep|.
	
\begin{codeexample}[]
\begin{tikzpicture}
   \tikzstyle{every node}=[trapezium, draw]
   \node at (0,2) {A};
   \node[trapezium left angle=75, trapezium right angle=45pt]
         at (0,1) {B};
   \node[trapezium left angle=120, trapezium right angle=60pt]
         at (0,0) {C};
\end{tikzpicture}
\end{codeexample}

         
  The \pgfname{} keys to set the lower internal angles of the trapezium 
  are shown below. 
  To use these keys in \tikzname, simply remove the \declare{|/pgf/|} path.
	
  \begin{key}{/pgf/trapezium left angle=\meta{angle} (initially 60)}
    Set the lower internal angle of the left side. 
  \end{key}
   
  \begin{key}{/pgf/trapezium right angle=\meta{angle} (initially 60)}
    Set the lower internal angle of the right side. 
  \end{key}
  
  \begin{stylekey}{/pgf/trapezium angle=\meta{angle}}
    This key stores no value itself, but sets the value of the
    previous two keys to \meta{angle}. 
  \end{stylekey}
     
  Regardless of the rotation of the shape border, the width
  and height of the trapezium are as follows:

\begin{codeexample}[]
\begin{tikzpicture}[>=stealth, every node/.style={text=black}, 
    shape border uses incircle, shape border rotate=60]
  \node [trapezium, fill=gray!25, minimum width=2cm] (t) {};
  \draw [red, <->] (t.bottom left corner) -- (t.bottom right corner) 
    node [midway, below right] {width};
  \draw [red, <->] (t.top side) -- (t.bottom side) 
    node [at start, above] {height};
\end{tikzpicture}
\end{codeexample}

  \begin{key}{/pgf/trapezium stretches=\meta{boolean} (default true)}
    This key controls whether \pgfname{} allows the width and the height
    of the trapezium to be enlarged independently, 
    when considering any minimum size specification. This is initially 
    |false|,  ensuring that the shape ``looks the same but bigger'' when 
    enlarged.
  
\begin{codeexample}[]
\tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}}
\begin{tikzpicture}
  \draw [help lines] grid (3,2);
  \node [my node=red]                                      {A};
  \node [my node=green, minimum height=1.5cm] at (1, 1.25) {B};
  \node [my node=blue,  minimum width=1.5cm]  at (2, 0)    {C};
\end{tikzpicture}
\end{codeexample} 

    By setting \meta{boolean} to |true|, the trapezium can be stretched
    horizontally or vertically.
  
\begin{codeexample}[]
\tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}}
\begin{tikzpicture}
\tikzset{trapezium stretches=true}
  \draw [help lines] grid (3,2);
  \node [my node=red]                                      {A};
  \node [my node=green, minimum height=1.5cm] at (1, 1.25) {B};
  \node [my node=blue,  minimum width=1.5cm]  at (2, 0)    {C};
\end{tikzpicture}
\end{codeexample}
\end{key}

  \begin{key}{/pgf/trapezium stretches body=\meta{boolean} (default true)}
    This is similar to the |trapezium stretches| key execept that
    when \meta{boolean} is |true|, \pgfname{} enlarges only the body 
    of the trapezium when applying minimum width.
  
\begin{codeexample}[]
\tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}}
\begin{tikzpicture}
  \draw [help lines] grid (3,2);
  \node [my node=red]                      at (1.5,.25)  {A};
  \node [my node=green, minimum width=3cm, trapezium stretches] 
    at (1.5,1)    {B};
  \node [my node=blue,  minimum width=3cm, trapezium stretches body] 
    at (1.5,1.75) {C};
\end{tikzpicture}
\end{codeexample}
  \end{key}

  The anchors for the trapezium are shown below. The anchor |160| is an
  example of a border anchor.

\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=trapezium, shape example, inner sep=1cm] 
    {Trapezium\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {bottom left corner/below, top right corner/right, 
     top left corner/left,     bottom right corner/below,
     bottom side/below,        left side/left, 
     right side/right,         top side/above,
     center/above,   text/below,      mid/right,       base/below, 
     mid west/right, base west/below, mid east/left,   base east/below, 
     west/above,     east/above,      north/below,     south/above,
     north west/above, north east/above, 
     south west/below, south east/below, 160/above}    
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}  
\end{shape}


\begin{shape}{semicircle}
  This shape is a semicircle, which tightly fits the node contents.
  This shape supports the rotation of the shape border, as described in 
  Section~\ref{section-rotating-shape-borders}.
  The anchors for the |semicircle| shape are shown below. 
  Anchor |30| is an example of a border anchor.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=semicircle,shape border rotate=0,shape example, inner sep=1cm] 
  	{Semicircle\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {apex/above,      arc start/below, arc end/below,  chord center/below,
     center/above,    base/below,      mid/right,      text/left,
     base west/below, base east/below, mid west/left, mid east/right, 
     north/below,     south/above,     east/above,     west/above,
     north west/above left, north east/above right,
     south west/below,      south east/below, 30/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}





\begin{shape}{regular polygon}
  This shape is a regular polygon, which, by default, is drawn so that 
  a side (rather than a corner) is always at the bottom. 
  This shape supports the rotation as described in 
  Section~\ref{section-rotating-shape-borders}, but the border of the 
  polygon is \emph{always} constructed using the incircle, whose
  radius is calculated to tightly fit the node contents (including
  any |inner sep|).
  
\begin{codeexample}[]
\begin{tikzpicture}
  \foreach \a in {3,...,7}{
    \draw[red, dashed] (\a*2,0)  circle(0.5cm);
    \node[regular polygon, regular polygon sides=\a, draw,
     inner sep=0.3535cm] at (\a*2,0) {};
   }  
\end{tikzpicture}
\end{codeexample}	
	
  If the node is enlarged to any specified minimum size, 
  this is interpreted as the diameter of the the 
  circumcircle, that is, the circle that passes through all the 
  corners of the polygon border.

\begin{codeexample}[]
\begin{tikzpicture}
  \foreach \a in {3,...,7}{
    \draw[blue, dashed] (\a*2,0)  circle(0.5cm);
    \node[regular polygon, regular polygon sides=\a, minimum size=1cm, draw] at (\a*2,0) {};
   }  
\end{tikzpicture}
\end{codeexample}	

  There is a \pgfname{} key to set the number of sides for the regular
  polygon.
  To use this key in \tikzname, simply remove the \declare{|/pgf/|} path.
	
  \begin{key}{/pgf/regular polygon sides=\meta{integer} (initially 5)}
  \end{key}
  
  The anchors for a regular polygon shape are shown below.  
  The anchor |75| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=regular polygon, shape example, inner sep=.5cm] 
    {Regular Polygon\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {corner 1/above, corner 2/above, corner 3/left, corner 4/right, corner 5/above, 
     side 1/above,   side 2/left,    side 3/below,  side 4/right,   side 5/above,  
     center/above, text/left,  mid/right,   base/below, 75/above,
     west/above,   east/above, north/below, south/above,
     north east/below, south east/above, north west/below, south west/above}
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{star}
  This shape is a star, which by default (minus any transformations) is
  drawn with the first point pointing upwards.  
  This shape supports the rotation as described in 
  Section~\ref{section-rotating-shape-borders}, but the border of the 
  star is \emph{always} constructed using the incircle.
  
  A star should be thought of as having an set of ``inner points'' and
  and ``outer points''. 
  The inner points of the border are based on the radius of the circle
  which tightly fits the node contents, and the outer points are based
  on the circumcircle, the circle that passes through every outer
  point.
  Any specified minimum size, width or height, is interpreted as the 
  diameter of the circumcircle.
 
\begin{codeexample}[]
\begin{tikzpicture}
   \draw [help lines]   (0,0) grid (2,2);
   \draw [blue, dashed]  (1,1) circle(1cm);
   \draw [red, dashed] (1,1) circle(.5cm);
   \node [star, star point height=.5cm, minimum size=2cm, draw] 
       at (1,1) {S};
\end{tikzpicture}
\end{codeexample} 
  
  The \pgfname{} keys to set the number of star points, and the height
  of the star points, are shown below. To use these keys in \tikzname,
  simply remove the \declare{|/pgf/|} path.
  
  \begin{key}{/pgf/star points=\meta{integer} (initially 5)}
    Sets the number of points for the star.
  \end{key}
  
  \begin{key}{/pgf/star point height=\meta{distance} (initially .5cm)}
    Sets the height of the star points. This is the distance between the
    inner point and outer point radii. If the star is enlarged to some
    specified minimum size, the inner radius is increased to maintain
    the point height.	
  \end{key}
  
  \begin{key}{/pgf/star point ratio=\meta{number} (initially 1.5)}
    Sets the ratio between the inner point and outer point radii.		
    If the star is enlarged to some specified minimum size, the
    inner radius is increased to maintain the ratio.	
  \end{key}

	The inner and outer points form the principle anchors for the star,
   as shown below (anchor |75| is an example of a border anchor).
  
  \begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=star, star points=5, star point ratio=1.65, shape example, inner sep=1.5cm] 
    {Star\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
     {inner point 1/above, inner point 2/above, inner point 3/below, inner point 4/right, 
      inner point 5/above, outer point 1/above, outer point 2/above, outer point 3/left,  
      outer point 4/right, outer point 5/above,
      center/above, text/left,  mid/right,   base/below, 75/above,
     	west/above,   east/above, north/below, south/above,
     	north east/below, south east/above, north west/below, south west/above}
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}





\begin{shape}{isosceles triangle}
  This shape is an isosceles triangle, which supports the rotation of 
  the shape border, as described in 
  Section~\ref{section-rotating-shape-borders}. The angle of rotation
  determines the direction in which the apex of the triangle points
  (provided no other transformations are applied). However, regardless
  of the rotation of the shape border, the width and height are 
  always considered as follows:
	
\begin{codeexample}[]
\begin{tikzpicture}[>=stealth, every node/.style={text=black},
    shape border uses incircle, shape border rotate=-30]
  \node [isosceles triangle, fill=gray!25, minimum width=1.5cm] (t) {};
  \draw [red, <->] (t.left corner) -- (t.right corner)
    node [midway, above left] {width};
  \draw [red, <->] (t.apex) -- (t.lower side)
    node [midway, above right] {height};
\end{tikzpicture}
\end{codeexample}

	There are \pgfname{} keys to customise this shape. 
	To use these keys in \tikzname, simply remove the \declare{|/pgf/|} 
	path.
    
  \begin{key}{/pgf/isosceles triangle apex angle=\meta{angle} (initially 45)}
    Sets the angle of the apex of the isosceles triangle. 
  \end{key}

\begin{key}{/pgf/isosceles triangle stretches=\meta{boolean} (default true)}
  
	By default \meta{boolean} is |false|. This means, that when applying
	any minimum width or minimum height requirements, increasing the 
	height will increase the width (and	vice versa), in order to keep the
	apex angle the same.
   
\begin{codeexample}[]
\begin{tikzpicture}[paint/.style={draw=#1!75, fill=#1!20}]
  \tikzset{every node/.style={isosceles triangle, draw, inner sep=0pt, 
    anchor=left corner, shape border rotate=90}}
  \draw[help lines] grid(4,2);
  \foreach \a/\c in {1.5/blue, 1/green, 0.5/red}{
    \node[paint=\c, minimum height=\a cm] at (0,0) {};
    \node[paint=\c, minimum width=\a cm] at (2,0) {};
  }
\end{tikzpicture}
\end{codeexample}	

	However, by setting \meta{boolean} to |true|, minimum width and 
	height can be applied	independently.
	
\begin{codeexample}[]
\begin{tikzpicture}[paint/.style={draw=#1!75, fill=#1!20}]
  \tikzset{every node/.style={isosceles triangle, draw, inner sep=0pt, 
     anchor=south, shape border rotate=90, isosceles triangle stretches}}
  \draw[help lines] grid(4,2);
  \foreach \a/\c in {1.5/blue, 1/green, 0.5/red}{
    \node[paint=\c, minimum height=\a cm, minimum width=1.5cm] at (0.75,0) {};
    \node[paint=\c, minimum width=\a cm, minimum height=1.5cm] at (3,0)    {};
  }
\end{tikzpicture}
\end{codeexample}	
\end{key}
	
   The anchors for the |isosceles triangle| are shown below 
   (anchor |150| is an	example of a border anchor). Note that,
   somewhat confusingly, the anchor names such as |left side| and
   |right corner| are named as if the triangle is rotated to 
   90 degrees. Note also that the |center| anchor
   does not	necessarily correspond to any kind of geometric center.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=isosceles triangle, shape example, inner xsep=1cm]
    {Isosceles Triangle\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {apex/above,      left corner/right, right corner/right,
     left side/above, right side/below,  lower side/right,    
     center/above,    text/right,        150/above,
     mid/right,       mid west/above,    mid east/right,
     base/below,      base west/below,   base east/below,
     west/above, east/below, north/below, south/above,
     north west/below, north east/below, 
     south west/above, south east/above}  
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample} 
\end{shape}






\par\leavevmode
\begin{shape}{kite}

	This shape is a kite, which supports the rotation of the shape border, 
	as described in Section~\ref{section-rotating-shape-borders}. 
	There are \pgfname{} keys to specify the upper and lower vertex angles
	of the kite. 
	To use these keys in \tikzname, simply remove the \declare{|/pgf/|} 
	path.
	
	\begin{key}{/pgf/kite upper vertex angle=\meta{angle} (initially 120)}
	Set the upper internal angle of the kite.
	\end{key}
	
	\begin{key}{/pgf/kite lower vertex angle=\meta{angle} (initially 60)}
	Set the lower internal angle of the kite.
	\end{key}
	
	\begin{key}{/pgf/kite vertex angles=\meta{angle specification}}
		This key sets the keys for both the upper and lower vertex angles
		(it stores no value itself).
	   \meta{angle specification} can be pair of angles in the form
	   \meta{upper angle} |and| \meta{lower angle}, or a single angle.
	   In this latter case, both the upper and lower vertex angles will 
	   be the same.
	\end{key}%
    
\begin{codeexample}[]
\begin{tikzpicture}
  \tikzstyle{every node}=[kite, draw]
  \node[kite upper vertex angle=135, kite lower vertex angle=70] at (0,0) {A};
  \node[kite vertex angles=90 and 45] at (1,0) {B};
  \node[kite vertex angles=60]        at (2,0) {C};
\end{tikzpicture}
\end{codeexample}


	The anchors for the |kite| are shown below. Anchor |110| is an 
	example of a border anchor.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=kite, shape example, inner sep=1.5cm] 
    {Kite\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {upper vertex/above, left vertex/above,    lower vertex/below, 
     right vertex/above, upper left side/above, upper right side/above,
     lower left side/below, lower right side/below,
     center/above,   text/left,       mid/right,        base/below, 
     mid west/left,  base west/below, mid east/right,   base east/below,
     west/above,     east/above,      north/below,     south/above,
     north west/left, north east/right, 
     south west/above, south east/above, 110/above}  
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}


\begin{shape}{dart}


	This shape is a dart (which can also be known as an arrowhead or
	concave kite). This shape supports the rotation of the shape border, 
	as described in Section~\ref{section-rotating-shape-borders}. 
	The angle of the border rotation determines the direction in which 
	the dart points (unless other transformations have been applied).
	
	There are \pgfname{} keys to set the 
	angle for the `tip' of the dart and the angle between the `tails'
	of the dart. 
	To use these keys in \tikzname, simply remove the \declare{|/pgf/|} 
	path.

\begin{codeexample}[]
\begin{tikzpicture}
   \node[dart, draw, gray, shape border uses incircle, shape border rotate=45] 
       (d) {dart};
   \draw [<->] (d.tip)++(202.5:.5cm) arc(202.5:247.5:.5cm);
   \node [left=.5cm] at (d.tip) {tip angle};
   \draw [<->] (d.tail center)++(157.5:.5cm) arc(157.5:292.5:.5cm);
   \node [right] at (d.tail center) {tail angle};
\end{tikzpicture}
\end{codeexample}

	\begin{key}{/pgf/dart tip angle=\meta{angle} (initially 45)}
		Set the angle at the tip of the dart.
	\end{key}
	
	\begin{key}{/pgf/dart tail angle=\meta{angle} (initially 135)}
		Set the angle between the tails of the dart.
	\end{key}
		
	The anchors for the |dart| shape are shown below (note that the 
	shape is rotated 90 degrees anti-clockwise). Anchor |110| is an 
	example of a border anchor.
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=dart, shape border rotate=90, shape example, inner sep=1.25cm] 
    {Dart\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {tip/above,       tail center/below, right tail/below, 
     left tail/below, right tail/below,  left side/left,   right side/right,
     center/above,    text/left,         mid/right,        base/below, 
     mid west/left,   base west/below,   mid east/right,   base east/below,
     west/above,      east/above,        north/below,      south/above,
     north west/left, north east/right,  south west/above, south east/above,
     110/above}    
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}




\begin{shape}{circular sector}

	This shape is a circular sector (which can also be known as a
	wedge).
	This shape supports the rotation of the shape border, 
	as described in Section~\ref{section-rotating-shape-borders}. 
	The angle of the border rotation determines the direction in which 
	the `apex' of the sector points (unless other transformations have 
	been applied).
	
\begin{codeexample}[]
\begin{tikzpicture}
	\tikzstyle{every node}=[circular sector, shape border uses incircle, draw];
   \node at (0,0) {A};
   \node [shape border rotate=30] at (1.5,0) {A};
\end{tikzpicture}
\end{codeexample}

	There is a \pgfname{} key to set the central angle of the sector, 
	which is expected to be less than 180 degrees. 
	To use this key in \tikzname,	simply remove the \declare{|/pgf/|} 
	path.
	
	\begin{key}{/pgf/circular sector angle=\meta{angle} (initially 60)}
		Set the central angle of the sector. 
	\end{key}
	
	The anchors for the circular sector shape are shown below.
	Anchor |30| is an example of a border anchor.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=circular sector,  style=shape example, inner sep=1cm] 
  	{Circular Sector\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
   {sector center/above, arc start/below, arc end/below, arc center/below,
    center/above,        base/below,      mid/right,     text/below,
    north/below,         south/above,     east/below,    west/above,
    north west/above left, north east/above right,
    south west/below,      south east/below, 30/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}




\begin{shape}{cylinder}
	This shape is a 2-dimensional representation of a cylinder, which 
	supports the rotation of the shape border as described in
	Section~\ref{section-rotating-shape-borders}.

\begin{codeexample}[]
\begin{tikzpicture}
  \node[cylinder, draw, shape aspect=.5] {ABC};
\end{tikzpicture}
\end{codeexample}
		
	Regardless the rotation of the shape border, the height is always the
	distance between the curved ends, and the width is always the	
	distance between the straight sides. 

\begin{codeexample}[]
\begin{tikzpicture}[>=stealth]
  \node [cylinder, gray!50, rotate=30, draw, 
    minimum height=2cm, minimum width=1cm] (c) {Cylinder};
  \draw[red, <->] (c.top)   -- (c.bottom) 
    node [at end, below, black]   {height};
  \draw[red, <->] (c.north) -- (c.south) 
    node [at start, above, black] {width};
\end{tikzpicture}
\end{codeexample}

	Enlarging the shape to some minimum height will stretch only the body
	of the cylinder. By contrast, enlarging the shape to some minimum 
	width will stretch the curved ends.
	
\begin{codeexample}[]
\begin{tikzpicture}[>=stealth, shape aspect=.5]
  \tikzset{every node/.style={cylinder, shape border rotate=90, draw}}
  \node [minimum height=1.5cm]            {A};  
  \node [minimum width=1.5cm]  at (1.5,0) {B};  
\end{tikzpicture}
\end{codeexample}

  There are various keys to customize this shape (to use \pgfname{}
  keys in \tikzname{}, simply remove the \declare{|/pgf/|} path).
  
\begin{key}{/pgf/aspect=\meta{value} (initially 1.0)}
  The aspect is a recommendation for the quotient of the radii of
  the cylinder end. This may be ignored if the shape is enlarged
  to some minimum width.

\begin{codeexample}[]
\begin{tikzpicture}[>=stealth]
  \tikzset{every node/.style={cylinder, shape border rotate=90, draw}}
  \node [aspect=1.0]           {A};  
  \node [aspect=0.5]  at (1,0) {B};  
  \node [aspect=0.25] at (2,0) {C};  
\end{tikzpicture}
\end{codeexample}

\end{key}

\begin{key}{/pgf/cylinder uses custom fill=\meta{boolean} (default true)}
	This enables the use of a custom fill for the body and the end of 
	the cylinder. The background path for the shape should not be 
	filled (e.g., in \tikzname{}, the |fill| option for the node must 
	be implicity or explicitly set to |none|).
  Internally, this key sets the \TeX-if 
  |\ifpgfcylinderusescustomfill| appropriately.
\end{key}

\begin{codeexample}[]
\begin{tikzpicture}[>=stealth, aspect=0.5]
  \node [cylinder, cylinder uses custom fill, cylinder end fill=red!50,
         cylinder body fill=red!25] {Cylinder};  
\end{tikzpicture}
\end{codeexample}

\begin{key}{/pgf/cylinder end fill=\meta{color} (initially white)}
	Set the color for the end of the cylinder.
\end{key}
\begin{key}{/pgf/cylinder body fill=\meta{color} (initially white)}
	Set the color for the body of the cylinder.
\end{key}


  The anchors this shape are shown below (anchor |160| is an
	example of a border anchor). Note the the cylinder shape does not 
	distinguish between |outer xsep| and |outer ysep|. Only the larger 
	of the two values is used for the shape. Note also the difference 
	between the |center| and |shape center| anchors: |center| is the
	center of the cylinder body and also the center of rotation. 
	The |shape center| is the center of the shape which includes the 
	2-dimensional representation of the cylinder top.	
	 

\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=cylinder, shape example, aspect=.5, inner xsep=3cm,
        inner ysep=1cm] {Cylinder\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {before top/above,    top/above,       after top/below,
     before bottom/below, bottom/above,    after bottom/above,
     mid/right,           mid west/right,  mid east/left,  
     base/below,          base west/below, base east/below,
     center/above,        text/above,      shape center/right, 
     west/right, east/left, north/above, south/below,
     north west/below, north east/above, 
     south west/above, south east/below, 160/above}    
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}  


\end{shape}






\subsection{Symbol Shapes}

\begin{pgflibrary}{shapes.symbols}
  This library defines shapes that can be used for drawing symbols
  like a forbidden sign or a cloud.
\end{pgflibrary}



\begin{shape}{forbidden sign}
  This shape places the node inside a circle with a diagonal from the
  lower left to the upper right added. The circle is part of the
  background, the diagonal line part of the foreground path; thus, the
  diagonal line is on top of the text.
  
\begin{codeexample}[]
\begin{tikzpicture}
  \node [forbidden sign,line width=1ex,draw=red,fill=white] {Smoking};
\end{tikzpicture}
\end{codeexample}

  The shape inherits all anchors from the |circle| shape, see also the
  following figure:
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=forbidden sign,shape example] {Forbidden\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}


\begin{shape}{cloud}

	This shape is a cloud, drawn to tightly fit the node contents 
	(strictly speaking, using an ellipse which tightly fits the node
	contents -- including any |inner sep|). 
	
\begin{codeexample}[]
\begin{tikzpicture}
  \node[cloud, draw, fill=gray!20, aspect=2] {ABC};
  \node[cloud, draw, fill=gray!20] at (1.5,0) {D};
\end{tikzpicture}
\end{codeexample}

	A cloud should be thought of as having a number of ``puffs'', which
	are the individual arcs drawn around the border. There are \pgfname{}
	keys to specify how the cloud is drawn (to use these keys in 
	\tikzname{}, simply remove the \declare{|/pgf/|} path).
	
	\begin{key}{/pgf/cloud puffs=\meta{integer} (initially 10)}
	  Set the number of puffs for the cloud.
	\end{key}
	
	\begin{key}{/pgf/cloud puff arc=\meta{angle} (initially 135)}
	  Set the length of the puff arc (in degrees). A shorter arc can 
	  produce better looking joins between puffs for larger line widths.
	\end{key}
	
	Like the diamond shape, the cloud shape also uses the 
	\declare{|aspect|} key, to determine the ratio of the width and the 
	height of the cloud. However there may be cirumstances where it may
	be undesirable to continually specify the |aspect| for the cloud.
	Therefore, the following key is implemented:
	
	\begin{key}{/pgf/cloud ignores aspect=\meta{boolean} (default true)}
		Instruct \pgfname{} to ignore the |aspect| key. Internally, the
		\TeX-if |\ifpgfcloudignoresaspect| is set appropriately. The initial
		value is |false|.

\begin{codeexample}[]
\begin{tikzpicture}[aspect=1, every node/.style={cloud, cloud puffs=11, draw}]
  \node [fill=gray!20]                                {rain};
  \node [cloud ignores aspect, fill=white] at (1.5,0) {snow};
\end{tikzpicture}
\end{codeexample}	
	
	\end{key}
	
	
	Any minimum size requirements are applied to the ``circum-ellipse'',
	which is the ellipse which passes through all the midpoints of the
	puff arcs. These requirements are considered \emph{after} any 
	aspect specification is applied.
	
\begin{codeexample}[]
\begin{tikzpicture}
  \draw [help lines] grid (3,2);
  \draw [blue, dashed] (1.5, 1) ellipse (1.5cm and 1cm);
  \node [cloud, cloud puffs=9, draw, minimum width=3cm, minimum height=2cm] 
    at (1.5, 1) {};
\end{tikzpicture}
\end{codeexample}
	
  The anchors for the cloud shape are shown below for a cloud with
  eleven puffs. Anchor 70 is an example of a border anchor. 
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=cloud, style=shape example, cloud puffs=11, aspect=1.5,
       cloud puff arc=120,inner ysep=1cm] {Cloud\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
   {puff 1/above, puff 2/above,  puff 3/above,  puff 4/below, 
    puff 5/left,  puff 6/below,  puff 7/below,  puff 8/right,
    puff 9/below, puff 10/above, puff 11/above, 70/right,
    center/above, base/below,    mid/right,     text/left, 
    north/below,  south/below,   east/above,    west/above,
    north west/left,             north east/right, 
    south west/below,            south east/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape} 






\begin{shape}{starburst}

	This shape is a randomly generated eliptical star,
	which supports the rotating of the shape border as described in 
	Section~\ref{section-rotating-shape-borders}. 
\begin{codeexample}[]
\begin{tikzpicture}
  \node[starburst, fill=yellow, draw=red, line width=2pt] {\bf BANG!};
\end{tikzpicture}
\end{codeexample}	
	Like the |star| shape, the starburst should be thought of as having a set
	of inner points and outer points. The inner points lie on the ellipse
	which tightly fits the node contents (including any |inner sep|).
	
	Using a specified `starburst point height' value, the outer points
	are generated randomly between this value and one quarter of this 
	value. For a given starburst shape the angle between each point is 
	fixed, and is determined by the number of points specified for
	the starburst.
	
	It is important to note that, whilst the maximum possible point 
	height is used to calculate minimum width or height requirements, 
	the outer points are randomly generated, so there is (unfortunately) 
	no guarantee that any such requirements will be fully met. 
	
\begin{codeexample}[]
\begin{tikzpicture}
  \draw[help lines] grid(3,2);
  \node[starburst, draw, minimum width=3cm, minimum height=2cm] 
    at (1.5, 1) {\bf BOOM!};
\end{tikzpicture}
\end{codeexample}

	There are \pgfname{} keys to control the drawing of the starburst
	shape. To use these keys in \tikzname,	simply remove the 
	\declare{|/pgf/|}	path.

	\begin{key}{/pgf/starburst points=\meta{integer} (initially 17)}
		Set the number of points for the starburst.
	\end{key}
	\begin{key}{/pgf/starburst point height=\meta{length} (initially .5cm)}
      Set the \emph{maximum} distance between the inner point radius  
      and the outer point radius.
	\end{key}
	
	\begin{key}{/pgf/random starburst=\meta{integer} (initially 100)}
      Set the seed for the random number generator for creating the
      starburst.  The maximum value for \meta{integer} is |16383|.
      If \meta{integer}|=0|, the random number generator will not be 
      used, and the maximum point height will be used for all outer 
      points. If \meta{integer} is omitted, a seed will be randomly
      chosen.
	\end{key}
	
	The basic anchors for a nine point |starburst| shape are shown below. 
	Anchor |80| is an example of a border anchor.
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=starburst, starburst points=9, starburst point height=3.5cm, 
        style=shape example,inner sep=1cm] 
    {Starburst\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {outer point 1/above, outer point 2/above, outer point 3/right,
     outer point 4/above, outer point 5/below, outer point 6/above,
     outer point 7/left,  outer point 8/above, outer point 9/above,
     inner point 1/below, inner point 2/above, inner point 3/left,
     inner point 4/above, inner point 5/above, inner point 6/above,
     inner point 7/below, inner point 8/above, inner point 9/below,
     center/above, text/left,   mid/right, base/below, 80/above,
     north/below,  south/below, east/left, west/right,
     north east/below, south west/below, south east/below, north west/below}
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{signal}

	This shape is a ``signal'' or sign shape, that is, a rectangle, with
	optionally pointed sides. A signal can point ``to'' somewhere, with 
	outward points in that direction. It can also be ``from'' 
	somewhere, with inward points from that direction. The resulting 
	points extend the node contents (which include the |inner sep|).
	
\begin{codeexample}[]
\begin{tikzpicture}[every node/.style={signal, draw,  text=white}]
  \node[fill=green!65!black, signal to=east] at (0,1) {To East};
  \node[fill=red!65!black, signal from=east] at (0,0) {From East};
\end{tikzpicture}
\end{codeexample}

	There are \pgfname{} keys for drawing the signal shape (to use these
	keys in \tikzname{}, simply remove the \declare{|/pgf/|} path):
	
	\begin{key}{/pgf/signal pointer angle=\meta{angle} (initially 90)} 
		Set the angle for the pointed sides of the shape. This angle is
		maintained when enforcing any minimum size requirements, so
		any adjustment to the width will affect the height, and vice versa.
	\end{key}
	
	\begin{key}{/pgf/signal from=\meta{direction}\space\opt{and \meta{opposite direction}} (initially nowhere)} 
		Set which sides take an inward pointer (i.e., that points towards the
		center of the shape). The possible values for \meta{direction} and 
		\meta{opposide direction} are the compass point directions |north|,
		|south|, |east| and |west| (or |above|, |below|, |right| and |left|).
		An additional keyword |nowhere| can be used to reset the sides so 
		they have no pointers. When used with |signal from| key, this only 
		resets inward pointers;	used with the |signal to| key, it only 
		resets outward pointers. 
		
	\end{key}
	
	\begin{key}{/pgf/signal to=\meta{direction}\space\opt{and \meta{opposite direction}} (initially east)} 
		Set which sides take an outward pointer (i.e., that points away from 
		the	the shape). 
	\end{key}
	
	Note that \pgfname{} will ignore any instruction to use directions
	that are not opposites (so using the value |east and north|, will
	result in only |north| being assigned a pointer). This is also 
	the case if non-opposite values are used in the |signal to| and
	|signal from| keys at the same time. So, for example, it is not 
	possible for a signal to have an outward point to the left, and also
	have an inward point from below.
	
	The anchors for the signal shape are shown below. Anchor |70| is an
	example of a border anchor.

\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=signal, signal from=west, shape example, inner sep=2cm] 
    {Signal\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {text/left,   center/above,    70/above,
     base/below,  base east/below, base west/below,
     mid/right,   mid east/above left,  mid west/above left, 
     north/above,      south/below, 
     east/above,       west/above,        
     north west/above, north east/above, 
     south west/below, south east/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}





\begin{shape}{tape}
	This shape is a rectangle with optional, ``bendy'' top and bottom
	sides, which tightly fits the node contents (including the 
	|inner sep|).
	
\begin{codeexample}[]
\begin{tikzpicture}
  \node[tape, draw]{ABCD};
  \node[tape, draw, tape bend top=none] at (1.5, 0) {EFGH};
\end{tikzpicture}
\end{codeexample}

  There are \pgfname{} keys to specify which sides bend and how high
  the bends are (to use these keys in \tikzname{}, simply remove the
  \declare{|/pgf/|} path):
  
  \begin{key}{/pgf/tape bend top=\meta{bend style} (initially in and out)}
  	Specify how the top side bends. The \meta{bend style} is either
  	|in and out|, |out and in| or |none| (i.e., a straight line). 
  	The bending sides are drawn in a 
  	clockwise direction, and using the bend style |in and out| will mean 
  	the side will first	bend inwards and then bend outwards. 
  	The opposite holds true for	|out and in|. 
  	
\begin{codeexample}[]
\begin{tikzpicture}[-stealth]
  \node[tape, draw, gray, minimum width=2cm](t){Tape};
  \draw [blue]([yshift=5pt] t.north west) -- ([yshift=5pt]t.north east) 
         node[midway, above, black]{in and out};
  \draw [blue]([yshift=-5pt]t.south east) -- ([yshift=-5pt]t.south west) 
         node[sloped, allow upside down, midway, above, black]{in and out};
\end{tikzpicture}
\end{codeexample}  

    This might take a bit of getting used to, but just remember that 
    when you want the bendy sides to be parallel, the sides take the 
    same bend style. It is possible for the top and bottom sides to 
    take opposite bend styles, but the author of this shape cannot 
    think of a single use for such a combination.
    
\begin{codeexample}[]
\begin{tikzpicture}
  \tikzstyle{every node}=[tape, draw]
  \node [tape bend top=out and in, tape bend bottom=out and in] {Parallel};
  \node at (2,0) [tape bend bottom=out and in]                  {Why?};
\end{tikzpicture}
\end{codeexample} 

	\end{key}
	
	\begin{key}{/pgf/tape bend bottom=\meta{bend style} (initially in and out)}
		Specify how the bottom side bends.
	\end{key}%
	
	\begin{key}{/pgf/tape bend height=\meta{length} (initially 5pt)}
		Set the total height for a side with a bend.
		
\begin{codeexample}[]
\begin{tikzpicture}[>=stealth]
  \draw [help lines] grid(3,2);
  \node [tape, fill, minimum size=2cm, red!50, tape bend top=none,
         tape bend height=1cm] at (1.5,1.5) (t) {};
  \draw [|<->|, blue] (1.5,0) -- (1.5,1) 
         node [at end, above, black]{tape bend height};
\end{tikzpicture}
\end{codeexample} 
 
	\end{key}
	
	The anchors for the tape shape are shown below. Anchor |60| is an
	example of a border anchor. Note that border anchors will snap to
	the center of convex curves (i.e. when bending in). 
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=tape, tape bend height=1cm, shape example, inner xsep=3cm] 
    {Tape\vrule width1pt height2cm};
   \foreach \anchor/\placement in
    {text/left,  center/above,    60/above, 
     base/below, base east/below, base west/below,
     mid/right,  mid east/left,   mid west/right,  
     north/above, south/below,  east/above, west/above,        
     north west/above, north east/above, 
     south west/below, south east/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}%



\subsection{Arrow Shapes}

\begin{pgflibrary}{shapes.arrows}
  This library defines arrow shapes. Note that an arrow shape is
  something quite different from a (normal) arrow tip: It is a shape
  that just ``happens'' to ``look like'' an arrow. In particular, you
  cannot use these shapes as arrow tips.
\end{pgflibrary}

\begin{shape}{single arrow}
	This shape is an arrow, which tightly fits the note contents 
	(including any |inner sep|). 
	This shape supports the rotation of the shape border, as 
	described in Section~\ref{section-rotating-shape-borders}. 
	The angle of rotation determines which direction the arrow
	points (provided no other rotational transformations are applied).
	
\begin{codeexample}[]
\begin{tikzpicture}[every node/.style={single arrow, draw},
    rotate border/.style={shape border uses incircle, shape border rotate=#1}]
  \node {right};
  \node at (2,0) [shape border rotate=90]{up};
  \node at (1,1) [rotate border=37, inner sep=0pt]{$37^\circ$};
\end{tikzpicture}
\end{codeexample}

	Regardless of the rotation of the arrow border, the width is 
  measured between the back ends of the arrow head, and the 
  height is measured from the arrow tip to the end of the arrow 
  tail.

\begin{codeexample}[]
\begin{tikzpicture}[>=stealth, 
    rotate border/.style={shape border uses incircle, shape border rotate=#1}]
  \node[rotate border=-30, fill=gray!25, minimum height=3cm, single arrow, 
    single arrow head extend=.5cm, single arrow head indent=.25cm] (arrow) {};
  \draw[red, <->] (arrow.before tip) -- (arrow.after tip)
    node [near end, left, black] {width};
  \draw[red, <->] (arrow.tip) -- (arrow.tail)
    node [near end, below left, black] {height};
\end{tikzpicture}
\end{codeexample}

	There are \pgfname{} keys that can be used to customize this shape (to
	use these keys in \tikzname{}, simply remove the \declare{|/pgf/|}
	path).
	
\begin{key}{/pgf/single arrow tip angle=\meta{angle} (initially 90)}
  Set the angle for the arrow tip. Enlarging the arrow to some
  minimum width may increase the the height of the shape to maintain
  this angle.
\end{key}

\begin{key}{/pgf/single arrow head extend=\meta{length} (initially .5cm)}
  This sets the distance between the tail of the arrow and the outer
  end of the arrow head. This may change if the shape is enlarged to
  some minimum width.
  
\begin{codeexample}[]
\begin{tikzpicture}
  \node[single arrow, draw, single arrow head extend=.5cm, gray!50, rotate=60] 
     (a) {Arrow};
  \draw[red, |<->|] (a.before tip) -- (a.before head) 
    node [midway, below, sloped, black] {head extend};
\end{tikzpicture}
\end{codeexample}
\end{key}

\begin{key}{/pgf/single arrow head indent=\meta{length} (initially 0cm)}
  This moves the point where the arrow head joins the shaft of the
  arrow \emph{towards} the arrow tip, by \meta{length}.
  
\begin{codeexample}[]
\begin{tikzpicture}[every node/.style={single arrow, draw=none, rotate=60}]
  \node [fill=red!50]                                           {arrow 1};
  \node [fill=blue!50, single arrow head indent=1ex] at (1.5,0) {arrow 2};
\end{tikzpicture}
\end{codeexample}
\end{key}

  The anchors for this shape are shown below (anchor |20| is an 
  example of a border anchor).
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=single arrow, shape example, single arrow head extend=1.5cm] 
    {Single Arrow\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {text/above,      center/above, 20/above,
     mid west/left,   mid/above,    mid east/above left,
     base west/below, base/below,   base east/below,
     tip/above, before tip/above, after tip/below, before head/above, 
     after head/below, after tail/above, before tail/below, tail/right,   
     north/above, south/below, east/below, west/above,
     north west/above, north east/below, south west/below, south east/above}    
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}





\begin{shape}{double arrow}
  This shape is a double arrow, which tightly fits the note contents 
	(including any |inner sep|), and supports the rotation of the shape
	 border, as described in Section~\ref{section-rotating-shape-borders}. 
	 
	
\begin{codeexample}[]
\begin{tikzpicture}[every node/.style={double arrow, draw}]
  \node [double arrow, draw] {Left or Right};
\end{tikzpicture}
\end{codeexample}

  The double arrow behaves exactly like the single arrow, so you
  need to remember that the width is \emph{always} the distance
  between the back ends of the arrow heads, and the height
  is \emph{always} the the tip-to-tip distance.
  
\begin{codeexample}[]
\begin{tikzpicture}[>=stealth, 
    rotate border/.style={shape border uses incircle, shape border rotate=#1}]
  \node[rotate border=210, fill=gray!25, minimum height=3cm, double arrow, 
    double arrow head extend=.5cm, double arrow head indent=.25cm] (arrow) {};
  \draw[red, <->] (arrow.before tip 1) -- (arrow.after tip 1)
    node [near start, right, black] {width};
  \draw[red, <->] (arrow.tip 1) -- (arrow.tip 2)
    node [near end, above left, black] {height};
\end{tikzpicture}
\end{codeexample}

  The \pgfname{} keys that can be used to customize the double arrow 
  behave similarly to the keys for the single arrow (to
	use these keys in \tikzname{}, simply remove the \declare{|/pgf/|}
	path).
  
\begin{key}{/pgf/double arrow tip angle=\meta{angle} (initially 90)}
  Set the angle for the arrow tip. Enlarging the arrow to some
  minimum width may increase the the height of the shape to maintain
  this angle.
\end{key}

\begin{key}{/pgf/double arrow head extend=\meta{length} (initially .5cm)}
  This sets the distance between the shaft of the arrow and the outer
  end of the arrow heads. This may change if the shape is enlarged to
  some minimum width.
\end{key}

\begin{key}{/pgf/double arrow head indent=\meta{length} (initially 0cm)}
  This moves the point where the arrow heads join the shaft of the
  arrow \emph{towards} the arrow tips, by \meta{length}.
  \begin{codeexample}[]
\begin{tikzpicture}[every node/.style={double arrow, draw=none, rotate=-60}]
  \node [fill=red!50]                                           {arrow 1};
  \node [fill=blue!50, double arrow head indent=1ex] at (1.5,0) {arrow 2};
\end{tikzpicture}
\end{codeexample}
\end{key}


  The anchors for this shape are shown below (anchor |20| is an 
  example of a border anchor).
  
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=double arrow, double arrow head extend=1.5cm, shape example, inner xsep=2cm] 
    {Double Arrow\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {text/above, center/above, 20/above,
     mid west/above right, mid/above, mid east/above left,
     base west/below, base/below, base east/below,
     before head 1/above, before tip 1/above, tip 1/above, after tip 1/below, after head 1/below,
     before head 2/above, before tip 2/below, tip 2/above, after tip 2/above, after head 2/below,
     north/above, south/below, east/below, west/below,
     north west/below, north east/below, south west/above, south east/above}    
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}




\begin{shape}{arrow box}
This shape is a rectangle with optional arrows which extend from the
four sides.

\begin{codeexample}[]
\begin{tikzpicture}
  \node[arrow box, draw] {A};
  \node[arrow box, draw, arrow box arrows={north:.5cm, west:0.75cm}] 
    at (2,0) {B};
\end{tikzpicture}
\end{codeexample}

Any minimum size requirements are applied to the main rectangle
\emph{only}. This does not pose too many problems if you wish to
accommodate the length of the arrows, as it is possible to specify 
the length of each arrow independently, from either the border of the
rectangle (the default) or the center of the rectangle.

\begin{codeexample}[]
\begin{tikzpicture}
	\tikzset{box/.style={arrow box, fill=#1}}
	\draw [help lines] grid(3,2);
  \node[box=blue!50, arrow box arrows={east:2cm}]             at (1,1.5){One};
  \node[box=red!50,  arrow box arrows={east:2cm from center}] at (1,0.5){Two};
\end{tikzpicture}
\end{codeexample}

There are various \pgfname{} keys for drawing this shape (to use these
keys in \tikzname, simply remove the \declare{/pgf/} path).

\begin{key}{/pgf/arrow box tip angle=\meta{angle} (initially 90)}
  Set the angle at the arrow tip for all four arrows. 
\end{key}

\begin{key}{/pgf/arrow box head extend=\meta{length} (initially .125cm)}
  Set the the distance the arrow head extends away from the the shaft
  of the arrow. This applies to all arrows.
\end{key}

\begin{key}{/pgf/arrow box head indent=\meta{length} (initially 0cm)}
  Move the point where the arrow head joins the shaft of the arrow
  \emph{towards} the arrow tip. This applies to all arrows.
\end{key}

\begin{key}{/pgf/arrow box shaft width=\meta{length} (initially .125cm)}
  Set the width of the shaft of all arrows.
\end{key}

\begin{key}{/pgf/arrow box north arrow=\meta{distance} (initially .5cm)}
  Set distance the north arrow extends from the node. By default this
  is from the border of the shape, but by using the additional keyword
  |from center|, the distance will be measured from the center of the
  shape. If \meta{distance} is |0pt| or a negative distance, the arrow
  will not be drawn.
\end{key}

\begin{key}{/pgf/arrow box south arrow=\meta{distance} (initially .5cm)}
	Set distance the south arrow extends from the node.
\end{key}

\begin{key}{/pgf/arrow box east arrow=\meta{distance} (initially .5cm)}
	Set distance the east arrow extends from the node.
\end{key}

\begin{key}{/pgf/arrow box west arrow=\meta{distance} (initially .5cm)}
	Set distance the west arrow extends from the node.
\end{key}

\begin{key}{/pgf/arrow box arrows={\ttfamily\char`\{}\meta{list}{\ttfamily\char`\}}}
  Set the distance that all arrows extend from the node. The 
  specification in \meta{list} consists of the four compass points
  |north|, |south|, |east| or |west|, separated by commas (so the list
  must be contained within braces). 
  The distances can be specified after each side separated by a colon 
  (e.g., |north:1cm|, or |west:5cm from center|). 
  If an item specifies no distance, the most recently specifed 
  distance will be used (at the start of the list this is |0cm|,
  so the first item in the list should specify a distance). 
  Any sides not specified will not be drawn with an arrow.
\end{key}

The anchors for this shape are shown below (unfortunately due to its
size, this example must be rotated). Anchor |75| is an example of a
border anchor.
If a side is drawn without an arrow, the anchors for that arrow should 
be considered unavailable. They are (unavoidably) defined, but default 
to the center of the appropriate side.

\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[shape=arrow box, shape example, inner xsep=1cm, inner ysep=1.5cm, arrow box shaft width=2cm,
    arrow box arrows={north:3.5cm from border, south, east:5cm from border, west}, 
    arrow box head extend=0.75cm, rotate=-90](s) {Arrow Box\vrule width1pt height2cm};
  \foreach \anchor/\placement in
   {center/above, text/above, mid/right, base/below, 75/above,
    mid east/right, mid west/left, base east/right, base west/left,
    north/below, south/below, east/below, west/below,
    north east/above, south east/above, south west/below, north west/below,
    north arrow tip/above,south arrow tip/above, east arrow tip/above, west arrow tip/above,
    before north arrow/above, before north arrow head/below left, before north arrow tip/above left, 
    after north arrow tip/above right, after north arrow head/below right, after north arrow/below,
    before south arrow/below, before south arrow head/above right, before south arrow tip/below right, 
    after south arrow tip/below left, after south arrow head/above left, after south arrow/above,
    before east arrow/above, before east arrow head/above right, before east arrow tip/above, 
    after east arrow tip/below, after east arrow head/below right, after east arrow/below, 
    before west arrow/below, before west arrow head/below left, before west arrow tip/below, 
    after west arrow tip/above, after west arrow head/above left, after west arrow/below}
      \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
        node[\placement, rotate=-90] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}



\subsection{Shapes with Multiple Text Parts}

\begin{pgflibrary}{shapes.multipart}
  This library defines general-purpose shapes that are composed of
  multiple (text) parts. 
\end{pgflibrary}


\begin{shape}{circle split}
  This shape is a multi-part shape consisting of a circle with a line
  in the middle. The upper part is the main part (the |text| part),
  the lower part is the |lower| part.
  
\begin{codeexample}[]
\begin{tikzpicture}
  \node [circle split,draw,double,fill=red!20]
  {
    $q_1$
    \nodepart{lower}
    $00$
  };
\end{tikzpicture}
\end{codeexample}

  The shape inherits all anchors from the |circle| shape and defines
  the |lower| anchor in addition. See also the
  following figure:
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=circle split,shape example] {text\nodepart{lower}lower};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/below, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, lower/left, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}


\begin{shape}{ellipse split}
	This shape is a multi-part shape consisting of an ellipse with a line
  in the middle. The upper part is the main part (the |text| part),
  the lower part is the |lower| part.  
  The anchors for this shape are shown below. Anchor |60| is a border anchor.
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=ellipse split,shape example] {text\nodepart{lower}lower};
  \foreach \anchor/\placement in
    {center/below, text/left, lower/left, 60/above right,
     mid/above, mid east/above, mid west/above,
     base/right, base east/left, base west/right,
     north/above, south/below, east/below, west/below,
     north east/above, south east/below, south west/below, north west/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}


\begin{shape}{rectangle split}
  This shape is a rectangle which can optionally be split into 
  two, three or four node parts, or even used with a single node 
  part. 

\begin{codeexample}[]
\begin{tikzpicture}[every text node part/.style={text centered}]
  \node[rectangle split, rectangle split parts=3, draw, text width=2.75cm] 
    {Student
     \nodepart{second}
       age:int \\
       name:String
     \nodepart{third}
       getAge():int \\
       getName():String};
\end{tikzpicture}
\end{codeexample} 

  
  The contents of node parts which are not used are ignored. 
  Which node parts are used in each case is shown below:

\begin{codeexample}[]
\begin{tikzpicture}
  \foreach \a/\x/\y in {1/0/0, 2/1.5/0, 3/0/-1.5, 4/1.5/-1.5}
  \node[rectangle split, rectangle split parts=\a, draw, anchor=north] 
    at (\x,\y){
      text
    \nodepart{second}
      second
    \nodepart{third}
      third
    \nodepart{fourth}
      fourth};
\end{tikzpicture}
\end{codeexample} 

  There are several \pgfname{} keys to specify how the shape is
  drawn. To use these keys in \tikzname, simply remove the 
  \declare{|/pgf/|} path:
  
  \begin{key}{/pgf/rectangle split parts=\meta{number} (initially 4)}
    Split the rectangle into \meta{number} parts, 
    which should be in the range |1| to |4|.
  \end{key}
  
  \begin{key}{/pgf/rectangle split empty part height=\meta{length} (initially 1ex)}
    Set the default height for a node part box if it is empty.
  \end{key}
  
  \begin{key}{/pgf/rectangle split part align={\ttfamily\char`\{}\meta{list}{\ttfamily\char`\}} (initially center)}
  	Set the alignment of the boxes inside the node parts.
  	There should be a maximum of four entries in \meta{list}, 
  	separated by commas (so if there is more than one entry in 
  	\meta{list} it must be surrounded by braces).
  	Each entry is one of |left|,
    |right|, or |center|. If \meta{list} has less entries than 
    node parts then the remaining node parts are aligned according to 
    the last entry in the list.    
    Note that this only aligns the boxes in each part and \emph{does not} 
    affect the alignment of the contents of the boxes.
    
\begin{codeexample}[]
\def\v#1{\vrule width#1ex height2ex}
\def\x{\v2 \nodepart{second} \v5 \nodepart{third} \v2 \nodepart{fourth} \v2}
\begin{tikzpicture}[every node/.style={rectangle split, draw, text=blue!40}]
  \node[rectangle split part align={center, left, right}] at (0,0)    {\x};
  \node[rectangle split part align={center, left}]        at (1.25,0) {\x};
  \node[rectangle split part align={center}]              at (2.5,0)  {\x};
\end{tikzpicture}
\end{codeexample}
  \end{key}
   
  \begin{key}{/pgf/rectangle split draw splits=\meta{boolean} (initially true)}
  	Set whether the line or lines between node parts will be drawn.
  	Internally, this sets the \TeX-if |\ifpgfrectanglesplitdrawsplits| 
  	appropriately.
  \end{key}
  
  \begin{key}{/pgf/rectangle split use custom fill=\meta{boolean} (initially false)}
    This enables the use of a custom fill for each of the node
    parts (including the area covered by the |inner sep|). The 
    background path for the shape should not be filled (e.g., in
    \tikzname{}, the |fill|
    option for the node must be implicity or explicitly set to |none|).
    Internally, this key sets the \TeX-if 
    |\ifpgfrectanglesplitusecustomfill| appropriately.
  \end{key}
  
  \begin{key}{/pgf/rectangle split part fill={\ttfamily\char`\{}\meta{list}{\ttfamily\char`\}} (initially white)}
  	Set the custom fill color for each node part shape. 
  	There should be a maximum of four entries in \meta{list} (one 
  	for each node part), separated by commas (so if there is more than 
  	one entry in \meta{list} it must be surrounded by braces).
  	If \meta{list}  has less entries than node
    parts then the remaining node parts use the color from
    the last entry in the list. This key will automatically set
    |/pgf/rectangle split use custom fill|.
    
\begin{codeexample}[]
\begin{tikzpicture}
  \tikzset{every node/.style={rectangle split, draw, minimum width=.5cm}}
  \node[rectangle split part fill={red!50, green!50, blue!50, yellow!50}]  {};
  \node[rectangle split part fill={red!50, green!50, blue!50}] at (0.75,0) {};
  \node[rectangle split part fill={red!50, green!50}]          at (1.5,0)  {};
  \node[rectangle split part fill={red!50}]                    at (2.25,0) {};
\end{tikzpicture}
\end{codeexample}

	\end{key}
	
  The anchors for the |rectangle split| shape, are
  shown below (anchor |70| is an example of a border angle). When a 
  node part is missing (i.e., when the number of parts is less than 
  |4|), the anchors prefixed with name of that node part should be 
  considered unavailable. They are (unavoidably) defined, but default 
  to other anchor positions.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=rectangle split, rectangle split parts=4, shape example] 
    {\nodepart{text}Text\nodepart{second}Second
		\nodepart{third}Third\nodepart{fourth}fourth};
  \foreach \anchor/\placement in
    {text/left,   text east/above,   text west/above, 
     second/left, second east/above, second west/above,    
     third/left,  third east/below,  third west/below,
     fourth/left, fourth east/below, fourth west/below,
     text split/left,   text split east/above,   text split west/above,
     second split/left, second split east/above, second split west/above,    
     third split/left,  third split east/below,  third split west/below, 
     north/above,  south/below,  east/below,  west/below,  
     center/above, 70/above,     mid/above,   base/below,
     north west/above, north east/above, south west/below, south east/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}





\subsection{Callout Shapes}

\begin{pgflibrary}{shapes.callout}
  Producing basic callouts can be done quite easily in \pgfname{} and 
	\tikzname{} by creating a node and then subsequently drawing a path
	from the border of the node to the required point. This library
	provides more fancy, `balloon'-style callouts.
    
\end{pgflibrary}

Callouts consist of a 
main shape, and a pointer (which is part of the shape) which points
to something in (or outside) the picture. The position on the border
of the main shape to which the pointer is connected is determined
automatically. However, the pointer is ignored when calculating the 
minimum size of the shape, and also when positioning anchors.

\begin{codeexample}[]
\begin{tikzpicture}[remember picture]
  \node[ellipse callout, draw] (hallo) {Hallo!};
\end{tikzpicture}
\end{codeexample}

There are two kinds of pointer:	the ``relative'' pointer and the 
``absolute'' pointer.	The relative pointer calculates the angle of a
specified coordinate relative to the center of the main shape, locates 
the point on the border to which this angle corresponds, and then adds 
the coordinate to this point. This seemingly over-complex approach 
means than you do not have to guess the size of the main shape: the 
relative pointer will always be outside. 
The absolute pointer, on the 
other hand, is much simpler: it points to the specified coordinate
absolutely (and can even point to named coordinates in different 
pictures).


\begin{codeexample}[]
\begin{tikzpicture}[remember picture, note/.style={rectangle callout, fill=#1}]
  \draw [help lines] grid(3,2);
  \node [note=red!50,  callout relative pointer={(0,1)}] at (3,1) {Relative};
  \node [note=blue!50, callout absolute pointer={(0,1)}] at (1,0) {Absolute};
  \node [note=green!50, opacity=.5, overlay, 
         callout absolute pointer={(hallo.south)}]       at (1,2) {Outside};
\end{tikzpicture}
\end{codeexample}


The following keys are common to all callouts. Please remember
that the |callout| |relative| |pointer|, and |callout| |absolute|
|pointer| keys take a different format for their value depending 
on whether they are being used in \pgfname{} or \tikzname{}.
  
  
\begin{key}{/pgf/callout relative pointer=\meta{coordinate} (initially {\ttfamily\char`\\pgfpointpolar\char`\{315\char`\}\char`\{.5cm\char`\}})}
  
  Set the vector of the callout pointer `relative' to the callout 
  shape. 
  
\end{key}

\begin{key}{/pgf/callout absolute pointer=\meta{coordinate}}
  
  Set the vector of the callout pointer absolutely within the picture.
  
\end{key}



\begin{key}{/tikz/callout relative pointer=\meta{coordinate} (initially {(315:.5cm)})}
	The \tikzname{} version of the |callout relative pointer| key. Here,
	\meta{coordinate} can be specified using the \tikzname{} format for
	coordinates.
\end{key}

\begin{key}{/tikz/callout absolute pointer=\meta{coordinate}}
	The \tikzname{} version of the |callout absolute pointer| key. Here,
	\meta{coordinate} can be specified using the \tikzname{} format for
	coordinates.
\end{key}

	It is also possible to shorten the pointer by some distance, using 
	the following key:
	
\begin{key}{/pgf/callout pointer shorten=\meta{distance} (initially 0cm)}
	Move the callout pointer towards the center of the callouts main 
	shape by \meta{distance}. 
	
\begin{codeexample}[]
\begin{tikzpicture}
	\tikzset{callout/.style={ellipse callout, callout pointer arc=30,
	  callout absolute pointer={#1}}}
  \draw (0,0) grid (3,2);
  \node[callout={(3,1.5)}, fill=red!50] at (0,1.5) {A};
  \node[callout={(3,.5)},  fill=green!50, callout pointer shorten=1cm]          
    at (0,.5)  {B};
\end{tikzpicture} 
\end{codeexample}
\end{key}
	
  
\begin{shape}{rectangle callout}%
	
  This shape is a callout whose main shape is a rectangle, which 
  tightly fits the node contents (including any |inner sep|).
  It  supports the keys described above and also the following 
  key:
  
  
\begin{key}{/pgf/callout pointer width=\meta{length} (initially .25cm)} 
  Set the width of the pointer at the border of the rectangle.
\end{key}
		
	The anchors for this shape are shown below (anchor |60| is an
	example of a border anchor). The pointer direction is ignored when 
	placing anchors. 
	Additionally, when using an absolute pointer, the |pointer| 
	anchor should not be used to used to position the shape as it is 
	calculated whilst the shape is being drawn.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=rectangle callout, callout relative pointer={(1.25cm,-1cm)}, 
     callout pointer width=2cm, shape example, inner xsep=2cm, inner ysep=1cm] 
  	{Rectangle Callout\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {center/above, text/below,      60/above,
     mid/right,    mid west/left,  mid east/right, 
     base/below,   base west/below, base east/below, 
     north/above,  south/below, east/above, west/above,
     north west/above, north east/above,     
     south west/below, south east/below,
     pointer/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}%


\begin{shape}{ellipse callout}%
	
  This shape is a callout whose main shape is a ellipse, which 
  tightly fits the node contents (including any |inner sep|).
  It uses the |absolute callout pointer|, 
	|relative callout pointer| and |callout pointer shorten| keys, and
	also the following key:
  
  
\begin{key}{/pgf/callout pointer arc=\meta{angle} (initially 15)} 
  Set the width of pointer at the border of the ellipse according
  to an arc of length \meta{angle}.
\end{key}
	
	
	The anchors for this shape are shown below (anchor |60| is an
	example of a border anchor). The pointer direction is ignored 
	when placing anchors and the |pointer| anchor can only be
	used to position the shape when the relative anchor is 
	specified.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=ellipse callout, callout relative pointer={(1.25cm,-1cm)}, 
    callout pointer width=2cm, shape example, inner xsep=1cm, inner ysep=.5cm] 
  	{Ellipse Callout\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {center/above, text/below,      60/above,
     mid/above,    mid west/right,  mid east/left, 
     base/below,   base west/below, base east/below, 
     north/above,  south/below, east/above, west/above,
     north west/above left,    north east/above right,     
     south west/below left,    south east/below right,
     pointer/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}


\begin{shape}{cloud callout}
This shape is a callout whose main shape is a cloud which fits the 
node contents. The pointer is segmented, consisting of a series of 
shrinking ellipses. This callout requires the symbol shape library 
(for the cloud shape). If this library is not loaded an error will 
result.

\begin{codeexample}[]
\begin{tikzpicture}
  \node[cloud callout, cloud puffs=15, aspect=2.5, cloud puff arc=120, 
    shading=ball,text=white] {\bf Imagine...};
\end{tikzpicture}
\end{codeexample}

The |cloud callout| supports the |absolute callout pointer|,
|relative callout pointer| and |callout pointer shorten| keys, as 
described above.
The main shape can be modified using the same keys as the |cloud| 
shape. The following keys are also supported:

\begin{key}{/pgf/callout pointer start size=\meta{value} (initially .2 of callout)}
	Set the size of the first segment in the pointer (i.e., the segment
	nearest the main cloud shape). There are three possible forms for
	\meta{value}:
	\begin{itemize}
		\item
			A single dimension (e.g., |5pt|), in which case the first ellipse 
			will have equal diameters of 5pt.
		\item
			Two dimensions (e.g., |10pt and 2.5pt|), which sets the $x$ and 
			$y$ diameters of the first ellipse.
		\item
			A decimal fraction (e.g., |.2 of callout|), in which case
			the $x$ and $y$ diameters of the first ellipse will be set as 
			fractions of the width and height of the main shape. The keyword
			|of callout| cannot be omitted.	
	\end{itemize}
\end{key}

\begin{key}{/pgf/callout pointer end size=\meta{value} (initially .1 of callout)}
	Set the size of the last ellipse in the pointer.
\end{key}

\begin{key}{/pgf/callout pointer segments=\meta{number} (initially 2)}
	Set the number of segments in the pointer. Note that \pgfname{} will 
	happily	overlap segments if too many are specified. 
\end{key}

The anchors for this shape are shown below (anchor |70| is an example 
of a border anchor). The pointer direction is ignored when placing 
anchors and the pointer anchor can only be used to position the
shape when the relative anchor is specified. Note that the center
of the last segment is drawn at the |pointer| anchor.

\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s, shape=cloud callout, style=shape example, cloud puffs=11, aspect=1.5,
    cloud puff arc=120,inner xsep=.5cm, callout pointer start size=.25 of callout,
    callout pointer end size=.15 of callout, callout relative pointer={(315:4cm)},
    callout pointer segments=2] {Cloud Callout\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {puff 1/above, puff 2/above, puff 3/above, puff 4/below,
     puff 5/left, puff 6/below, puff 7/below, puff 8/right,
     puff 9/below, puff 10/above, puff 11/above, 70/right,
     center/above, base/below, mid/right, text/left,
     north/below, south/below, east/above, west/above,
     north west/left, north east/right,
     south west/below, south east/below,pointer/above}
  \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
    node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}%
\end{shape}




\subsection{Logic Gate Shapes}

\subsubsection{Overview}
	\pgfname{} provides two libraries of logic gates, one providing
	``American'' style gates and the other, providing ``rectangular'' 
	logic gates.	
	Each library suffixes the gate names with an identifer:
	|US| for the American style gates, and |IEC| for the rectangular
	gates (additionally, two shapes in the |US| library use the
	suffix |CDH|). Keys which are specific
	to a particular library	also contain this identifier (e.g., 
	|/pgf/and gate IEC symbol|).
	However, as described below, a \tikzname{} key is provided which
	sets up several styles allowing the identifier to be omitted,
	for example, |and gate| can become a synonym for |shape=and gate US|.
	
	Multiple inputs can be specified for a logic gate (provided they
  support multiple inputs: a not gate --- also known as an inverter ---
  does not). However, there is an upper limit for the number of inputs 
  which has been set at 1024, which should be \emph{way} 
  more than would ever be needed.
    
  There are some \pgfname{} keys which are common to both 
  libraries, which have no library identifier contained in them:
  
  
  \begin{key}{/pgf/logic gate inputs=\meta{input list} (initially \char`\{normal,normal\char`\})}
  Specify the inputs for for the logic gate. The keyword |inverted|
  indicates an inverted input which will mean \pgfname{} will draw a
  circle attached to the main shape of the logic gate. Any keyword
  that is not |inverted| will be treated as a ``normal'' or 
  ``non-inverted'' input (however, for readability, you may wish to 
  use |normal| or |non-inverted|), and \pgfname{} will not draw the 
  circle.  
  In both cases the anchors for the inputs will be set 
  up appropriately, numbered from top to bottom |input 1|, |input 2|,
  \ldots and so on. If the gate only supports one input the anchor
  is simply called |input| with no numerical index.
  
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=0.75cm]
  \node[and gate IEC, draw, logic gate inputs={inverted, normal, inverted}] 
  (A) {};
  \foreach \a in {1,...,3}
    \draw (A.input \a -| -1,0) -- (A.input \a);
  \draw (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample} 
  
  For multiple inputs it may be somewhat unweildy to specify a long
  list, thus, the following ``shorthand'' is permitted (this is an  
  extension of ideas due to Juergen Werber and Christoph Bartoschek):
  Using |i| for inverted and |n| for normal inputs, \meta{input list}
  can be specfied \emph{without the commas}. So, for example,
  |ini| is equivalent to |inverted, normal, inverted|.
  
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=0.75cm]
  \node[or gate US, draw,logic gate inputs=inini] (A) {};
  \foreach \a in {1,...,5}
    \draw (A.input \a -| -1,0) -- (A.input \a);
  \draw (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample} 
 
\end{key}


The height of the gate may be increased to accommodate the number 
of inputs. In fact, it depends on three variables:
$n$, the number of inputs, $r$, the radius of the circle used
to indicate an inverted input and $s$, the distance between
the centers of the inputs.
The default height is then calculated according to the expression 
$(n+1)\times\max(2r,s)$. This then may
be increased to accommodate the node contents or any
minimum size specifications.

The radius of the inverted input circle and the distance between the 
centers of the inputs can be customised using the following keys:

\begin{key}{/pgf/logic gate inverted radius=\meta{length} (initially 2pt)}
  Set the radius of the circle that is used to indicate inverted
  inputs. This is also the radius of the circle used for the inverted
  output of the |nand|, |nor|, |xnor| and |not| gates. 
    
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=0.75cm]
  \tikzset{every node/.style={shape=nand gate CDH, draw, logic gate inputs=ii}}
  \node[logic gate inverted radius=2pt] {A};
  \node[logic gate inverted radius=4pt] at (0,-1) {B};
\end{tikzpicture}
\end{codeexample} 
\end{key}

\begin{key}{/pgf/logic gate input sep=\meta{length} (initially .125cm)}
  Set the distance between the \emph{centers} of the inputs to the
  logic gate. 
  
\begin{codeexample}[]
\begin{tikzpicture}[minimum size=0.75cm]
  \draw [help lines] grid (3,2);
  \tikzset{every node/.style={shape=and gate IEC, draw, logic gate inputs=ini}}
  \node[logic gate input sep=0.33333cm] at (1,1)(A) {A};
  \node[logic gate input sep=0.5cm]     at (3,1) (B) {B};
  \foreach \a in {1,...,3}
    \draw (A.input \a -| 0,0) -- (A.input \a)
          (B.input \a -| 2,0) -- (B.input \a);
\end{tikzpicture}
\end{codeexample} 
\end{key}


\subsubsection{US Logic Gates}

\begin{pgflibrary}{shapes.gates.logic.US}
 This library provides ``American'' logic gate shapes whose names are 
  suffixed with the identifier |US|. Additionally,
  alternative |and| and |nand| gates are provided which are based on the 
  logic symbols used in A. Croft, R. Davidson, and M. Hargreaves (1992), 
  \emph{Engineering Mathematics}, Addison-Wesley, 82--95. These two 
  shapes are suffixed with |CDH|. 
\end{pgflibrary}

  To use the shapes in \tikzname{} without their suffixes, the 
  following keys are provided:
  
\begin{key}{/tikz/use US style logic gates}
	This allows the the shapes suffixed with |US| to be used without
	the suffix. So, for example, |and gate| becomes a synonym for
	|shape=and gate US|.
\begin{codeexample}[]
\tikz\node[draw, and gate US, red]{and};
\space
\tikz[use US style logic gates,blue]\node[draw, and gate]{and};
\end{codeexample}
\end{key}

\begin{key}{/tikz/use CDH style logic gates}
	This key again allows the the shapes suffixed with |US| to be used 
	without	the |US| suffix. However, |and gate| becomes a synonym for
	|shape=and gate CDH| and |nand gate| becomes a synonym for
	|shape=nand gate CDH|, providing alternative symbols for these
	gates.
	
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=1cm]
  \node[draw, and gate US, red]  at  (0,1.5) {and};
  \node[draw, nand gate US, red] at (2,1.5) {nand};
  \tikzset{use CDH style logic gates}
  \node[draw, and gate, blue]  at (0,0) {and};
  \node[draw, nand gate, blue] at (2,0) {nand};
\end{tikzpicture}
\end{codeexample}
\end{key}



As described above, \pgfname{} will increase the size of the 
logic gate to accommodate the number of inputs, and the size
of the inverted radius and the separation between the inputs.
However with all shapes in this library, any increase in size 
(including any minimum size requirements) will be applied so that 
the default aspect ratio is unaltered. This means that changing
the height will change the width and vice versa. 

The ``compass point'' anchors apply to the main part of the shape
and do not include any inverted inputs or outputs. This library
provides an additonal feature to facilitate the relative positioning
of logic gates:

\begin{key}{/pgf/logic gate anchors use bounding box=\meta{boolean} (initially false)}
When set to |true| this key will ensure that the 
compass point anchors use the bounding rectangle of the
main shape, which, ignore any inverted inputs or outputs, but
includes any |outer sep|. 
This \emph{only} affects the compass point anchors
and is not set on a shape by shape basis: whether the bounding
box is used is determined by value of this key when the anchor
is accessed.

\begin{codeexample}[]
\begin{tikzpicture}[minimum height=1.5cm]
  \node[xnor gate US, draw, gray!50,line width=2pt] (A) {};
  \foreach \x/\y/\z in {false/blue/1pt, true/red/2pt}
    \foreach \a in {north, south, east, west, north east, 
      south east, north west, south west}
      \draw[logic gate anchors use bounding box=\x, color=\y]	
        (A.\a) circle(\z);
\end{tikzpicture}
\end{codeexample} 



\end{key}




\begin{shape}{and gate US}
  This shape is an and gate which supports two or more inputs. If
	less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=and gate US,shape example, inner sep=0cm,
    logic gate inverted radius=.5cm] {And Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/right, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{nand gate US}
  This shape is a nand gate, which supports two or more inputs. If
	less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
 
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=nand gate US,shape example, inner sep=0cm,
  logic gate inverted radius=.5cm] {Nand Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{or gate US}

	This shape is an or gate, which supports two or more inputs. If
	less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=or gate US,shape example, inner sep=0cm,
  logic gate inverted radius=.5cm] {Or Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/left, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{nor gate US}
	This shape is a nor gate, which supports two or more inputs. If
	less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.

\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=nor gate US,shape example, inner sep=0cm,
  logic gate inverted radius=.5cm] {Nor Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/left, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{xor gate US}
  This shape is an xor gate, which supports only two inputs. If
  less than two inputs are specified an error will result. If more
  than two inputs are specified, the extra inputs are ignored.
  The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=xor gate US,shape example, inner sep=0cm,
    logic gate inverted radius=.5cm] {Xor Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{xnor gate US}

	This shape is an xnor gate, which supports only two inputs. If
	less than two inputs are specified an error will result. If more
	than two inputs are specified, the extra inputs are ignored.
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=xnor gate US,shape example, inner sep=0cm,
  logic gate inverted radius=.5cm] {Xnor Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/above, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}


\end{shape}

\begin{shape}{not gate US}
	This shape is a not gate, which supports only one input. If
	no inputs are specified an error will result. If more
	than one input is specified, the extra inputs are ignored.
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=not gate US,shape example, inner sep=1.5cm,
  logic gate inverted radius=.5cm] 
  {Not Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/below,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{buffer gate US}
	This shape is a not gate, which supports only one input. If
	no inputs are specified an error will result. If more
	than one input is specified, the extra inputs are ignored.
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=buffer gate US,shape example, inner sep=1.5cm,
  logic gate inverted radius=.5cm] 
  {Buffer Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/below,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}





\begin{shape}{and gate CDH}
  This shape is the alternative and gate. It supports two or more inputs.
  If less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=and gate CDH,shape example, inner sep=0cm,
    logic gate inverted radius=.5cm] {And Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{nand gate CDH}
  This shape is the alternative nand gate. It supports two or more inputs.
  If less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs (using the normal compass point anchors) are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=nand gate CDH,shape example, inner xsep=0cm,
    logic gate inverted radius=.5cm] {Nand Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}





\subsubsection{IEC Logic Gates}

\begin{pgflibrary}{shapes.gates.logic.IEC}
  This library provides rectangular logic gate shapes. These shapes
  are suffixed with |IEC| as they are based on gates recommended by
  the International Electrotechincal Commission.
\end{pgflibrary}

  In order to use these shapes in \tikzname{} without the |IEC|
  suffix, the following key is provided:
  
\begin{key}{/tikz/use IEC style logic gates}
	This allows the the shapes suffixed with |IEC| to be used without
	the suffix. So, for example, |and gate| becomes a synonym for
	|shape=and gate IEC|. In addtion the |IEC| specific keys can be
	used without |IEC|, so |and gate symbol| can be
	used for |and gate IEC symbol|.
\end{key}

  By default each gate is drawn with a symbol, $\char`\&$ for |and| and 
  |nand| gates, $\geq1$ for |or| and |nor| gates, $1$ for |not| and 
  |buffer| gates, and $=1$ for |xor| and |xnor| gates. These symbols 
  are drawn automatically (internally they are drawn using the 
  ``foreground'' path), and are not strictly speaking part of the node
  contents. However, the gate is enlarged to make sure the symbols are 
  within the border of the node.
  It is possible to change
  the symbols and their position within the node using the following
  keys:
  
\begin{key}{/pgf/and gate IEC symbol=\meta{text} (initially \char`\\char\char`\`\char`\\\char`\&)}
  Set the symbol for the |and gate|. Note that if the node is filled,
  this color will be used for the symbol, making it invisible, so
  it will be necessary set \meta{text} to something like
  |\color{black}\char`\&|. Alternatively, the 
  |logic gate IEC symbol color| key can be used to set the color
  of all symbols simultaneously.
  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |and gate symbol|.
\end{key}

\begin{key}{/pgf/nand gate IEC symbol=\meta{text} (initially \char`\\char\char`\`\char`\\\char`\&)}
  Set the symbol for the |nand gate|.  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |nand gate symbol|.
\end{key}

\begin{key}{/pgf/or gate IEC symbol=\meta{text} (initially \char`\$\char`\\geq1\char`\$)}
  Set the symbol for the |or gate|.  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |or gate symbol|.
\end{key}

\begin{key}{/pgf/nor gate IEC symbol=\meta{text} (initially \char`\$\char`\\geq1\char`\$)}
  Set the symbol for the |nor gate|.  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |nor gate symbol|.
\end{key}

\begin{key}{/pgf/xor gate IEC symbol=\meta{text} (initially \char`\{\char`\$=1\char`\$\char`\})}
  Set the symbol for the |xor gate|. Note the necessity for braces,
  as the symbol contains |=|.
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |or gate symbol|.
\end{key}

\begin{key}{/pgf/xnor gate IEC symbol=\meta{text} (initially  \char`\{\char`\$=1\char`\$\char`\})}
  Set the symbol for the |xnor gate|.  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |xnor gate symbol|.
\end{key}

\begin{key}{/pgf/not gate IEC symbol=\meta{text} (initially 1)}
  Set the symbol for the |not gate|.  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |not gate symbol|.
\end{key}

\begin{key}{/pgf/buffer gate IEC symbol=\meta{text} (initially 1)}
  Set the symbol for the |buffer gate|.  
  In \tikzname, when the |use IEC style logic gates| key has been 
  used, this key can be replaced by |buffer gate symbol|.
\end{key}

\begin{key}{/pgf/logic gate IEC symbol align=\meta{align} (initially top)}
  Set the alignment of the logic gate symbol (in \tikzname, when the 
  |use IEC style logic gates| key has been used, |IEC| can be omitted.
  The specification in \meta{align} is a comma separated list from
  |top|, |bottom|, |left| or |right|. The distance between the border
  of the node and the outer edge of the symbol is determined by the values 
  of the |inner xsep| and |inner ysep|.
  
\begin{codeexample}[]
\begin{tikzpicture}[minimum size=1cm, use IEC style logic gates]
	\tikzset{every node/.style={nor gate, draw}}
  \node (A) at (0,1.5) {};
  \node [logic gate symbol align={bottom, right}] (B) at (0,0) {}; 
  \foreach \g in {A, B}{
    \foreach \i in {1,2}
      \draw ([xshift=-0.5cm]\g.input \i) -- (\g.input \i);
    \draw (\g.output) -- ([xshift=0.5cm]\g.output);
  }
\end{tikzpicture}
\end{codeexample} 

\end{key}


\begin{key}{/pgf/logic gate IEC symbol color=\meta{color}}
  This key sets the color for all symbols simultaneously. This color
  can be overridden on a case by case basis by specifying a color
  when seting the symbol text.
\end{key}


\begin{shape}{and gate IEC}
  This shape is an and gate. It supports two or more inputs.
  If less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=and gate IEC ,shape example, inner xsep=1cm, inner ysep=1cm,
    minimum height=6cm, and gate IEC symbol=\color{black!30}\char`\&] 
  {And Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}


\begin{shape}{nand gate IEC}
  This shape is a nand gate. It supports two or more inputs.
  If less than two inputs are specified an error will result. 
	The anchors for this gate with two
  non-inverted inputs are
  shown below. Anchor |30| is an example of a border anchor.
  
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=nand gate IEC ,shape example, inner xsep=1cm, inner ysep=1cm,
    minimum height=6cm, nand gate IEC symbol=\color{black!30}\char`\&,
    logic gate inverted radius=0.65cm] 
  {Nand Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{or gate IEC}
  This shape is an or gate. It supports two or more inputs.
  If less than two inputs are specified an error will result. 
	See the |and gate IEC| shape for the anchors.
	
\begin{codeexample}[]
\begin{tikzpicture}[minimum width=.875cm, minimum height=1cm]
  \node[or gate IEC, draw, logic gate inputs=in] (A) {};
  \draw (A.input 1 -| -1,0) -- (A.input 1) (A.input 2 -| -1,0) -- (A.input 2)
        (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample} 

\end{shape}


\begin{shape}{nor gate IEC}
  This shape is an nor gate. It supports two or more inputs.
  If less than two inputs are specified an error will result. 
	See the |nand gate IEC| shape for the anchors.
	
\begin{codeexample}[]
\begin{tikzpicture}[minimum width=.875cm, minimum height=1cm]
  \node[nor gate IEC, draw, logic gate inputs=in] (A) {};
  \draw (A.input 1 -| -1,0) -- (A.input 1) (A.input 2 -| -1,0) -- (A.input 2)
        (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{xor gate IEC}
  This shape is an xor gate. It supports only two inputs.
   If less than two inputs are specified an error will result.
  Any extra inputs are ignored.  
		See the |and gate IEC| shape for the anchors.
	
\begin{codeexample}[]
\begin{tikzpicture}[minimum width=.875cm, minimum height=1cm]
  \node[xor gate IEC, draw, logic gate inputs=in] (A) {};
  \draw (A.input 1 -| -1,0) -- (A.input 1) (A.input 2 -| -1,0) -- (A.input 2)
        (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}

\end{shape}


\begin{shape}{xnor gate IEC}
  This shape is an xnor gate. It supports only two inputs.
  If less than two inputs are specified an error will result.
  Any extra inputs are ignored.  
	See the |nand gate IEC| shape for the anchors.
	
\begin{codeexample}[]
\begin{tikzpicture}[minimum width=.875cm, minimum height=1cm]
  \node[xnor gate IEC, draw, logic gate inputs=in] (A) {};
  \draw (A.input 1 -| -1,0) -- (A.input 1) (A.input 2 -| -1,0) -- (A.input 2)
        (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}

\end{shape}

\begin{shape}{buffer gate IEC}
   This shape is a buffer gate. It supports only one input.
  If less than one input is specified an error will result.
  Any extra inputs are ignored. 
	See the |and gate IEC| shape for the anchors.

\begin{codeexample}[]
\begin{tikzpicture}[minimum width=.875cm, minimum height=1cm]
  \node[buffer gate IEC, draw] (A) {};
  \draw (A.input -| -1,0) -- (A.input) (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}

\end{shape}


\begin{shape}{not gate IEC}
  This shape is a not gate. It supports only one input.
  If less than one input is specified an error will result.
  Any extra inputs are ignored. 
  See the |nand gate IEC| shape for the anchors.

\begin{codeexample}[]
\begin{tikzpicture}[minimum width=.875cm, minimum height=1cm]
  \node[not gate IEC, draw] (A) {};
  \draw (A.input -| -1,0) -- (A.input) (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}


\end{shape}






\subsection{Miscellaneous Shapes}

\begin{pgflibrary}{shapes.misc}
  This library defines general-purpose shapes that do not fit in the
  previous categories.
\end{pgflibrary}

\begin{shape}{cross out}
  This shape ``crosses out'' the node. Its foreground path are simply
  two diagonal lines that between the corners of the node's bounding
  box. Here is an example:  
\begin{codeexample}[]
\begin{tikzpicture} 
  \draw [help lines] (0,0) grid (3,2); 
  \node [cross out,draw=red] at (1.5,1) {cross out}; 
\end{tikzpicture}
\end{codeexample}

  A useful application is inside text as in the following example:
\begin{codeexample}[]
Cross \tikz[baseline] \node [cross out,draw,anchor=text] {me}; out!  
\end{codeexample}

  This shape inherits all anchors from the |rectangle| shape, see also
  the following figure:
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=cross out,shape example] {cross out\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}


\begin{shape}{cross out}
  This shape ``crosses out'' the node. Its foreground path are simply
  two diagonal lines that between the corners of the node's bounding
  box. Here is an example:

\begin{codeexample}[]
\begin{tikzpicture}
  \draw[help lines] (0,0) grid (3,2);
  \node [cross out,draw=red] at (1.5,1) {cross out};
\end{tikzpicture}
\end{codeexample}

  A useful application is inside text as in the following example:
\begin{codeexample}[]
Cross \tikz[baseline] \node [cross out,draw,anchor=text] {me}; out!  
\end{codeexample}

  This shape inherits all anchors from the |rectangle| shape, see also
  the following figure:
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=cross out,shape example] {cross out\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right, 
     west/left, center/above, east/right, 
     mid west/right, mid/above, mid east/left, 
     base west/left, base/below, base east/right, 
     south west/below left, south/below, south east/below right, 
     text/left, 10/right, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
\end{shape}

\begin{shape}{strike out}
  This shape is idential to the |cross out| shape, only its foreground
  path consists of a single line from the lower left to the upper
  right.
  
\begin{codeexample}[]
Strike \tikz[baseline] \node [strike out,draw,anchor=text] {me}; out!  
\end{codeexample}

  See the |cross out| shape for the anchors.
\end{shape}




\begin{shape}{rounded rectangle}
	This shape is a rectangle which can be optionally round sides.

\begin{codeexample}[]
\begin{tikzpicture}
  \node[rounded rectangle, draw, fill=red!20]{Hallo};
\end{tikzpicture}
\end{codeexample}

	There are keys to specify how the sides are rounded (to use
	these keys in \tikzname, simply remove the \declare{|/pgf/|} path).


\begin{key}{/pgf/rounded rectangle arc length=\meta{angle} (initially 180)}

	Set the length of the arcs for the rounded ends. Recommended values 
	for	\meta{angle} are between |90| and |180|. 
	
\begin{codeexample}[]
\begin{tikzpicture}
  \matrix[row sep=5pt, every node/.style={draw, rounded rectangle}]{
    \node[rounded rectangle arc length=180] {180}; \\
    \node[rounded rectangle arc length=120] {120}; \\
    \node[rounded rectangle arc length=90]  {90};  \\};
\end{tikzpicture} 
\end{codeexample}

\end{key}

\begin{key}{/pgf/rounded rectangle west arc=\meta{arc type} (initially convex)}
	Set the style of the rounding for the left side. The permitted values
	for \meta{arc type} are |concave|, |convex|, or |none|.

\begin{codeexample}[]
\begin{tikzpicture}
  \matrix[row sep=5pt, every node/.style={draw, rounded rectangle}]{
  	\node[rounded rectangle west arc=concave] {Concave}; \\
  	\node[rounded rectangle west arc=convex]  {Convex};  \\
  	\node[rounded rectangle left arc=none]    {None};    \\};
\end{tikzpicture} 
\end{codeexample}
\end{key}

\begin{stylekey}{/pgf/rounded rectangle left arc=\meta{arc type}}
	Alternative key for specifying the west arc.
\end{stylekey}

\begin{key}{/pgf/rounded rectangle east arc=\meta{arc type} (initially convex)}
	Set the style of the rounding for the east side.
\end{key}

\begin{stylekey}{/pgf/rounded rectangle right arc=\meta{arc type}}
	Alternative key for specifying the east arc.
\end{stylekey}

	The anchors for this shape are shown below (anchor |10| is an example
	of a border angle). Note that if only one side is rounded, the 
	|center| anchor will not be the precise center of the shape.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=rounded rectangle, shape example, inner xsep=1.5cm, inner ysep=1cm] 
  	{Rounded Rectangle\vrule width 1pt height 2cm};
  \foreach \anchor/\placement in
    {center/above, text/below,      10/above,
     mid/above,    mid west/right,  mid east/left, 
     base/below,   base west/below, base east/below, 
     north/above,  south/below, east/above, west/above, 
     north west/above left,    north east/above right,     
     south west/below left,    south east/below right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}


\begin{shape}{chamfered rectangle}

	This shape is a rectangle with optionally chamfered corners.
	
\begin{codeexample}[]
\begin{tikzpicture}
  \node[chamfered rectangle, white, fill=red, double=red, draw, very thick]
    {\bf STOP!};
\end{tikzpicture}
\end{codeexample}

	There are \pgfname{} keys to specify how this shape is drawn (to use
	these keys in \tikzname{} simply remove the \declare{|/pgf/|} path).

\begin{key}{/pgf/chamfered rectangle angle=\meta{angle} (initially 45)}
	Set the angle \emph{from the vertical} for the chamfer.
	
\begin{codeexample}[]
\begin{tikzpicture}
  \tikzset{every node/.style={chamfered rectangle, draw}}
  \node[chamfered rectangle angle=30] {abc};
  \node[chamfered rectangle angle=60] at (1.5,0) {123};
\end{tikzpicture}
\end{codeexample}
\end{key}

\begin{key}{/pgf/chamfered rectangle xsep=\meta{length} (initially .666ex)}
	Set the distance that the chamfer extends horizontally beyond the node 
	contents (which includes the |inner sep|). 
	If \meta{length} is large, such
	that the top and bottom chamfered edges would cross, then 
	\meta{length} is ignored and the chamfered edges are drawn so that
	they meet in the middle.

\begin{codeexample}[]
\begin{tikzpicture}
  \tikzset{every node/.style={chamfered rectangle, draw}}
  \node[chamfered rectangle xsep=2pt] {def};
  \node[chamfered rectangle xsep=2cm] at (1.5,0) {456};
\end{tikzpicture}
\end{codeexample}
	
\end{key}

\begin{key}{/pgf/chamfered rectangle ysep=\meta{length} (initially .666ex)}
	Set the distance that the chamfer extends vertically beyond the node 
	contents. 
	If \meta{length} is large, such that the left and right chamfered 
	edges would cross, then \meta{length} is ignored and the chamfered 
	edges are drawn so that	they meet in the middle.
\end{key}

\begin{key}{/pgf/chamfered rectangle sep=\meta{length} (initially .666ex)}
	Set both the |xsep| and |ysep| simultaneously.
\end{key}

\begin{key}{/pgf/chamfered rectangle corners=\meta{list} (initially chamfer all)}
	Specify which corners are chamfered. The corners are identified by 
	their ``compass point'' directions (i.e. |north east|, |north west|,
	|south west|, and |south east|), and must be separated by commas (so
	if there is more than one corner in the list, it must be surrounded
	by braces). Any corners not mentioned in 
	\meta{list} are automatically not chamfered. Two additional values
	|chamfer all| and |chamfer none|, are also permitted.

\begin{codeexample}[]
\begin{tikzpicture}
  \tikzset{every node/.style={chamfered rectangle, draw}}
  \node[chamfered rectangle corners=north west] {ghi};
  \node[chamfered rectangle corners={north east, south east}] at (1.5,0) {789};
\end{tikzpicture}
\end{codeexample}
\end{key}


	The anchors for this shape are shown below (anchor |60| is an example
	of a border angle.
	
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=chamfered rectangle, chamfered rectangle sep=1cm,
        shape example, inner ysep=1cm, inner xsep=.75cm] 
    {Chamfered Rectangle\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {text/right, center/above,    70/above, 
     base/below, base east/left, base west/right,
     mid/right,  mid east/above,   mid west/above,  
     north/above, south/below, east/above, west/above,
     before north east/above, north east/above, after north east/above,
     before north west/above, north west/above, after north west/above,
     before south west/below, south west/below, after south west/below,
     before south east/below, south east/below, after south east/below}     
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\end{shape}



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "pgfmanual-pdftex-version"
%%% End: