This file is indexed.

/usr/lib/ocaml/mlpost/mlpost.mli is in libmlpost-ocaml-dev 0.8.1-6build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
(**************************************************************************)
(*                                                                        *)
(*  Copyright (C) Johannes Kanig, Stephane Lescuyer                       *)
(*  Jean-Christophe Filliatre, Romain Bardou and Francois Bobot           *)
(*                                                                        *)
(*  This software is free software; you can redistribute it and/or        *)
(*  modify it under the terms of the GNU Library General Public           *)
(*  License version 2.1, with the special exception on linking            *)
(*  described in file LICENSE.                                            *)
(*                                                                        *)
(*  This software is distributed in the hope that it will be useful,      *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *)
(*                                                                        *)
(**************************************************************************)
(** This is Mlpost *)

module Signature : sig
  type point
  type num

  module type Boxlike =
  sig
    type t
    val width : t -> num
    val height : t -> num
    val set_pos : point -> t -> t
  end

end


(** {2 Interfaces to basic Metapost datatypes} *)

  (** Abstract numeric values *)
module Num : sig

  (** Numerics are a symbolic representation of numeric values.
    In many cases, but not always, an object of type {!Num.t} is intended to be
    a length in some unit. In addition, values of type {!Num.t} may actually be
    unknown to Mlpost. This is why there is no function that gives back a
    [float].
  *)

  type t = Signature.num
      (** The Mlpost numeric type is an abstract datatype *)

  (** {2 Conversion functions} *)

  val of_float : float -> t
  (** Convert a float into a {!Num.t} *)

  val bp : float -> t
  (** The base unit in Mlpost is bp. *)

  val pt : float -> t
  (** pt are PostScript points. This is the same unit as the pt unit in TeX *)

  val cm : float -> t
  val mm : float -> t
  val inch : float -> t

  (** The following are units dependent of the font used *)

  val em : float -> t
  (** the width of an "m" *)

  val ex : float -> t
  (** the height of an "x" *)

  (** {2 Useful operations on Nums} *)

  val addn : t -> t -> t
  val subn : t -> t -> t
  val multn : t -> t -> t
  val multf : float -> t -> t
  val divf : t -> float -> t
  val neg : t -> t
  val divn : t -> t -> t
  val maxn : t -> t -> t
  val minn : t -> t -> t

  val gmean : t -> t -> t
  (** the geometric mean of two nums : sqrt(a * a + b * b) *)

  val if_null : t -> t -> t -> t
    (** if_null n n1 n2 is equal to n1 if n is null, n2 othewise *)

  (** {3 Infix operators}  *)

  module Infix : sig
    (** Infix symbols for convenience *)

    val (+/) : t -> t -> t
    (** alias for {!Num.addn} *)

    val (-/) : t -> t -> t
    (** alias for {!Num.subn} *)

    val ( */) : t -> t -> t
    (** alias for {!Num.multn} *)

    val (//) : t -> t -> t
    (** alias for {!Num.divn} *)

    val ( *./): float -> t -> t
    (** alias for {!Num.multf} *)

    val (/./): t -> float -> t
    (** alias for {!Num.divf} *)

  end

  (** {2 Useful constants and functions} *)

  val zero : t
  val one : t
  val two : t
  (** Shortcuts for [bp 0.], [bp 1.] and [bp 2.]. *)

  val pi : float
  (** 3 .14159 *)
  val deg2rad : float -> float
  (** Converts degrees into radians *)

  type scale = float -> t

  module Scale : sig
    val bp : float -> scale
    val pt : float -> scale
    val cm : float -> scale
    val mm : float -> scale
    val inch : float -> scale
  end
end

(** Definitions of many colors *)
module Color : sig

  (** Colors *)

  type t
    (** the abstract type of colors *)

  val default : t
    (** the default color is black *)

  val rgb : float -> float -> float -> t
    (** [rgb r g b] constructs the color that corresponds to the color code
	RGB(r,g,b)  *)
  val rgb8 : int -> int -> int -> t
    (** similar to [rgb], but takes integers between 0 and 255 as argument *)

  val cmyk : float -> float -> float -> float -> t
    (** [cmyk c m y k] constructs the color that corresponds to the color code
	CMYK(c,m,y,k)  *)

  val rgba : float -> float -> float -> float -> t
    (** similar to [rgb], but takes the factor of transparency *)
  val rgb8a : int -> int -> int -> int -> t
    (** similar to [rgb8], but takes the factor of transparency *)

  val cmyka : float -> float -> float -> float -> float -> t
    (** similar to [cmyk], but takes the factor of transparency *)

  val is_opaque : t -> bool
    (** test if the color is opaque *)

  val opaque : t -> t
    (** make a color opaque *)

  val transparent : float -> t -> t
    (** [transparent f c] multiplies by f the factor of transparency of c *)

  val hsv : float -> float -> float -> t
    (** hsv h s v convert an hsv color to an rgb.
        0 <= h < 360, 0 <= s,v <= 1*)

  (** {3 color generator} *)

  val color_gen : float -> float -> (unit -> t)
    (* color_gen s v creates a generator of colors which return a
       different color (with saturation s and value v) each time it is
       called. The goal is to have colors with a good contrast between
       them. For given s and v the resutl is deterministically *)

  (** {2 Predefined Colors} *)

  (** {3 base colors} *)

  val white : t
  val black : t
  val red : t
  val blue : t
  val green : t
  val cyan : t
  val yellow : t
  val magenta : t

  (** {3 lighter colors} *)

  val lightred : t
  val lightblue : t
  val lightgreen : t
  val lightcyan : t
  val lightyellow : t
  val lightmagenta : t

  (** {3 grays} *)

  val gray : float -> t
  val lightgray : t
  val mediumgray : t
  val darkgray : t

  (** {3 additional colors} *)

  val orange : t
  val purple : t

  (** {3 X11-named Colors} *)

  val color : string -> t
    (** [color n] returns the RGB color associated to name [n]
	(as defined in /etc/X11/rgb.txt). Raises [Not_found] if [n] does not
	correspond to a color.
        See {{:http://en.wikipedia.org/wiki/X11_color_names} this list} for an
        overview.*)

end

  (** Points in the plane *)
module rec Point : sig

  (** The abstract type for points *)
  type t = Signature.point

  (**  Construct a point from two numeric values *)
  val pt : Num.t * Num.t -> t

  (** The following functions create points of length 1.
      They are especially useful to specify directions with [Path.Vec] *)

  (** [dir f] is the point at angle [f] on the unit circle.
      [f] shall be given in degrees *)
  val dir : float -> t

  (** The unitary vectors pointing up, down, left and right *)

  val up : t
  val down : t
  val left : t
  val right : t

  val origin : t

  val length : t -> Num.t
  (** [length p] is the length of vector from the origin to [p] *)

  val xpart : t -> Num.t
  (** [xpart p] is the x coordinate of point [p] *)

  val ypart : t -> Num.t
  (** [ypart p] is the y coordinate of point [p] *)

  (** {2 Operations on points} *)

  val transform : Transform.t -> t -> t
  (** Apply a transformation to a point *)

  val segment : float -> t -> t -> t
  (** [segment f p1 p2] is the point [(1-f)p1 + fp2]. Stated otherwise, if
     [p1] is at [0.] and [p2] is at [1.], return the point that lies at [f] *)

  val add : t -> t -> t
  val shift : t -> t -> t
  (** Sum two points *)

  val sub : t -> t -> t
  (** Substract two points *)

  val mult : Num.t -> t -> t
  val scale : Num.t -> t -> t
  (** Multiply a point by a scalar *)

  val rotate : float -> t -> t
  (** Rotate a point by an angle in degrees *)

  (** [rotate_around p1 f p2] rotates [p2] around [p1] by an angle [f]
      in degrees *)
  val rotate_around : t -> float -> t -> t

  (** Scales the X coordinate of a point by a scalar *)
  val xscale : Num.t -> t -> t

  (** Scales the Y coordinate of a point by a scalar *)
  val yscale : Num.t -> t -> t

  (** Normalize the vector represented by the point.
      The origin becomes the origin *)
  val normalize : t -> t

  (** {2 Convenient constructors} *)

  (** The following functions build a point at a
      given scale (see {!Num.t} for scales) *)

  val bpp : float * float -> t
  val inp : float * float -> t
  val cmp : float * float -> t
  val mmp : float * float -> t
  val ptp : float * float -> t

  (** Same as the previous functions but build list of points *)

  val map_bp : (float * float) list -> t list
  val map_in: (float * float) list -> t list
  val map_cm: (float * float) list -> t list
  val map_mm: (float * float) list -> t list
  val map_pt: (float * float) list -> t list

  (** Builds a point from a pair of floats
      @param scale a scaling function to be applied to each float;
      see {!Num.t} for scaling functions for usual units *)
  val p : ?scale:(float -> Num.t) -> float * float -> t

  (** Same as [p], but builds a list of points *)
  val ptlist : ?scale:(float -> Num.t) -> (float * float) list -> t list

  val draw : ?brush:Brush.t -> ?color:Color.t -> ?pen:Pen.t -> t -> Command.t
    (** Draw a point
	@param color the color of the point; default is black
	@param pen the pen used to draw the pen; default is
               [Brush.Pen.default]*)

end

(** MetaPaths: gradually build a path with constraints, get a real
    path at thxe end. *)
and MetaPath : sig

  (** MetaPaths are the objects used to describe lines, curves, and
      more generally almost everything that is drawn with Mlpost.
      A path ([Path.t]) is defined by points and control points.
      A metapath is defined by points (knots) and constraints on the links
      between the points. A metapath is an easy way to define a path gradually
      with only a few points, and apply heuristics afterwards to transform it
      into a real path (using [of_metapath]). *)

  (** A [direction] is used to put constraints on metapaths:
      {ul {- [vec p] defines a direction by a point (interpreted as a vector)}
      {- [curl f] changes the curling factor of the extremity of a metapath;
      higher curling factor means flatter curves}
      {- [noDir] means no particular direction} } *)
  type direction = Path.direction

  val vec : Point.t -> direction
  val curl : float -> direction
  val noDir : direction

  (** A [knot] is the basic element of a metapath, and is simply a point
      with an incoming and outgoing direction constraint *)
  type knot = Path.knot

  (** Build a knot from a point; the optional arguments are the
      incoming directions *)
  val knotp :
    ?l:direction -> ?r:direction -> Point.t -> knot

  val knotlist : (direction * Point.t * direction) list -> knot list


  (** A joint is the connection between two knots in a metapath. It is either
      {ul {- [jLine] for a straight line}
      {- [jCurve] for a spline curve}
      {- [jCurveNoInflex] to avoid inflexion points}
      {- [jTension f1 f2] to specify "tension" on the joint; [jCurve] uses a
      default tension of 1. Higher tension means less "wild" curves}
      {- [jControls p1 p2] to explicitely specify control points}} *)
  type joint = Path.joint
  val jLine : joint
  val jCurve : joint
  val jCurveNoInflex : joint
  val jTension : float -> float -> joint
  val jControls : Point.t -> Point.t -> joint

  (** The abstract type of metapaths *)
  type t
  type path = Path.t


    (** In all the functions below :
        - noDir is the default direction
        - jCurve is the default joint *)

  (** {2 Labelled metapath constructors} *)
  (** Build a knot from a pair of floats
      @param l an incoming direction
      @param r an outgoing direction
      @param scale a scaling factor applied to the floats *)
  val knot :
    ?l:direction -> ?r:direction ->
    ?scale:(float -> Num.t) -> float * float -> knot

  (** Build a knot from a Num.t pair; the optional arguments are as in
      {!knot} *)
  val knotn : ?l:direction -> ?r:direction -> Num.t * Num.t -> knot

  (** Build a metapath from a list of pairs of floats
      @param style the joint style used for all joints in the metapath
      @param cycle if given, the metapath is closed using the given style
      @param scale permits to scale the whole metapath *)
  val path :
    ?style:joint -> ?scale:(float -> Num.t) ->
    (float * float) list -> t

  (** Same as [metapath], but uses a [Num.t] list *)
  val pathn :
    ?style:joint -> (Num.t * Num.t) list -> t

  (** Same as [metapath], but uses a knot list *)
  val pathk :
    ?style:joint -> knot list -> t

  (** Same as [metapath] but uses a point list *)
  val pathp : ?style:joint -> Point.t list -> t

  (** Build a metapath from [n] knots and [n-1] joints *)
  val jointpathk : knot list -> joint list -> t

  (** Build a metapath from [n] points and [n-1] joints,
      with default directions *)
  val jointpathp : Point.t list -> joint list -> t

  val jointpathn : (Num.t * Num.t) list -> joint list -> t

  (** Build a metapath from [n] float_pairs and [n-1] joints,
      with default directions *)
  val jointpath :
    ?scale:(float -> Num.t) -> (float * float) list ->
    joint list -> t

  (** Close a metapath using direction [dir] and style [style] *)
  val cycle : ?dir:direction -> ?style:joint -> t -> path


  (** {2 Primitive metapath constructors} *)
  (** Add a knot at the end of a metapath  *)
  val concat : ?style:joint -> t -> knot -> t

  (** Create a simple metapath with one knot *)
  val start : knot -> t

  (** Append a metapath to another using joint [style] *)
  val append : ?style:joint -> t -> t -> t

  (** {2 Predefined values} *)

  (** The default joint style ([JCurve]) *)
  val defaultjoint : joint

  (** {2 Conversions} *)
  (** Compute the control point of the path
      for a good looking result according to the constraint
      on the direction, tension, curve *)
  val to_path : t -> path

  (** Obtain a metapath from a path with exactly the same
      control point. p = of_metapath (of_path p) is true but
      not the opposite.*)
  val of_path : path -> t

end

  (** Fixed Paths *)
and Path : sig

  (** Paths are the objects used to describe lines, curves, and
      more generally almost everything that is drawn with Mlpost *)

  (** A [direction] is used to put constraints on paths:
      {ul {- [vec p] defines a direction by a point (interpreted as a vector)}
      {- [curl f] changes the curling factor of the extremity of a path;
      higher curling factor means flatter curves}
      {- [noDir] means no particular direction} } *)
  type direction

  val vec : Point.t -> direction
  val curl : float -> direction
  val noDir : direction

  (** A [knot] is the basic element of a path, and is simply a point
      with an incoming and outgoing direction constraint *)
  type knot

  (** Build a knot from a point; the optional arguments are the
      incoming directions *)
  val knotp :
    ?l:direction -> ?r:direction -> Point.t -> knot

  val knotlist : (direction * Point.t * direction) list -> knot list


  (** A joint is the connection between two knots in a path. It is either
      {ul {- [jLine] for a straight line}
      {- [jCurve] for a spline curve}
      {- [jCurveNoInflex] to avoid inflexion points}
      {- [jTension f1 f2] to specify "tension" on the joint; [jCurve] uses a
      default
      tension of 1. Higher tension means less "wild" curves}
      {- [jControls p1 p2] to explicitely specify control points}} *)
  type joint
  val jLine : joint
  val jCurve : joint
  val jCurveNoInflex : joint
  val jTension : float -> float -> joint
  val jControls : Point.t -> Point.t -> joint

  (** The abstract type of paths *)
  type t

    (** In all the functions below :
        - noDir is the default direction
        - jCurve is the default joint *)

  (** {2 Labelled path constructors} *)
  (** Build a knot from a pair of floats
      @param l an incoming direction
      @param r an outgoing direction
      @param scale a scaling factor applied to the floats *)
  val knot :
    ?l:direction -> ?r:direction ->
    ?scale:(float -> Num.t) -> float * float -> knot

  (** Build a knot from a Num.t pair; the optional arguments are as in
      {!knot} *)
  val knotn : ?l:direction -> ?r:direction -> Num.t * Num.t -> knot

  (** Build a path from a list of pairs of floats
      @param style the joint style used for all joints in the path
      @param cycle if given, the path is closed using the given style
      @param scale permits to scale the whole path *)
  val path :
    ?style:joint -> ?cycle:joint -> ?scale:(float -> Num.t) ->
    (float * float) list -> t

  (** Same as [path], but uses a [Num.t] list *)
  val pathn :
    ?style:joint -> ?cycle:joint -> (Num.t * Num.t) list -> t

  (** Same as [path], but uses a knot list *)
  val pathk :
    ?style:joint -> ?cycle:joint -> knot list -> t

  (** Same as [path] but uses a point list *)
  val pathp : ?style:joint -> ?cycle:joint -> Point.t list -> t

  (** Build a path from [n] knots and [n-1] joints *)
  val jointpathk : knot list -> joint list -> t

  (** Build a path from [n] points and [n-1] joints,
      with default directions *)
  val jointpathp : Point.t list -> joint list -> t

  val jointpathn : (Num.t * Num.t) list -> joint list -> t

  (** Build a path from [n] float_pairs and [n-1] joints,
      with default directions *)
  val jointpath :
    ?scale:(float -> Num.t) -> (float * float) list ->
    joint list -> t

  (** Close a path using direction [dir] and style [style] *)
  val cycle : ?dir:direction -> ?style:joint -> t -> t


  (** {2 Primitive path constructors} *)
  (** Add a knot at the end of a path  *)
  val concat : ?style:joint -> t -> knot -> t

  (** Create a simple path with one knot *)
  val start : knot -> t

  (** Append a path to another using joint [style] *)
  val append : ?style:joint -> t -> t -> t


  (** {2 More complex constructions on paths} *)

  (** Number of nodes in a path, minus one. *)
  val length : t -> Num.t

  (** [point f p] returns a certain point on the path [p]; [f] is
      given "in control points": [0.] means the first control point,
      [1.] the second and so on; intermediate values are accepted. *)
  val point : float -> t -> Point.t

  (** Same as [point] but for a [Num.t]. *)
  val pointn : Num.t -> t -> Point.t

  (** [direction f p] returns the direction of the tangent at [point f p]. *)
  val direction : float -> t -> Point.t

  (** Same as [direction] but for a [Num.t]. *)
  val directionn : Num.t -> t -> Point.t

  (** [subpath start end path] selects the subpath of [path] that lies
      between [start] and [end]. [start] and [end] are given in
      control points, as in {!point}. *)
  val subpath : float -> float -> t -> t

  (** Same as [subpathn] but using [Num.t]. *)
  val subpathn : Num.t -> Num.t -> t -> t

  (** Apply a transformation to a path *)
  val transform : Transform.t -> t -> t

  val scale : Num.t -> t -> t
  val rotate : float -> t -> t
  val shift : Point.t -> t -> t
  val yscale : Num.t -> t -> t
  val xscale : Num.t -> t -> t
  (** Shortcuts for transformations of Paths *)

  (** [cut_after p1 p2] cuts [p2] after the intersection with [p1].
      To memorize the order of the arguments,
      you can read: "cut after [p1]" *)
  val cut_after : t -> t -> t

  (** Same as {!cut_after}, but cuts before *)
  val cut_before: t -> t -> t

  (** [strip n p] removes two segments of length [n] at each end of path [p] *)
  val strip : Num.t -> t -> t

  (** Build a cycle from a set of intersecting paths *)
  val build_cycle : t list -> t

  (** {2 Predefined values} *)

  (** The default joint style ([JCurve]) *)
  val defaultjoint : joint

  (** A full circle of radius 1 and centered on the origin *)
  val fullcircle : t

  (** The upper half of [fullcircle] *)
  val halfcircle : t

  (** The right half of [halfcircle] *)
  val quartercircle: t

  (** A full square of size 1 and centered on the origin *)
  val unitsquare: t

  (** {2 Conversions} *)

  type metapath = MetaPath.t
  (** Compute the control point of the path
      for a good looking result according to the constraint
      on the direction, tension, curve *)
  val of_metapath : metapath -> t

  (** Obtain a metapath from a path with exactly the same
      control point. p = of_metapath (of_path p) is true but
      not the opposite.*)
  val to_metapath : t -> metapath

  (** {2 Smart path } *)

  type orientation =
    | Up | Down | Left | Right
    | Upn of Num.t | Downn of Num.t | Leftn of Num.t | Rightn of Num.t

  val smart_path : ?style:joint -> orientation list -> Point.t -> Point.t -> t

  val draw : ?brush:Brush.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t
    -> t -> Command.t
    (** Draw a path
        @param brush the brush used to draw the path; the next argument
               redefined this one
	@param color the color of the path; default is black
	@param pen the pen used to draw the path; default is
               [Brush.Pen.default]
	@param dashed if given, the path is drawn using that dash_style. *)

  val fill : ?color:Color.t -> t -> Command.t
    (** Fill a contour given by a closed path
	@param color the color used to fill the area; default is black *)

end

(**/**)
  (** Pens: change the way lines are drawn in Mlpost *)
and Pen : sig
  (** Pens are used to change the the way lines are drawn in Mlpost *)

  type t
    (** The abstract type of pens *)

  val transform : Transform.t -> t -> t
    (** Apply a transformation to pens *)
  val default : t
    (** The default pen; it corresponds to
      [Pen.scale (Num.bp 0.5) Pen.circle] *)
  val circle : t
    (** A circular pen of diameter 1 bp *)
  val square : t
    (** A pen in form of a square, of length 1 bp *)
  val from_path : Path.t -> t
    (** Construct a pen from a closed path *)

  val scale : Num.t -> t -> t
  val rotate : float -> t -> t
  val shift : Point.t -> t -> t
  val yscale : Num.t -> t -> t
  val xscale : Num.t -> t -> t
  (** Shortcuts for transformations of pens *)
end

(** Dash patterns *)
and Dash : sig
  (** This module permits to define dash patterns, that are used to draw lines
   in different styles *)

  type t
    (** The abstract type of dash patterns *)

  val evenly : t
    (** The pattern composed of evenly spaced dashes *)
  val withdots : t
    (** The pattern composed of evenly spaced dots *)

  val scaled : float -> t -> t
    (** Scale a dash pattern *)
  val shifted : Point.t -> t -> t
    (** Shift a dash pattern *)

  type on_off

  val on : Num.t -> on_off
  val off : Num.t -> on_off

  val pattern : on_off list -> t
    (** This function, together with the type [on_off]  permits to construct
     custom dash patterns, by giving a list of [on] / [off] constructors, with
      corresponding lengths *)

end
(**/**)

(** Brushes : change the way lines are drawn in Mlpost *)
and Brush : sig

  (** Pens: change the way lines look like in Mlpost *)
  module Pen : sig
    (** Pens are used to change the the way lines are drawn in Mlpost *)

    type t (**/**) = Pen.t (**/**)
      (** The abstract type of pens *)

    val transform : Transform.t -> t -> t
      (** Apply a transformation to pens *)
    val default : t
      (** The default pen; it corresponds to
      [Pen.scale (Num.bp 0.5) Pen.circle] *)
    val circle : t
    (** A circular pen of diameter 1 bp *)
    val square : t
      (** A pen in form of a square, of length 1 bp *)
    val from_path : Path.t -> t
      (** Construct a pen from a closed path *)

    val scale : Num.t -> t -> t
    val rotate : float -> t -> t
    val shift : Point.t -> t -> t
    val yscale : Num.t -> t -> t
    val xscale : Num.t -> t -> t
      (** Shortcuts for transformations of pens *)

  end

  (** Dash patterns *)
  module Dash : sig
    (** This module permits to define dash patterns, that are used to
        draw lines in different styles *)

    type t (**/**) = Dash.t (**/**)
      (** The abstract type of dash patterns *)

    val evenly : t
      (** The pattern composed of evenly spaced dashes *)
    val withdots : t
      (** The pattern composed of evenly spaced dots *)

    val scaled : Num.t -> t -> t
      (** Scale a dash pattern *)
    val shifted : Point.t -> t -> t
      (** Shift a dash pattern *)

    type on_off

    val on : Num.t -> on_off
    val off : Num.t -> on_off

    val pattern : on_off list -> t
      (** This function, together with the type [on_off] permits to
          construct custom dash patterns, by giving a list of [on] /
          [off] constructors, with corresponding lengths *)

  end

  type t

  val t :
    ?color:Color.t -> ?pen:Pen.t ->
    ?dash:Dash.t -> ?scale:Num.t ->
    ?brush:t -> (* use the value of brush for the default value *)
    unit -> t

  val pen : t -> Pen.t option
  val dash : t -> Dash.t option
  val color : t -> Color.t option

  (** {2 Brushes with Predefined Colors} *)
  type brush_colored =
      ?pen:Pen.t -> ?dash:Dash.t -> ?scale:Num.t ->
    ?brush:t -> unit -> t
  (** {3 base colors} *)

  val white : brush_colored
  val black : brush_colored
  val red : brush_colored
  val blue : brush_colored
  val green : brush_colored
  val cyan : brush_colored
  val yellow : brush_colored
  val magenta : brush_colored

  (** {3 lighter colors} *)

  val lightred : brush_colored
  val lightblue : brush_colored
  val lightgreen : brush_colored
  val lightcyan : brush_colored
  val lightyellow : brush_colored
  val lightmagenta : brush_colored

  (** {3 grays} *)

  val gray : float -> brush_colored
  val lightgray : brush_colored
  val mediumgray : brush_colored
  val darkgray : brush_colored

  (** {3 additional colors} *)

  val orange : brush_colored
  val purple : brush_colored

end


(** Apply linear transformations to objects in Mlpost *)
and Transform : sig

  (** Transformations are an important way to modify objects in Mlpost.
      Objects can be scaled, shifted, rotated, etc, and any combination of
      these transformations is possible. Currently, transformations can be
      applied to Pictures, Pens and Paths. *)

  type t'
    (** The abstract type of a single transformation *)

  val scaled : Num.t -> t'
    (** Scale an object by a constant factor.
      @param scale a scaling function to be applied to each float;
      see {!Num.t} for scaling functions for usual units. This makes only sense
      when the object to be transformed is given in "bp" units *)
  val rotated : float -> t'
    (** Rotate an object by an angle given in degrees *)
  val shifted : Point.t -> t'
    (** Shift an object with respect to a point *)
  val slanted : Num.t -> t'
    (** Slant an object: the point [(x,y)] becomes [(x+ay,y)], with slanting
        factor [a] *)
  val xscaled : Num.t -> t'
    (** Scale an object by a constant factor, but only in the [x] direction *)
  val yscaled : Num.t -> t'
    (** Scale an object by a constant factor, but only in the [y] direction *)
  val zscaled : Point.t -> t'
    (** Zscaled multiplies points of the object by the given point, using
        "complex" multiplication: [(x,y) * (a,b) = (ax - by, bx + ay)];
        its effect is to rotate and scale so as to map [(1,0)] into [(a,b)] *)
  val reflect : Point.t -> Point.t -> t'
    (** Reflect an object with respect to the line that goes through the two
        given points *)
  val rotate_around : Point.t -> float -> t'
    (** Rotate an object by an angle given in degrees, around a given point *)

  type matrix  =
      { xx : Num.t; yx : Num.t;
        xy : Num.t; yy : Num.t; x0 : Num.t; y0 : Num.t}

  val explicit : matrix -> t'

  type t = t' list
    (** A transformation is a list of single transformations *)

  val id : t
    (** The identity transformation  *)
end

(** Functions to manipulate commands as if they were pictures  *)
and Picture : sig
  (** Pictures are a powerful way to reuse and modify parts of a figure *)

  type t = Command.t
    (** The abstract type of pictures *)

  val make : Command.t -> t
    (** Make a picture from a drawing command *)

  val tex : string -> t
   (** Take a string in Latex format and transform it into a picture *)

  val transform : Transform.t -> t -> t
    (** Apply a transformation to a picture *)

  val bbox : t -> Path.t
    (** Get the bounding box of a picture (with default padding, as
	in MetaPost) *)

  val corner_bbox : ?dx:Num.t -> ?dy:Num.t -> t -> Path.t
    (** Get the bounding box of a picture, according to its corners
        and supplied padding [dx] and [dy]. *)

  val center :  Point.t -> t -> t
    (** Place a picture centered at some point *)

  val place_up_left : Point.t -> t -> t
    (** Place a picture with its upper left corner at some point *)

  val place_up_right : Point.t -> t -> t
    (** Place a picture with its upper right corner at some point *)

  val place_bot_left : Point.t -> t -> t
    (** Place a picture with its bottom left corner at some point *)

  val place_bot_right : Point.t -> t -> t
    (** Place a picture with its bottom right corner at some point *)

  val beside : t -> t -> t
    (** [beside p1 p2] returns a picture in which [p2] is placed right
        to [p1] *)

  val below : t -> t -> t
    (** [below p1 p2] returns a picture in which [p2] is placed below [p1] *)

  (** {2 Special points of the bounding box of a picture} *)

  val ctr : t -> Point.t
  (** @img ctr.png *)
  val north : t -> Point.t
  (** @img north.png *)
  val south : t -> Point.t
  (** @img south.png *)
  val west  : t -> Point.t
  (** @img west.png *)
  val east  : t -> Point.t
  (** @img east.png *)
  val north_west : t -> Point.t
  (** @img north_west.png *)
  val south_west : t -> Point.t
  (** @img south_west.png *)
  val north_east : t -> Point.t
  (** @img north_east.png *)
  val south_east : t -> Point.t
  (** @img south_east.png *)

  val corner : Command.position -> t -> Point.t

  (** {2 Special points of the bounding box of a picture (Deprecated)} *)

  (** These have been superseded by the preceding functions *)
  val ulcorner : t -> Point.t
  val llcorner : t -> Point.t
  val urcorner : t -> Point.t
  val lrcorner : t -> Point.t

  val clip : t -> Path.t -> t
  (** [clip pic path] limits [pic] to the cyclic path [path]; all elements
      outside of [path] are cut off. *)

  (** {2 Dimensions} *)

  val width : t -> Num.t
  val height : t -> Num.t

  (** Predefined Transformations *)

  val scale : Num.t -> t -> t
  val rotate : float -> t -> t
  val shift : Point.t -> t -> t
  val yscale : Num.t -> t -> t
  val xscale : Num.t -> t -> t
  val spin : float -> t -> t

  type escaped = [`Backslash|`Underscore]

  val escape_latex : escaped list -> string -> string

  val escape_all : string -> string

  val set_pos : Point.t -> t -> t
    (** alias of center *)
end

(** Basic drawing commands *)
and Command : sig

  (** Set the verbosity of all mlpost *)
  val set_verbosity : bool -> unit


  (** General Commands to build figures *)

  type t
    (** The abstract commands type *)

  (*
    val logo : figure
  (** The Mlpost logo. *)

  *)
  (** {2 Drawing Commands} *)

  val draw : ?brush:Brush.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t
 -> Path.t -> t
    (** Draw a path
	@param color the color of the path; default is black
	@param pen the pen used to draw the path; default is
        [Brush.Pen.default]
	@param dashed if given, the path is drawn using that dash_style. *)

  (*
    val draw_arrow : ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t -> Path.t
    -> t
  (** Draw a path with an arrow head; the optional arguments
    are the same as for {!draw} *)
  *)

  val fill : ?color:Color.t -> Path.t -> t
    (** Fill a contour given by a closed path
	@param color the color used to fill the area; default is black *)

  val draw_pic : Picture.t -> t
    (** draws a picture *)

  val externalimage : string ->
    [ `None
    | `Width of Num.t (** keep the proportion of the image *)
    | `Height of Num.t
    | `Inside of Num.t * Num.t
        (** must be inside a box of this height and width *)
    | `Exact of Num.t * Num.t]
    -> t
    (** insert an image given its filename - *EXPERIMENTAL* *)

  (** {2 Manipulating Commands} *)

  val nop : t
    (** A command that has no effect *)

  val append : t -> t -> t
    (** Append two commands to form a compound command *)

  val (++) : t -> t -> t
    (** Abbreviation for [append] *)

  val seq : t list -> t
    (** Group a list of commands to a single command *)

  val iter : int -> int -> (int -> t) -> t
    (** [iter m n f] builds a command that corresponds to the sequence
	of commands [f m; f (m+1); ... ; f(n)] *)

  val iterl : ('a -> t) -> 'a list -> t
    (** [iterl f l] builds a command that corresponds to the sequence
	of commands [f x1; f x2; ... ; f xn] for [l = [x1;x2;...;xn]] *)

  (** {2 Labels} *)

  type hposition = [ | `Center | `West | `East | `Left | `Right ]
  type vposition = [ `Center | `North | `South | `Top | `Bot | `Bottom ]
  type position = [
  | hposition
  | vposition
  | `Northwest | `Northeast | `Southwest | `Southeast
  | `Upperleft | `Upperright | `Lowerleft | `Lowerright
  | `Topleft | `Topright | `Bottomleft | `Bottomright
  | `Upleft | `Upright | `Lowleft | `Lowright
  ]
      (** Positions - they are used at many places in Mlpost to indicate a
          direction or position. *)

  (** [label ~pos:`West pic p] puts picture [pic] at the left of the
      point [p] *)
  val label : ?pos:position -> Picture.t -> Point.t -> t

  (** Works like [label], but puts a dot at point [p] as well *)
  val dotlabel : ?pos:position -> Picture.t -> Point.t -> t

end

(** {2 Advanced graphical components} *)

(** Rectangles, Circles, etc. *)
module Shapes : sig

(** Various Basic Geometric Shapes *)

  val round_rect : Num.t -> Num.t -> Num.t -> Num.t -> Path.t
    (** [round_rect w h rx ry] returns a rectangle of width [w] and
	height [h] with rounded corners. The rounded corners are arcs
	of an ellipse of radii [rx] and [ry]. [rx] (resp. [ry]) should
	be positive and smaller than [w/2] (resp. [h/2]).
    *)

  val rectangle : Num.t -> Num.t -> Path.t
    (** [rectangle w h] returns a rectangle of width [w] and height [h].
    *)

  val ellipse : Num.t -> Num.t -> Path.t
    (** [ellipse rx ry] returns an ellipse of great axis [rx] and small axis
        [ry]. The ellipse is centered on the origin and aligned with the x
        axis.
	@param fill the color with which to fill the ellipse ; if no color
	  is provided, it is not filled.
	@param stroke the color with which the ellipse's outline shall be
	  drawn ; default is black.
	@param thickness the thickness of the pen used to draw
	  the outline ; 1. is default
    *)

  val circle : Num.t -> Path.t

  val patatoid : Num.t -> Num.t -> Path.t
    (** See {!Box.patatoid}. *)

  val patatoid2 : Num.t -> Num.t -> Path.t
    (** See {!Box.patatoid2}. *)

(*
  val arc_ellipse :
    ?fill:Color.t -> ?stroke:Color.t -> ?thickness:float -> ?close:bool ->
    Num.t -> Num.t -> float -> float -> Picture.t
    (** [arc_ellipse rx ry th1 th2] draws an arc of the ellipse
	of great axis [rx] and small axis [ry] starting at angle [th1] and
	ending at angle [th2] (in radians).
	The ellipse is centered on the origin and aligned with the x axis.
	@param fill the colod with which to fill the ellipse ; if no color
	  is provided, it is not filled.
	@param stroke the color with which the ellipse's outline shall be
	  drawn ; default is black.
	@param thickness the thickness of the pen used to draw
	  the outline ; 1. is default
	@param close if true, the extremities of the arc are joined to
	the origin by straight lines, thus closing path. If [fill] is provided,
	then [close] will be true by default ; otherwise it is false.
    *)

*)
end

(** A Box is a rectangle with some content and a (not necessarily rectangular)
    frame. Boxes can be placed, aligned and modified.   *)
module Box : sig

  (** Boxes *)

  (** The abstract type of boxes *)
  type t

  (** {2 Creating boxes} *)

  type style =
    | Rect
    | Circle
    | RoundRect
    | Patatoid
    | Patatoid2
    | Ellipse
    | RoundBox
    | Custom of (Num.t -> Num.t -> Num.t * Num.t * Path.t)

  type 'a box_creator =
    ?dx:Num.t -> ?dy:Num.t -> ?name:string ->
    ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t ->
    ?fill:Color.t -> 'a -> t
    (** All functions used to create boxes take the following optional
	parameters : [dx] (resp. [dy]) is the horizontal
	(resp. vertical) padding between the box border and its
	contents ; [name], if present, is associated with the box and
	can be used to retrieve it using [get] ; [stroke] is the color
	used to draw the outline of the box ; when equal to [None],
	the outline will not be drawn ; [pen] is the pen used to draw
	the box's outline, if absent [Brush.Pen.default] is used ;
	[fill], if present, is the color used to fill the box.
    *)

  val empty :
    ?width:Num.t -> ?height:Num.t -> ?style:style -> ?name:string ->
    ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t -> ?fill:Color.t ->
    unit -> t
    (** the empty box *)

  val empty_from_box :
    ?style:style -> ?name:string ->
    ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t -> ?fill:Color.t -> t
    -> t
    (** the empty box with the same position and dimension as the box *)

  val pic : ?style:style -> Picture.t box_creator
    (** [pic p] creates a new box containing the picture [p] *)

  val path : ?style:style -> Path.t box_creator
    (** [path p] creates a new box containing the path [p] *)

  val tex : ?style:style -> string box_creator
    (** [tex s] creates a new box containing the LaTeX string [s]
     @img tex.png *)

  val box : ?style:style -> t box_creator
    (** [box b] creates a new box containing the box [b] *)

  val circle : t box_creator
    (** [circle pic] creates a circle box containing the picture
    [pic]. Optional padding is given by arguments [dx] and [dy];
    default is 2bp.
    @img circle.png *)

  val ellipse : t box_creator
    (** [ellipse pic] creates a elliptic box containing the picture
	[pic]. Optional padding is given by arguments [dx] and [dy];
	default is 2bp
    @img ellipse.png *)

  val rect :  t box_creator
    (** [rect pic] creates a rectangular box containing the picture
	[pic]. Optional padding is given by arguments [dx] and [dy];
	default is 2bp.
    @img rect.png *)

  val round_rect : t box_creator
    (** [round_rect pic] creates a rectangular box containing the picture
	[pic], with rounded corners. Optional padding is given by [dx]
	and [dy]; default is 2bp
    @img round_rect.png *)

  val patatoid : t box_creator
    (** [patatoid pic] creates an undefined, vaguely rectangular box
	containing the picture [pic]. It may happen that the content
	overlaps with the box.
    @img patatoid.png *)

  val patatoid2 : t box_creator
    (** [patatoid2 pic] creates an undefined, vaguely rectangular box
	containing the picture [pic], which is guaranteed to be fully
        contained in the patatoid. *)

  val round_box : t box_creator

(***
  val round_rect_gen : ?dx:Num.t -> ?dy:Num.t -> ?rx:Num.t -> ?ry:Num.t ->
    Point.t -> Picture.t -> t
    (** [round_rect_gen p pic] creates a rectangular box of center [p] and
	of contents [pic], with rounded corners of radii [rx] and [ry].
	Optional padding is given by [dx] and [dy] ; default is 2bp *)
***)

  (** Get the bounding path of a box *)
  val bpath : t -> Path.t

  (** {2 Special points on a box} *)

  val ctr : t -> Point.t
  (** @img ctr.png *)
  val north : t -> Point.t
  (** @img north.png *)
  val south : t -> Point.t
  (** @img south.png *)
  val west  : t -> Point.t
  (** @img west.png *)
  val east  : t -> Point.t
  (** @img east.png *)
  val north_west : t -> Point.t
  (** @img north_west.png *)
  val south_west : t -> Point.t
  (** @img south_west.png *)
  val north_east : t -> Point.t
  (** @img north_east.png *)
  val south_east : t -> Point.t
  (** @img south_east.png *)

  type vposition = [ |Command.vposition | `Custom of t -> Num.t]
  type hposition = [ |Command.hposition | `Custom of t -> Num.t]
  type position  = [ |Command.position | `Custom of t -> Point.t]

  val corner : position -> t -> Point.t

  val opposite_position : position -> position
    (** Return the opposite position of a position (west for east, southeast
        for northwest, center for center, ...). *)

  (** {2 Operators} *)

  val height : t -> Num.t
  (** return the height of the box
   @img height.png *)
  val width : t -> Num.t
  (** return the width of the box
   @img width.png *)
  val shift : Point.t -> t -> t
  (** [shift pt x] shifts the box [x] about the point [pt]
   @img shift.png *)
  val center : Point.t -> t -> t
  (** [center pt x] centers the box [x] at the point [pt]
   @img center.png *)

  val draw : ?debug:bool -> t -> Command.t
    (** Draws a box
	@param debug if set to to true, the bounding
	path and the center of the box are drawn as well, default is false
    *)

  val group : ?style:style -> t list box_creator
    (** [group bl] groups a list of boxes [bl] into a single box *)


  (** {2 Boxes alignment} *)

  val halign : ?pos:vposition -> Num.t -> t list -> t list
    (** [halign ~pos y l] vertically moves the boxes in [l] such that
        the vertical position given by [pos] is equal to [y]. The default
        value of [pos] is `Center, so by default this function moves each
        box such that the y coordinate of its center is [y]. The
        horizontal position of each box is unchanged. @img halign.png *)

  val valign : ?pos:hposition -> Num.t -> t list -> t list
    (** the vertical counterpart of [valign]. *)

  val hplace : ?padding:Num.t -> ?pos:position ->
               ?min_width:Num.t -> ?same_width:bool -> t list -> t list
    (** [hplace l] places the boxes of [l] horizontally, from left to right
       following the order of list elements, without changing their vertical
       position.
       @param min_width minimum width of all boxes; default is zero
       @param same_width if [true], all boxes are of same width,
               and at least of [min_width]; default is false
       @img hplace.png
               *)
  val vplace : ?padding:Num.t -> ?pos:position ->
               ?min_height:Num.t -> ?same_height:bool -> t list -> t list
    (** the vertical counterpart of [hplace] *)

  val hbox : ?padding:Num.t -> ?pos:position -> ?style:style ->
             ?min_width:Num.t -> ?same_width:bool ->
               t list box_creator
      (** places the given boxes horizontally, aligning them horizontally, and
          returns a box containing these boxes as sub-components. Leave the
          first box at its place. [hbox l] actually gives the same result as
          [group (hplace (halign l))].
	  @param padding horizontal padding used to separate the boxes;
	  defaults to 0
	  @param pos used to determine the way boxes are aligned; defaults to
	  [`Center]
      @img hbox.png
      *)

  val hbox_list :
    ?padding:Num.t -> ?pos:position ->
    ?min_width:Num.t -> ?same_width:bool -> t list -> t list
    (** as [hbox], but does not group the resulting boxes into a
        surrounding box; it returns the list of placed boxes instead.
        [hbox_list l] is equal to [hplace (halign l)]. *)


  val vbox : ?padding:Num.t -> ?pos:position -> ?style:style ->
    ?min_height:Num.t -> ?same_height:bool ->
    t list box_creator
      (** aligns the given boxes vertically and returns a box containing
	  these boxes as sub-components. Leave the first box at its place.
	  @param padding vertical padding used to separate the boxes
	  @param pos used to determine the way boxes are aligned
      *)

  val vbox_list :
    ?padding:Num.t -> ?pos:position ->
    ?min_height:Num.t -> ?same_height:bool -> t list -> t list
    (* as vbox_list, but does not group the resulting boxes into a surrounding
       box *)

  val tabular :
    ?hpadding:Num.t -> ?vpadding:Num.t -> ?pos:Command.position ->
    ?style:style -> ?name:string -> ?stroke:Color.t option ->
    ?pen:Pen.t -> ?dash:Dash.t -> ?fill:Color.t ->
    t array array -> t
    (** aligns the given boxes both vertically and horizontally and returns
	a box containing all these boxes (with rows as first sub-components,
	and then individual boxes as sub-components of each row).
	Columns (resp. rows) are separated by [hpadding] (resp. [vpadding]);
	both default to 0.
	Alignment within columns and rows is controlled using [pos].
	The arrays for rows must have the same lengths; otherwise
	[Invalid_argument] is raised. *)

  val tabularl :
    ?hpadding:Num.t -> ?vpadding:Num.t -> ?pos:Command.position ->
    ?style:style -> ?name:string -> ?stroke:Color.t option ->
    ?pen:Pen.t -> ?dash:Dash.t -> ?fill:Color.t ->
    t list list -> t
    (** similar to [tabular], but using lists instead of arrays *)

  val tabulari :
    ?hpadding:Num.t -> ?vpadding:Num.t -> ?pos:Command.position ->
    ?style:style -> ?name:string -> ?stroke:Color.t option ->
    ?pen:Pen.t -> ?dash:Dash.t -> ?fill:Color.t ->
    int -> int -> (int -> int -> t) -> t
    (** similar to [tabular], but using a matrix defined with a function *)

  val hblock : ?padding:Num.t -> ?pos:Command.position -> ?name:string ->
               ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t ->
               ?min_width:Num.t -> ?same_width:bool -> t list -> t
    (** [hblock bl] aligns the boxes of [bl] horizontally and surround
	them with new rectangular boxes of the same height; all these new
	boxes are packed together into the returned box.
        @param min_width minimum width of all boxes; default is zero
        @param same_width if [true], all boxes are of same width,
               and at least of [min_width]; default is false*)

  val vblock : ?padding:Num.t -> ?pos:Command.position -> ?name:string ->
               ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t ->
               ?min_height:Num.t -> ?same_height:bool -> t list -> t
    (** similar to [hblock], with vertical alignment. @param
        min_height minimum height of all boxes; default is zero @param
        same_height if [true], all boxes are of same height, and at
        least of [min_height]; default is false*)

  val grid :
    ?hpadding:Num.t -> ?vpadding:Num.t -> ?pos:Command.position ->
    ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t ->
    t array array -> t
    (** Aligns the given boxes in a way that is similar to [hblock]
	and [vblock]: boxes are aligned in a grid where all cells have
	the same size. Each one of these cells is a box containing the
	original corresponding box. *)

  val gridl :
    ?hpadding:Num.t -> ?vpadding:Num.t -> ?pos:Command.position ->
    ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t ->
    t list list -> t
    (** similar to [grid], but using lists instead of arrays *)

  val gridi :
    ?hpadding:Num.t -> ?vpadding:Num.t -> ?pos:Command.position ->
    ?stroke:Color.t option -> ?pen:Pen.t -> ?dash:Dash.t ->
    int -> int -> (int -> int -> t) -> t
    (** similar to [gridi], but using a matrix defined with a function *)

  val place :
    position -> ?pos: position -> ?padding: Num.t -> t -> t -> t
    (** Place a box relatively to another box.

        [place `East a] is a function which places a box at the east
        of [a]. Thus, [place `East a b] returns a copy of [b] placed
        at the east of [a].

        [place posa ~pos: posb ~padding a b] returns a new box [c] which is
        obtained by moving [b] to place the [posa] point of [a] on top of the
        [posb] point of [b], and then padding the result by [padding] in
        direction [posa].

        Default value of [posb] is the opposite direction of [posa] wrt. the
        center (see {!opposite_position}).
        Default value of [padding] is zero.

        The padding argument multiplies a unit vector which goes from
        the center of [a] to the corner of [a] indicated by [posa].
        This effectively places point [posa] of [a] at exactly
        [padding] units of point [posb] of [b], in direction [posa].
        This also means that for diagonal directions, the actual
        direction will change according to the width / height ratio of
        [a]. *)

  (** {2 Sub-boxes accessors} *)

  val nth : int -> t -> t
    (** [nth i b] returns the [i]-th sub-box of [b]. The first sub-box
	has index 0. Raises [Invalid_argument] if there is no such sub-box. *)

  val get : string -> t -> t
    (** [get n b] returns the sub-box of [b] of name [n], if any, and
	raises [Invalid_argument] otherwise. The behavior is not specified
	if [b] contains several sub-boxes with name [n]. *)

  val sub : t -> t -> t
  (** [sub b1 b] returns the sub-box of [b] which has the same name as [b1],
     if any, and raises [Invalid_argument] otherwise. The behavior is not
     specified if [b] contains several sub-boxes with the name of [b1]. *)

  val elts : t -> t array
    (** [elts b] returns the sub-boxes of [b]; returns the empty array for
        the empty box or a box containing a picture. *)

  (** {2 Specials Points} *)

  val setp : string -> Point.t -> t -> t

  val getp : string -> t -> Point.t
  val getpx : string -> t -> Num.t
  val getpy : string -> t -> Num.t


  (** {2 Box properties} *)

  val get_fill : t -> Color.t option
  val set_fill : Color.t -> t -> t

  val get_stroke : t -> Color.t option
  val set_stroke : Color.t -> t -> t
  val clear_stroke : t -> t

  val get_name : t -> string option
  val set_name : string -> t -> t

  val get_pen : t -> Pen.t option
  val set_pen : Pen.t -> t -> t

  val set_height : Command.vposition -> Num.t -> t -> t
  val set_width : Command.hposition -> Num.t -> t -> t

  val get_dash : t -> Dash.t option
  val set_dash : Dash.t -> t -> t
  val clear_dash : t -> t

  val set_height2 : vposition -> Num.t -> vposition -> Num.t -> t -> t
    (** set_height2 `North y1 `South y2 b return the box b with its height and
     center chosen such as the ordinate of the top (because of `North) of the
     box is at y1 and the ordinate of its south is at y2*)

  val set_width2 : hposition -> Num.t -> hposition -> Num.t-> t -> t

  val set_size : Command.position -> width:Num.t -> height:Num.t -> t -> t

  val same_height : ?pos:vposition -> t list -> t list
  val same_width : ?pos:hposition -> t list -> t list
  val same_size : ?pos:position -> t list -> t list

  val set_post_draw : (t -> Command.t) -> t -> t
  val clear_post_draw : t -> t
  val set_pre_draw : (t -> Command.t) -> t -> t
  val clear_pre_draw : t -> t

  (** {2 Misc.} *)

  val shadow : t -> t

  val cpath :
    ?style:Path.joint ->
    ?outd:Path.direction ->
    ?ind:Path.direction ->
    ?sep:Num.t ->
    t -> t -> Path.t
    (** the path that connects 2 boxes and stops at the box boundaries *)

  val cpath_left :
    ?style:Path.joint ->
    ?outd:Path.direction ->
    ?ind:Path.direction -> t -> Point.t -> Path.t
    (** the path that connects a box and a point and stops at the box
        boundaries *)

  val cpath_right :
    ?style:Path.joint ->
    ?outd:Path.direction ->
    ?ind:Path.direction -> Point.t -> t -> Path.t
    (** the path that connects a box and a point and stops at the box
        boundaries *)

  val transform : Transform.t -> t -> t

  val scale : Num.t -> t -> t
  val rotate : float -> t -> t
  val shift : Point.t -> t -> t
  val yscale : Num.t -> t -> t
  val xscale : Num.t -> t -> t

  (** {2 Boxlike : An argument for functor of object that are similar to box} *)

  val set_pos : Point.t -> t -> t
    (** same as center *)
end

(** Draw arrows and build new forms of arrows. *)
module Arrow : sig
  (** Draw simple or complex arrows. *)

  (** To draw an arrow, choose your arrow [kind], then call the [draw] function
      (giving the path that the arrow will follow) or the [draw2] function
      (giving the starting and ending points of the arrow). If your favorite
      arrow [kind] does not exist, use the tools from this module to build your
      own! *)

  type kind
    (** The abstract type for arrow kinds. *)

  (** {2 Drawing Arrows} *)

  (** If you need to place a label which is not TeX but any picture, if
      you need to place it at a symbolic position on the path,
      or if you need to place more than one label, you cannot do it directly
      using the [draw] commands. First draw the arrow, then use functions such
      as {!Command.label}. *)

  val simple :
    ?color:Color.t -> ?brush:Brush.t -> ?pen:Pen.t -> ?dashed:Dash.t -> Path.t
    -> Command.t
    (** Draw a simple arrow following the given path.
        @param color the color of the arrow
        @param pen the pen to use to draw the body of the arrow
        @param dashed the dash pattern to use to draw the body of the arrow *)

  val draw: ?kind: kind -> ?tex: string -> ?pos: float ->
    ?anchor: Command.position -> Path.t ->
    Command.t
    (** Draw an arrow following the given path.
        @param kind the kind of arrow (default is {!triangle_full})
        @param tex add a LaTeX label
        @param pos label position on the path
        @param anchor label anchor *)

  val point_to_point: ?kind: kind -> ?tex: string -> ?pos: float ->
    ?anchor: Command.position ->
    ?outd: Path.direction -> ?ind: Path.direction -> Point.t -> Point.t ->
    Command.t
    (** Use [point_to_point a b] to draw an arrow from [a] to [b].
        @param kind the kind of arrow (default is {!triangle_full})
        @param tex add a LaTeX label
        @param pos label position on the path
        @param anchor label anchor
        @param outd the outgoing direction, at the beginning of the arrow
        @param ind the ingoing direction, at the end of the arrow *)

  val box_to_box: ?kind: kind -> ?tex: string -> ?pos: float ->
    ?anchor: Command.position ->
    ?outd: Path.direction -> ?ind: Path.direction -> Box.t -> Box.t ->
    Command.t
    (** Use [box_to_box] to draw an arrow from [a] to [b], stopping at the
        box boundaries. The arguments are the same as those of
        [point_to_point]. *)

  val point_to_box: ?kind: kind -> ?tex: string -> ?pos: float ->
    ?anchor: Command.position ->
    ?outd: Path.direction -> ?ind: Path.direction -> Point.t -> Box.t ->
    Command.t
    (** Use [point_to_box] to draw an arrow from [a] to [b], stopping at the
        box boundaries. The arguments are the same as those of
        [point_to_point]. *)

  val box_to_point: ?kind: kind -> ?tex: string -> ?pos: float ->
    ?anchor: Command.position ->
    ?outd: Path.direction -> ?ind: Path.direction -> Box.t -> Point.t ->
    Command.t
    (** Use [box_to_point] to draw an arrow from [a] to [b], stopping at the
        box boundaries. The arguments are the same as those of
        [point_to_point]. *)

  (** {2 Built-in Kinds} *)

  val classic: kind
    (** A simple arrow with one line and two straight lines for the head. *)

  val triangle: kind
    (** A simple arrow with a triangular head. Same as [classic] but with an
        extra line and some clipping. *)

  val triangle_full: kind
    (** A simple arrow with a triangular head filled with black. *)

  val implies: kind
    (** An arrow made of two parallel lines and a classic head. *)

  val iff: kind
    (** An arrow made of two parallel lines, a classic head and a classic
        foot. *)

  (** {2 Heads} *)

  type head_description
    (** The type of head descriptions (see [make_head] and [head] below). *)

  val make_head: ?cut: Path.t -> Command.t -> head_description
    (** Head description constructor. The command parameter is used to draw
        the head.
        @param cut a path that can be used to cut the arrow body lines
        (only used by heads and feet, not by belts) *)

  type head = Point.t -> Point.t -> head_description
    (** If [h] is a head, [h p d] returns a head description used to
        draw the head at point [p] with direction [d]. Direction [d]
        is normalized before being given to the function. *)

  val head_classic : ?color:Color.t ->
    ?brush:Brush.t ->
    ?pen:Pen.t ->
    ?dashed:Dash.t ->
    ?angle:float -> ?size:Num.t -> head
    (** A simple head with two straight lines.
        @param color the color of the head; default is black
        @param pen the pen used to draw the head; default is
               [Brush.Pen.default]
        @param dashed if given, the head is drawn using that dash_style
        @param angle the angle between the two lines in degrees, default is 60
        degrees
        @param size the length of the two lines, default is 4bp *)

  val head_triangle : ?color:Color.t -> ?brush:Brush.t -> ?pen:Pen.t ->
    ?dashed:Dash.t ->
    ?angle:float -> ?size:Num.t -> head
  (** Same as [head_classic] except that the two lines are joined together
      to form a triangle. *)

  val head_triangle_full : ?color:Color.t -> ?angle:float -> ?size:Num.t
    -> head
  (** Same as [head_triangle] except that the triangle is not drawn (hence the
      absence of pen properties) but is filled with the given [color]. *)

  (** {2 Building Your Own Kinds} *)

  (** Start from the empty kind [empty] and add features to it using
      [add_line], [add_head], ... *)

  val empty: kind
    (** The empty kind with no line nor head. *)

  val add_line: ?brush:Brush.t -> ?dashed: Dash.t -> ?color: Color.t ->
    ?pen: Pen.t ->
    ?from_point: float -> ?to_point: float -> ?dist: Num.t -> kind -> kind
    (** Add a line to a body. The line will be parallel to the path used
        to draw the arrow.
        @param dashed the dash style used to draw the line (default is plain)
        @param color the color of the line (default is black)
        @param pen the pen used to draw the line
               (default is [Brush.Pen.default])
        @param from_point from [0.] (foot of the arrow) to [1.] (head of the
          arrow), the line will start from this point
        @param to_point from [0.] (foot of the arrow) to [1.] (head of the
          arrow), the line will end at this point
        @param dist the distance between the path of the arrow and this line
          (positive values are on the right of the arrows) *)

  val add_head: ?head: head -> kind -> kind
    (** Add a head at the end of the arrow.
        @param head the kind of head to add (default is {!head_classic}) *)

  val add_foot: ?head: head -> kind -> kind
    (** Add a foot (an inverted head) at the beginning of the arrow.
        @param head the kind of head to add (default is {!head_classic}) *)

  val add_belt: ?clip: bool -> ?rev: bool -> ?point: float -> ?head: head ->
    kind -> kind
    (** Add an arrow head at any point of an arrow.
        @param clip if [true], the arrow lines will be clipped after the belt
          (or before if the [rev] is [true]) (default is [false])
        @param rev if [true], the head will be drawn in the opposite direction
          (default is [false])
        @param point the point where to draw the arrow ([0.] for the beginning,
          and [1.] for the end, or any number in-between) (default is [0.5])
        @param head the kind of head to add (default is {!head_classic}) *)

  (** {2 Miscellaneous} *)

  (** Warning: the following functions might be either deleted, modified
      and / or moved somewhere else. Don't use them if you need some backward
      compatibility. *)

  val draw_thick :
    ?style:Path.joint ->
    ?boxed:bool ->
    ?line_color:Color.t ->
    ?fill_color:Color.t ->
    ?outd:Path.direction ->
    ?ind:Path.direction ->
    ?width:Num.t ->
    ?head_length:Num.t ->
    ?head_width:Num.t -> Point.t -> Point.t -> Command.t
    (** Draw a thick arrow. *)
end

(** {2 Helpers and Extensions} *)

(** A few helper functions *)
module Helpers : sig
  val dotlabels :
    ?pos:Command.position -> string list -> Point.t list -> Command.t
  val draw_simple_arrow :
    ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    Point.t -> Point.t -> Command.t
  val draw_label_arrow :
    ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?pos:Command.position -> Picture.t ->
    Point.t -> Point.t -> Command.t
  val draw_labelbox_arrow :
    ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?pos:Command.position -> Box.t ->
    Point.t -> Point.t -> Command.t
  val box_arrow :
    ?within:Box.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?sep:Num.t ->
    Box.t -> Box.t -> Command.t
  (** Draw an arrow between two boxes. The options [pen], [dashed], [color]
    change the drawing of the arrow. [outd] and [ind] specify the outgoing and
    ingoing direction. [sep] specifies the distance of the arrow ends to both
    boxes. If [within] is set, the boxes will be searched within the box
    [within]. *)
  val box_line :
    ?within:Box.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?sep:Num.t ->
    Box.t -> Box.t -> Command.t
  val box_label_arrow :
    ?within:Box.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?sep:Num.t ->
    ?pos:Command.position -> Picture.t ->
    Box.t -> Box.t -> Command.t
  val box_label_line :
    ?within:Box.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?sep:Num.t ->
    ?pos:Command.position -> Picture.t ->
    Box.t -> Box.t -> Command.t
  val box_labelbox_arrow :
    ?within:Box.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?style:Path.joint -> ?outd:Path.direction -> ?ind:Path.direction ->
    ?sep:Num.t ->
    ?pos:Command.position -> Box.t ->
    Box.t -> Box.t -> Command.t
(***
  val hboxjoin :
    ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t ->
    ?dx:Num.t -> ?dy:Num.t -> ?pos:Command.position -> ?spacing:Num.t ->
     Picture.t list -> Command.t
***)

end


(** Create and draw trees *)
module Tree : sig

  (** This module provides high-level means for creating and drawing Trees *)

  type t
    (** The type of trees *)

  (** The style of arrows between nodes *)
  type arrow_style =
      Directed     (** edges are directed and an
		       arrow is drawn at the end of an edge *)
    | Undirected   (** edges are undirected and no arrow is drawn *)

  (** There are several styles available for edges *)
  type edge_style =
      Straight 	  (** edges are straight lines between nodes *)
    | Curve 	  (** edges are curved lines between nodes *)
    | Square 	  (** edges are straight lines and
		      branch out from the sides of nodes *)
    | HalfSquare  (** edges are straight lines and
		      branch out from below nodes *)

  (** {2 Creation} *)
  val leaf : Box.t -> t
    (** [leaf b] creates a leaf with Box [b]. *)

  val node : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style ->
             ?edge_style:edge_style -> ?stroke:Color.t ->
             ?brush:Brush.t -> ?pen:Pen.t ->
             ?sep:Num.t ->
             Box.t -> t list -> t
    (** [node label children] creates a node with label [label] and a list
	of children [children].
        Default arrow_style is [Directed].
	Default edge_style is [Straight].
	- [ls] (level sep): vertical distance between levels.
        The default value is 1.0. A negative value draws the tree upward.
	- [cs] (children sep): horizontal distance between siblings.
        The default value is 0.2.
	Optional arguments are the same as in [leaf]. *)

  val nodel : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style ->
             ?edge_style:edge_style -> ?stroke:Color.t ->
             ?brush:Brush.t -> ?pen:Pen.t ->
             ?sep:Num.t ->
             Box.t -> (t * (Command.position * Picture.t)) list -> t
    (** Similar to [node] but with labels on edges.
        Labels are taken into account only when [edge_style] is [Straight]. *)

  val bin  : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style ->
             ?edge_style:edge_style -> ?stroke:Color.t ->
             ?brush:Brush.t -> ?pen:Pen.t ->
             ?sep:Num.t ->
             Box.t -> t -> t -> t
    (** [bin label l r] creates a binary node with label [label] and
	children [l] and [r].
	Optional arguments are the same as in [leaf]. *)

  val to_box : t -> Box.t

  val draw : ?debug:bool -> t -> Command.t

  module Simple : sig
    type t
    val leaf : Box.t -> t
    val node : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style ->
      ?edge_style:edge_style -> ?stroke:Color.t ->
      ?brush:Brush.t -> ?pen:Pen.t -> ?sep:Num.t ->
      ?valign:Command.position -> ?halign:Command.position ->
      Box.t -> t list -> t
    (** a simple tree placement algorithm: align all subtrees horizontally ,
        and place the parent node above.
        Default arrow_style is [Directed].
	Default edge_style is [Straight].
	@param ls (level sep): vertical distance between levels.
        The default value is 1.0. A negative value draws the tree upward.
	@param cs (children sep): horizontal distance between siblings.
        The default value is 0.2.
      @param halign change alignment of children (default: [`Top])
      @param valign change alignment of parent node wrt. children
               (default: [`Children])
    *)

    val bin  : ?ls:Num.t -> ?cs:Num.t -> ?arrow_style:arrow_style ->
      ?edge_style:edge_style -> ?stroke:Color.t -> ?brush:Brush.t -> ?pen:Pen.t
      -> ?sep:Num.t -> Box.t -> t -> t -> t
      (* [bin t1 t2] is the same as [node [t1;t2] ] *)

    val to_box : t -> Box.t

    val draw : ?debug:bool -> t -> Command.t
  end

end

(** EXPERIMENTAL: A new way of placing trees. *)
module Tree_adv : sig

  (** This module provides even more high-level means for placing trees. *)

  type 'a t = Node of 'a * 'a t list
  (** The type of polymorphic trees *)

  (** {2 Functions for placement} *)

  module Place (X : Signature.Boxlike) : sig
    val gen_place :
      place:(Box.t t -> Box.t) -> X.t t -> X.t t
      (** This is a generic function for placing trees, provided that the user
          can give us the following functions:
          @param place a function which knows how to place a tree of boxes - it
          should return a box where all the boxes of the input tree appear.
      *)

    val place :
      ?ls:Num.t -> ?cs:Num.t ->
      ?valign:Box.position -> ?halign:Box.position ->
      X.t t -> X.t t
      (** This is an instance of [gen_place] using the tree drawing algorithm
          from the module {!Tree}. *)
  end

  val gen_draw_arrows :
     'c -> style:(Point.t -> Point.t -> 'c) ->
     corner:(Box.position -> 'a -> Point.t) -> 'a t -> 'c t
   (** draws arrows from a node to its children with a given style *)

  val draw : ('a -> Box.t) -> 'a t ->  Command.t
  (** Draws a tree that has already been placed when one knows how to draw its
     elements. *)

    (** {2 Useful functions} *)

  val map : ('a -> 'b) -> 'a t -> 'b t
  (** apply a function everywhere in the tree *)

  val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
  (** [map2 f] takes two trees of identical structure and applies the function
    [f] to every pair of nodes. Raise [Invalid_argument] if the trees do not
    have the same structure. *)

  val combine : 'a t -> 'b t -> ('a * 'b) t
  (** Transform a pair of trees into a tree of pairs. Raise [Invalid_argument]
     if the trees do not have the same structure. *)

  val split : ('a * 'b) t -> 'a t * 'b t
  (** Transform a tree of pairs  into a pair of trees. *)

  val root_map : ('a option -> 'a -> 'b) -> 'a t -> 'b t
  (** [root_map f t] calls [f (Some father) node] for each node of [t] and its
     father. It calls [f None root], where [root] is the root of the once, once
     at the beginning. A tree having the same structure is built with the
     results. *)

  val map_children : ('a -> 'a list -> 'b) -> 'a t -> 'b t
  (** [map_children f t] calls [f node children] for each node of [t] and its
     children. A tree having the same structure is built with the results *)

  val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
    (** Traverse the tree in a bottom-up, left-to-right order *)

  val filter : ('a -> bool) -> 'a t -> 'a t
    (** filter f t
        If for a node n of t f n is false then it doesn't appear in the result
        as well as its descendants. If f is false for the root node,
        invalid_argument is raised *)

  val filter_option : ('a -> 'b option) -> 'a t -> 'b t
  (** Suppress a subtree depending on a condition on the node *)

  val wrap_corner_box :
    ('a -> Box.t) ->
    ( corner : (Box.position -> 'a -> Point.t) -> 'c)
    -> 'c
    (** [wrap_corner_box give_box f] returns [f] where its argument corner has
     been set *)

  (** Tools for overlay aware trees  *)
  module Overlays :
  sig

    (** This module provides a type to associate an interval of time
        to a value, to control its visibility *)

    type interval = | Bet of int * int (** \[|a,b|\] *)
			| Bef of int       (** \]|-oo,a|\] *)
			| Aft of int       (** \[|a,+oo|\[ *)
			| Nev              (** emptyset *)
			| Alw              (** N *)
       (** This type describes an interval of discrete points of time *)

	val in_interval : int -> interval -> bool
        (** test if an integer is in an interval *)

	val min_interval : int -> interval -> int
        (** The minimum between the integer argument and the beginning of the
        interval; returns the integer argument in the cases [Nev] and [Alw] *)

	val max_interval : int -> interval -> int
        (** The dual of [min_interval] *)

	val min_tree : ('a -> interval) -> 'a t -> int
        (** The first moment of the tree to appear, not considering [Nev] and
           [Alw] *)

	val max_tree : ('a -> interval) -> 'a t -> int
        (** The last moment of the tree to appear, not considering [Nev] and
           [Alw] *)

	type 'a spec = (interval * 'a) list
            (** A spec is a list of objects associated with a visibility
                interval *)

	val assoq : int -> 'a spec -> 'a
          (** returns the first element which is visible in the specification;
              raises [Not_found] if no element is visible *)

	val max : ('a -> Num.t) -> ('b * 'a) list -> Num.t
          (** given a function to compute a numeric from an ['a], and a
              list of objects [('b,'a)], return the maximal numeric from
              that list; intended to be used with width and height functions
              for objects and with a ['a spec list] *)

	val set_pos : (Point.t -> 'a -> 'b) -> Point.t -> 'a spec -> 'b spec
          (** Given a function to move objects of type ['a], return a
              function to move functions of type ['a spec] *)
  end

  module Overlays_Boxlike (X : Signature.Boxlike):
    Signature.Boxlike with type t = X.t Overlays.spec

end

(** Create simple diagrams by placing objects in a table. Deprecated. *)
module Diag : sig

  (** Diagrams. *)

  (** This module permits to create diagrams in a very simple and yet quite
   flexible fashion. It permits to specify content, form and color of nodes as
   well as color, form and labels of arrows between nodes. Nodes have to be
   placed by hand, though *)

  (** {2 Creation} *)

  type node
    (** The abstract type of nodes *)

  type node_style = Box.t -> Box.t
  (** The type for node styles; It corresponds to the type of the box
    creation functions in the {!Box} module *)

  val node : ?style:node_style -> ?fill:Color.t -> ?boxed:bool ->
                float -> float -> Box.t -> node
    (** Construct a node at a given position with a given content in Latex
        format and a box style *)

  type t
    (** The abstract type of diagrams *)

  val create : node list -> t
    (** Create a diagram that consists of the given nodes *)

  type dir = Up | Down | Left | Right | Angle of float

  val arrow :
    t -> ?lab:string ->
    ?line_width:Num.t ->
    ?boxed:bool ->
    ?line_color:Color.t ->
    ?fill_color:Color.t ->
    ?pos:Command.position ->
    ?head:bool -> ?dashed:Dash.t -> ?outd:dir -> ?ind:dir ->
    node -> node -> unit
    (** [arrow d n1 n2] adds an arrow between n1 and n2 in the diagram d, by
        side effect.
	@param lab The label of the arrow, in Latex format
	@param pos The position of the label, relative to the arrow
	@param line_width Draws a thick arrow of that width, if present
               (experimental)
	@param head If true, the arrow has a head. Otherwise, it's just a line.
	@param outd The outgoing direction of the arrow
	@param ind The ingoing direction of the arrow *)

  (** {2 Drawing} *)

  val draw :
    ?scale:(float -> Num.t) -> ?style:node_style ->
    ?boxed:bool -> ?fill:Color.t -> ?stroke:Color.t -> ?pen:Pen.t ->
    t -> Command.t
    (** Draws the diagram.
        @param scale The distance between nodes; default is 40 bp
	@param style The style of nodes: circular or rectangular
	(default is circular)
	@param boxed The border is drawn if set (default is true)
	@param fill The color to fill nodes
	@param stroke The color to draw arrows
	@param pen The pen used for arrows *)
end

(** A simple and limited way of plotting functions from int to int. *)
module Plot : sig

  (** Plots. *)

  (** This module helps drawing grids and plotting functions. *)

  type skeleton
    (** The abstract skeleton for grids, axes and functions *)

  val mk_skeleton : int -> int -> Num.t -> Num.t -> skeleton
    (** [mk_skeleton w h dx dy] builds a skeleton of width [w] and height [h],
	each cell being [dx] units wide and [dy] units high. *)

  type labels = int -> Num.t -> Picture.t option
  type ticks =  (Num.t * Pen.t) option

  type drawing = Stepwise | Normal

  val draw_grid : ?hdash:(int -> Dash.t) ->
                  ?vdash:(int -> Dash.t) ->
                  ?hpen:(int -> Pen.t) ->
                  ?vpen:(int -> Pen.t) -> ?color:Color.t ->
                  skeleton -> Command.t

  val draw_axes : ?hpen:Pen.t -> ?vpen:Pen.t -> ?hlabel:labels ->
                  ?vlabel:labels -> ?ticks:ticks -> ?closed:bool ->
                  ?hcaption:Picture.t -> ?vcaption:Picture.t ->
                    skeleton -> Command.t

  val draw_simple_axes : ?hpen:Pen.t -> ?vpen:Pen.t -> string -> string ->
                            skeleton -> Command.t


  val draw_func : ?pen:Pen.t -> ?drawing:drawing ->
                  ?style:Path.joint -> ?dashed:Dash.t -> ?color:Color.t ->
                  ?label:(Picture.t * Command.position * int) ->
                  ?from_x:int -> ?to_x:int ->
                    (int -> float) -> skeleton -> Command.t
end

(** A simple and limited way of plotting functions from float to
    float. *)
module Real_plot :
sig
  type 'a curve
    (** 'a store the information about :
       - the way the curve is drawn (style and color)
       - the label used in the legend
    *)

  val curve : (float -> float) -> 'a -> 'a curve
    (** create a curve from a function and some information of
        drawing *)

  val curve_opt : (float -> float option) -> 'a -> 'a curve
    (** create a curve from a function and some information of
        drawing. If the function return None the function is not
        defined on this value *)

  val curve_l : (float -> float option) list -> 'a -> 'a curve
    (** create a curve from multiple function and some information of
        drawing. The different functions symbolize different part of
        the curve which mustn't be connected *)

  val draw :
    ?logarithmic : bool -> (* use a logarithmic scale for ordinate *)
    ?curve_brush : ('a -> Brush.t) -> (* how to draw a curve *)
    ?label : ('a -> string) ->
    (* return the label to use in the legend.
       If no function is given the legend is not drawn *)
    ?ymin : float -> ?ymax : float ->
    xmin : float ->
    xmax : float ->
    pitch : float ->
    width : Num.t ->
    height : Num.t ->
    'a curve list -> Command.t
    (* Draw a graph. If concrete is supported (Concrete.supported) the
       label of ticks on the axes will not overlap *)
end

(** Draw Bar diagrams (Histograms). *)
module Hist : sig

  (** Histograms. *)

  (** This module draws histograms. *)

  type 'a labels = Values | User of 'a list

  val simple :
    ?width:Num.t ->
    ?height:Num.t ->
    ?padding:Num.t ->
    ?fill:Color.t list ->
    ?perspective: bool ->
    ?hcaption:Picture.t ->
    ?vcaption:Picture.t ->
    ?histlabel:Command.vposition * Picture.t labels ->
    ?vlabel:Plot.labels ->
    ?hlabel:Picture.t list ->
    float list -> Command.t
    (** [simple l] draws an histogram from a list [l] of floating-point values.
	@param width Total width of the histogram (default: 100 bp)
	@param height Total height for the histogram (default: 200 bp)
	@param fill The colors used to draw the successive blocks;
	  it is used circularly
	@param padding Horizontal space between two blocks
	@param hcaption See module Plot
	@param vcaption See module Plot
	@param hlabel Labels for each block
	@param vlabel See module Plot
	@param histlabel Add a label to each block; the first component
          controls the placement of the label; the second component, of type
          [insideBox], controls the label itself, which is either the numerical
          value of the block (i.e. the float) or a user picture
    *)

  val compare :
    ?width:Num.t ->
    ?height:Num.t ->
    ?padding:Num.t ->
    ?fill:Color.t list ->
    ?perspective: bool ->
    ?hcaption:Picture.t ->
    ?vcaption:Picture.t ->
    ?histlabel:Command.vposition * Picture.t list labels ->
    ?vlabel:Plot.labels ->
    ?hlabel:Picture.t list ->
    float list list -> Command.t
    (** [compare l] draws a comparative histogram from a list [l]
	of floating-point lists.
	For optional arguments, see function [simple] above.
    *)

  val stack :
    ?width:Num.t ->
    ?height:Num.t ->
    ?padding:Num.t ->
    ?fill:Color.t list ->
    ?perspective: bool ->
    ?hcaption:Picture.t ->
    ?vcaption:Picture.t ->
    ?histlabel:Command.vposition * Picture.t list labels ->
    ?vlabel:Plot.labels ->
    ?hlabel:Picture.t list ->
    float list list -> Command.t
    (** [compare l] draws a stacked histogram from a list [l]
	of floating-point lists.
	For optional arguments, see function [simple] above.
    *)

end

(** Radar diagrams. *)
module Radar : sig

  (** This module draws radar diagrams.*)

  val stack :
    ?radius:Num.t ->
    ?color:Color.t list ->
    ?pen:Pen.t ->
    ?style:Dash.t list ->
    ?ticks:float ->
    ?label:string list ->
    ?scale:float list ->
    float list list -> Picture.t
    (** [stack l] builds a picture from a list [l] of floating-point lists.
	The radars are all drawn on the same picture.
	Each sublist represents one radar datas.
	All sublists must have the same length.
	@param radius The radius of the whole picture
	@param pen The pen used to draw the radars
	@param color The colors used to draw each radar; it is used circularly
	@param style The dash-styles used to draw each radar; it is used
	  circularly
	@param ticks The interval between each ticks along the axes
	  (relative to the values)
	@param scale The size of every axe, relative to the values;
	  when not specified, the maximal value along each axe is chosen
    *)

  val compare :
    ?radius:Num.t ->
    ?color:Color.t list ->
    ?fill:bool ->
    ?pen:Pen.t ->
    ?style:Dash.t list ->
    ?ticks:float ->
    ?label:string list ->
    ?scale:float list ->
    float list list -> Picture.t list
    (** [stack l] builds a list of pictures from a list [l] of
	floating-point lists.
	Each picture represents one radar, and all picture have the same size.
	Each sublist represents one radar datas, and all sublists must have
	the same length.
	For most optional arguments, see function [stack] above.
	@param fill Fill the radar with its color.
    *)

end

(** Build a legend for diagrams. *)
module Legend : sig

  val legend :
    ?ensstroke:Color.t ->
    ?colstroke:Color.t ->
    ?fill:Color.t ->
    (Color.t * string) list -> Picture.t

end

(** {2 Metapost generation} *)

(* Misc does not appear in the documentation *)
(**/**)
module Misc : sig
  val write_to_file : string -> (out_channel -> 'a) -> unit
  val write_to_formatted_file : string -> (Format.formatter -> 'a) -> unit
  val print_option :
    string ->
    (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a option -> unit
  val print_list :
    ('a -> unit -> 'b) -> ('a -> 'c -> unit) -> 'a -> 'c list -> unit
  val space : Format.formatter -> unit -> unit
  val comma : Format.formatter -> unit -> unit

  val fold_from_to : ('a -> int -> 'a) -> 'a -> int -> int -> 'a
  (** [fold_from_to f acc i j] is equivalent to
      [List.fold_left f acc [i; i +1; .. j] ],
     where i <= j *)
  val call_cmd :
    ?inv:bool -> ?outv:bool -> ?verbose:bool -> string -> int * string

end
(**/**)

(** Functions to generate Metapost files *)
module Metapost : sig

  val set_filename_prefix : string -> unit
    (** Add to the filename given to the emit function this prefix.
        This function is here just for convenience *)

  val generate_mp :
    string ->
    ?prelude:string ->
    ?eps:bool ->
    (int * Command.t) list -> unit

  val generate :
    string ->
    ?prelude:string ->
    ?pdf:bool ->
    ?eps:bool ->
    ?verbose:bool ->
    ?clean:bool ->
    (int * Command.t) list -> unit

  val emit : string -> Command.t -> unit
  val dump :
    ?prelude:string ->
    ?pdf:bool ->
    ?eps:bool ->
    ?verbose:bool ->
    ?clean:bool ->
    string -> unit
    (** [dump ?prelude ?pdf f] builds a Metapost file [f.mp] for all figures,
	then runs Metapost on it, and renames figure files according to the
	names specified to [emit]. The file suffix is [.mps] if [pdf] is
	set, and [.1] otherwise. *)

  val dump_mp :
    ?prelude:string -> string -> unit
  val dump_png :
    ?prelude:string -> ?verbose:bool -> ?clean:bool -> string -> unit

  val read_prelude_from_tex_file : string -> string
    (** read the prelude from a tex file, until the end of file or the text
       "\begin\{document\}" if it is outside a comment *)

  val dump_tex : ?prelude:string -> string -> unit
    (** [dump_tex ?prelude f] builds a LaTeX file [f.tex] for all the figures,
	using LaTeX prelude [prelude] if given. *)

  val slideshow : Command.t list -> int -> (int * Command.t) list
    (** takes a list of figures and returns a list of figures of exactly the
        same size (the size of the biggest figure). Shared objects are
        hopefully placed at the same absolute location across figures. The
        resulting figures are numbered with consecutive increasing integers,
        starting with the given value. *)

  val emit_slideshow : string -> Command.t list -> unit
    (** emit the list of figures as a slideshow, using the [slideshow]
        function.*)

  val dumpable : unit -> unit
  val depend : string -> unit

end

(** Helper functions to generate test TeX files *)
module Generate : sig
  val generate_tex : ?pdf:bool -> string -> string -> string
    -> (int * 'a) list -> unit

  val generate_tex_cairo : string -> string -> string -> string
    -> (int * 'a) list -> unit

end

(** Compute concrete values of numerics, points and paths;
   not always available *)
module Concrete : sig
  val supported : bool

  (** The module of concrete points *)
  module CPoint : sig

    IFDEF CAIRO THEN
      type t = Cairo.point = { x : float; y : float }
    ELSE
      type t = { x : float; y : float }
    END

    val add : t -> t -> t
    val sub : t -> t -> t
    val opp : t -> t
    val mult : float -> t -> t
    val div : t -> float -> t

    module Infix :
    sig
      val (+/) : t -> t -> t
        (** alias for {!Concrete.CPoint.add} *)

      val (-/) : t -> t -> t
        (** alias for {!Concrete.CPoint.sub} *)

      val ( */) : float -> t -> t
        (** alias for {!Concrete.CPoint.mult} *)

      val ( //) : t -> float -> t
        (** alias for {!Concrete.CPoint.div} *)

    end

    val print : Format.formatter -> t -> unit
  end

  (** Concrete Paths *)
  module CPath : sig
    (* A path is a succession of splines *)
    type t
    type abscissa = float

    val length : t -> float
    val is_closed : t -> bool
    val is_a_point : t -> CPoint.t option

    val intersection : t -> t -> (abscissa * abscissa) list
      (** intersection p1 p2 return a list of pair of abscissa. In each
          pairs (a1,a2), a1 (resp. a2) is the abscissa in p1 (resp. p2) of
          one intersection point between p1 and p2. Additionnal point of
          intersection (two point for only one real intersection) can
          appear in degenerate case. *)

    val one_intersection : t -> t -> (abscissa * abscissa)
      (** one_intersection p1 p2 return one of the intersections
          between p1 and p2 or raise Not_found if none exists*)


    val reverse : t -> t
      (** reverse p return the path p reversed *)

    val iter :
      (CPoint.t -> CPoint.t -> CPoint.t -> CPoint.t -> unit) -> t -> unit
      (** iter on all the splines of a path: iter f p applies f
          successively to the splines of p with :
          - the start point of the spline as first argument
          - the control point of the start point as second argument
          - the control point of the end point as third argument
          - the end point as fourth argument *)

    val fold_left :
      ('a -> CPoint.t -> CPoint.t -> CPoint.t -> CPoint.t -> 'a)
      -> 'a -> t -> 'a
      (** fold on all the splines of a path *)

    val cut_before : t -> t -> t
    val cut_after : t -> t -> t
      (** remove the part of a path before the first intersection
          or after the last*)

    val split : t -> abscissa -> t * t
    val subpath : t -> abscissa -> abscissa -> t

    val direction_of_abscissa : t -> abscissa -> CPoint.t
    val point_of_abscissa : t -> abscissa -> CPoint.t

    val bounding_box : t -> CPoint.t * CPoint.t

    val dist_min_point : t -> CPoint.t -> float * abscissa
    val dist_min_path : t -> t -> float * (abscissa * abscissa)

    val print : Format.formatter -> t -> unit
  end

  module CTransform :
  sig
    IFDEF CAIRO THEN
    type t = Cairo.matrix =
        { xx : float; yx : float
        ; xy : float; yy : float; x0 : float; y0 : float; }
    ELSE
    type t =
        { xx : float; yx : float;
          xy : float; yy : float; x0 : float; y0 : float; }
    END
  end

  (** {2 Compute the concrete value} *)
  val float_of_num : Num.t -> float
  val compute_nums : unit -> (Num.t -> unit) * (unit -> unit)
    (** The value of a num in bp *)

  val cpoint_of_point : Point.t -> CPoint.t

  val cpath_of_path : Path.t -> CPath.t

  val ctransform_of_transform : Transform.t -> CTransform.t

  (** {2 Compute the baselines of a tex} *)
  val baselines : string -> float list

  (** {2 Simple functions for the opposite operations} *)

  val num_of_float : float -> Num.t
    (** exactly Num.bp *)

  val point_of_cpoint : CPoint.t -> Point.t
  val path_of_cpath : CPath.t -> Path.t

  val transform_of_ctransform : CTransform.t -> Transform.t

    (** {2 Some options (the mlpost tool takes care of them)} *)
  val set_verbosity : bool -> unit

  val set_prelude : string -> unit
    (** set_prelude filename uses the prelude of the file filename
        for compilation of the tex snippets *)

  val set_prelude2 : string option -> unit
    (** set_prelude2 prelude uses this prelude
        for compilation of the tex snippets *)

  val set_t1disasm : string option -> unit
    (** Deprecated in a next release *)

end

(** Use the Cairo backend to draw your figures; not always available *)
module Cairost : sig

  val supported : bool

  val emit_pdf : ?msg_error:float -> string -> Command.t -> unit
    (* The optional argument set the replacement the figure by the
       text of the exception in a paragraph of width msg_error *)
  val emit_ps : string -> Command.t -> unit
  val emit_png : string -> Command.t -> unit
  val emit_svg : string -> Command.t -> unit
  val emit_pdfs : string -> Command.t list -> unit
    (** One figure by page *)

  val dump_pdf : unit -> unit
  val dump_ps : unit -> unit
  val dump_png : unit -> unit
  val dump_svg : unit -> unit
  val dump_pdfs : string -> unit
    (** Use the figures recorded by the function emit of metapost *)

  val generate_pdfs : string ->
    (int * Command.t) list -> unit

  IFDEF CAIRO THEN
    type cairo_t = Cairo.t
  ELSE
    type cairo_t
  END

  val emit_cairo : cairo_t -> float * float -> Command.t -> unit

end

(**/**)
module Metapost_tool : sig
  val read_prelude_from_tex_file : string -> string
end
(**/**)