~tex-sx/tex-sx/development

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
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
----------------------------------------------------------------
spath --- Functions for manipulating PGF soft paths
E-mail: stacey@math.ntnu.no
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

This package defines some functions used to manipulate PGFs soft paths.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
----------------------------------------------------------------
spath --- Functions for manipulating PGF soft paths
E-mail: stacey@math.ntnu.no
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

\endpreamble
\postamble

Copyright (C) 2011 by Andrew Stacey <stacey@math.ntnu.no>

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
version 1.3c of this license or (at your option) any later
version.  The latest version of this license is in the file:

http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) by
Andrew Stacey.

This work consists of the file  spath.dtx
and the derived files           spath.ins,
                                spath.pdf, and
                                spath.sty.

\endpostamble
\usedir{tex/latex/spath}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/spath}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/demopkg}
\generate{
  \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{spath}[2011/06/03 v1.0 Functions for manipulating PGF soft paths]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
%\usepackage{morefloats}
\usepackage{tikz}
\usepackage{\jobname}
\usepackage[numbered]{hypdoc}
\definecolor{lstbgcolor}{rgb}{0.9,0.9,0.9} 
 
\usepackage{listings}
\lstloadlanguages{[LaTeX]TeX}
\lstset{breakatwhitespace=true,breaklines=true,language=TeX}
 
\usepackage{fancyvrb}

\newenvironment{example}
  {\VerbatimEnvironment
   \begin{VerbatimOut}[gobble=2]{example.out}}
  {\end{VerbatimOut}
   \begin{center}
%   \setlength{\parindent}{0pt}
   \fbox{\begin{minipage}{.9\linewidth}
     \lstset{breakatwhitespace=true,breaklines=true,language=TeX,basicstyle=\small}
     \lstinputlisting[]{example.out}
   \end{minipage}}

   \fbox{\begin{minipage}{.9\linewidth}
     \input{example.out}
   \end{minipage}}
\end{center}
}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{1.0}{2011/05/03}{Converted to DTX file}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{spath.sty}
% \title{The \textsf{spath} package}
% \author{Andrew Stacey \\ \url{stacey@math.ntnu.no}}
% \date{\fileversion~from \filedate}
%
%
% \maketitle
%
% 
% \section{Introduction}
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% Load the \Verb+pgf.oo+ module.
%    \begin{macrocode}
\usepgfmodule{oo}
%    \end{macrocode}
% Define some auxilliary macros (should replace these with \Verb+etoolbox+
% \begin{macro}{\ge@addto@macro}
%    \begin{macrocode}
\long\def\ge@addto@macro#1#2{%
  \begingroup
  \toks@\expandafter\expandafter\expandafter{\expandafter#1#2}%
  \xdef#1{\the\toks@}%
  \endgroup}

\def\tikz@clear@foreach{%
\let\pgffor@beginhook=\pgfutil@empty
\let\pgffor@endhook=\pgfutil@empty
\let\pgffor@afterhook=\pgfutil@empty
}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ge@addbefore@macro}
%    \begin{macrocode}
\long\def\ge@addbefore@macro#1#2{%
  \begingroup
  \toks@\expandafter\expandafter\expandafter{\expandafter#2#1}%
  \xdef#1{\the\toks@}%
  \endgroup}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\g@addbefore@macro}
%    \begin{macrocode}
\long\def\g@addbefore@macro#1#2{%
  \def\@temp{#2}%
  \ge@addbefore@macro{#1}{\@temp}}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\tikzset{%
  use path/.code={%
    \pgfsyssoftpath@setcurrentpath{#1}%
  }
}
%    \end{macrocode}
% This is the \Verb+spath+ object.
% It is defined using the \Verb+pgf.oo+ module.
% It represents a ``soft path''.
%    \begin{macrocode}
\pgfooclass{spath}{
%    \end{macrocode}
% Certain attributes of the soft path are saved to avoid having to recompute them for every operation.
% The \Verb+path+ attribute is the soft path itself.
%    \begin{macrocode}
  \attribute path;
%    \end{macrocode}
% The \Verb+length+ is the crudest measure of length: the number of soft path tokens in the path.
%    \begin{macrocode}
  \attribute length;
%    \end{macrocode}
% Since some path pieces consist of more than one token, the \Verb+length+ is longer than what one might call the path length.
% The \Verb+real length+ counts only the key tokens.
%    \begin{macrocode}
  \attribute real length;
%    \end{macrocode}
% A path can be viewed as being a collection of drawing tokens and moving tokens.
% We call a collection of subsequent drawing tokens a \Verb+component+.
% The \Verb+number of components+ counts this.
% (Actually, it counts the number of \Verb+moveto+s, which could be more if there are successive \Verb+moveto+s.)
%    \begin{macrocode}
  \attribute number of components;
%    \end{macrocode}
% The \Verb+initial point+ is where the path starts.
%    \begin{macrocode}
  \attribute initial point;
%    \end{macrocode}
% The \Verb+final point+ is where the path ends.
%    \begin{macrocode}
  \attribute final point;
%    \end{macrocode}
% The \Verb+first action+ is the first drawing action on the path (so not including the initial \Verb+moveto+.)
%    \begin{macrocode}
  \attribute first action;
%    \end{macrocode}
% The \Verb+last action+ is the last action on the path (which might be a \Verb+moveto+.)
%    \begin{macrocode}
  \attribute last action;
%    \end{macrocode}
% To compute most of these attributes, we need to walk along the path.
% Obviously, we save their values to avoid having to do this walk too often.
% The \Verb+prepared+ attribute tells us whether or not we've already done this walk.
%    \begin{macrocode}
  \attribute prepared;
%    \end{macrocode}
% For the path tapering, we need to know the line width and the width to taper to.
% The \Verb+taper line width+ holds the latter.
%    \begin{macrocode}
  \attribute taper line width;
%    \end{macrocode}
% We need to keep track of our bounding box
%    \begin{macrocode}
  \attribute min bb;
  \attribute max bb;
%    \end{macrocode}
%
% Our last attribute is a ``scratch'' attribute for saving some macro that relates to the object in some way.
%    \begin{macrocode}
  \attribute scratch pad;
%    \end{macrocode}
% 
% Now we have the methods for the \Verb+spath+ object.
%
% We start with the creator.
% If given a path, we store it as the \Verb+path+ attribute.
%    \begin{macrocode}
  \method spath(#1) {%
    \let\spath@temp=#1\relax
    \ifx\spath@temp\relax
    \else
     \pgfoolet{path}{#1}%
    \fi
  }
%    \end{macrocode}
% Set path from current path
%    \begin{macrocode}
  \method use current path() {%
    \pgfsyssoftpath@getcurrentpath{\spath@temp}%
    \pgfoolet{path}{\spath@temp}%
    \let\spath@temp=\pgfutil@empty
  }
%    \end{macrocode}
%
% Next, we have some generic attribute handling methods.
% These allow us to set, get, and let attributes, and also to show them in the logs.
%
% We start with one that inserts the value of the given attribute in the token stream.
%    \begin{macrocode}
  \method value(#1) {%
    \pgfoovalueof{#1}%
  }
%    \end{macrocode}
% This sets the attribute (first argument) to the second argument.
%    \begin{macrocode}
  \method set(#1,#2) {%
    \pgfooset{#1}{#2}%
  }
%    \end{macrocode}
% This lets the attribute (first argument) to the second argument, which must be a macro.
%    \begin{macrocode}
  \method let(#1,#2) {%
    \pgfoolet{#1}{#2}%
  }
%    \end{macrocode}
% This sets the attribute (first argument) to the second argument if the attribute is not empty.
%    \begin{macrocode}
  \method set if not empty(#1,#2) {%
  \pgfooget{#1}{\spath@tmp}%
  \ifx\spath@tmp\pgfutil@empty
    \pgfooset{#1}{#2}%
  \fi
  }
%    \end{macrocode}
% This lets the attribute (first argument) to the second argument, which must be a macro, if the attribute is not empty.
%    \begin{macrocode}
  \method let if not empty(#1,#2) {%
  \pgfooget{#1}{\spath@tmp}%
  \ifx\spath@tmp\pgfutil@empty
    \pgfoolet{#1}{#2}%
  \fi
  }
%    \end{macrocode}
% This gets the attribute (first argument) into the second argument, which must be a macro.
%    \begin{macrocode}
  \method get(#1,#2) {%
    \pgfooget{#1}{#2}%
  }
%    \end{macrocode}
% This shows the attribute (argument) in the logs, via \Verb+\show+.
% (Should prefix with the attribute name to be more useful.)
%    \begin{macrocode}
  \method show(#1) {%
    \pgfooget{#1}{\@temp}%
    \show\@temp
  }
%    \end{macrocode}
% This says what we are
%    \begin{macrocode}
  \method what am I() {%
     \message{I am an spath object}%
  }
%    \end{macrocode}
% This clones the path to the macro passed to it.
% The macro must already exist (at the moment, though in thinking about it that's a little daft) but will be overwritten.
%    \begin{macrocode}
  \method clone(#1) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \else
     \pgfoonew \spath@newpath =new spath()%
  \tikz@clear@foreach
     \foreach \attribute in {
      path,
      length,
      real length,
      number of components,
      initial point,
      final point,
      first action,
      last action,
      prepared,
      taper line width,
      min bb,
      max bb%,
     } {
      \pgfooget{\attribute}{\spath@temp}%
      \spath@newpath.let(\attribute,\spath@temp)%
    }
    \let#1=\spath@newpath%
    \fi
  }
%    \end{macrocode}
%
% Now we begin the path-walking methods.
% These methods work by ``evaluating'' the path under certain conditions.
% A soft path consists of a series of commands which take two arguments, nominally an x-coordinate and a y-coordinate.
% By reseting the commands, we can make a soft path rewrite itself in a modified form, or to extract certain information from it.
% The actual implementation of these uses various auxilliary macros which are defined later.
%
% This method translates the path by \#2 in x and \#3 in y.
% If \#1 is given then it should be a macro and it will be turned into an object with the translated path, otherwise the current object is modified.
%
% It works by redefining each soft path token to add the given dimensions to its arguments and then rewrite itself back to the path.
% Having done that, we have to adjust the various other attributes which are location-specific.
%    \begin{macrocode}
  \method translate path(#1,#2,#3) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \spath@trx=#2\relax
     \spath@try=#3\relax
     \spath@translate@init
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
     \let\spath@tmppath=\pgfutil@empty
  \tikz@clear@foreach
     \foreach \attribute in {
      initial point,
      final point,
      min bb,
      max bb%,
     } {
      \pgfooget{\attribute}{\spath@temp}%
      \ifx\spath@temp\pgfutil@empty
      \else
       \spath@temp
       \advance\pgf@x by \spath@trx\relax
       \advance\pgf@y by \spath@try\relax
       \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
       \pgfoolet{\attribute}{\spath@temp}%
      \fi
    }
    \endgroup
    \let\spath@tmppath=\pgfutil@empty
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.translate path(,#2,#3)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% Transform path according to an affine transformation
%    \begin{macrocode}
  \method transform path(#1,#2) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \pgftransformreset
     \pgfsettransform{#2}%
     \spath@transform@init
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
     \let\spath@tmppath=\pgfutil@empty
  \tikz@clear@foreach
     \foreach \attribute in {
      initial point,
      final point,
      min bb,
      max bb,
      prepared%,
     } {
      \pgfoolet{\attribute}{\pgfutil@empty}%
     }%
    \endgroup
    \let\spath@tmppath=\pgfutil@empty
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.transform path(,#2)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% Scale all coordinates
%    \begin{macrocode}
  \method scale path(#1,#2,#3) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \edef\spath@scx{#2}%
     \edef\spath@scy{#3}%
     \ifx\spath@scy\pgfutil@empty
      \edef\spath@scy{#2}%
     \fi
     \spath@scale@init
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
     \let\spath@tmppath=\pgfutil@empty
  \tikz@clear@foreach
     \foreach \attribute in {
      initial point,
      final point,
      min bb,
      max bb%,
     } {
      \pgfooget{\attribute}{\spath@temp}%
      \ifx\spath@temp\pgfutil@empty
      \else
       \spath@temp
       \pgf@x=\spath@scx\pgf@x\relax
       \pgf@y=\spath@scy\pgf@y\relax
       \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
       \pgfoolet{\attribute}{\spath@temp}%
      \fi
    }
    \endgroup
    \let\spath@tmppath=\pgfutil@empty
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.scale path(,#2,#3)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% Round all the corners on the path, ignoring any that are already set
%    \begin{macrocode}
  \method round corners(#1,#2,#3) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \spath@round@init
     \edef\spath@rndx{#2}%
     \edef\spath@rndy{#3}%
  \ifx\spath@rndy\pgfutil@empty
   \let\spath@rndy\spath@rndx
  \fi
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
    \endgroup
     \pgfooget{path}{\spath@tmppath}%
     \pgfprocessround\spath@tmppath\spath@temppath
     \pgfoolet{path}{\spath@temppath}%
   \else
    \pgfooget{path}{\spath@tmppath}%
    \spath@newpath =new spath(\spath@tmppath)%
    \begingroup
    \spath@newpath.round corners(,#2)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% This shrinks the path towards a particular point by a given number of points.
% It doesn't scale the path, rather it adds a number of points to each coordinate depending on which quadrant the point is in relative to the given point.
%    \begin{macrocode}
  \method shrink path(#1,#2,#3,#4) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \spath@trx=#2\relax
     \spath@try=#3\relax
     \edef\spath@shrinkby{#4}%
     \spath@shrink@init
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
     \let\spath@tmppath=\pgfutil@empty
  \tikz@clear@foreach
     \foreach \attribute in {
      initial point,
      final point,
      min bb,
      max bb%,
     } {
      \pgfooget{\attribute}{\spath@temp}%
      \ifx\spath@temp\pgfutil@empty
      \else
       \spath@temp
       \pgfmathsetlength{\pgf@xa}{\pgf@x < \spath@trx ? \pgf@x + \spath@shrinkby : (\pgf@x > \spath@trx ? \pgf@x - \spath@shrinkby : \pgf@x)}%
       \pgfmathsetlength{\pgf@ya}{\pgf@y < \spath@try ? \pgf@y + \spath@shrinkby : (\pgf@y > \spath@try ? \pgf@y - \spath@shrinkby : \pgf@y)}%
       \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}%
       \pgfoolet{\attribute}{\spath@temp}%
      \fi
    }
    \endgroup
    \let\spath@tmppath=\pgfutil@empty
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.shrink path(,#2,#3)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
%
% This method prepares the path for a spirograph by applying an incremental rotation to each coordinate.
% If \#1 is given then it should be a macro and it will be turned into an object with the transformed path, otherwise the current object is modified.
%
% It works by redefining each soft path token to apply the given rotation to its arguments and then rewrite itself back to the path.
% Having done that, we have to adjust the various other attributes which are location-specific.
%    \begin{macrocode}
  \method prepare spirograph(#1,#2,#3,#4) {%
    \pgfoothis.prepare()%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \spath@trx=#2\relax
     \spath@try=#3\relax
     \def\spath@n{0}%
     \pgfooget{length}{\spath@temp}%
     \pgfmathsetmacro{\spath@gang}{#4/(\spath@temp-1)}%
     \spath@spirograph@init
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
     \let\spath@tmppath=\pgfutil@empty
     \pgfooget{final point}{\spath@temp}%
     \ifx\spath@temp\pgfutil@empty
     \else
      \spath@temp
      \pgf@xa=\pgf@x\relax
      \pgf@ya=\pgf@y\relax
      \advance\pgf@xa by -\spath@trx\relax
      \advance\pgf@ya by -\spath@try\relax
      \pgfmathsetmacro{\spath@gcos}{cos(#4)}%
      \pgfmathsetmacro{\spath@gsin}{sin(#4)}%
      \pgfmathsetlength{\pgf@xb}{\spath@gcos * \pgf@xa - \spath@gsin * \pgf@ya}%
      \pgfmathsetlength{\pgf@yb}{\spath@gsin * \pgf@xa + \spath@gcos * \pgf@ya}%
      \advance\pgf@xb by \spath@trx\relax
      \advance\pgf@yb by \spath@try\relax
      \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}%
      \pgfoolet{final point}{\spath@temp}%
     \fi
    \endgroup
    \let\spath@tmppath=\pgfutil@empty
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.prepare spirograph(,#2,#3,#4)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
%
% This method actually makes a spirograph.
% The arguments are the point of rotation and the number of iterations.
%    \begin{macrocode}
\method spirograph(#1,#2,#3,#4) {
    \pgfoothis.prepare()%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \begingroup
     \pgfmathsetmacro{\spath@gn}{360/#4}%
     \pgfoothis.prepare spirograph(,#2,#3,\spath@gn)%
     \pgfoothis.clone(\spath@tempa)%
     \pgfmathsetmacro{\spath@gna}{2*\spath@gn}%
     \pgfmathsetmacro{\spath@gnb}{360-\spath@gn}%
  \tikz@clear@foreach
     \foreach \k in {\spath@gn,\spath@gna,...,\spath@gnb} {%
      \spath@tempa.rotate path(,\spath@gn)%
      \pgfoothis.weld(,\spath@tempa)%
     }%
    \endgroup
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.spirograph(,#2,#3,#4)%
    \endgroup
    \let#1=\spath@newpath
   \fi
}
%    \end{macrocode}
%
% This method rotates the path by the given angle.
% If \#1 is given then it should be a macro and it will be turned into an object with the transformed path, otherwise the current object is modified.
%
% It works by redefining each soft path token to apply the given rotation to its arguments and then rewrite itself back to the path.
% Having done that, we have to adjust the various other attributes which are location-specific.
%    \begin{macrocode}
  \method rotate path(#1,#2) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
     \pgfmathsetmacro{\spath@gcos}{cos(#2)}%
     \pgfmathsetmacro{\spath@gsin}{sin(#2)}%
     \spath@rotate@init
     \pgfoovalueof{path}%
     \pgfoolet{path}{\spath@tmppath}%
     \let\spath@tmppath=\pgfutil@empty
     \pgfooget{initial point}{\spath@temp}%
     \ifx\spath@temp\pgfutil@empty
     \else
      \spath@temp
      \pgf@xa=\pgf@x\relax
      \pgf@ya=\pgf@y\relax
      \pgfmathsetlength{\pgf@xb}{\spath@gcos * \pgf@xa - \spath@gsin * \pgf@ya}%
      \pgfmathsetlength{\pgf@yb}{\spath@gsin * \pgf@xa + \spath@gcos * \pgf@ya}%
      \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}%
      \pgfoolet{initial point}{\spath@temp}%
     \fi
     \pgfooget{final point}{\spath@temp}%
     \ifx\spath@temp\pgfutil@empty
     \else
      \spath@temp
      \pgf@xa=\pgf@x\relax
      \pgf@ya=\pgf@y\relax
      \pgfmathsetlength{\pgf@xb}{\spath@gcos * \pgf@xa - \spath@gsin * \pgf@ya}%
      \pgfmathsetlength{\pgf@yb}{\spath@gsin * \pgf@xa + \spath@gcos * \pgf@ya}%
      \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}%
      \pgfoolet{final point}{\spath@temp}%
     \fi
    \endgroup
    \let\spath@tmppath=\pgfutil@empty
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.rotate path(,#2)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% Get the length of the path (number of pieces)
%    \begin{macrocode}
  \method length() {%
    \pgfooget{length}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \setcounter{spath@length}{0}%
    \begingroup
    \spath@length@init
    \pgfoovalueof{path}%
    \endgroup
     \edef\spath@temp{\the\value{spath@length}}%
     \pgfoolet{length}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the real length of the path (number of components that draw)
%    \begin{macrocode}
  \method real length() {%
    \pgfooget{real length}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \setcounter{spath@length}{0}%
    \begingroup
    \spath@reallength@init
    \pgfoovalueof{path}%
    \endgroup
     \edef\spath@temp{\the\value{spath@length}}%
     \pgfoolet{real length}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the number of components of the path
%    \begin{macrocode}
  \method number of components() {%
    \pgfooget{number of components}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \setcounter{spath@length}{0}%
    \begingroup
    \spath@components@init
    \pgfoovalueof{path}%
    \endgroup
     \edef\spath@temp{\the\value{spath@length}}%
     \pgfoolet{real length}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the initial point of the path
%    \begin{macrocode}
  \method initial point() {%
    \pgfooget{initial point}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \begingroup
    \spath@start@init
    \pgfoovalueof{path}%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@sx}{\spath@sy}}%
    \pgfoolet{initial point}{\spath@temp}%
    \endgroup
    \pgfooget{initial point}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the final point of the path
%    \begin{macrocode}
  \method final point() {%
    \pgfooget{final point}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \begingroup
    \spath@end@init
    \pgfoovalueof{path}%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@ex}{\spath@ey}}%
    \pgfoolet{final point}{\spath@temp}%
    \endgroup
    \pgfooget{final point}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the bounding box of the path
%    \begin{macrocode}
  \method bounding box() {%
    \pgfooget{min bb}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \else
     \pgfooget{min bb}{\spath@temp}%
    \fi
    \ifx\spath@temp\pgfutil@empty
     \begingroup
      \spath@boundingbox@init
      \pgfoovalueof{path}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{min bb}{\spath@temp}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@max}{\spath@may}}%
      \pgfoolet{max bb}{\spath@temp}%
     \endgroup
    \fi
  }
%    \end{macrocode}
% Get the bounding box of the path: minimum corner
%    \begin{macrocode}
  \method min bb() {%
    \pgfooget{min bb}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
     \pgfoothis.bounding box()%
     \pgfooget{min bb}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the bounding box of the path: maximum corner
%    \begin{macrocode}
  \method max bb() {%
    \pgfooget{max bb}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
     \pgfoothis.bounding box()%
     \pgfooget{max bb}{\spath@temp}%
    \fi
    \spath@temp
  }
%    \end{macrocode}
% Get the mid point of the path (according to the bounding box)
%    \begin{macrocode}
  \method mid point() {%
    \pgfoothis.min bb()%
    \pgf@xa=.5\pgf@x
    \pgf@ya=.5\pgf@y
    \pgfoothis.max bb()%
    \pgf@x=.5\pgf@x
    \pgf@y=.5\pgf@y
    \advance\pgf@xa by \pgf@x
    \advance\pgf@ya by \pgf@y
    \edef\spath@temp{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}%
    \spath@temp
  }
%    \end{macrocode}
% Reverse the path.
% If \#1 is given then it should be a macro and it will be an object with the reversed path, otherwise the current object is modified.
%    \begin{macrocode}
  \method reverse path(#1) {%
   \let\spath@newpath=#1\relax
   \ifx\spath@newpath\relax
    \let\spath@tmppath=\pgfutil@empty
    \pgfoothis.prepare()%
    \begingroup
    \spath@reverse@init
    \pgfoovalueof{path}%
    \g@addbefore@macro\spath@tmppath\pgfsyssoftpath@movetotoken
    \endgroup
    \pgfoolet{path}{\spath@tmppath}%
    \pgfooget{initial point}{\spath@temp}%
    \pgfooget{final point}{\spath@tempa}%
    \pgfoolet{final point}{\spath@temp}%
    \pgfoolet{initial point}{\spath@tempa}%
    \pgfooget{first action}{\spath@temp}%
    \pgfooget{last action}{\spath@tempa}%
    \pgfoolet{last action}{\spath@temp}%
    \pgfoolet{first action}{\spath@tempa}%
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.reverse()%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% Prepare the path, filling out all the attributes.
% As many of the attributes require ``walking'' the path to figure them out, by doing them all in one go we can avoid too much duplication of effort.
%    \begin{macrocode}
  \method prepare() {%
    \pgfooget{prepared}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \let\spath@tmppath=\pgfutil@empty
    \begingroup
    \setcounter{spath@reallength}{0}%
    \setcounter{spath@components}{0}%
    \setcounter{spath@length}{0}%
    \spath@prepare@init
    \let\spath@first=\pgfutil@empty
    \pgfoovalueof{path}%
    \edef\spath@temp{\the\value{spath@components}}%
    \pgfoolet{number of components}{\spath@temp}%
    \edef\spath@temp{\the\value{spath@length}}%
    \pgfoolet{length}{\spath@temp}%
    \edef\spath@temp{\the\value{spath@reallength}}%
    \pgfoolet{real length}{\spath@temp}%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@sx}{\spath@sy}}%
    \pgfoolet{initial point}{\spath@temp}%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@ex}{\spath@ey}}%
    \pgfoolet{final point}{\spath@temp}%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
    \pgfoolet{min bb}{\spath@temp}%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@max}{\spath@may}}%
    \pgfoolet{max bb}{\spath@temp}%
    \pgfoolet{first action}{\spath@first}%
    \pgfoolet{last action}{\spath@last}%
    \pgfoolet{prepared}{1}%
    \endgroup
    \fi
  }
%    \end{macrocode}
%
% Now we have some other path manipulation methods that don't involve walking a path.
%
% For tapering a path, it is important that the path has at least 3 components so that the first and last can be tapered.
% This method ensures that that is so by splitting the path if its real length is less than 3.
% If the real length is 1, it replaces the component by three.
% If the real length is 2, it splits both of them in half.
%    \begin{macrocode}
  \method at least three() {%
    \pgfoothis.prepare()%
    \pgfooget{real length}{\spath@temp}%
    \pgfooget{path}{\spath@tmppath}%
    \ifnum\spath@temp=1\relax
     \pgfooget{first action}{\spath@temp}%
     \ifx\spath@temp\spath@lineto
      \expandafter\spath@split@single@lineto\spath@tmppath\relax
      \pgfoolet{path}{\spath@tmppath}%
      \pgfooset{length}{4}%
     \else
      \expandafter\spath@split@single@curveto\spath@tmppath\relax
      \pgfoolet{path}{\spath@tmppath}%
      \pgfooset{length}{10}%
     \fi
     \pgfooset{real length}{3}%
    \else
     \ifnum\spath@temp=2\relax
      \pgfooget{first action}{\spath@temp}%
      \def\spath@tempa{0}%
      \ifx\spath@temp\spath@lineto
       \expandafter\spath@split@first@lineto\spath@tmppath\relax
       \def\spath@tempa{3}%
      \else
       \expandafter\spath@split@first@curveto\spath@tmppath\relax
       \def\spath@tempa{7}%
      \fi
      \pgfooget{last action}{\spath@temp}%
      \ifx\spath@temp\spath@lineto
       \expandafter\spath@split@second@lineto\spath@split@path@end\relax
       \pgfmathsetmacro{\spath@tempa}{\spath@tempa + 2}
      \else
       \expandafter\spath@split@second@curveto\spath@split@path@end\relax
       \pgfmathsetmacro{\spath@tempa}{\spath@tempa + 6}
      \fi
      \let\spath@tmppath=\spath@split@path@start
      \ge@addto@macro\spath@tmppath\spath@split@path@end
      \pgfoolet{path}{\spath@tmppath}%
      \pgfoolet{length}{\spath@tempa}%
      \pgfooset{real length}{4}%
     \fi
    \fi
  }
%    \end{macrocode}
% This is the tapering method.
% It actually only tapers the first (real) component of the path and throws away the rest.
% It should therefore be called after a path has been split (and after the path has been made to have at least 3 components).
%    \begin{macrocode}
  \method taper out() {%
    \pgfoothis.prepare()%
    \pgfooget{first action}{\spath@temp}%
    \pgfooget{path}{\spath@tmppath}%
    \pgfooget{taper line width}{\taper@line@width}%
    \ifx\taper@line@width\pgfutil@empty
     \pgfmathsetmacro{\taper@line@width}{.5*\pgflinewidth}%
    \fi
    \ifx\spath@temp\spath@lineto
     \expandafter\spath@taper@lineto@out\spath@tmppath\relax
    \pgfoolet{path}{\spath@tapered@path}%
    \else
     \ifx\spath@temp\spath@curveto
      \expandafter\spath@taper@curveto@out\spath@tmppath\relax
      \pgfoolet{path}{\spath@tapered@path}%
     \fi
    \fi
  }
%    \end{macrocode}
% The next few methods split a path by various conditions.
% The actual splitting routine is the same for all, the next few methods work by setting up the conditions necessary to determine the place to split the path.
%
% The arguments are the same for each: macros to store the first and second parts of the path, and the number at which to split (negative counts from the end).
%
% The first splits the path by number of tokens.
%    \begin{macrocode}
  \method split path by length(#1,#2,#3) {%
    \pgfoothis.prepare()%
    \def\spath@test{\the\value{spath@length}}%
    \pgfooget{length}{\spath@length}%
    \pgfoothis.split(#1,#2,#3)%
  }
%    \end{macrocode}
% This splits the path by number of drawing tokens.
%    \begin{macrocode}
  \method split path by real length(#1,#2,#3) {%
    \pgfoothis.prepare()%
    \def\spath@test{\the\value{spath@reallength}}%
    \pgfooget{real length}{\spath@length}%
    \pgfoothis.split(#1,#2,#3)%
  }
%    \end{macrocode}
% This splits the path by the number of components (\Verb+moveto+s).
%    \begin{macrocode}
  \method split path by component(#1,#2,#3) {%
    \pgfoothis.prepare()%
    \def\spath@test{\the\value{spath@components}}%
    \pgfooget{number of components}{\spath@length}%
    \pgfoothis.split(#1,#2,#3)%
  }
%    \end{macrocode}
% This is the actual splitting code.
% It's another path-walker, counting as it goes and splitting when we get to the right place.
% Negative numbers mean working from the end.
% After the split, we have to ensure that the second part has a suitable \Verb+moveto+ since all paths start with a move.
%    \begin{macrocode}
  \method split(#1,#2,#3) {%
    \pgfmathsetmacro{\spath@splitat}{#3 < 0 ? \spath@length + #3: #3}%
    \pgfooget{path}{\spath@tmppath}%
    \let\spath@tmppatha=\pgfutil@empty
    \setcounter{spath@length}{0}%
    \setcounter{spath@reallength}{0}%
    \setcounter{spath@components}{-1}%
    \expandafter\spath@gobble\spath@tmppath\relax
    \pgfoonew #1 =new spath(\spath@tmppatha)%
    \pgfoonew #2 =new spath(\spath@tmppath)%
    #1.let(last action,\spath@last)%
    #2.let(first action,\spath@first)%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@ex}{\spath@ey}}%
    #1.let(final point,\spath@temp)%
    \edef\spath@temp{\noexpand\pgfpoint{\spath@sx}{\spath@sy}}%
    #2.let(initial point,\spath@temp)%
    \pgfooget{first action}{\spath@temp}%
    #1.let(first action,\spath@temp)%
    \pgfooget{last action}{\spath@temp}%
    #2.let(last action,\spath@temp)%
    \pgfooget{initial point}{\spath@temp}%
    #1.let(initial point,\spath@temp)%
    \pgfooget{final point}{\spath@temp}%
    #2.let(final point,\spath@temp)%
    #1.let(length,\spath@splitat)%
    \edef\spath@temp{\the\value{spath@reallength}}
    #1.let(real length,\spath@temp)%
    \pgfmathsetmacro{\spath@temp}{\pgfoovalueof{real length} - \spath@temp}
    #2.let(real length,\spath@temp)%
    \edef\spath@temp{\the\value{spath@components}}
    #1.let(number of components,\spath@temp)%
    \pgfmathsetmacro{\spath@temp}{\pgfoovalueof{number of components} - \spath@temp}
    #2.let(number of components,\spath@temp)%
    \pgfooget{taper line width}{\spath@temp}%
    #1.let(taper line width,\spath@temp)%
    #2.let(taper line width,\spath@temp)%
    \pgfmathsetmacro{\spath@splitat}{\spath@length - \spath@splitat}%
    #2.let(length,\spath@splitat)%
    #1.set(prepared,1)%
    #2.set(prepared,1)%
  }
%   \end{macrocode}
% This reprocesses the path (it's another walker).
% The purpose here is that we can set new conditions (via TikZ or PGF options) which might affect how the path should be built.
% An obvious example is to turn on the \Verb+rounded corners+ option.
%   \begin{macrocode}
  \method reprocess path() {%
    \begingroup
    \spath@reprocess@init
    \pgfsyssoftpath@setcurrentpath{\pgfutil@empty}%
    \pgfoovalueof{path}%
    \pgfsyssoftpath@getcurrentpath{\spath@tmppath}%
    \pgfoolet{path}{\spath@tmppath}%
    \endgroup
    \let\spath@tmppath\pgfutil@empty
  }
%    \end{macrocode}
% Now we come to a family of methods that actually use the path.
% The first sets the path as the current path.
% This means, for example, that the next TikZ command will start work on this path rather than an empty path. 
%    \begin{macrocode}
  \method set as current path() {%
    \pgfooget{path}{\spath@tmppath}%
    \pgfsyssoftpath@setcurrentpath{\spath@tmppath}%
  }
%    \end{macrocode}
% This replaces the path in the object by the current soft path in the TikZ/PGF system.
% As this replaces the path, all other attributes should be thrown away.
%    \begin{macrocode}
  \method get from current path() {%
    \pgfsyssoftpath@getcurrentpath{\spath@tmppath}%
    \pgfooset{path}{\spath@tmppath}%
    \pgfoothis.set(prepared,0)%
  }
%    \end{macrocode}
% This uses the path with the \Verb+\pgfusepath+ command, so is a low-level access to the path.
%    \begin{macrocode}
  \method use path(#1) {%
    \pgfooget{path}{\spath@tmppath}%
    \pgfoothis.min bb()%
    \pgf@protocolsizes\pgf@x\pgf@y
    \pgfoothis.max bb()%
    \pgf@protocolsizes\pgf@x\pgf@y
    \pgfsyssoftpath@setcurrentpath{\spath@tmppath}%
    \pgfsyssoftpath@flushcurrentpath
    \pgfusepath{#1}%
  }
%    \end{macrocode}
% This uses the path via a TikZ-like command, so can use TikZ style options (passed as the argument).
%    \begin{macrocode}
  \method use path with tikz(#1) {%
    \path[#1] \pgfextra{%
    \begingroup
    \spath@reprocess@init
    \pgfsyssoftpath@setcurrentpath{\pgfutil@empty}%
    \pgfoovalueof{path}%
    \endgroup};
  }
%    \end{macrocode}
% This produces a string representation of the path (mainly for preloading paths)
%    \begin{macrocode}
  \method to string() {%
     \begingroup
     \spath@string@init
     \pgfoovalueof{path}%
     \endgroup
  }
%    \end{macrocode}
% Now we get some methods which act on two paths and join them in some fashion.
%
% The first simply concatenates the paths.
% As each path starts with a \Verb+moveto+, the two paths are still somewhat separate.
%    \begin{macrocode}
  \method concatenate(#1,#2) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
     \let\spath@other=#2\relax
     \ifx\spath@other\relax
     \else
      \spath@other.get(path,\spath@tmppath)%
      \pgfooget{path}{\spath@tmppatha}%
      \ge@addto@macro\spath@tmppatha\spath@tmppath
      \pgfoolet{path}{\spath@tmppatha}%
      \spath@other.get(final point,\spath@temp)%
      \pgfoolet{final point}{\spath@temp}%
      \spath@other.get(last action,\spath@temp)%
      \pgfoolet{last action}{\spath@temp}%
      \pgfooget{min bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(min bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@mix}{min(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@miy}{min(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{min bb}{\spath@temp}%
      \pgfooget{max bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(max bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@max}{max(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@may}{max(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{max bb}{\spath@temp}%
  \tikz@clear@foreach
      \foreach \attribute in {
        length,
        real length,
        number of components%
      } {
        \spath@other.get(\attribute,\spath@temp)%
        \pgfooget{\attribute}{\spath@tempa}%
        \ifx\spath@temp\pgfutil@empty
        \else
        \ifx\spath@tempa\pgfutil@empty
        \else
         \pgfmathsetmacro{\spath@tempa}{\spath@temp + \spath@tempa}%
         \pgfoolet{\attribute}{\spath@tempa}%
        \fi
        \fi
      }%
    \fi
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.concatenate(,#2)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% This concatenates the paths but with a lineto instead of a moveto 
%    \begin{macrocode}
  \method concatenate with lineto(#1,#2) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
     \let\spath@other=#2\relax
     \ifx\spath@other\relax
     \else
      \spath@other.get(path,\spath@tmppath)%
      \expandafter\spath@movetoline\spath@tmppath\relax
      \pgfooget{path}{\spath@tmppatha}%
      \ge@addto@macro\spath@tmppatha\spath@tmppath
      \pgfoolet{path}{\spath@tmppatha}%
      \spath@other.get(final point,\spath@temp)%
      \pgfoolet{final point}{\spath@temp}%
      \spath@other.get(last action,\spath@temp)%
      \pgfoolet{last action}{\spath@temp}%
      \pgfooget{min bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(min bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@mix}{min(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@miy}{min(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{min bb}{\spath@temp}%
      \pgfooget{max bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(max bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@max}{max(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@may}{max(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{max bb}{\spath@temp}%
  \tikz@clear@foreach
      \foreach \attribute in {
        length,
        real length,
        number of components%
      } {
        \spath@other.get(\attribute,\spath@temp)%
        \pgfooget{\attribute}{\spath@tempa}%
        \ifx\spath@temp\pgfutil@empty
        \else
        \ifx\spath@tempa\pgfutil@empty
        \else
         \pgfmathsetmacro{\spath@tempa}{\spath@temp + \spath@tempa}%
         \pgfoolet{\attribute}{\spath@tempa}%
        \fi
        \fi
      }%
    \fi
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.concatenate with lineto(,#2)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% This concatenates the paths but removes the moveto 
%    \begin{macrocode}
  \method concatenate without moveto(#1,#2) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
     \let\spath@other=#2\relax
     \ifx\spath@other\relax
     \else
      \spath@other.get(path,\spath@tmppath)%
      \expandafter\spath@trimfirst\spath@tmppath\relax
      \pgfooget{path}{\spath@tmppatha}%
      \ge@addto@macro\spath@tmppatha\spath@tmppath
      \pgfoolet{path}{\spath@tmppatha}%
      \spath@other.get(final point,\spath@temp)%
      \pgfoolet{final point}{\spath@temp}%
      \spath@other.get(last action,\spath@temp)%
      \pgfoolet{last action}{\spath@temp}%
      \pgfooget{min bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(min bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@mix}{min(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@miy}{min(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{min bb}{\spath@temp}%
      \pgfooget{max bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(max bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@max}{max(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@may}{max(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{max bb}{\spath@temp}%
  \tikz@clear@foreach
      \foreach \attribute in {
        length,
        real length,
        number of components%
      } {
        \spath@other.get(\attribute,\spath@temp)%
        \pgfooget{\attribute}{\spath@tempa}%
        \ifx\spath@temp\pgfutil@empty
        \else
        \ifx\spath@tempa\pgfutil@empty
        \else
         \pgfmathsetmacro{\spath@tempa}{\spath@temp + \spath@tempa}%
         \pgfoolet{\attribute}{\spath@tempa}%
        \fi
        \fi
      }%
      \pgfooget{length}{\spath@tempa}%
      \pgfmathsetmacro{\spath@tempa}{\spath@tempa - 1}%
      \pgfoolet{length}{\spath@tempa}%
     \fi
   \else
    \pgfoothis.clone(\spath@newpath)%
    \begingroup
    \spath@newpath.concatenate without moveto(,#2)%
    \endgroup
    \let#1=\spath@newpath
   \fi
  }
%    \end{macrocode}
% Welding is like concatenation except that the paths are brought
% together and the intervening moveto is removed
%    \begin{macrocode}
  \method weld(#1,#2) {%
    \let\spath@newpath=#1\relax
    \ifx\spath@newpath\relax
     \let\spath@other=#2\relax
     \ifx\spath@other\relax
     \else
      \pgfoothis.final point()%
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.initial point()%
      \advance\pgf@xa by -\pgf@x
      \advance\pgf@ya by -\pgf@y
      \spath@other.translate path(\spath@tempo,\the\pgf@xa,\the\pgf@ya)%
%
      \spath@tempo.get(path,\spath@tmppath)%
      \expandafter\spath@trimfirst\spath@tmppath\relax
      \pgfooget{path}{\spath@tmppatha}%
      \ge@addto@macro\spath@tmppatha\spath@tmppath
      \pgfoolet{path}{\spath@tmppatha}%
%
      \spath@tempo.get(final point,\spath@temp)%
      \pgfoolet{final point}{\spath@temp}%
      \spath@tempo.get(last action,\spath@temp)%
      \pgfoolet{last action}{\spath@temp}%
      \pgfooget{min bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(min bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@mix}{min(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@miy}{min(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{min bb}{\spath@temp}%
      \spath@temp
      \pgf@xa=\pgf@x
      \pgf@ya=\pgf@y
      \spath@other.get(max bb,\spath@temp)%
      \spath@temp
      \pgfmathsetmacro{\spath@max}{max(\pgf@x,\pgf@xa)}%
      \pgfmathsetmacro{\spath@may}{max(\pgf@y,\pgf@ya)}%
      \edef\spath@temp{\noexpand\pgfpoint{\spath@mix}{\spath@miy}}%
      \pgfoolet{max bb}{\spath@temp}%
  \tikz@clear@foreach
      \foreach \attribute in {
        length,
        real length,
        number of components%
      } {
        \spath@tempo.get(\attribute,\spath@temp)%
        \pgfooget{\attribute}{\spath@tempa}%
        \ifx\spath@temp\pgfutil@empty
        \else
         \ifx\spath@tempa\pgfutil@empty
         \else
          \pgfmathsetmacro{\spath@tempa}{\spath@temp + \spath@tempa}%
          \pgfoolet{\attribute}{\spath@tempa}%
         \fi
        \fi
      }%
     \fi
    \else
     \pgfoothis.clone(\spath@newpath)%
     \begingroup
      \spath@newpath.weld(,#2)%
     \endgroup
     \let#1=\spath@newpath
    \fi
  }
%    \end{macrocode}
% This library isn't great with closed paths, but we can certainly close up an existing path.
%    \begin{macrocode}
  \method close() {%
    \pgfooget{path}{\spath@tmppath}%
    \g@addto@macro\spath@tmppath{\pgfsyssoftpath@closepathtoken{0pt}{0pt}}%
    \pgfoolet{path}{\spath@tmppath}%
    \pgfooget{length}{\spath@temp}%
    \pgfmathtruncatemacro{\spath@temp}{\spath@temp + 1}%
    \pgfoolet{length}{\spath@temp}%
    \pgfooget{real length}{\spath@temp}%
    \pgfmathtruncatemacro{\spath@temp}{\spath@temp + 1}%
    \pgfoolet{real length}{\spath@temp}%
    \pgfooget{number of components}{\spath@temp}%
    \pgfmathtruncatemacro{\spath@temp}{\spath@temp + 1}%
    \pgfoolet{number of components}{\spath@temp}%
    \pgfooget{initial point}{\spath@temp}%
    \pgfoolet{final point}{\spath@temp}%
    \pgfooset{last action}{closepath}%
    \pgfooset{prepared}{0}%
  }
%    \end{macrocode}
% This method steps through the path and splits curvetos that might possibly self-intersect.
%    \begin{macrocode}
  \method split self intersecting pieces() {%
  \begingroup
    \let\spath@tmppath=\pgfutil@empty
    \spath@selfintersect@init
    \pgfoovalueof{path}%
    \pgfoolet{path}{\spath@tmppath}%
  \endgroup
}
%    \end{macrocode}
% Explode the path into an array of drawing components
%    \begin{macrocode}
  \method explode(#1) {%
  \pgfooget{path}{\spath@tmp}%
  \spathexplode#1\spath@tmp
}
%    \end{macrocode}
%    \begin{macrocode}
  \method at intersections(#1) {%
  \pgfooget{path}{\spath@tmppath}%
  #1.get(path,\spath@tmppatha)%
  \ifx\spath@tmppatha\pgfutil@empty
  \else
  \pgfoothis.get handle(\spath@firstpath)%
  \let\spath@secondpath=#1%
  \pgfintersectionofpaths{\pgfsetpath\spath@tmppatha}{\pgfsetpath\spath@tmppath}%
  \ifnum\pgfintersectionsolutions>0\relax
  \pgfsyssoftpath@setcurrentpath\pgfutil@empty
  \tikz@clear@foreach
  \foreach \spath@k in {1,...,\pgfintersectionsolutions} {
    \pgfpointintersectionsolution{\spath@k}%
    \edef\spath@ix{\the\pgf@x}%
    \edef\spath@iy{\the\pgf@y}%
    \pgfoothis.initial point()%
    \pgfmathtruncatemacro{\spath@first@nearstart}{(abs(\pgf@x - \spath@ix) + abs(\pgf@y - \spath@iy)) < \spath@intersectiontolerance}%
    \pgfoothis.final point()
    \pgfmathtruncatemacro{\spath@first@nearend}{(abs(\pgf@x - \spath@ix) + abs(\pgf@y - \spath@iy) <  \spath@intersectiontolerance)}%
    \pgfmathtruncatemacro{\spath@first@nearends}{\spath@first@nearstart || \spath@first@nearend}%
    \spath@secondpath.initial point()%
    \pgfmathtruncatemacro{\spath@second@nearstart}{(abs(\pgf@x - \spath@ix) + abs(\pgf@y - \spath@iy)) < \spath@intersectiontolerance}%
    \spath@secondpath.final point()
    \pgfmathtruncatemacro{\spath@second@nearend}{(abs(\pgf@x - \spath@ix) + abs(\pgf@y - \spath@iy) <  \spath@intersectiontolerance)}%
    \pgfmathtruncatemacro{\spath@second@nearends}{\spath@second@nearstart || \spath@second@nearend}%
    \pgfmathtruncatemacro{\spath@nearends}{\spath@first@nearends || \spath@second@nearends}%
    \spath@execute@at@intersections
  }
  \fi
  \fi
}
%    \end{macrocode}
% Here endeth the \Verb+spath+ object.
%    \begin{macrocode}
}
%    \end{macrocode}
%
% The \Verb+spath component+ is designed to be part of an array of \Verb+spath+ objects.
% Each \Verb+spath component+ consists of an \Verb+spath+ object and a link to a previous and a next \Verb+spath component+ (either of which could be empty).
%    \begin{macrocode}
\pgfooclass{spath component}{
%    \end{macrocode}
% Our attributes are our \Verb+spath+, and the next and previous components.
%    \begin{macrocode}
  \attribute path;
  \attribute next component;
  \attribute previous component;
%    \end{macrocode}
% This is the creator.
% If called with an argument, that is assumed to be the previous component in the array.
%    \begin{macrocode}
  \method spath component(#1) {%
    \def\spath@temp{#1}%
    \ifx\spath@temp\pgfutil@empty
    \else
    \pgfoolet{previous component}{#1}%
    \fi
  }
%    \end{macrocode}
% Generic attribute handling, see \Verb+spath+ class for details
%    \begin{macrocode}
  \method value(#1) {%
    \pgfoovalueof{#1}%
  }
%    \end{macrocode}
%    \begin{macrocode}
  \method set(#1,#2) {%
    \pgfooset{#1}{#2}%
  }
%    \end{macrocode}
%    \begin{macrocode}
  \method let(#1,#2) {%
    \pgfoolet{#1}{#2}%
  }
%    \end{macrocode}
%    \begin{macrocode}
  \method get(#1,#2) {%
    \pgfooget{#1}{#2}%
  }
%    \end{macrocode}
%    \begin{macrocode}
  \method show(#1) {%
    \pgfooget{#1}{\@temp}%
    \show\@temp
  }
%    \end{macrocode}
% This says what we are
%    \begin{macrocode}
  \method what am I() {%
     \message{I am an spath component object}%
  }
%    \end{macrocode}
% This sets the \Verb+path+ attribute (as an instance of the \Verb+spath+ class) from a saved path.
%    \begin{macrocode}
  \method set path(#1) {%
    \pgfoonew \spath@tempa =new spath(#1)%
    \pgfoolet{path}{\spath@tempa}%
  }
%    \end{macrocode}
% This recurses along the array applying an action to every object.
% Specifically, it applies the action to the \Verb+path+ attribute and then calls the next component with the same arguments.
%    \begin{macrocode}
  \method apply to paths(#1,#2) {%
    \pgfooget{path}{\spath@tmppath}%
    \ifx\spath@tmppath\pgfutil@empty
    \else
    \spath@tmppath.#1(#2)%
    \fi
    \pgfooget{next component}{\spath@temp}%
    \let\spath@next=\pgfutil@empty
    \ifx\spath@temp\pgfutil@empty
    \else
     \def\spath@next{\spath@temp.apply to paths(#1,{#2})}%
    \fi
    \spath@next
  }
  \method apply to previous paths(#1,#2) {%
    \pgfooget{path}{\spath@tmppath}%
    \ifx\spath@temppath\pgfutil@empty
    \else
    \spath@tmppath.#1(#2)%
    \fi
    \pgfooget{previous component}{\spath@temp}%
    \let\spath@next=\pgfutil@empty
    \ifx\spath@temp\pgfutil@empty
    \else
     \def\spath@next{\spath@temp.apply to previous paths(#1,{#2})}%
    \fi
    \spath@next%
  }
  \method apply for paths(#1) {%
    #1%
    \pgfooget{next component}{\spath@temp}%
    \let\spath@next=\pgfutil@empty
    \ifx\spath@temp\pgfutil@empty
    \else
     \def\spath@next{\spath@temp.apply for paths({#1})}%
    \fi
    \spath@next%
  }
  \method apply for previous paths(#1) {%
    #1%
    \pgfooget{previous component}{\spath@temp}%
    \let\spath@next=\pgfutil@empty
    \ifx\spath@temp\pgfutil@empty
    \else
     \def\spath@next{\spath@temp.apply for previous paths({#1})}%
    \fi
    \spath@next%
  }
%    \end{macrocode}
% We look for intersections between paths.
% If \#1 is given, we use that as one of the \Verb+spath+ objects to intersect with and look for intersections with that starting with us and proceeding to all following components.
% If \#1 is not given, we take our \Verb+spath+ object as the one to use and look for intersections for all subsequent components.
% We carry the previous and next components around with us in case the intersection happens to be too close to an endpoint and we want to use the other components as well.
%    \begin{macrocode}
  \method at intersections(#1,#2,#3) {%
  \let\spath@next=\pgfutil@empty
  \let\spath@tmp#1\relax%
  \let\spath@secondpath@prev#2\relax
  \let\spath@secondpath@next#3\relax
  \ifx\spath@tmp\relax
   \pgfooget{path}{\spath@tmp}%
   \pgfooget{previous component}{\spath@temp}%
   \ifx\spath@temp\pgfutil@empty
   \else
   \spath@temp.get(path,\spath@secondpath@prev)%
   \fi
   \pgfooget{next component}{\spath@temp}%
   \ifx\spath@temp\pgfutil@empty
   \else
    \spath@temp.get(path,\spath@secondpath@next)%
    \def\spath@next{%
     \begingroup
     \spath@temp.at intersections(\spath@tmp,\spath@secondpath@prev,\spath@secondpath@next)%
     \endgroup
     \spath@temp.at intersections(,,)%
    }
   \fi
  \else
   \begingroup
    \pgfooget{previous component}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \else
     \spath@temp.get(path,\spath@firstpath@prev)%
    \fi
    \pgfooget{next component}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \else
     \spath@temp.get(path,\spath@firstpath@next)%
    \fi
    \pgfooget{path}{\spath@temp}%
    \ifx\spath@temp\pgfutil@empty
    \else
     \spath@temp.at intersections(\spath@tmp)%
    \fi
   \endgroup
   \pgfooget{next component}{\spath@temp}%
   \ifx\spath@temp\pgfutil@empty
   \else
    \def\spath@next{%
     \spath@temp.at intersections(\spath@tmp,\spath@secondpath@prev,\spath@secondpath@next)%
    }
   \fi
  \fi
  \spath@next
  }
%    \end{macrocode}
% That's all, folks.
% At least for the \Verb+spath component+
%    \begin{macrocode}
}
%    \end{macrocode}
% The reason that the above array structure was created was to be able to work on a soft path ``component by component''.
% The following macros take a soft path and split it at \Verb+moveto+s.
%    \begin{macrocode}
\def\spathsplit#1#2{%
  \ifx#1\relax
  \pgfoonew #1 =new spath component({})%
  \else
  \message{\string#1\space already defined}
  \fi
  \let\spath@this@component=#1\relax
  \expandafter\spath@split@#2\relax
}
%    \end{macrocode}
%    \begin{macrocode}
\def\spath@split@\pgfsyssoftpath@movetotoken#1\relax{%
  \spath@split@@#1\pgfsyssoftpath@movetotoken\relax
}
%    \end{macrocode}
%    \begin{macrocode}
\def\spath@split@@#1\pgfsyssoftpath@movetotoken#2\relax{%
  \def\spath@tmppath{\pgfsyssoftpath@movetotoken#1}%
  \spath@this@component.set path(\spath@tmppath)%
  \def\spath@tmppath{#2}%
  \ifx\spath@tmppath\pgfutil@empty
  \else
   \pgfoonew \spath@next@component =new spath component(\spath@this@component)%
   \spath@this@component.let(next component,\spath@next@component)%
   \let\spath@this@component=\spath@next@component
   \spath@split@@#2\relax
  \fi
}
%    \end{macrocode}
% The following macros take a soft path and split it into drawing components.
%    \begin{macrocode}
\def\spathexplode#1#2{%
  \ifdefined#1
  \else
  \pgfoonew #1 =new spath component({})%
  \fi
  \let\spath@this@component=#1\relax
  \expandafter\spath@explode@#2\relax
}
%    \end{macrocode}
%    \begin{macrocode}
\def\spath@explode@#1{%
  \let\spath@explode@next=\pgfutil@empty
  \ifx#1\pgfsyssoftpath@movetotoken
  \let\spath@explode@next=\spath@explode@savexy
  \else
  \ifx#1\pgfsyssoftpath@linetotoken
  \let\spath@explode@next=\spath@explode@lineto
  \else
  \ifx#1\pgfsyssoftpath@curvetosupportatoken
  \let\spath@explode@next=\spath@explode@curveto
  \else
  \ifx#1\pgfsyssoftpath@closepathtoken
  \let\spath@explode@next=\spath@explode@lineto
  \else
  \ifx#1\pgfsyssoftpath@recttoken
  \let\spath@explode@next=\spath@explode@rect
  \fi
  \fi
  \fi
  \fi
  \fi
  \spath@explode@next
}
%    \end{macrocode}
%    \begin{macrocode}
\def\spath@explode@savexy#1#2{%
  \def\spath@ex{#1}%
  \def\spath@ey{#2}%
  \spath@explode@%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\spath@explode@lineto#1#2{%
  \edef\spath@tmppath{\noexpand\pgfsyssoftpath@movetotoken{\spath@ex}{\spath@ey}\noexpand\pgfsyssoftpath@linetotoken{#1}{#2}}%
  \spath@this@component.set path(\spath@tmppath)%
  \pgfoonew \spath@next@component =new spath component(\spath@this@component)%
  \spath@this@component.let(next component,\spath@next@component)%
  \let\spath@this@component=\spath@next@component
  \def\spath@ex{#1}%
  \def\spath@ey{#2}%
  \spath@explode@%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\spath@explode@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
  \edef\spath@tmppath{\noexpand\pgfsyssoftpath@movetotoken{\spath@ex}{\spath@ey}\noexpand\pgfsyssoftpath@curvetosupportatoken{#1}{#2}\noexpand\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}\noexpand\pgfsyssoftpath@curvetotoken{#5}{#6}}%
  \spath@this@component.set path(\spath@tmppath)%
  \pgfoonew \spath@next@component =new spath component(\spath@this@component)%
  \spath@this@component.let(next component,\spath@next@component)%
  \let\spath@this@component=\spath@next@component
  \def\spath@ex{#5}%
  \def\spath@ey{#6}%
  \spath@explode@%
}
%    \end{macrocode}
%    \begin{macrocode}
% These are all our helper macros.
% The first batch are for defining the ``walker'' methods of the \Verb+spath+ class.
% For each of the methods we have to define some initialiser code which redefines the soft path token macros to something appropriate.
% As the ``something appropriate'' is often independent of the actual token macro, we set up a default action using \Verb+\spath@define@<something>+ macros.
% These set the default actions which can be overridden afterwards.
%
% We start with translation.
% Each soft path token translates its arguments and then appends itself, with the translated arguments, to the temporary path.
%    \begin{macrocode}
\def\spath@define@translate#1\relax{%
  \expandafter\gdef\csname spath@tr@#1\endcsname##1##2{%
    \pgf@xa=##1\relax
    \pgf@ya=##2\relax
    \advance\pgf@xa by \spath@trx
    \advance\pgf@ya by \spath@try
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{\the\pgf@xa}{\the\pgf@ya}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% Apply a transformation to the path
%    \begin{macrocode}
\def\spath@define@transform#1\relax{%
  \expandafter\gdef\csname spath@trans@#1\endcsname##1##2{%
    \pgf@xa=##1\relax
    \pgf@ya=##2\relax
    \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{\the\pgf@x}{\the\pgf@y}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% Scale all coordinates
%    \begin{macrocode}
\def\spath@define@scale#1\relax{%
  \expandafter\gdef\csname spath@sc@#1\endcsname##1##2{%
    \pgf@xa=##1\relax
    \pgf@ya=##2\relax
    \pgf@xa=\spath@scx\pgf@xa\relax
    \pgf@ya=\spath@scy\pgf@ya\relax
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{\the\pgf@xa}{\the\pgf@ya}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% Define the rounding macros, most do nothing
%    \begin{macrocode}
\def\spath@define@round#1\relax{%
  \expandafter\gdef\csname spath@rnd@#1\endcsname##1##2{%
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{##1}{##2}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% Each soft path token shrinks its arguments towards the given point and then appends itself to the temporary path.
%    \begin{macrocode}
\def\spath@define@shrink#1\relax{%
  \expandafter\gdef\csname spath@sh@#1\endcsname##1##2{%
    \pgfmathsetlength{\pgf@xa}{##1 < \spath@trx ? ##1 + \spath@shrinkby : (##1 > \spath@trx ? ##1 - \spath@shrinkby : ##1)}%
    \pgfmathsetlength{\pgf@ya}{##2 < \spath@try ? ##2 + \spath@shrinkby : (##2 > \spath@try ? ##2 - \spath@shrinkby : ##2)}%
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{\the\pgf@xa}{\the\pgf@ya}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% Each soft path token rotates its arguments about the given origin and then appends itself to the temporary path.
% Then it increments the rotation counter.
%    \begin{macrocode}
\def\spath@define@spirograph#1\relax{%
  \expandafter\gdef\csname spath@gch@#1\endcsname##1##2{%
    \pgf@xa=##1\relax
    \pgf@ya=##2\relax
    \advance\pgf@xa by -\spath@trx
    \advance\pgf@ya by -\spath@try
    \pgfmathsetmacro\spath@gcos{cos(\spath@n * \spath@gang)}
    \pgfmathsetmacro\spath@gsin{sin(\spath@n * \spath@gang)}
    \pgfmathsetmacro\spath@n{\spath@n + 1}%
    \global\let\spath@n=\spath@n
    \pgfmathsetlength\pgf@xb{\spath@gcos * \pgf@xa - \spath@gsin * \pgf@ya}
    \pgfmathsetlength\pgf@yb{\spath@gsin * \pgf@xa + \spath@gcos * \pgf@ya}
    \advance\pgf@xb by \spath@trx
    \advance\pgf@yb by \spath@try
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{\the\pgf@xb}{\the\pgf@yb}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% Each soft path token rotates its arguments and then appends itself to the temporary path.
%    \begin{macrocode}
\def\spath@define@rotate#1\relax{%
  \expandafter\gdef\csname spath@rot@#1\endcsname##1##2{%
    \pgf@xa=##1\relax
    \pgf@ya=##2\relax
    \pgfmathsetlength\pgf@xb{\spath@gcos * \pgf@xa - \spath@gsin * \pgf@ya}
    \pgfmathsetlength\pgf@yb{\spath@gsin * \pgf@xa + \spath@gcos * \pgf@ya}
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{\the\pgf@xb}{\the\pgf@yb}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% This is for the length, we simply increment the length counter.
%    \begin{macrocode}
\def\spath@define@length#1\relax{%
  \expandafter\gdef\csname spath@len@#1\endcsname##1##2{%
    \stepcounter{spath@length}
  }
}
%    \end{macrocode}
% This is for the number of components, by default we do nothing.
% The special code for the \Verb+moveto+ will be set up later.
%    \begin{macrocode}
\def\spath@define@components#1\relax{%
  \expandafter\gdef\csname spath@comp@#1\endcsname##1##2{%
  }
}
%    \end{macrocode}
% This is for the real length, by default we do nothing.
% The special code for the \Verb+lineto+ and \Verb+curveto+ will be set up later.
%    \begin{macrocode}
\def\spath@define@reallength#1\relax{%
  \expandafter\gdef\csname spath@rlen@#1\endcsname##1##2{%
  }
}
%    \end{macrocode}
% This is for reversing the path.
% By default, we place our coordinates \emph{before} the current token.
% The special code for the \Verb+curveto+ will be set up later.
%    \begin{macrocode}
\def\spath@define@reverse#1\relax{%
  \expandafter\gdef\csname spath@rev@#1\endcsname##1##2{%
    \edef\spath@tmp{{##1}{##2}\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname}
    \ge@addbefore@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% This is for recording the start of a path, so we save our coordinates and then reinitialise so that the rest of the path does nothing.
%    \begin{macrocode}
\def\spath@define@start#1\relax{%
  \expandafter\gdef\csname spath@start@#1\endcsname##1##2{%
    \edef\spath@sx{##1}
    \edef\spath@sy{##2}
    \spath@start@reinit
  }
}
%    \end{macrocode}
% This is for recording the end of a path, so we save our coordinates.
% Each component overwrites what the previous one saved so we're left with the final coordinates.
%    \begin{macrocode}
\def\spath@define@end#1\relax{%
  \expandafter\gdef\csname spath@end@#1\endcsname##1##2{%
    \edef\spath@ex{##1}
    \edef\spath@ey{##2}
  }
}
%    \end{macrocode}
% This is for splitting a soft path into components.
% The default action is to add ourself to the current temporary path.
%    \begin{macrocode}
\def\spath@define@array#1\relax{%
  \expandafter\gdef\csname spath@array@#1\endcsname##1##2{%
    \edef\spath@tmp{\expandafter\noexpand\csname       pgfsyssoftpath@#1token\endcsname{##1}{##2}}
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% This is for reprocessing the path.
%    \begin{macrocode}
\def\spath@define@reprocess#1\relax{%
  \expandafter\gdef\csname spath@rep@#1\endcsname##1##2{%
    \csname pgfpath#1\endcsname{\pgfpoint{##1}{##2}}%
  }%
}
%    \end{macrocode}
% This is for splitting self-intersecting pieces.
% Most pieces just record the endpoints.
% We only actually split \Verb+curveto+s.
%    \begin{macrocode}
\def\spath@define@selfintersect#1{%
  \expandafter\gdef\csname spath@selfintersect@#1\endcsname##1##2{%
    \edef\spath@ex{##1}%
    \edef\spath@ey{##2}%
    \edef\spath@tmp{\expandafter\noexpand\csname pgfsyssoftpath@#1token\endcsname{##1}{##2}}%
    \ge@addto@macro\spath@tmppath\spath@tmp
  }
}
%    \end{macrocode}
% This is for computing the bounding box
%    \begin{macrocode}
\def\spath@define@boundingbox#1{%
  \expandafter\gdef\csname spath@boundingbox@#1\endcsname##1##2{%
     \pgfmathsetmacro\spath@mix{min(\spath@mix,##1)}%
     \pgfmathsetmacro\spath@miy{min(\spath@miy,##2)}%
     \pgfmathsetmacro\spath@max{max(\spath@max,##1)}%
     \pgfmathsetmacro\spath@may{max(\spath@may,##2)}%
  }%
}%
%    \end{macrocode}
% This is for converting the path into a string
%    \begin{macrocode}
\def\spath@define@string#1\relax{%
  \expandafter\gdef\csname spath@str@#1\endcsname##1##2{%
  \pgfmathsetmacro\spath@sx{##1/1cm}%
  \pgfmathsetmacro\spath@sy{##2/1cm}%
    \expandafter\string\csname pgfpath#1\endcsname\{\string\pgfpointxy\{\spath@sx\}\{\spath@sy\}\}\\%
  }%
}
%    \end{macrocode}
% The next part of the code sets up the initialiser code for each of the routines.
% We start with empty initialiser code.
%    \begin{macrocode} 
\let\spath@spirograph@init=\pgfutil@empty
\let\spath@rotate@init=\pgfutil@empty
\let\spath@round@init=\pgfutil@empty
\let\spath@translate@init=\pgfutil@empty
\let\spath@transform@init=\pgfutil@empty
\let\spath@scale@init=\pgfutil@empty
\let\spath@shrink@init=\pgfutil@empty
\let\spath@length@init=\pgfutil@empty
\let\spath@components@init=\pgfutil@empty
\let\spath@reallength@init=\pgfutil@empty
\let\spath@reverse@init=\pgfutil@empty
\let\spath@start@init=\pgfutil@empty
\let\spath@start@reinit=\pgfutil@empty
\let\spath@end@init=\pgfutil@empty
\let\spath@array@init=\pgfutil@empty
\let\spath@prepare@init=\pgfutil@empty
\let\spath@reprocess@init=\pgfutil@empty
\let\spath@string@init=\pgfutil@empty
\let\spath@selfintersect@init=\pgfutil@empty
\def\spath@boundingbox@init{%
  \def\spath@mix{16000pt}%
  \def\spath@miy{16000pt}%
  \def\spath@max{-16000pt}%
  \def\spath@may{-16000pt}%
}
%    \end{macrocode}
% We now loop over the possible soft path tokens and define the different types of action each will expand to in the different circumstances.
% These are the default actions, as defined by the above macros.
% Specific actions can be redefined afterwards.
%    \begin{macrocode}
  \tikz@clear@foreach
\foreach \spath@cpt in {
  moveto,
  lineto,
  curvetosupporta,
  curvetosupportb,
  curveto,
  rectcorner,
  rectsize,
  closepath,
  specialround%
} {
%    \end{macrocode}
% Save token names for comparison
%    \begin{macrocode}
\expandafter\xdef\csname spath@\spath@cpt\endcsname{\expandafter\string\csname pgfsyssoftpath@\spath@cpt token\endcsname}
%    \end{macrocode}
% Define the translation macros.
%    \begin{macrocode}
\expandafter\spath@define@translate\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@tr@\spath@cpt \endcsname}

\ge@addto@macro\spath@translate@init\spath@tmp
%    \end{macrocode}
% Define the transformation macros.
%    \begin{macrocode}
\expandafter\spath@define@transform\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@trans@\spath@cpt \endcsname}

\ge@addto@macro\spath@transform@init\spath@tmp
%    \end{macrocode}
% Define the scaling macros.
%    \begin{macrocode}
\expandafter\spath@define@scale\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@sc@\spath@cpt \endcsname}

\ge@addto@macro\spath@scale@init\spath@tmp
%    \end{macrocode}
% Define the rounding macros.
%    \begin{macrocode}
\expandafter\spath@define@round\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@rnd@\spath@cpt \endcsname}

\ge@addto@macro\spath@round@init\spath@tmp
%    \end{macrocode}
% Define the shrinking macros.
%    \begin{macrocode}
\expandafter\spath@define@shrink\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@sh@\spath@cpt \endcsname}

\ge@addto@macro\spath@shrink@init\spath@tmp
%    \end{macrocode}
% Define the spirograph macros.
%    \begin{macrocode}
\expandafter\spath@define@spirograph\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@gch@\spath@cpt \endcsname}

\ge@addto@macro\spath@spirograph@init\spath@tmp
%    \end{macrocode}
% Define the rotation macros.
%    \begin{macrocode}
\expandafter\spath@define@rotate\spath@cpt\relax
%    \end{macrocode}
% Add the ``redefinition'' code to the initialiser
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@rot@\spath@cpt \endcsname}

\ge@addto@macro\spath@rotate@init\spath@tmp
%    \end{macrocode}
% Now do the same for counting the total length.
%    \begin{macrocode}
\expandafter\spath@define@length\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@len@\spath@cpt \endcsname}

\ge@addto@macro\spath@length@init\spath@tmp
%    \end{macrocode}
% Now do the same for counting the components.
%    \begin{macrocode}
\expandafter\spath@define@components\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@comp@\spath@cpt \endcsname}

\ge@addto@macro\spath@components@init\spath@tmp
%    \end{macrocode}
% Now do the same for counting the real length.
%    \begin{macrocode}
\expandafter\spath@define@reallength\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@rlen@\spath@cpt \endcsname}

\ge@addto@macro\spath@reallength@init\spath@tmp
%    \end{macrocode}
% This is for reversing a path.
%    \begin{macrocode}
\expandafter\spath@define@reverse\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@rev@\spath@cpt \endcsname}

\ge@addto@macro\spath@reverse@init\spath@tmp
%    \end{macrocode}
% This is for the initial coordinates
%    \begin{macrocode}
\expandafter\spath@define@start\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@start@\spath@cpt \endcsname}

\ge@addto@macro\spath@start@init\spath@tmp
%    \end{macrocode}
% Once we have the initial coordinates, we reinitialise our path tokens so that they just gobble their code.
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\noexpand\@gobbletwo}

\ge@addto@macro\spath@start@reinit\spath@tmp
%    \end{macrocode}
% This is for the final coordinates.
%    \begin{macrocode}
\expandafter\spath@define@end\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@end@\spath@cpt \endcsname}

\ge@addto@macro\spath@end@init\spath@tmp
%    \end{macrocode}
% Split in to array
%    \begin{macrocode}
\expandafter\spath@define@array\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@array@\spath@cpt \endcsname}

\ge@addto@macro\spath@array@init\spath@tmp
%    \end{macrocode}
% Prepare a path, figuring out all the data.
% Actions are too complicated to specify a template so just create
% initialisation code
%    \begin{macrocode}
\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@prepare@\spath@cpt \endcsname}

\ge@addto@macro\spath@prepare@init\spath@tmp
%    \end{macrocode}
% Reprocess a path
%    \begin{macrocode}
\expandafter\spath@define@reprocess\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@rep@\spath@cpt \endcsname}

\ge@addto@macro\spath@reprocess@init\spath@tmp
%    \end{macrocode}
% Split self-intersecting pieces
%    \begin{macrocode}
\expandafter\spath@define@selfintersect\expandafter{\spath@cpt}

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@selfintersect@\spath@cpt \endcsname}

\ge@addto@macro\spath@selfintersect@init\spath@tmp
%    \end{macrocode}
% Bounding box
%    \begin{macrocode}
\expandafter\spath@define@boundingbox\expandafter{\spath@cpt}

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@boundingbox@\spath@cpt \endcsname}

\ge@addto@macro\spath@boundingbox@init\spath@tmp
%    \end{macrocode}
% To string
%    \begin{macrocode}
\expandafter\spath@define@string\spath@cpt\relax

\edef\spath@tmp{\noexpand\let\expandafter\noexpand\csname pgfsyssoftpath@\spath@cpt token\endcsname=\expandafter\noexpand\csname spath@str@\spath@cpt \endcsname}

\ge@addto@macro\spath@string@init\spath@tmp
%    \end{macrocode}
% Phew!
%    \begin{macrocode}
}
%    \end{macrocode}
% Now we add the corrections for the above: where an action deviates from the ``default'' we need to redefine it.
%
% Correction for counting components: count movetos
%    \begin{macrocode}
\def\spath@comp@moveto#1#2{%
  \stepcounter{spath@length}%
}
%    \end{macrocode}
% Correction for counting real length: count linetos and curvetos
%    \begin{macrocode}
\def\spath@rlen@lineto#1#2{%
  \stepcounter{spath@length}%
}
\def\spath@rlen@curveto#1#2{%
  \stepcounter{spath@length}%
}
%    \end{macrocode}
% Correction for reversing initial moveto
%    \begin{macrocode}
\def\spath@rev@moveto#1#2{
  \ifx\spath@tmppath\pgfutil@empty
  \edef\spath@tmp{{#1}{#2}}%
  \else
  \edef\spath@tmp{{#1}{#2}\noexpand\pgfsyssoftpath@movetotoken}%
  \fi
  \ge@addbefore@macro\spath@tmppath\spath@tmp
}
%    \end{macrocode}
% Correction for reversing curvetos
%    \begin{macrocode}
\def\spath@rev@curvetosupporta#1#2{%
  \edef\spath@tmp{{#1}{#2}\noexpand\pgfsyssoftpath@curvetotoken}%
  \ge@addbefore@macro\spath@tmppath\spath@tmp
}
\def\spath@rev@curvetosupportb#1#2{%
  \edef\spath@tmp{{#1}{#2}\noexpand\pgfsyssoftpath@curvetosupportbtoken}%
  \ge@addbefore@macro\spath@tmppath\spath@tmp
}
\def\spath@rev@curveto#1#2{%
  \edef\spath@tmp{{#1}{#2}\noexpand\pgfsyssoftpath@curvetosupportatoken}%
  \ge@addbefore@macro\spath@tmppath\spath@tmp
}
%    \end{macrocode}
% Correction for reversing closepaths
%    \begin{macrocode}
\def\spath@rev@closepath#1#2{%
  \edef\spath@tmp{\noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}}%
  \ge@addto@macro\spath@tmppath\spath@tmp
}
%    \end{macrocode}
% Correction for reprocessing path: curvetos
%    \begin{macrocode}
\def\spath@rep@curvetosupporta#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
    \pgfpathcurveto{\pgfpoint{#1}{#2}}{\pgfpoint{#3}{#4}}{\pgfpoint{#5}{#6}}%
  }%
%    \end{macrocode}
% Correction for converting path to string: curvetos
%    \begin{macrocode}
\def\spath@str@curvetosupporta#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
  \pgfmathsetmacro\spath@sx{#1/1cm}%
  \pgfmathsetmacro\spath@sy{#2/1cm}%
    \string\pgfpathcurveto\{\string\pgfpointxy\{\spath@sx\}\{\spath@sy\}\}%
  \pgfmathsetmacro\spath@sx{#3/1cm}%
  \pgfmathsetmacro\spath@sy{#4/1cm}%
  \{\string\pgfpointxy\{\spath@sx\}\{\spath@sy\}\}%
  \pgfmathsetmacro\spath@sx{#5/1cm}%
  \pgfmathsetmacro\spath@sy{#6/1cm}%
  \{\string\pgfpointxy\{\spath@sx\}\{\spath@sy\}\}\\%
  }%
%    \end{macrocode}
% Closepath
%    \begin{macrocode}
\def\spath@str@closepath#1#2{%
  \string\pgfclosepath\\}
%    \end{macrocode}
% Correction for splitting in to an array
%    \begin{macrocode}
\def\spath@array@moveto#1#2{%
  \ifx\spath@tmppath\pgfutil@empty
  \else
   \expandafter\global\expandafter\let\csname spath@array@\spath@path@name @\the\value{spath@array}\endcsname=\spath@tmppath
   \def\spath@tmppath{\pgfsyssoftpath@movetotoken{#1}{#2}}%
  \fi
  \stepcounter{spath@array}%
}
%    \end{macrocode}
% Correction for rounding corners: lineto and curvetosupporta need to add the extra token
%    \begin{macrocode}
\def\spath@rnd@lineto#1#2{%
  \edef\spath@tmp{%
    \noexpand\pgfsyssoftpath@specialroundtoken{\spath@rndx}{\spath@rndy}%
    \noexpand\pgfsyssoftpath@linetotoken{#1}{#2}}%
    \ge@addto@macro\spath@tmppath\spath@tmp
}
\def\spath@rnd@closepath#1#2{%
  \edef\spath@tmp{%
    \noexpand\pgfsyssoftpath@specialroundtoken{\spath@rndx}{\spath@rndy}%
    \noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}}%
    \ge@addto@macro\spath@tmppath\spath@tmp
}
\def\spath@rnd@curvetosupportatoken#1#2{%
  \edef\spath@tmp{%
    \noexpand\pgfsyssoftpath@specialroundtoken{\spath@rndx}{\spath@rndy}%
    \noexpand\pgfsyssoftpath@curvetosupportatoken{#1}{#2}}%
    \ge@addto@macro\spath@tmppath\spath@tmp
}
%    \end{macrocode}
% Whereas existing special round tokens should take the maximum of their rounding and the specified rounding, and also ensure that the next corner is not \emph{doubly} rounded.
%    \begin{macrocode}
\def\spath@rnd@specialround#1#2#3#4#5{%
  \pgfmathsetmacro{\spath@srndx}{max(#1,\spath@rndx)}%
  \pgfmathsetmacro{\spath@srndy}{max(#1,\spath@rndy)}%
  \edef\spath@tmp{%
    \noexpand\pgfsyssoftpath@specialroundtoken{\spath@srndx pt}{\spath@srndy pt}%
    \noexpand#3{#4}{#5}}%
    \ge@addto@macro\spath@tmppath\spath@tmp
}
%    \end{macrocode}
% Correction for special rounds: almost nothing should touch these
%    \begin{macrocode}
\def\spath@tr@specialround#1#2{%
  \edef\spath@tmp{\noexpand\pgfsyssoftpath@specialroundtoken{#1}{#2}}%
  \ge@addto@macro\spath@tmppath\spath@tmp
}  
\def\spath@rev@specialround#1#2{%
  \edef\spath@tmp{\noexpand\pgfsyssoftpath@specialroundtoken{#1}{#2}}%
  \ge@addto@macro\spath@tmppath\spath@tmp
}  
\def\spath@sh@specialround#1#2{%
  \edef\spath@tmp{\noexpand\pgfsyssoftpath@specialroundtoken{#1}{#2}}%
  \ge@addto@macro\spath@tmppath\spath@tmp
}  
\def\spath@rot@specialround#1#2{%
  \edef\spath@tmp{\noexpand\pgfsyssoftpath@specialroundtoken{#1}{#2}}%
  \ge@addto@macro\spath@tmppath\spath@tmp
}  
%    \end{macrocode}
% The ``prepare'' routine is too complicated to have defaults, so we need to set up them all here.
% At the moment, this reverses the path as well.
% This is now implemented in a different way so should be removed.
%    \begin{macrocode}
\def\spath@prepare@moveto#1#2{%
  \ifx\spath@tmppath\pgfutil@empty
  \g@addbefore@macro\spath@tmppath{{#1}{#2}}%
  \edef\spath@sx{#1}%
  \edef\spath@sy{#2}%
  \edef\spath@mix{#1}%
  \edef\spath@miy{#2}%
  \edef\spath@max{#1}%
  \edef\spath@may{#2}%
  \else
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@movetotoken}%
  \pgfmathsetmacro{\spath@mix}{min(\spath@mix,#1)}%
  \pgfmathsetmacro{\spath@max}{max(\spath@max,#1)}%
  \pgfmathsetmacro{\spath@miy}{min(\spath@miy,#2)}%
  \pgfmathsetmacro{\spath@may}{max(\spath@may,#2)}%
  \fi
  \edef\spath@ex{#1}%
  \edef\spath@ey{#2}%
  \stepcounter{spath@length}%
  \stepcounter{spath@components}%
  \let\spath@last\spath@moveto
}

\def\spath@prepare@lineto#1#2{%
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@linetotoken}%
  \edef\spath@ex{#1}%
  \edef\spath@ey{#2}%
  \pgfmathsetmacro{\spath@mix}{min(\spath@mix,#1)}%
  \pgfmathsetmacro{\spath@max}{max(\spath@max,#1)}%
  \pgfmathsetmacro{\spath@miy}{min(\spath@miy,#2)}%
  \pgfmathsetmacro{\spath@may}{max(\spath@may,#2)}%
  \stepcounter{spath@length}%
  \stepcounter{spath@reallength}%
  \let\spath@last\spath@lineto
  \ifx\spath@first\pgfutil@empty
  \let\spath@first\spath@lineto
  \fi
}

\def\spath@prepare@curveto#1#2{%
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@curvetosupportatoken}%
  \edef\spath@ex{#1}%
  \edef\spath@ey{#2}%
  \pgfmathsetmacro{\spath@mix}{min(\spath@mix,#1)}%
  \pgfmathsetmacro{\spath@max}{max(\spath@max,#1)}%
  \pgfmathsetmacro{\spath@miy}{min(\spath@miy,#2)}%
  \pgfmathsetmacro{\spath@may}{max(\spath@may,#2)}%
  \stepcounter{spath@length}%
  \stepcounter{spath@reallength}%
  \let\spath@last\spath@curveto
  \ifx\spath@first\pgfutil@empty
  \let\spath@first\spath@curveto
  \fi
}

\def\spath@prepare@curvetosupporta#1#2{%
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@curvetotoken}%
  \stepcounter{spath@length}%
  \pgfmathsetmacro{\spath@mix}{min(\spath@mix,#1)}%
  \pgfmathsetmacro{\spath@max}{max(\spath@max,#1)}%
  \pgfmathsetmacro{\spath@miy}{min(\spath@miy,#2)}%
  \pgfmathsetmacro{\spath@may}{max(\spath@may,#2)}%
}

\def\spath@prepare@curvetosupportb#1#2{%
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@curvetosupportbtoken}%
  \stepcounter{spath@length}%
  \pgfmathsetmacro{\spath@mix}{min(\spath@mix,#1)}%
  \pgfmathsetmacro{\spath@max}{max(\spath@max,#1)}%
  \pgfmathsetmacro{\spath@miy}{min(\spath@miy,#2)}%
  \pgfmathsetmacro{\spath@may}{max(\spath@may,#2)}%
}

\def\spath@prepare@closepath#1#2{%
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@closepathtoken}%
  \stepcounter{spath@length}%
}

\def\spath@prepare@specialround#1#2{%
  \g@addbefore@macro\spath@tmppath{{#1}{#2}\pgfsyssoftpath@specialroundtoken}%
  \stepcounter{spath@length}%
}
%    \end{macrocode}
% At the moment, this doesn't handle the closepath variants very well (if at all).
% This needs implementing.
%
% This splits a \Verb+curveto+ if there is a possibility that it self-intersects.
%    \begin{macrocode}
\def\spath@selfintersect@curvetosupporta#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
  \pgfmathsetmacro{\spath@ax}{\spath@ex/28}
  \pgfmathsetmacro{\spath@bx}{#1/28}
  \pgfmathsetmacro{\spath@cx}{#3/28}
  \pgfmathsetmacro{\spath@dx}{#5/28}
  \pgfmathsetmacro{\spath@ay}{\spath@ey/28}
  \pgfmathsetmacro{\spath@by}{#2/28}
  \pgfmathsetmacro{\spath@cy}{#4/28}
  \pgfmathsetmacro{\spath@dy}{#6/28}
  \pgfmathsetmacro{\spath@enum}{%
    ( (\spath@ay - 3 * \spath@by + 3 * \spath@cy - \spath@dy) * (3 * \spath@cx - 3 * \spath@dx)
    - (\spath@ax - 3 * \spath@bx + 3 * \spath@cx - \spath@dx) * (3 * \spath@cy - 3 * \spath@dy) )}
  \pgfmathsetmacro{\spath@denum}{%
    ( (\spath@ax - 3 * \spath@bx + 3 * \spath@cx - \spath@dx) * (3 * \spath@by - 6 * \spath@cy + 3 * \spath@dy)
    - (\spath@ay - 3 * \spath@by + 3 * \spath@cy - \spath@dy) * (3 * \spath@bx - 6 * \spath@cx + 3 * \spath@dx) )}
  \pgfmathtruncatemacro{\spath@split}{\spath@enum > 0 ? (\spath@enum < 2 * \spath@denum) : (\spath@enum > 2 * \spath@denum)}
  \ifnum\spath@split=1\relax
  \pgfmathsetmacro{\spath@splitt}{.5*(\spath@enum)/(\spath@denum)}%
  \pgfsyssoftpath@setcurrentpath{\spath@tmppath}%
  \pgfpathcurvebetweentimecontinue{0}{\spath@splitt}{\pgfqpoint{\spath@ex}{\spath@ey}}{\pgfqpoint{#1}{#2}}{\pgfqpoint{#3}{#4}}{\pgfqpoint{#5}{#6}}%
  \pgfpathcurvebetweentimecontinue{\spath@splitt}{1}{\pgfqpoint{\spath@ex}{\spath@ey}}{\pgfqpoint{#1}{#2}}{\pgfqpoint{#3}{#4}}{\pgfqpoint{#5}{#6}}%
  \pgfsyssoftpath@getcurrentpath{\spath@tmppath}%
  \else
    \g@addto@macro\spath@tmppath{%
    \pgfsyssoftpath@curvetosupportatoken{#1}{#2}%
    \pgfsyssoftpath@curvetosupportbtoken{#3}{#4}%
    \pgfsyssoftpath@curvetotoken{#5}{#6}%
  }%
  \fi
  \edef\spath@ex{#5}%
  \edef\spath@ey{#6}%
}
%    \end{macrocode}
%
% Now we have some helper macros.
% This gets rid of the initial \Verb+moveto+, leaving the rest in \Verb+\spath@tmppath+.
%    \begin{macrocode}
\def\spath@trimfirst#1#2#3#4\relax{%
  \edef\spath@this@action{\string#1}%
  \ifx\spath@this@action\spath@moveto
   \def\spath@tmppath{#4}%
  \else
   \def\spath@tmppath{#1{#2}{#3}#4}%
  \fi
}
%    \end{macrocode}
% This replaces the initial \Verb+moveto+ with a \Verb+lineto+, leaving the whole path in \Verb+\spath@tmppath+.
%    \begin{macrocode}
\def\spath@movetoline#1#2#3#4\relax{%
  \edef\spath@this@action{\string#1}%
  \ifx\spath@this@action\spath@moveto
   \def\spath@tmppath{\pgfsyssoftpath@linetotoken{#2}{#3}#4}%
  \else
   \def\spath@tmppath{#1{#2}{#3}#4}%
  \fi
}
%    \end{macrocode}
% This is our gobbling macro for splitting a path according to some criterion (length, real length, or number of components).
%    \begin{macrocode}
\def\spath@gobble#1#2#3{%
  \stepcounter{spath@length}%
  \edef\spath@this@action{\string#1}%
  \ifx\spath@this@action\spath@lineto
   \stepcounter{spath@reallength}%
  \fi
  \ifx\spath@this@action\spath@curveto
   \stepcounter{spath@reallength}%
  \fi
  \ifx\spath@this@action\spath@moveto
   \stepcounter{spath@components}%
  \fi
  \g@addto@macro\spath@tmppatha{#1{#2}{#3}}%
  \ifnum\spath@test=\spath@splitat\relax
   \def\spath@tmppath{\pgfsyssoftpath@movetotoken{#2}{#3}}%
   \edef\spath@last{\string#1}%
   \ifx\spath@last\spath@curvetosupporta
    \let\spath@last=\spath@curveto
   \fi
   \edef\spath@ex{#2}%
   \edef\spath@ey{#3}%
   \let\spath@next=\spath@lastgobble
  \else
   \let\spath@next=\spath@gobble
  \fi
  \pgfutil@ifnextchar\relax{%
    \ifx\spath@next\spath@gobble
     \def\spath@tmppath{\pgfsyssoftpath@movetotoken{#2}{#3}}%
     \edef\spath@last{\string#1}%
     \ifx\spath@last\spath@curvetosupporta
      \let\spath@last=\spath@curveto
     \fi
     \edef\spath@ex{#2}%
     \edef\spath@ey{#3}%
    \fi
    \edef\spath@sx{#2}%
    \edef\spath@sy{#3}%
    \let\spath@first\spath@moveto
    }{\spath@next}%
}
\def\spath@lastgobble#1#2#3#4\relax{%
  \g@addto@macro\spath@tmppath{#1{#2}{#3}#4}%
   \edef\spath@first{\string#1}%
  \ifx\spath@first\spath@curvetosupporta
  \let\spath@first=\spath@curveto
  \fi
   \edef\spath@sx{#2}%
   \edef\spath@sy{#3}%
}
%    \end{macrocode}
% We need a few dimensions and counters to keep track of things.
%    \begin{macrocode}
\newdimen\spath@trx
\newdimen\spath@try
\newcounter{spath@length}
\newcounter{spath@reallength}
\newcounter{spath@components}
\newcounter{spath@array}
%    \end{macrocode}
%
% \begin{macro}{\spath@taper@lineto@out}
% This macro sets things up for tapering a \Verb+lineto+.
%    \begin{macrocode}
\def\spath@taper@lineto@out#1#2#3#4#5#6#7\relax{%
%    \end{macrocode}
% \#1 is \Verb+\pgfsyssoftpath@movetotoken+
% \#2 is x-coord of starting point
% \#3 is y-coord of starting point
% \#4 is \Verb+\pgfsyssoftpath@linetotoken+
% \#5 is x-coord of ending point
% \#6 is y-coord of ending point
% \#7 shouldn't have anything in
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@sx}{.7 * #2 + .3 * #5}
  \pgfmathsetmacro{\spath@sy}{.7 * #3 + .3 * #6}
  \pgfmathsetmacro{\spath@ex}{.3 * #2 + .7 * #5}
  \pgfmathsetmacro{\spath@ey}{.3 * #3 + .7 * #6}
  \edef\spath@tmp{\noexpand\spath@taper@path{#2}{#3}{\spath@sx pt}{\spath@sy pt}{\spath@ex pt}{\spath@ey pt}{#5}{#6}}
  \spath@tmp
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@taper@curveto@out}
% This macro sets things up for tapering a \Verb+curveto+.
%    \begin{macrocode}
\def\spath@taper@curveto@out\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@curvetosupportatoken#3#4\pgfsyssoftpath@curvetosupportbtoken#5#6\pgfsyssoftpath@curvetotoken#7#8#9\relax{%
  \spath@taper@path{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@taper@path}
% This is the actual tapering macro.
%    \begin{macrocode}
\def\spath@taper@path#1#2#3#4#5#6#7#8{
%    \end{macrocode}
% \#1 is x-coord of starting point
% \#2 is y-coord of starting point
% \#3 is x-coord of first control point
% \#4 is y-coord of first control point
% \#5 is x-coord of second control point
% \#6 is y-coord of second control point
% \#7 is x-coord of ending point
% \#8 is y-coord of ending point
%    \begin{macrocode}
  \edef\spath@sx{#1}
  \edef\spath@sy{#2}
  \edef\spath@cx{#3}
  \edef\spath@cy{#4}
  \edef\spath@dx{#5}
  \edef\spath@dy{#6}
  \edef\spath@ex{#7}
  \edef\spath@ey{#8}
  
%    \end{macrocode}
% Orthogonal vector at end
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@ox}{-\spath@ey + \spath@dy}
  \pgfmathsetmacro{\spath@oy}{\spath@ex - \spath@dx}
  
%    \end{macrocode}
% Orthogonal vector at start
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@sox}{\spath@sy - \spath@cy}
  \pgfmathsetmacro{\spath@soy}{-\spath@sx + \spath@cx}
  
%    \end{macrocode}
% Adjust length to half the line width
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@oox}{.5*\spath@ox * \pgflinewidth / veclen(\spath@ox,\spath@oy)}
  \pgfmathsetmacro{\spath@ooy}{.5*\spath@oy * \pgflinewidth / veclen(\spath@ox,\spath@oy)}
  
%    \end{macrocode}
% Adjust length to half the thinner line width
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@soox}{.5*\spath@sox * \taper@line@width / veclen(\spath@sox,\spath@soy)}
  \pgfmathsetmacro{\spath@sooy}{.5*\spath@soy * \taper@line@width / veclen(\spath@sox,\spath@soy)}
%    \end{macrocode}
% Shift the start point, the control points, and the end points
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@sx}{\spath@sx + \spath@soox}
  \pgfmathsetmacro{\spath@sy}{\spath@sy + \spath@sooy}
  \pgfmathsetmacro{\spath@cx}{\spath@cx + \spath@soox}
  \pgfmathsetmacro{\spath@cy}{\spath@cy + \spath@sooy}
  \pgfmathsetmacro{\spath@dx}{\spath@dx + \spath@oox}
  \pgfmathsetmacro{\spath@dy}{\spath@dy + \spath@ooy}
  \pgfmathsetmacro{\spath@ex}{\spath@ex + \spath@oox}
  \pgfmathsetmacro{\spath@ey}{\spath@ey + \spath@ooy}
%    \end{macrocode}
% Add the first pieces
%    \begin{macrocode}
  \let\spath@tapered@path=\pgfutil@empty
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@movetotoken{\spath@sx pt}{\spath@sy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx pt}{\spath@cy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetotoken{\spath@ex pt}{\spath@ey pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
%    \end{macrocode}
% Make the end roughly round
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@fx}{\spath@ex + 1.32*\spath@ooy}
  \pgfmathsetmacro{\spath@fy}{\spath@ey - 1.32*\spath@oox}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@fx pt}{\spath@fy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
%    \end{macrocode}
% Shift the end points and the control points again
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@fx}{\spath@fx - 2*\spath@oox}
  \pgfmathsetmacro{\spath@fy}{\spath@fy - 2*\spath@ooy}
  \pgfmathsetmacro{\spath@dx}{\spath@dx - 2*\spath@oox}
  \pgfmathsetmacro{\spath@dy}{\spath@dy - 2*\spath@ooy}
  \pgfmathsetmacro{\spath@ex}{\spath@ex - 2*\spath@oox}
  \pgfmathsetmacro{\spath@ey}{\spath@ey - 2*\spath@ooy}
  \pgfmathsetmacro{\spath@cx}{\spath@cx - 2*\spath@soox}
  \pgfmathsetmacro{\spath@cy}{\spath@cy - 2*\spath@sooy}
  \pgfmathsetmacro{\spath@sx}{\spath@sx - 2*\spath@soox}
  \pgfmathsetmacro{\spath@sy}{\spath@sy - 2*\spath@sooy}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@fx pt}{\spath@fy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetotoken{\spath@ex pt}{\spath@ey pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@dx pt}{\spath@dy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@cx pt}{\spath@cy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetotoken{\spath@sx pt}{\spath@sy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
%    \end{macrocode}
% Make the end roughly round
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@fx}{\spath@sx - 1.32*\spath@sooy}
  \pgfmathsetmacro{\spath@fy}{\spath@sy + 1.32*\spath@soox}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@fx pt}{\spath@fy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \pgfmathsetmacro{\spath@fx}{\spath@fx + 2*\spath@soox}
  \pgfmathsetmacro{\spath@fy}{\spath@fy + 2*\spath@sooy}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@fx pt}{\spath@fy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
  \pgfmathsetmacro{\spath@sx}{\spath@sx + 2*\spath@soox}
  \pgfmathsetmacro{\spath@sy}{\spath@sy + 2*\spath@sooy}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetotoken{\spath@sx pt}{\spath@sy pt}}
  \ge@addto@macro\spath@tapered@path\spath@to@add
%    \end{macrocode}
% Close the path, ought to make it rounded
%    \begin{macrocode}
%  \g@addto@macro{\spath@tapered@path}{\pgfsyssoftpath@closepathtoken}
}
%    \end{macrocode}
% \end{macro}
%
% The following have been modified to fit the new routines
%
% \begin{macro}{\spath@single@split}
%    \begin{macrocode}
\def\spath@single@split{.3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spath@split@single@lineto}
% This splits a single \Verb+lineto+ into three pieces.
%    \begin{macrocode}
\def\spath@split@single@lineto\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@linetotoken#3#4#5\relax{%
  \pgfmathsetmacro{\spath@sx}{(1-\spath@single@split)*#1 + \spath@single@split * #3}
  \pgfmathsetmacro{\spath@sy}{(1-\spath@single@split)*#2 + \spath@single@split * #4}
  \pgfmathsetmacro{\spath@ex}{(1-\spath@single@split)*#3 + \spath@single@split * #1}
  \pgfmathsetmacro{\spath@ey}{(1-\spath@single@split)*#4 + \spath@single@split * #2}
  \edef\spath@tmppath{\noexpand\pgfsyssoftpath@movetotoken{#1}{#2}\noexpand\pgfsyssoftpath@linetotoken{\spath@sx     pt}{\spath@sy pt}\noexpand\pgfsyssoftpath@linetotoken{\spath@ex pt}{\spath@ey pt}\noexpand\pgfsyssoftpath@linetotoken{#3}{#4}}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@split@single@curveto}
% This splits a single \Verb+curveto+ into three pieces.
%    \begin{macrocode}
\def\spath@split@single@curveto\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@curvetosupportatoken#3#4\pgfsyssoftpath@curvetosupportbtoken#5#6\pgfsyssoftpath@curvetotoken#7#8#9\relax{%
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@single@split)*#1 + \spath@single@split * #3}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@single@split)*#2 + \spath@single@split * #4}
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@single@split)^2 * #1 + 2*\spath@single@split * (1 - \spath@single@split) * #3 + \spath@single@split^2 * #5}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@single@split)^2 * #2 + 2*\spath@single@split * (1 - \spath@single@split) * #4 + \spath@single@split^2 * #6}
  \pgfmathsetmacro{\spath@ex}{(1 - \spath@single@split)^3 * #1 + 3*\spath@single@split * (1 - \spath@single@split)^2 * #3 + 3*\spath@single@split^2 * (1 - \spath@single@split) * #5 + \spath@single@split^3 * #7}
  \pgfmathsetmacro{\spath@ey}{(1 - \spath@single@split)^3 * #2 + 3*\spath@single@split * (1 - \spath@single@split)^2 * #4 + 3*\spath@single@split^2 * (1 - \spath@single@split) * #6 + \spath@single@split^3 * #8}
  \edef\spath@tmppath{\noexpand\pgfsyssoftpath@movetotoken{#1}{#2}\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{\spath@ex pt}{\spath@ey pt}}
%    \end{macrocode}
% Should be some sort of optimisation to do here
%    \begin{macrocode}
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@single@split)^2*\spath@single@split * #1 + (1 - 3 * \spath@single@split + 5 * \spath@single@split^2 - 3 * \spath@single@split^3) * #3 + (2 * \spath@single@split - 4 * \spath@single@split^2 + 3 * \spath@single@split^3) * #5 + \spath@single@split^2 * (1 - \spath@single@split) * #7}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@single@split)^2*\spath@single@split * #2 + (1 - 3 * \spath@single@split + 5 * \spath@single@split^2 - 3 * \spath@single@split^3) * #4 + (2 * \spath@single@split - 4 * \spath@single@split^2 + 3 * \spath@single@split^3) * #6 + \spath@single@split^2 * (1 - \spath@single@split) * #8}
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@single@split)^2*\spath@single@split * #7 + (1 - 3 * \spath@single@split + 5 * \spath@single@split^2 - 3 * \spath@single@split^3) * #5 + (2 * \spath@single@split - 4 * \spath@single@split^2 + 3 * \spath@single@split^3) * #3 + \spath@single@split^2 * (1 - \spath@single@split) * #1}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@single@split)^2*\spath@single@split * #8 + (1 - 3 * \spath@single@split + 5 * \spath@single@split^2 - 3 * \spath@single@split^3) * #6 + (2 * \spath@single@split - 4 * \spath@single@split^2 + 3 * \spath@single@split^3) * #4 + \spath@single@split^2 * (1 - \spath@single@split) * #2}
  \pgfmathsetmacro{\spath@ex}{\spath@single@split^3 * #1 + 3 * \spath@single@split^2 * (1 - \spath@single@split) * #3 + 3 * \spath@single@split * (1 - \spath@single@split)^2 * #5 + (1 - \spath@single@split)^3 * #7}
  \pgfmathsetmacro{\spath@ey}{\spath@single@split^3 * #2 + 3 * \spath@single@split^2 * (1 - \spath@single@split) * #4 + 3 * \spath@single@split * (1 - \spath@single@split)^2 * #6 + (1 - \spath@single@split)^3 * #8}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{\spath@ex pt}{\spath@ey pt}}
  \ge@addto@macro\spath@tmppath\spath@to@add
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@single@split)*#7 + \spath@single@split * #5}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@single@split)*#8 + \spath@single@split * #6}
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@single@split)^2 * #7 + 2*\spath@single@split * (1 - \spath@single@split) * #5 + \spath@single@split^2 * #3}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@single@split)^2 * #8 + 2*\spath@single@split * (1 - \spath@single@split) * #6 + \spath@single@split^2 * #4}
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{#7}{#8}}
  \ge@addto@macro\spath@tmppath\spath@to@add
}
%    \end{macrocode}
% \end{macro}
%
% The next routines split two path tokens into four, they therefore split each one in half.
%
% \begin{macro}{\spath@double@split}
%    \begin{macrocode}
\def\spath@double@split{.5}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@split@first@lineto}
% This splits the first token if it is a \Verb+lineto+.
%    \begin{macrocode}
\def\spath@split@first@lineto\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@linetotoken#3#4#5\relax{%
  \pgfmathsetmacro{\spath@sx}{(1-\spath@single@split)*#1 + \spath@single@split * #3}
  \pgfmathsetmacro{\spath@sy}{(1-\spath@single@split)*#2 + \spath@single@split * #4}
  \edef\spath@split@path@start{\noexpand\pgfsyssoftpath@movetotoken{#1}{#2}\noexpand\pgfsyssoftpath@linetotoken{\spath@sx     pt}{\spath@sy pt}\noexpand\pgfsyssoftpath@linetotoken{#3}{#4}}
  \edef\spath@split@path@end{\noexpand\pgfsyssoftpath@movetotoken{#3}{#4}}
  \g@addto@macro\spath@split@path@end{#5}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@split@second@lineto}
% This splits the second token if it is a \Verb+lineto+.
%    \begin{macrocode}
\def\spath@split@second@lineto\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@linetotoken#3#4#5\relax{%
  \pgfmathsetmacro{\spath@sx}{(1-\spath@single@split)*#3 + \spath@single@split * #1}
  \pgfmathsetmacro{\spath@sy}{(1-\spath@single@split)*#4 + \spath@single@split * #2}
  \edef\spath@split@path@end{\noexpand\pgfsyssoftpath@linetotoken{\spath@sx pt}{\spath@sy pt}\noexpand\pgfsyssoftpath@linetotoken{#3}{#4}}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@split@first@curveto}
% This splits the first token if it is a \Verb+curveto+.
%    \begin{macrocode}
\def\spath@split@first@curveto\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@curvetosupportatoken#3#4\pgfsyssoftpath@curvetosupportbtoken#5#6\pgfsyssoftpath@curvetotoken#7#8#9\relax{%
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@double@split)*#1 + \spath@double@split * #3}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@double@split)*#2 + \spath@double@split * #4}
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@double@split)^2 * #1 + 2*\spath@double@split * (1 - \spath@double@split) * #3 + \spath@double@split^2 * #5}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@double@split)^2 * #2 + 2*\spath@double@split * (1 - \spath@double@split) * #4 + \spath@double@split^2 * #6}
  \pgfmathsetmacro{\spath@ex}{(1 - \spath@double@split)^3 * #1 + 3*\spath@double@split * (1 - \spath@double@split)^2 * #3 + 3*\spath@double@split^2 * (1 - \spath@double@split) * #5 + \spath@double@split^3 * #7}
  \pgfmathsetmacro{\spath@ey}{(1 - \spath@double@split)^3 * #2 + 3*\spath@double@split * (1 - \spath@double@split)^2 * #4 + 3*\spath@double@split^2 * (1 - \spath@double@split) * #6 + \spath@double@split^3 * #8}
  \edef\spath@split@path@start{\noexpand\pgfsyssoftpath@movetotoken{#1}{#2}\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{\spath@ex pt}{\spath@ey pt}}
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@double@split)*#5 + \spath@double@split * #7}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@double@split)*#6 + \spath@double@split * #8}
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@double@split)^2 * #3 + 2*\spath@double@split * (1 - \spath@double@split) * #5 + \spath@double@split^2 * #7}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@double@split)^2 * #4 + 2*\spath@double@split * (1 - \spath@double@split) * #6 + \spath@double@split^2 * #8}
  
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{#7}{#8}}
  \ge@addto@macro\spath@split@path@start\spath@to@add
  \edef\spath@split@path@end{\noexpand\pgfsyssoftpath@movetotoken{#7}{#8}}
  \g@addto@macro\spath@split@path@end{#9}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\spath@split@second@curveto}
% This splits the second token if it is a \Verb+curveto+.
%    \begin{macrocode}
\def\spath@split@second@curveto\pgfsyssoftpath@movetotoken#1#2\pgfsyssoftpath@curvetosupportatoken#3#4\pgfsyssoftpath@curvetosupportbtoken#5#6\pgfsyssoftpath@curvetotoken#7#8#9\relax{%
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@double@split)*#1 + \spath@double@split * #3}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@double@split)*#2 + \spath@double@split * #4}
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@double@split)^2 * #1 + 2*\spath@double@split * (1 - \spath@double@split) * #3 + \spath@double@split^2 * #5}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@double@split)^2 * #2 + 2*\spath@double@split * (1 - \spath@double@split) * #4 + \spath@double@split^2 * #6}
  \pgfmathsetmacro{\spath@ex}{(1 - \spath@double@split)^3 * #1 + 3*\spath@double@split * (1 - \spath@double@split)^2 * #3 + 3*\spath@double@split^2 * (1 - \spath@double@split) * #5 + \spath@double@split^3 * #7}
  \pgfmathsetmacro{\spath@ey}{(1 - \spath@double@split)^3 * #2 + 3*\spath@double@split * (1 - \spath@double@split)^2 * #4 + 3*\spath@double@split^2 * (1 - \spath@double@split) * #6 + \spath@double@split^3 * #8}
  \edef\spath@split@path@end{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{\spath@ex pt}{\spath@ey pt}}
  \pgfmathsetmacro{\spath@dx}{(1 - \spath@double@split)*#5 + \spath@double@split * #7}
  \pgfmathsetmacro{\spath@dy}{(1 - \spath@double@split)*#6 + \spath@double@split * #8}
  \pgfmathsetmacro{\spath@cx}{(1 - \spath@double@split)^2 * #3 + 2*\spath@double@split * (1 - \spath@double@split) * #5 + \spath@double@split^2 * #7}
  \pgfmathsetmacro{\spath@cy}{(1 - \spath@double@split)^2 * #4 + 2*\spath@double@split * (1 - \spath@double@split) * #6 + \spath@double@split^2 * #8}
  
  \edef\spath@to@add{\noexpand\pgfsyssoftpath@curvetosupportatoken{\spath@cx     pt}{\spath@cy pt}\noexpand\pgfsyssoftpath@curvetosupportbtoken{\spath@dx pt}{\spath@dy pt}\noexpand\pgfsyssoftpath@curvetotoken{#7}{#8}}
  \ge@addto@macro\spath@split@path@end\spath@to@add
}
%    \end{macrocode}
% \end{macro}
% \iffalse
%</package>
% \fi
%
% \Finale

\endinput