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
|
;;; COPYRIGHT NOTICE
;;;
;;; Copyright (C) 2007-2017 Mario Rodriguez Riotorto
;;;
;;; This program is free software; you can redistribute
;;; it and/or modify it under the terms of the
;;; GNU General Public License as published by
;;; the Free Software Foundation; either version 2
;;; of the License, or (at your option) any later version.
;;;
;;; This program 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. See the
;;; GNU General Public License for more details at
;;; http://www.gnu.org/copyleft/gpl.html
;;; This is a maxima-gnuplot interface.
;;; Visit
;;; http://tecnostats.net/Maxima/gnuplot
;;; and
;;; http://tecnostats.net/Maxima/vtk
;;; for examples
;;; Some portions of this package were written by
;;; Andrej Vodopivec and Joan Pau Beltran.
;;; Some other people has also helped with bug reports,
;;; comments, complains and feature requests.
;;; Thanks to everybody!!
;;; For questions, suggestions, bugs and the like, feel free
;;; to contact me at
;;; riotorto @@@ yahoo DOT com
;; Possible draw renderers:
;; gnuplot_pipes (default)
;; gnuplot
;; vtk or vtk6
;; vtk7
(defvar $draw_renderer '$gnuplot_pipes)
(defvar $draw_use_pngcairo nil "If true, use pngcairo terminal when png is requested.")
;; Stores user defaults
(defvar *user-gr-default-options* nil)
(defun $set_draw_defaults (&rest opts)
(setf *user-gr-default-options* opts)
(cons '(mlist) opts))
(defun user-defaults ()
(dolist (x *user-gr-default-options*)
(if (equal ($op x) "=")
(update-gr-option ($lhs x) ($rhs x))
(merror "draw: item ~M is not recognized as an option assignment" x))))
;; Stores user defined allocations of scenes
(defvar *allocations* nil)
;; Sets default values of graphics options
(defvar *gr-options* (make-hash-table))
(defun ini-gr-options ()
(setf
; global options to control general aspects of graphics
(gethash '$allocation *gr-options*) nil ; or user-defined allocation
(gethash '$proportional_axes *gr-options*) '$none ; three possible options: none, xy, xyz
(gethash '$xrange *gr-options*) nil ; nil => automatic computation
(gethash '$xrange_secondary *gr-options*) nil ; nil => automatic computation
(gethash '$yrange *gr-options*) nil ; nil => automatic computation
(gethash '$yrange_secondary *gr-options*) nil ; nil => automatic computation
(gethash '$zrange *gr-options*) nil ; nil => automatic computation
(gethash '$cbrange *gr-options*) nil ; nil => automatic computation
(gethash '$logx *gr-options*) nil
(gethash '$logx_secondary *gr-options*) nil
(gethash '$logy *gr-options*) nil
(gethash '$logy_secondary *gr-options*) nil
(gethash '$logz *gr-options*) nil
(gethash '$logcb *gr-options*) nil
(gethash '$title *gr-options*) ""
(gethash '$view *gr-options*) '(60 30) ; in [0,180] x [0,360]
(gethash '$xy_file *gr-options*) ""
(gethash '$user_preamble *gr-options*) ""
(gethash '$xyplane *gr-options*) nil
(gethash '$font *gr-options*) "";
(gethash '$font_size *gr-options*) 10;
(gethash '$key_pos *gr-options*) nil
; colors are specified by name
(gethash '$background_color *gr-options*) "#ffffff"
(gethash '$color *gr-options*) "#0000ff" ; for lines, points, borders and labels
(gethash '$fill_color *gr-options*) "#ff0000" ; for filled regions
(gethash '$fill_density *gr-options*) nil ; if specified, must be in [0, 1]
; implicit plot options
(gethash '$ip_grid *gr-options*) '((mlist simp) 50 50)
(gethash '$ip_grid_in *gr-options*) '((mlist simp) 5 5)
(gethash '$x_voxel *gr-options*) 10
(gethash '$y_voxel *gr-options*) 10
(gethash '$z_voxel *gr-options*) 10
; tics
(gethash '$grid *gr-options*) (list 0 0)
(gethash '$xtics *gr-options*) "autofreq"
(gethash '$xtics_secondary *gr-options*) nil ; no tics in top x-axis
(gethash '$ytics *gr-options*) "autofreq"
(gethash '$ytics_secondary *gr-options*) nil ; no tics in right y-axis
(gethash '$ztics *gr-options*) "autofreq"
(gethash '$cbtics *gr-options*) "autofreq"
(gethash '$xtics_rotate *gr-options*) nil
(gethash '$xtics_secondary_rotate *gr-options*) nil
(gethash '$ytics_rotate *gr-options*) nil
(gethash '$ytics_secondary_rotate *gr-options*) nil
(gethash '$ztics_rotate *gr-options*) nil
(gethash '$xtics_axis *gr-options*) nil
(gethash '$xtics_secondary_axis *gr-options*) nil
(gethash '$ytics_axis *gr-options*) nil
(gethash '$ytics_secondary_axis *gr-options*) nil
(gethash '$ztics_axis *gr-options*) nil
; axes
(gethash '$axis_bottom *gr-options*) t
(gethash '$axis_left *gr-options*) t
(gethash '$axis_top *gr-options*) t
(gethash '$axis_right *gr-options*) t
(gethash '$axis_3d *gr-options*) t
(gethash '$xaxis *gr-options*) nil ; no xaxis by default
(gethash '$xaxis_width *gr-options*) 1
(gethash '$xaxis_type *gr-options*) 0 ; two options: 1 (solid) and 0 (dots)
(gethash '$xaxis_color *gr-options*) "#000000"
(gethash '$yaxis *gr-options*) nil ; no yaxis by default
(gethash '$yaxis_width *gr-options*) 1
(gethash '$yaxis_type *gr-options*) 0 ; two options: 1 (solid) and 0 (dots)
(gethash '$yaxis_color *gr-options*) "#000000"
(gethash '$zaxis *gr-options*) nil ; no zaxis by default
(gethash '$zaxis_width *gr-options*) 1
(gethash '$zaxis_type *gr-options*) 0 ; two options: 1 (solid) and 0 (dots)
(gethash '$zaxis_color *gr-options*) "#000000"
(gethash '$xlabel *gr-options*) ""
(gethash '$xlabel_secondary *gr-options*) ""
(gethash '$ylabel *gr-options*) ""
(gethash '$ylabel_secondary *gr-options*) ""
(gethash '$zlabel *gr-options*) ""
(gethash '$zlabel_rotate *gr-options*) '$auto
; point options
(gethash '$point_size *gr-options*) 1
(gethash '$point_type *gr-options*) 1
(gethash '$points_joined *gr-options*) nil ; other options are: true and $impulses
; error bars option
(gethash '$error_type *gr-options*) '$y
; polygon options
(gethash '$transparent *gr-options*) nil
(gethash '$opacity *gr-options*) 1
(gethash '$border *gr-options*) t
; vector options
(gethash '$head_both *gr-options*) nil
(gethash '$head_length *gr-options*) 2 ; in x-axis units
(gethash '$head_angle *gr-options*) 45 ; with respect to the segment
(gethash '$head_type *gr-options*) '$filled ; other options are: $empty and $nofilled
(gethash '$unit_vectors *gr-options*) nil
; label options
(gethash '$label_alignment *gr-options*) '$center ; other options are: $left and $right
(gethash '$label_orientation *gr-options*) '$horizontal ; the other option is $vertical
; line options
(gethash '$line_width *gr-options*) 1
(gethash '$line_type *gr-options*) 1 ; two options: 1 (solid) and 0 (dots)
; function options
(gethash '$nticks *gr-options*) 29
(gethash '$adapt_depth *gr-options*) 10
(gethash '$key *gr-options*) "" ; by default, no keys
(gethash '$filled_func *gr-options*) nil ; false, true (y axis) or an expression
(gethash '$xaxis_secondary *gr-options*) nil
(gethash '$yaxis_secondary *gr-options*) nil
(gethash '$draw_realpart *gr-options*) t
; transformation option
(gethash '$transform *gr-options*) '$none
; 3d options
(gethash '$xu_grid *gr-options*) 50
(gethash '$yv_grid *gr-options*) 50
(gethash '$surface_hide *gr-options*) nil
(gethash '$interpolate_color *gr-options*) "depthorder"
(gethash '$enhanced3d *gr-options*) '$none
(gethash '$isolines *gr-options*) '$none
(gethash '$wired_surface *gr-options*) nil
(gethash '$contour *gr-options*) '$none ; other options are: $base, $surface, $both and $map
(gethash '$contour_levels *gr-options*) 5 ; 1-50, [lowest_level,step,highest_level] or {e1,e2,...}
(gethash '$isolines_levels *gr-options*) 10 ; 1-50, [lowest_level_fraction,step,highest_level_fraction],
; or {e1_fraction,e2_fraction,...}. Only for VTK.
(gethash '$colorbox *gr-options*) t ; in pm3d mode, always show colorbox
(gethash '$palette *gr-options*) '$color ; '$color is a short cut for [7,5,15]
; and '$gray is a short cut for [3,3,3].
; See command 'show palette rgbformulae' in gnuplot.
(gethash '$capping *gr-options*) '((mlist simp) nil nil)
) )
;; Returns option value
(defun get-option (opt) (gethash opt *gr-options*))
;; update options color, fill_color, xaxis_color, yaxis_color,
;; $zaxis_color, and $background_color
;; -----------------------------------------------------------
;; defined as a color name or hexadecimal #rrggbb
(defun atom-to-downcased-string (val)
; also, remove spaces, minus symbols, and underscores
(remove-if
#'(lambda (z) (member (char-int z) '(32 45 95)))
(string-downcase
(string-trim
"\""
(coerce (mstring val) 'string)))))
(defvar *color-table* (make-hash-table :test 'equal))
(setf (gethash "snow" *color-table*) "#FFFAFA"
(gethash "ghostwhite" *color-table*) "#F8F8FF"
(gethash "whitesmoke" *color-table*) "#F5F5F5"
(gethash "gainsboro" *color-table*) "#DCDCDC"
(gethash "floralwhite" *color-table*) "#FFFAF0"
(gethash "oldlace" *color-table*) "#FDF5E6"
(gethash "linen" *color-table*) "#FAF0E6"
(gethash "antiquewhite" *color-table*) "#FAEBD7"
(gethash "papayawhip" *color-table*) "#FFEFD5"
(gethash "blanchedalmond" *color-table*) "#FFEBCD"
(gethash "bisque" *color-table*) "#FFE4C4"
(gethash "peachpuff" *color-table*) "#FFDAB9"
(gethash "navajowhite" *color-table*) "#FFDEAD"
(gethash "moccasin" *color-table*) "#FFE4B5"
(gethash "cornsilk" *color-table*) "#FFF8DC"
(gethash "ivory" *color-table*) "#FFFFF0"
(gethash "lemonchiffon" *color-table*) "#FFFACD"
(gethash "seashell" *color-table*) "#FFF5EE"
(gethash "honeydew" *color-table*) "#F0FFF0"
(gethash "mintcream" *color-table*) "#F5FFFA"
(gethash "azure" *color-table*) "#F0FFFF"
(gethash "aliceblue" *color-table*) "#F0F8FF"
(gethash "lavender" *color-table*) "#E6E6FA"
(gethash "lavenderblush" *color-table*) "#FFF0F5"
(gethash "mistyrose" *color-table*) "#FFE4E1"
(gethash "white" *color-table*) "#FFFFFF"
(gethash "black" *color-table*) "#000000"
(gethash "darkslategray" *color-table*) "#2F4F4F"
(gethash "darkslategrey" *color-table*) "#2F4F4F"
(gethash "dimgray" *color-table*) "#696969"
(gethash "dimgrey" *color-table*) "#696969"
(gethash "slategray" *color-table*) "#708090"
(gethash "slategrey" *color-table*) "#708090"
(gethash "lightslategray" *color-table*) "#778899"
(gethash "lightslategrey" *color-table*) "#778899"
(gethash "gray" *color-table*) "#BEBEBE"
(gethash "grey" *color-table*) "#BEBEBE"
(gethash "lightgrey" *color-table*) "#D3D3D3"
(gethash "lightgray" *color-table*) "#D3D3D3"
(gethash "midnightblue" *color-table*) "#191970"
(gethash "navy" *color-table*) "#000080"
(gethash "navyblue" *color-table*) "#000080"
(gethash "cornflowerblue" *color-table*) "#6495ED"
(gethash "darkslateblue" *color-table*) "#483D8B"
(gethash "slateblue" *color-table*) "#6A5ACD"
(gethash "mediumslateblue" *color-table*) "#7B68EE"
(gethash "lightslateblue" *color-table*) "#8470FF"
(gethash "mediumblue" *color-table*) "#0000CD"
(gethash "royalblue" *color-table*) "#4169E1"
(gethash "blue" *color-table*) "#0000FF"
(gethash "dodgerblue" *color-table*) "#1E90FF"
(gethash "deepskyblue" *color-table*) "#00BFFF"
(gethash "skyblue" *color-table*) "#87CEEB"
(gethash "lightskyblue" *color-table*) "#87CEFA"
(gethash "steelblue" *color-table*) "#4682B4"
(gethash "lightsteelblue" *color-table*) "#B0C4DE"
(gethash "lightblue" *color-table*) "#ADD8E6"
(gethash "powderblue" *color-table*) "#B0E0E6"
(gethash "paleturquoise" *color-table*) "#AFEEEE"
(gethash "darkturquoise" *color-table*) "#00CED1"
(gethash "mediumturquoise" *color-table*) "#48D1CC"
(gethash "turquoise" *color-table*) "#40E0D0"
(gethash "cyan" *color-table*) "#00FFFF"
(gethash "lightcyan" *color-table*) "#E0FFFF"
(gethash "cadetblue" *color-table*) "#5F9EA0"
(gethash "mediumaquamarine" *color-table*) "#66CDAA"
(gethash "aquamarine" *color-table*) "#7FFFD4"
(gethash "darkgreen" *color-table*) "#006400"
(gethash "darkolivegreen" *color-table*) "#556B2F"
(gethash "darkseagreen" *color-table*) "#8FBC8F"
(gethash "seagreen" *color-table*) "#2E8B57"
(gethash "mediumseagreen" *color-table*) "#3CB371"
(gethash "lightseagreen" *color-table*) "#20B2AA"
(gethash "palegreen" *color-table*) "#98FB98"
(gethash "springgreen" *color-table*) "#00FF7F"
(gethash "lawngreen" *color-table*) "#7CFC00"
(gethash "green" *color-table*) "#00FF00"
(gethash "chartreuse" *color-table*) "#7FFF00"
(gethash "mediumspringgreen" *color-table*) "#00FA9A"
(gethash "greenyellow" *color-table*) "#ADFF2F"
(gethash "limegreen" *color-table*) "#32CD32"
(gethash "yellowgreen" *color-table*) "#9ACD32"
(gethash "forestgreen" *color-table*) "#228B22"
(gethash "olivedrab" *color-table*) "#6B8E23"
(gethash "darkkhaki" *color-table*) "#BDB76B"
(gethash "khaki" *color-table*) "#F0E68C"
(gethash "palegoldenrod" *color-table*) "#EEE8AA"
(gethash "lightgoldenrodyellow" *color-table*) "#FAFAD2"
(gethash "lightyellow" *color-table*) "#FFFFE0"
(gethash "yellow" *color-table*) "#FFFF00"
(gethash "gold" *color-table*) "#FFD700"
(gethash "lightgoldenrod" *color-table*) "#EEDD82"
(gethash "goldenrod" *color-table*) "#DAA520"
(gethash "darkgoldenrod" *color-table*) "#B8860B"
(gethash "rosybrown" *color-table*) "#BC8F8F"
(gethash "indianred" *color-table*) "#CD5C5C"
(gethash "saddlebrown" *color-table*) "#8B4513"
(gethash "sienna" *color-table*) "#A0522D"
(gethash "peru" *color-table*) "#CD853F"
(gethash "burlywood" *color-table*) "#DEB887"
(gethash "beige" *color-table*) "#F5F5DC"
(gethash "wheat" *color-table*) "#F5DEB3"
(gethash "sandybrown" *color-table*) "#F4A460"
(gethash "tan" *color-table*) "#D2B48C"
(gethash "chocolate" *color-table*) "#D2691E"
(gethash "firebrick" *color-table*) "#B22222"
(gethash "brown" *color-table*) "#A52A2A"
(gethash "darksalmon" *color-table*) "#E9967A"
(gethash "salmon" *color-table*) "#FA8072"
(gethash "lightsalmon" *color-table*) "#FFA07A"
(gethash "orange" *color-table*) "#FFA500"
(gethash "darkorange" *color-table*) "#FF8C00"
(gethash "coral" *color-table*) "#FF7F50"
(gethash "lightcoral" *color-table*) "#F08080"
(gethash "tomato" *color-table*) "#FF6347"
(gethash "orangered" *color-table*) "#FF4500"
(gethash "red" *color-table*) "#FF0000"
(gethash "hotpink" *color-table*) "#FF69B4"
(gethash "deeppink" *color-table*) "#FF1493"
(gethash "pink" *color-table*) "#FFC0CB"
(gethash "lightpink" *color-table*) "#FFB6C1"
(gethash "palevioletred" *color-table*) "#DB7093"
(gethash "maroon" *color-table*) "#B03060"
(gethash "mediumvioletred" *color-table*) "#C71585"
(gethash "violetred" *color-table*) "#D02090"
(gethash "magenta" *color-table*) "#FF00FF"
(gethash "violet" *color-table*) "#EE82EE"
(gethash "plum" *color-table*) "#DDA0DD"
(gethash "orchid" *color-table*) "#DA70D6"
(gethash "mediumorchid" *color-table*) "#BA55D3"
(gethash "darkorchid" *color-table*) "#9932CC"
(gethash "darkviolet" *color-table*) "#9400D3"
(gethash "blueviolet" *color-table*) "#8A2BE2"
(gethash "purple" *color-table*) "#A020F0"
(gethash "mediumpurple" *color-table*) "#9370DB"
(gethash "thistle" *color-table*) "#D8BFD8"
(gethash "snow1" *color-table*) "#FFFAFA"
(gethash "snow2" *color-table*) "#EEE9E9"
(gethash "snow3" *color-table*) "#CDC9C9"
(gethash "snow4" *color-table*) "#8B8989"
(gethash "seashell1" *color-table*) "#FFF5EE"
(gethash "seashell2" *color-table*) "#EEE5DE"
(gethash "seashell3" *color-table*) "#CDC5BF"
(gethash "seashell4" *color-table*) "#8B8682"
(gethash "antiquewhite1" *color-table*) "#FFEFDB"
(gethash "antiquewhite2" *color-table*) "#EEDFCC"
(gethash "antiquewhite3" *color-table*) "#CDC0B0"
(gethash "antiquewhite4" *color-table*) "#8B8378"
(gethash "bisque1" *color-table*) "#FFE4C4"
(gethash "bisque2" *color-table*) "#EED5B7"
(gethash "bisque3" *color-table*) "#CDB79E"
(gethash "bisque4" *color-table*) "#8B7D6B"
(gethash "peachpuff1" *color-table*) "#FFDAB9"
(gethash "peachpuff2" *color-table*) "#EECBAD"
(gethash "peachpuff3" *color-table*) "#CDAF95"
(gethash "peachpuff4" *color-table*) "#8B7765"
(gethash "navajowhite1" *color-table*) "#FFDEAD"
(gethash "navajowhite2" *color-table*) "#EECFA1"
(gethash "navajowhite3" *color-table*) "#CDB38B"
(gethash "navajowhite4" *color-table*) "#8B795E"
(gethash "lemonchiffon1" *color-table*) "#FFFACD"
(gethash "lemonchiffon2" *color-table*) "#EEE9BF"
(gethash "lemonchiffon3" *color-table*) "#CDC9A5"
(gethash "lemonchiffon4" *color-table*) "#8B8970"
(gethash "cornsilk1" *color-table*) "#FFF8DC"
(gethash "cornsilk2" *color-table*) "#EEE8CD"
(gethash "cornsilk3" *color-table*) "#CDC8B1"
(gethash "cornsilk4" *color-table*) "#8B8878"
(gethash "ivory1" *color-table*) "#FFFFF0"
(gethash "ivory2" *color-table*) "#EEEEE0"
(gethash "ivory3" *color-table*) "#CDCDC1"
(gethash "ivory4" *color-table*) "#8B8B83"
(gethash "honeydew1" *color-table*) "#F0FFF0"
(gethash "honeydew2" *color-table*) "#E0EEE0"
(gethash "honeydew3" *color-table*) "#C1CDC1"
(gethash "honeydew4" *color-table*) "#838B83"
(gethash "lavenderblush1" *color-table*) "#FFF0F5"
(gethash "lavenderblush2" *color-table*) "#EEE0E5"
(gethash "lavenderblush3" *color-table*) "#CDC1C5"
(gethash "lavenderblush4" *color-table*) "#8B8386"
(gethash "mistyrose1" *color-table*) "#FFE4E1"
(gethash "mistyrose2" *color-table*) "#EED5D2"
(gethash "mistyrose3" *color-table*) "#CDB7B5"
(gethash "mistyrose4" *color-table*) "#8B7D7B"
(gethash "azure1" *color-table*) "#F0FFFF"
(gethash "azure2" *color-table*) "#E0EEEE"
(gethash "azure3" *color-table*) "#C1CDCD"
(gethash "azure4" *color-table*) "#838B8B"
(gethash "slateblue1" *color-table*) "#836FFF"
(gethash "slateblue2" *color-table*) "#7A67EE"
(gethash "slateblue3" *color-table*) "#6959CD"
(gethash "slateblue4" *color-table*) "#473C8B"
(gethash "royalblue1" *color-table*) "#4876FF"
(gethash "royalblue2" *color-table*) "#436EEE"
(gethash "royalblue3" *color-table*) "#3A5FCD"
(gethash "royalblue4" *color-table*) "#27408B"
(gethash "blue1" *color-table*) "#0000FF"
(gethash "blue2" *color-table*) "#0000EE"
(gethash "blue3" *color-table*) "#0000CD"
(gethash "blue4" *color-table*) "#00008B"
(gethash "dodgerblue1" *color-table*) "#1E90FF"
(gethash "dodgerblue2" *color-table*) "#1C86EE"
(gethash "dodgerblue3" *color-table*) "#1874CD"
(gethash "dodgerblue4" *color-table*) "#104E8B"
(gethash "steelblue1" *color-table*) "#63B8FF"
(gethash "steelblue2" *color-table*) "#5CACEE"
(gethash "steelblue3" *color-table*) "#4F94CD"
(gethash "steelblue4" *color-table*) "#36648B"
(gethash "deepskyblue1" *color-table*) "#00BFFF"
(gethash "deepskyblue2" *color-table*) "#00B2EE"
(gethash "deepskyblue3" *color-table*) "#009ACD"
(gethash "deepskyblue4" *color-table*) "#00688B"
(gethash "skyblue1" *color-table*) "#87CEFF"
(gethash "skyblue2" *color-table*) "#7EC0EE"
(gethash "skyblue3" *color-table*) "#6CA6CD"
(gethash "skyblue4" *color-table*) "#4A708B"
(gethash "lightskyblue1" *color-table*) "#B0E2FF"
(gethash "lightskyblue2" *color-table*) "#A4D3EE"
(gethash "lightskyblue3" *color-table*) "#8DB6CD"
(gethash "lightskyblue4" *color-table*) "#607B8B"
(gethash "slategray1" *color-table*) "#C6E2FF"
(gethash "slategray2" *color-table*) "#B9D3EE"
(gethash "slategray3" *color-table*) "#9FB6CD"
(gethash "slategray4" *color-table*) "#6C7B8B"
(gethash "lightsteelblue1" *color-table*) "#CAE1FF"
(gethash "lightsteelblue2" *color-table*) "#BCD2EE"
(gethash "lightsteelblue3" *color-table*) "#A2B5CD"
(gethash "lightsteelblue4" *color-table*) "#6E7B8B"
(gethash "lightblue1" *color-table*) "#BFEFFF"
(gethash "lightblue2" *color-table*) "#B2DFEE"
(gethash "lightblue3" *color-table*) "#9AC0CD"
(gethash "lightblue4" *color-table*) "#68838B"
(gethash "lightcyan1" *color-table*) "#E0FFFF"
(gethash "lightcyan2" *color-table*) "#D1EEEE"
(gethash "lightcyan3" *color-table*) "#B4CDCD"
(gethash "lightcyan4" *color-table*) "#7A8B8B"
(gethash "paleturquoise1" *color-table*) "#BBFFFF"
(gethash "paleturquoise2" *color-table*) "#AEEEEE"
(gethash "paleturquoise3" *color-table*) "#96CDCD"
(gethash "paleturquoise4" *color-table*) "#668B8B"
(gethash "cadetblue1" *color-table*) "#98F5FF"
(gethash "cadetblue2" *color-table*) "#8EE5EE"
(gethash "cadetblue3" *color-table*) "#7AC5CD"
(gethash "cadetblue4" *color-table*) "#53868B"
(gethash "turquoise1" *color-table*) "#00F5FF"
(gethash "turquoise2" *color-table*) "#00E5EE"
(gethash "turquoise3" *color-table*) "#00C5CD"
(gethash "turquoise4" *color-table*) "#00868B"
(gethash "cyan1" *color-table*) "#00FFFF"
(gethash "cyan2" *color-table*) "#00EEEE"
(gethash "cyan3" *color-table*) "#00CDCD"
(gethash "cyan4" *color-table*) "#008B8B"
(gethash "darkslategray1" *color-table*) "#97FFFF"
(gethash "darkslategray2" *color-table*) "#8DEEEE"
(gethash "darkslategray3" *color-table*) "#79CDCD"
(gethash "darkslategray4" *color-table*) "#528B8B"
(gethash "aquamarine1" *color-table*) "#7FFFD4"
(gethash "aquamarine2" *color-table*) "#76EEC6"
(gethash "aquamarine3" *color-table*) "#66CDAA"
(gethash "aquamarine4" *color-table*) "#458B74"
(gethash "darkseagreen1" *color-table*) "#C1FFC1"
(gethash "darkseagreen2" *color-table*) "#B4EEB4"
(gethash "darkseagreen3" *color-table*) "#9BCD9B"
(gethash "darkseagreen4" *color-table*) "#698B69"
(gethash "seagreen1" *color-table*) "#54FF9F"
(gethash "seagreen2" *color-table*) "#4EEE94"
(gethash "seagreen3" *color-table*) "#43CD80"
(gethash "seagreen4" *color-table*) "#2E8B57"
(gethash "palegreen1" *color-table*) "#9AFF9A"
(gethash "palegreen2" *color-table*) "#90EE90"
(gethash "palegreen3" *color-table*) "#7CCD7C"
(gethash "palegreen4" *color-table*) "#548B54"
(gethash "springgreen1" *color-table*) "#00FF7F"
(gethash "springgreen2" *color-table*) "#00EE76"
(gethash "springgreen3" *color-table*) "#00CD66"
(gethash "springgreen4" *color-table*) "#008B45"
(gethash "green1" *color-table*) "#00FF00"
(gethash "green2" *color-table*) "#00EE00"
(gethash "green3" *color-table*) "#00CD00"
(gethash "green4" *color-table*) "#008B00"
(gethash "chartreuse1" *color-table*) "#7FFF00"
(gethash "chartreuse2" *color-table*) "#76EE00"
(gethash "chartreuse3" *color-table*) "#66CD00"
(gethash "chartreuse4" *color-table*) "#458B00"
(gethash "olivedrab1" *color-table*) "#C0FF3E"
(gethash "olivedrab2" *color-table*) "#B3EE3A"
(gethash "olivedrab3" *color-table*) "#9ACD32"
(gethash "olivedrab4" *color-table*) "#698B22"
(gethash "darkolivegreen1" *color-table*) "#CAFF70"
(gethash "darkolivegreen2" *color-table*) "#BCEE68"
(gethash "darkolivegreen3" *color-table*) "#A2CD5A"
(gethash "darkolivegreen4" *color-table*) "#6E8B3D"
(gethash "khaki1" *color-table*) "#FFF68F"
(gethash "khaki2" *color-table*) "#EEE685"
(gethash "khaki3" *color-table*) "#CDC673"
(gethash "khaki4" *color-table*) "#8B864E"
(gethash "lightgoldenrod1" *color-table*) "#FFEC8B"
(gethash "lightgoldenrod2" *color-table*) "#EEDC82"
(gethash "lightgoldenrod3" *color-table*) "#CDBE70"
(gethash "lightgoldenrod4" *color-table*) "#8B814C"
(gethash "lightyellow1" *color-table*) "#FFFFE0"
(gethash "lightyellow2" *color-table*) "#EEEED1"
(gethash "lightyellow3" *color-table*) "#CDCDB4"
(gethash "lightyellow4" *color-table*) "#8B8B7A"
(gethash "yellow1" *color-table*) "#FFFF00"
(gethash "yellow2" *color-table*) "#EEEE00"
(gethash "yellow3" *color-table*) "#CDCD00"
(gethash "yellow4" *color-table*) "#8B8B00"
(gethash "gold1" *color-table*) "#FFD700"
(gethash "gold2" *color-table*) "#EEC900"
(gethash "gold3" *color-table*) "#CDAD00"
(gethash "gold4" *color-table*) "#8B7500"
(gethash "goldenrod1" *color-table*) "#FFC125"
(gethash "goldenrod2" *color-table*) "#EEB422"
(gethash "goldenrod3" *color-table*) "#CD9B1D"
(gethash "goldenrod4" *color-table*) "#8B6914"
(gethash "darkgoldenrod1" *color-table*) "#FFB90F"
(gethash "darkgoldenrod2" *color-table*) "#EEAD0E"
(gethash "darkgoldenrod3" *color-table*) "#CD950C"
(gethash "darkgoldenrod4" *color-table*) "#8B6508"
(gethash "rosybrown1" *color-table*) "#FFC1C1"
(gethash "rosybrown2" *color-table*) "#EEB4B4"
(gethash "rosybrown3" *color-table*) "#CD9B9B"
(gethash "rosybrown4" *color-table*) "#8B6969"
(gethash "indianred1" *color-table*) "#FF6A6A"
(gethash "indianred2" *color-table*) "#EE6363"
(gethash "indianred3" *color-table*) "#CD5555"
(gethash "indianred4" *color-table*) "#8B3A3A"
(gethash "sienna1" *color-table*) "#FF8247"
(gethash "sienna2" *color-table*) "#EE7942"
(gethash "sienna3" *color-table*) "#CD6839"
(gethash "sienna4" *color-table*) "#8B4726"
(gethash "burlywood1" *color-table*) "#FFD39B"
(gethash "burlywood2" *color-table*) "#EEC591"
(gethash "burlywood3" *color-table*) "#CDAA7D"
(gethash "burlywood4" *color-table*) "#8B7355"
(gethash "wheat1" *color-table*) "#FFE7BA"
(gethash "wheat2" *color-table*) "#EED8AE"
(gethash "wheat3" *color-table*) "#CDBA96"
(gethash "wheat4" *color-table*) "#8B7E66"
(gethash "tan1" *color-table*) "#FFA54F"
(gethash "tan2" *color-table*) "#EE9A49"
(gethash "tan3" *color-table*) "#CD853F"
(gethash "tan4" *color-table*) "#8B5A2B"
(gethash "chocolate1" *color-table*) "#FF7F24"
(gethash "chocolate2" *color-table*) "#EE7621"
(gethash "chocolate3" *color-table*) "#CD661D"
(gethash "chocolate4" *color-table*) "#8B4513"
(gethash "firebrick1" *color-table*) "#FF3030"
(gethash "firebrick2" *color-table*) "#EE2C2C"
(gethash "firebrick3" *color-table*) "#CD2626"
(gethash "firebrick4" *color-table*) "#8B1A1A"
(gethash "brown1" *color-table*) "#FF4040"
(gethash "brown2" *color-table*) "#EE3B3B"
(gethash "brown3" *color-table*) "#CD3333"
(gethash "brown4" *color-table*) "#8B2323"
(gethash "salmon1" *color-table*) "#FF8C69"
(gethash "salmon2" *color-table*) "#EE8262"
(gethash "salmon3" *color-table*) "#CD7054"
(gethash "salmon4" *color-table*) "#8B4C39"
(gethash "lightsalmon1" *color-table*) "#FFA07A"
(gethash "lightsalmon2" *color-table*) "#EE9572"
(gethash "lightsalmon3" *color-table*) "#CD8162"
(gethash "lightsalmon4" *color-table*) "#8B5742"
(gethash "orange1" *color-table*) "#FFA500"
(gethash "orange2" *color-table*) "#EE9A00"
(gethash "orange3" *color-table*) "#CD8500"
(gethash "orange4" *color-table*) "#8B5A00"
(gethash "darkorange1" *color-table*) "#FF7F00"
(gethash "darkorange2" *color-table*) "#EE7600"
(gethash "darkorange3" *color-table*) "#CD6600"
(gethash "darkorange4" *color-table*) "#8B4500"
(gethash "coral1" *color-table*) "#FF7256"
(gethash "coral2" *color-table*) "#EE6A50"
(gethash "coral3" *color-table*) "#CD5B45"
(gethash "coral4" *color-table*) "#8B3E2F"
(gethash "tomato1" *color-table*) "#FF6347"
(gethash "tomato2" *color-table*) "#EE5C42"
(gethash "tomato3" *color-table*) "#CD4F39"
(gethash "tomato4" *color-table*) "#8B3626"
(gethash "orangered1" *color-table*) "#FF4500"
(gethash "orangered2" *color-table*) "#EE4000"
(gethash "orangered3" *color-table*) "#CD3700"
(gethash "orangered4" *color-table*) "#8B2500"
(gethash "red1" *color-table*) "#FF0000"
(gethash "red2" *color-table*) "#EE0000"
(gethash "red3" *color-table*) "#CD0000"
(gethash "red4" *color-table*) "#8B0000"
(gethash "debianred" *color-table*) "#D70751"
(gethash "deeppink1" *color-table*) "#FF1493"
(gethash "deeppink2" *color-table*) "#EE1289"
(gethash "deeppink3" *color-table*) "#CD1076"
(gethash "deeppink4" *color-table*) "#8B0A50"
(gethash "hotpink1" *color-table*) "#FF6EB4"
(gethash "hotpink2" *color-table*) "#EE6AA7"
(gethash "hotpink3" *color-table*) "#CD6090"
(gethash "hotpink4" *color-table*) "#8B3A62"
(gethash "pink1" *color-table*) "#FFB5C5"
(gethash "pink2" *color-table*) "#EEA9B8"
(gethash "pink3" *color-table*) "#CD919E"
(gethash "pink4" *color-table*) "#8B636C"
(gethash "lightpink1" *color-table*) "#FFAEB9"
(gethash "lightpink2" *color-table*) "#EEA2AD"
(gethash "lightpink3" *color-table*) "#CD8C95"
(gethash "lightpink4" *color-table*) "#8B5F65"
(gethash "palevioletred1" *color-table*) "#FF82AB"
(gethash "palevioletred2" *color-table*) "#EE799F"
(gethash "palevioletred3" *color-table*) "#CD6889"
(gethash "palevioletred4" *color-table*) "#8B475D"
(gethash "maroon1" *color-table*) "#FF34B3"
(gethash "maroon2" *color-table*) "#EE30A7"
(gethash "maroon3" *color-table*) "#CD2990"
(gethash "maroon4" *color-table*) "#8B1C62"
(gethash "violetred1" *color-table*) "#FF3E96"
(gethash "violetred2" *color-table*) "#EE3A8C"
(gethash "violetred3" *color-table*) "#CD3278"
(gethash "violetred4" *color-table*) "#8B2252"
(gethash "magenta1" *color-table*) "#FF00FF"
(gethash "magenta2" *color-table*) "#EE00EE"
(gethash "magenta3" *color-table*) "#CD00CD"
(gethash "magenta4" *color-table*) "#8B008B"
(gethash "orchid1" *color-table*) "#FF83FA"
(gethash "orchid2" *color-table*) "#EE7AE9"
(gethash "orchid3" *color-table*) "#CD69C9"
(gethash "orchid4" *color-table*) "#8B4789"
(gethash "plum1" *color-table*) "#FFBBFF"
(gethash "plum2" *color-table*) "#EEAEEE"
(gethash "plum3" *color-table*) "#CD96CD"
(gethash "plum4" *color-table*) "#8B668B"
(gethash "mediumorchid1" *color-table*) "#E066FF"
(gethash "mediumorchid2" *color-table*) "#D15FEE"
(gethash "mediumorchid3" *color-table*) "#B452CD"
(gethash "mediumorchid4" *color-table*) "#7A378B"
(gethash "darkorchid1" *color-table*) "#BF3EFF"
(gethash "darkorchid2" *color-table*) "#B23AEE"
(gethash "darkorchid3" *color-table*) "#9A32CD"
(gethash "darkorchid4" *color-table*) "#68228B"
(gethash "purple1" *color-table*) "#9B30FF"
(gethash "purple2" *color-table*) "#912CEE"
(gethash "purple3" *color-table*) "#7D26CD"
(gethash "purple4" *color-table*) "#551A8B"
(gethash "mediumpurple1" *color-table*) "#AB82FF"
(gethash "mediumpurple2" *color-table*) "#9F79EE"
(gethash "mediumpurple3" *color-table*) "#8968CD"
(gethash "mediumpurple4" *color-table*) "#5D478B"
(gethash "thistle1" *color-table*) "#FFE1FF"
(gethash "thistle2" *color-table*) "#EED2EE"
(gethash "thistle3" *color-table*) "#CDB5CD"
(gethash "thistle4" *color-table*) "#8B7B8B"
(gethash "gray0" *color-table*) "#000000"
(gethash "grey0" *color-table*) "#000000"
(gethash "gray1" *color-table*) "#030303"
(gethash "grey1" *color-table*) "#030303"
(gethash "gray2" *color-table*) "#050505"
(gethash "grey2" *color-table*) "#050505"
(gethash "gray3" *color-table*) "#080808"
(gethash "grey3" *color-table*) "#080808"
(gethash "gray4" *color-table*) "#0A0A0A"
(gethash "grey4" *color-table*) "#0A0A0A"
(gethash "gray5" *color-table*) "#0D0D0D"
(gethash "grey5" *color-table*) "#0D0D0D"
(gethash "gray6" *color-table*) "#0F0F0F"
(gethash "grey6" *color-table*) "#0F0F0F"
(gethash "gray7" *color-table*) "#121212"
(gethash "grey7" *color-table*) "#121212"
(gethash "gray8" *color-table*) "#141414"
(gethash "grey8" *color-table*) "#141414"
(gethash "gray9" *color-table*) "#171717"
(gethash "grey9" *color-table*) "#171717"
(gethash "gray10" *color-table*) "#1A1A1A"
(gethash "grey10" *color-table*) "#1A1A1A"
(gethash "gray11" *color-table*) "#1C1C1C"
(gethash "grey11" *color-table*) "#1C1C1C"
(gethash "gray12" *color-table*) "#1F1F1F"
(gethash "grey12" *color-table*) "#1F1F1F"
(gethash "gray13" *color-table*) "#212121"
(gethash "grey13" *color-table*) "#212121"
(gethash "gray14" *color-table*) "#242424"
(gethash "grey14" *color-table*) "#242424"
(gethash "gray15" *color-table*) "#262626"
(gethash "grey15" *color-table*) "#262626"
(gethash "gray16" *color-table*) "#292929"
(gethash "grey16" *color-table*) "#292929"
(gethash "gray17" *color-table*) "#2B2B2B"
(gethash "grey17" *color-table*) "#2B2B2B"
(gethash "gray18" *color-table*) "#2E2E2E"
(gethash "grey18" *color-table*) "#2E2E2E"
(gethash "gray19" *color-table*) "#303030"
(gethash "grey19" *color-table*) "#303030"
(gethash "gray20" *color-table*) "#333333"
(gethash "grey20" *color-table*) "#333333"
(gethash "gray21" *color-table*) "#363636"
(gethash "grey21" *color-table*) "#363636"
(gethash "gray22" *color-table*) "#383838"
(gethash "grey22" *color-table*) "#383838"
(gethash "gray23" *color-table*) "#3B3B3B"
(gethash "grey23" *color-table*) "#3B3B3B"
(gethash "gray24" *color-table*) "#3D3D3D"
(gethash "grey24" *color-table*) "#3D3D3D"
(gethash "gray25" *color-table*) "#404040"
(gethash "grey25" *color-table*) "#404040"
(gethash "gray26" *color-table*) "#424242"
(gethash "grey26" *color-table*) "#424242"
(gethash "gray27" *color-table*) "#454545"
(gethash "grey27" *color-table*) "#454545"
(gethash "gray28" *color-table*) "#474747"
(gethash "grey28" *color-table*) "#474747"
(gethash "gray29" *color-table*) "#4A4A4A"
(gethash "grey29" *color-table*) "#4A4A4A"
(gethash "gray30" *color-table*) "#4D4D4D"
(gethash "grey30" *color-table*) "#4D4D4D"
(gethash "gray31" *color-table*) "#4F4F4F"
(gethash "grey31" *color-table*) "#4F4F4F"
(gethash "gray32" *color-table*) "#525252"
(gethash "grey32" *color-table*) "#525252"
(gethash "gray33" *color-table*) "#545454"
(gethash "grey33" *color-table*) "#545454"
(gethash "gray34" *color-table*) "#575757"
(gethash "grey34" *color-table*) "#575757"
(gethash "gray35" *color-table*) "#595959"
(gethash "grey35" *color-table*) "#595959"
(gethash "gray36" *color-table*) "#5C5C5C"
(gethash "grey36" *color-table*) "#5C5C5C"
(gethash "gray37" *color-table*) "#5E5E5E"
(gethash "grey37" *color-table*) "#5E5E5E"
(gethash "gray38" *color-table*) "#616161"
(gethash "grey38" *color-table*) "#616161"
(gethash "gray39" *color-table*) "#636363"
(gethash "grey39" *color-table*) "#636363"
(gethash "gray40" *color-table*) "#666666"
(gethash "grey40" *color-table*) "#666666"
(gethash "gray41" *color-table*) "#696969"
(gethash "grey41" *color-table*) "#696969"
(gethash "gray42" *color-table*) "#6B6B6B"
(gethash "grey42" *color-table*) "#6B6B6B"
(gethash "gray43" *color-table*) "#6E6E6E"
(gethash "grey43" *color-table*) "#6E6E6E"
(gethash "gray44" *color-table*) "#707070"
(gethash "grey44" *color-table*) "#707070"
(gethash "gray45" *color-table*) "#737373"
(gethash "grey45" *color-table*) "#737373"
(gethash "gray46" *color-table*) "#757575"
(gethash "grey46" *color-table*) "#757575"
(gethash "gray47" *color-table*) "#787878"
(gethash "grey47" *color-table*) "#787878"
(gethash "gray48" *color-table*) "#7A7A7A"
(gethash "grey48" *color-table*) "#7A7A7A"
(gethash "gray49" *color-table*) "#7D7D7D"
(gethash "grey49" *color-table*) "#7D7D7D"
(gethash "gray50" *color-table*) "#7F7F7F"
(gethash "grey50" *color-table*) "#7F7F7F"
(gethash "gray51" *color-table*) "#828282"
(gethash "grey51" *color-table*) "#828282"
(gethash "gray52" *color-table*) "#858585"
(gethash "grey52" *color-table*) "#858585"
(gethash "gray53" *color-table*) "#878787"
(gethash "grey53" *color-table*) "#878787"
(gethash "gray54" *color-table*) "#8A8A8A"
(gethash "grey54" *color-table*) "#8A8A8A"
(gethash "gray55" *color-table*) "#8C8C8C"
(gethash "grey55" *color-table*) "#8C8C8C"
(gethash "gray56" *color-table*) "#8F8F8F"
(gethash "grey56" *color-table*) "#8F8F8F"
(gethash "gray57" *color-table*) "#919191"
(gethash "grey57" *color-table*) "#919191"
(gethash "gray58" *color-table*) "#949494"
(gethash "grey58" *color-table*) "#949494"
(gethash "gray59" *color-table*) "#969696"
(gethash "grey59" *color-table*) "#969696"
(gethash "gray60" *color-table*) "#999999"
(gethash "grey60" *color-table*) "#999999"
(gethash "gray61" *color-table*) "#9C9C9C"
(gethash "grey61" *color-table*) "#9C9C9C"
(gethash "gray62" *color-table*) "#9E9E9E"
(gethash "grey62" *color-table*) "#9E9E9E"
(gethash "gray63" *color-table*) "#A1A1A1"
(gethash "grey63" *color-table*) "#A1A1A1"
(gethash "gray64" *color-table*) "#A3A3A3"
(gethash "grey64" *color-table*) "#A3A3A3"
(gethash "gray65" *color-table*) "#A6A6A6"
(gethash "grey65" *color-table*) "#A6A6A6"
(gethash "gray66" *color-table*) "#A8A8A8"
(gethash "grey66" *color-table*) "#A8A8A8"
(gethash "gray67" *color-table*) "#ABABAB"
(gethash "grey67" *color-table*) "#ABABAB"
(gethash "gray68" *color-table*) "#ADADAD"
(gethash "grey68" *color-table*) "#ADADAD"
(gethash "gray69" *color-table*) "#B0B0B0"
(gethash "grey69" *color-table*) "#B0B0B0"
(gethash "gray70" *color-table*) "#B3B3B3"
(gethash "grey70" *color-table*) "#B3B3B3"
(gethash "gray71" *color-table*) "#B5B5B5"
(gethash "grey71" *color-table*) "#B5B5B5"
(gethash "gray72" *color-table*) "#B8B8B8"
(gethash "grey72" *color-table*) "#B8B8B8"
(gethash "gray73" *color-table*) "#BABABA"
(gethash "grey73" *color-table*) "#BABABA"
(gethash "gray74" *color-table*) "#BDBDBD"
(gethash "grey74" *color-table*) "#BDBDBD"
(gethash "gray75" *color-table*) "#BFBFBF"
(gethash "grey75" *color-table*) "#BFBFBF"
(gethash "gray76" *color-table*) "#C2C2C2"
(gethash "grey76" *color-table*) "#C2C2C2"
(gethash "gray77" *color-table*) "#C4C4C4"
(gethash "grey77" *color-table*) "#C4C4C4"
(gethash "gray78" *color-table*) "#C7C7C7"
(gethash "grey78" *color-table*) "#C7C7C7"
(gethash "gray79" *color-table*) "#C9C9C9"
(gethash "grey79" *color-table*) "#C9C9C9"
(gethash "gray80" *color-table*) "#CCCCCC"
(gethash "grey80" *color-table*) "#CCCCCC"
(gethash "gray81" *color-table*) "#CFCFCF"
(gethash "grey81" *color-table*) "#CFCFCF"
(gethash "gray82" *color-table*) "#D1D1D1"
(gethash "grey82" *color-table*) "#D1D1D1"
(gethash "gray83" *color-table*) "#D4D4D4"
(gethash "grey83" *color-table*) "#D4D4D4"
(gethash "gray84" *color-table*) "#D6D6D6"
(gethash "grey84" *color-table*) "#D6D6D6"
(gethash "gray85" *color-table*) "#D9D9D9"
(gethash "grey85" *color-table*) "#D9D9D9"
(gethash "gray86" *color-table*) "#DBDBDB"
(gethash "grey86" *color-table*) "#DBDBDB"
(gethash "gray87" *color-table*) "#DEDEDE"
(gethash "grey87" *color-table*) "#DEDEDE"
(gethash "gray88" *color-table*) "#E0E0E0"
(gethash "grey88" *color-table*) "#E0E0E0"
(gethash "gray89" *color-table*) "#E3E3E3"
(gethash "grey89" *color-table*) "#E3E3E3"
(gethash "gray90" *color-table*) "#E5E5E5"
(gethash "grey90" *color-table*) "#E5E5E5"
(gethash "gray91" *color-table*) "#E8E8E8"
(gethash "grey91" *color-table*) "#E8E8E8"
(gethash "gray92" *color-table*) "#EBEBEB"
(gethash "grey92" *color-table*) "#EBEBEB"
(gethash "gray93" *color-table*) "#EDEDED"
(gethash "grey93" *color-table*) "#EDEDED"
(gethash "gray94" *color-table*) "#F0F0F0"
(gethash "grey94" *color-table*) "#F0F0F0"
(gethash "gray95" *color-table*) "#F2F2F2"
(gethash "grey95" *color-table*) "#F2F2F2"
(gethash "gray96" *color-table*) "#F5F5F5"
(gethash "grey96" *color-table*) "#F5F5F5"
(gethash "gray97" *color-table*) "#F7F7F7"
(gethash "grey97" *color-table*) "#F7F7F7"
(gethash "gray98" *color-table*) "#FAFAFA"
(gethash "grey98" *color-table*) "#FAFAFA"
(gethash "gray99" *color-table*) "#FCFCFC"
(gethash "grey99" *color-table*) "#FCFCFC"
(gethash "gray100" *color-table*) "#FFFFFF"
(gethash "grey100" *color-table*) "#FFFFFF"
(gethash "darkgrey" *color-table*) "#A9A9A9"
(gethash "darkgray" *color-table*) "#A9A9A9"
(gethash "darkblue" *color-table*) "#00008B"
(gethash "darkcyan" *color-table*) "#008B8B"
(gethash "darkmagenta" *color-table*) "#8B008B"
(gethash "lightred" *color-table*) "#f03232"
(gethash "darkred" *color-table*) "#8B0000"
(gethash "lightgreen" *color-table*) "#90EE90")
(defun correct-color-name (str)
(some #'(lambda (z) (string= z str))
(loop for k being the hash-keys of *color-table* collect k)))
;; Hex colors can either read
;; #rrggbb or #rrggbbaa
;; with rr, bb, gg and aa being two-digit hex numbers.
;; Numbers containing a transparency aa only work if the gnuplot version
;; that is being used supports it which should be any gnuplot >=5.0.
(defun correct-color-hex (str)
(and ( or (= (length str) 7) (= (length str) 9))
(char= (schar str 0) #\#)
(every #'(lambda (z) (position z "0123456789abcdef"))
(subseq str 1))))
(defun correct-color (str)
(or (correct-color-name str)
(correct-color-hex str)
(string= str "auto")))
(defun hex-to-numeric-list (str)
(let ((hex1 (subseq str 1 3))
(hex2 (subseq str 3 5))
(hex3 (subseq str 5)))
(list
(/ (parse-integer hex1 :radix 16) 255.0)
(/ (parse-integer hex2 :radix 16) 255.0)
(/ (parse-integer hex3 :radix 16) 255.0))))
;; Interprets a rgb string or a rgba string and converts the latter to argb
;; as gnuplot needs this format
(defun hex-to-rgb (str)
(if (= (length str) 7)
(format nil "rgb '~a'" str)
(format nil "rgb '#~a~a'" (subseq str 7 9) (subseq str 1 7))))
(defun update-color (opt val)
(if (numberp val)
(case val
(0 (setf val "black"))
(1 (setf val "red"))
(2 (setf val "blue"))
(3 (setf val "green"))
(4 (setf val "pink"))
(5 (setf val "orange"))
(6 (setf val "violet"))
(7 (setf val "yellow"))
(8 (setf val "magenta"))
(9 (setf val "cyan"))
(10 (setf val "gray"))
(11 (setf val "springgreen"))
(12 (setf val "darkcyan"))
(13 (setf val "darkmagenta"))
(14 (setf val "darkred"))
(15 (setf val "mintcream"))
(16 (setf val "azure"))
(17 (setf val "navy"))
(otherwise (merror "model3d: unknown color ~M" val))))
(let ((str (atom-to-downcased-string val)))
(unless (correct-color str)
(merror "model3d: unknown color ~M" val))
(when (correct-color-name str)
(setf str (gethash str *color-table*)))
(setf (gethash opt *gr-options*) str)))
;; update option key_pos
;; ---------------------
(defun update-key_pos (val)
(case val
($top_left (setf (gethash '$key_pos *gr-options*) "top left"))
($top_center (setf (gethash '$key_pos *gr-options*) "top center"))
($top_right (setf (gethash '$key_pos *gr-options*) "top right"))
($center_left (setf (gethash '$key_pos *gr-options*) "center left"))
($center (setf (gethash '$key_pos *gr-options*) "center center"))
($center_right (setf (gethash '$key_pos *gr-options*) "center right"))
($bottom_left (setf (gethash '$key_pos *gr-options*) "bottom left"))
($bottom_center (setf (gethash '$key_pos *gr-options*) "bottom center"))
($bottom_right (setf (gethash '$key_pos *gr-options*) "bottom right"))
(otherwise (merror "draw: illegal key position specification"))))
;; update option terminal
;; ----------------------
;; *draw-terminal-number* is used when working with
;; multiple windows. Empty string means
;; we are working with only one window
(defvar *draw-terminal-number* "")
(defun update-terminal (val)
(let ((terms '($screen $png $pngcairo $jpg $gif $eps $eps_color $canvas
$epslatex $epslatex_standalone $svg $x11 $qt
$dumb $dumb_file $pdf $pdfcairo $wxt $animated_gif $windows
$multipage_pdfcairo $multipage_pdf $multipage_eps
$multipage_eps_color $aquaterm $tiff $vrml $obj $stl $pnm $ply)))
(cond
((member val terms)
(when (and (eq val '$png) $draw_use_pngcairo)
(setq val '$pngcairo))
(setf (gethash '$terminal *gr-options*) val
*draw-terminal-number* ""))
((and ($listp val)
(= ($length val) 2)
(member (cadr val) '($screen $wxt $aquaterm $qt $windows))
(integerp (caddr val))
(>= (caddr val) 0))
(setf (gethash '$terminal *gr-options*) (cadr val)
*draw-terminal-number* (caddr val)))
(t
(merror "draw: illegal terminal specification: ~M" val)))))
;; update option transform
;; -----------------------
(defvar *draw-transform-dimensions* 0)
(defvar *draw-transform-f1* nil)
(defvar *draw-transform-f2* nil)
(defvar *draw-transform-f3* nil)
(defmacro transform-point (n)
(if (= n 2)
'(when (> *draw-transform-dimensions* 0)
(let ((xold xx)
(yold yy))
(setf xx (funcall *draw-transform-f1* xold yold)
yy (funcall *draw-transform-f2* xold yold))))
'(when (> *draw-transform-dimensions* 0)
(let ((xold xx)
(yold yy)
(zold zz))
(setf xx (funcall *draw-transform-f1* xold yold zold)
yy (funcall *draw-transform-f2* xold yold zold)
zz (funcall *draw-transform-f3* xold yold zold) )))))
(defmacro transform-lists (n)
(if (= n 2)
'(when (> *draw-transform-dimensions* 0)
(let ((xold x)
(yold y))
(setf x (mapcar #'(lambda (u1 u2) (funcall *draw-transform-f1* u1 u2))
xold yold)
y (mapcar #'(lambda (u1 u2) (funcall *draw-transform-f2* u1 u2))
xold yold)) ))
'(when (> *draw-transform-dimensions* 0)
(let ((xold x)
(yold y)
(zold z))
(setf x (mapcar #'(lambda (u1 u2 u3) (funcall *draw-transform-f1* u1 u2 u3))
xold yold zold)
y (mapcar #'(lambda (u1 u2 u3) (funcall *draw-transform-f2* u1 u2 u3))
xold yold zold)
z (mapcar #'(lambda (u1 u2 u3) (funcall *draw-transform-f3* u1 u2 u3))
xold yold zold))) )))
(defun update-transform (val)
(let (vars)
(cond
((equal val '$none)
(setf (gethash '$transform *gr-options*) '$none
*draw-transform-dimensions* 0
*draw-transform-f1* nil
*draw-transform-f2* nil
*draw-transform-f3* nil))
((and ($listp val)
(= ($length val) 4)
($subsetp ($union ($setify ($listofvars ($first val)))
($setify ($listofvars ($second val))))
($setify (list '(mlist) ($third val) ($fourth val)))) )
; transformation in 2d
(setf vars (list '(mlist) ($third val) ($fourth val)))
(setf (gethash '$transform *gr-options*) val
*draw-transform-dimensions* 2
*draw-transform-f1* (coerce-float-fun ($first val) vars)
*draw-transform-f2* (coerce-float-fun ($second val) vars) ))
((and ($listp val)
(= ($length val) 6)
($subsetp ($union ($setify ($listofvars ($first val)))
($setify ($listofvars ($second val)))
($setify ($listofvars ($third val))))
($setify (list '(mlist) ($fourth val) ($fifth val) ($sixth val)))) )
; transformation in 3d
(setf vars (list '(mlist) ($fourth val) ($fifth val) ($sixth val)))
(setf (gethash '$transform *gr-options*) val
*draw-transform-dimensions* 3
*draw-transform-f1* (coerce-float-fun ($first val) vars)
*draw-transform-f2* (coerce-float-fun ($second val) vars)
*draw-transform-f3* (coerce-float-fun ($third val) vars)))
(t
(merror "draw: illegal transform definition")) )))
;; update option enhanced3d
;; ------------------------
(defvar *draw-enhanced3d-type* 0)
(defvar *draw-enhanced3d-fun* nil)
(defun check-enhanced3d-model (grobj lis)
(when (null (position *draw-enhanced3d-type* lis))
(merror (format nil "draw (~a): unacceptable enhanced3d model" grobj))))
(defun update-enhanced3d-expression (vars)
(let ((texture (gethash '$enhanced3d *gr-options*)))
(when (not ($subsetp ($setify ($listofvars texture))
($setify vars)))
(merror "draw: incompatible variables in enhanced3d expression"))
(setf *draw-enhanced3d-fun* (coerce-float-fun texture vars))))
(defun update-enhanced3d (val)
(cond
((or (null val)
(equal val '$none))
(setf (gethash '$enhanced3d *gr-options*) '$none
*draw-enhanced3d-type* 0
*draw-enhanced3d-fun* nil))
((equal val t)
(let ((model '((mlist) $z $x $y $z)))
(setf (gethash '$enhanced3d *gr-options*) model
*draw-enhanced3d-type* 3
*draw-enhanced3d-fun* (coerce-float-fun
($first model)
(list '(mlist) ($second model) ($third model) ($fourth model))))))
((and ($listp val)
($subsetp ($setify ($listofvars ($first val)))
($setify ($rest val))))
(case ($length val)
(2 (setf (gethash '$enhanced3d *gr-options*) val
*draw-enhanced3d-type* 1
*draw-enhanced3d-fun* (coerce-float-fun
($first val)
(list '(mlist) ($second val)))))
(3 (setf (gethash '$enhanced3d *gr-options*) val
*draw-enhanced3d-type* 2
*draw-enhanced3d-fun* (coerce-float-fun
($first val)
(list '(mlist) ($second val) ($third val)))))
(4 (setf (gethash '$enhanced3d *gr-options*) val
*draw-enhanced3d-type* 3
*draw-enhanced3d-fun* (coerce-float-fun
($first val)
(list '(mlist) ($second val) ($third val) ($fourth val)))))
(otherwise (merror "draw: illegal length of enhanced3d"))))
((not ($listp val))
; enhanced3d is given an expression without
; explicit declaration of its variables.
; Each graphic object must check for them.
(setf (gethash '$enhanced3d *gr-options*) val
*draw-enhanced3d-type* 99
*draw-enhanced3d-fun* nil))
(t
(merror "draw: illegal enhanced3d definition")) ) )
;; update option isolines
;; ----------------------
(defvar *draw-isolines-type* 0)
(defvar *draw-isolines-fun* nil)
(defun check-isolines-model (grobj lis)
(when (null (position *draw-isolines-type* lis))
(merror (format nil "draw (~a): unacceptable isolines model" grobj))))
(defun update-isolines-expression (vars)
(let ((texture (gethash '$isolines *gr-options*)))
(when (not ($subsetp ($setify ($listofvars texture))
($setify vars)))
(merror "draw: incompatible variables in isolines expression"))
(setf *draw-isolines-fun* (coerce-float-fun texture vars))))
(defun update-isolines (val)
(cond
((or (null val)
(equal val '$none))
(setf (gethash '$isolines *gr-options*) '$none
*draw-isolines-type* 0
*draw-isolines-fun* nil))
((equal val t)
(let ((model '((mlist) $z $x $y $z)))
(setf (gethash '$isolines *gr-options*) model
*draw-isolines-type* 3
*draw-isolines-fun* (coerce-float-fun
($first model)
(list '(mlist) ($second model) ($third model) ($fourth model))))))
((and ($listp val)
($subsetp ($setify ($listofvars ($first val)))
($setify ($rest val))))
(case ($length val)
(2 (setf (gethash '$isolines *gr-options*) val
*draw-isolines-type* 1
*draw-isolines-fun* (coerce-float-fun
($first val)
(list '(mlist) ($second val)))))
(3 (setf (gethash '$isolines *gr-options*) val
*draw-isolines-type* 2
*draw-isolines-fun* (coerce-float-fun
($first val)
(list '(mlist) ($second val) ($third val)))))
(4 (setf (gethash '$isolines *gr-options*) val
*draw-isolines-type* 3
*draw-isolines-fun* (coerce-float-fun
($first val)
(list '(mlist) ($second val) ($third val) ($fourth val)))))
(otherwise (merror "draw: illegal length of isolines"))))
((not ($listp val))
; isolines is given an expression without
; explicit declaration of its variables.
; Each graphic object must check for them.
(setf (gethash '$isolines *gr-options*) val
*draw-isolines-type* 99
*draw-isolines-fun* nil))
(t
(merror "draw: illegal isolines definition")) ) )
;; update contour (Gnuplot) and isolines (VTK) levels
;; ---------------------------------------------------
(defun update-contour-isolines (opt val)
(cond ((and (integerp val) (> val 0 ))
(setf (gethash opt *gr-options*) val))
((and ($listp val) (= ($length val) 3) )
(let ((ini ($float (nth 1 val)))
(step ($float (nth 2 val)))
(end ($float (nth 3 val))))
(cond ((and (< ini end)
(< step (- end ini)))
(setf (gethash opt *gr-options*) (format nil "incremental ~a,~a,~a" ini step end)))
(t
(merror "draw: illegal contour level incremental description: ~M " val))) ))
((and ($setp val) (not ($emptyp val)))
(let ((pts (map 'list #'$float (rest val)))
(str "discrete ") )
(dolist (num pts 'done)
(setf str (concatenate 'string str " " (format nil "~a," num))))
(setf (gethash opt *gr-options*) (string-trim '(#\,) str) ) ))
(t
(merror "draw: unknown contour level description: ~M " val))))
;; update boolean type options
;; ---------------------------
(defun update-boolean-option (opt val)
(if (or (equal val t)
(null val))
(setf (gethash opt *gr-options*) val)
(merror "draw: non boolean value: ~M " val)))
;; update positive integer type options
;; ------------------------------------
(defun update-positive-integer (opt val)
(if (and (integerp val)
(> val 0 ))
(setf (gethash opt *gr-options*) val)
(merror "draw: non positive integer: ~M " val)))
;; update positive float type options
;; ----------------------------------
(defun update-positive-float (opt val)
(setf val ($float val))
(if (and (numberp val)
(> val 0 ))
(setf (gethash opt *gr-options*) val)
(merror "draw: Non positive number: ~M " val)))
;; update non negative float type options
;; --------------------------------------
(defun update-nonnegative-float (opt val)
(setf val ($float val))
(if (and (numberp val)
(>= val 0 ))
(setf (gethash opt *gr-options*) val)
(merror "draw: Not a non-negative number: ~M " val)))
;; update option: view
;; -------------------
(defun update-view (val)
(cond
((eql val '$map)
(setf (gethash '$view *gr-options*) val))
((and ($listp val)
(= ($length val) 2))
(let ((rv ($float (cadr val)))
(rh ($float (caddr val))) )
(unless
(and (numberp rv) (>= rv 0) (<= rv 360) )
(merror "draw: vertical rotation angle must be in [0, 360]"))
(unless
(and (numberp rh) (>= rh 0) (<= rh 360) )
(merror "draw: horizontal rotation angle must be in [0, 360]"))
(setf (gethash '$view *gr-options*)
(list rv rh))))
(t
(merror "draw: illegal view specification ~M" val)) ))
;; update option: interpolate_color
;; --------------------------------
(defun update-interpolate_color (val)
(cond
((null val)
(setf (gethash '$interpolate_color *gr-options*) "depthorder"))
((equal val t)
(setf (gethash '$interpolate_color *gr-options*) "interpolate 0, 0"))
((and ($listp val)
(= ($length val) 2))
(let ((x ($float (cadr val)))
(y ($float (caddr val))) )
(unless
(and (numberp x) (numberp y))
(merror "draw: interpolate_color parameters must be numbers"))
(setf (gethash '$interpolate_color *gr-options*)
(format nil "interpolate ~a,~a" x y))))
(t
(merror "draw: illegal interpolate_color specification ~M" val)) ))
;; update option allocation
;; ------------------------
(defun update-allocation (val)
(let (fval cls)
(cond
((and ($listp val)
(= ($length val) 2)
(every #'(lambda (z) (and ($listp z)
(= ($length z) 2)))
(rest val))
(setf fval (rest ($float val)))
(setf cls (list (cadar fval) (caddar fval) (cadadr fval) (caddr (cadr fval))))
(if (every #'(lambda (z) (and (float z) (>= z 0.0) (<= z 1.0))) cls)
(setf (gethash '$allocation *gr-options*) cls)
(merror "draw: allocations must me given in relative values")) ))
(t
(merror "draw: illegal allocation format ~M" val)))))
;; update option dimensions
;; ------------------------
(defun update-dimensions (val)
(let (cls)
(cond
((and ($listp val)
(= ($length val) 2))
(setf cls (rest val))
(if (every #'(lambda (z) (and (numberp z) (> z 0))) cls)
(setf (gethash '$dimensions *gr-options*) cls)
(merror "draw: illegal dimensions")))
(t
(merror "draw: illegal dimensions format ~M" val)))))
;; update option point_type
;; ------------------------
(defun update-pointtype (val)
(cond
((and (integerp val) (>= val -1 ))
(setf (gethash '$point_type *gr-options*) val))
(t (let*
((shapes '($none $dot $plus $multiply $asterisk
$square $filled_square $circle $filled_circle
$up_triangle $filled_up_triangle $down_triangle
$filled_down_triangle $diamant $filled_diamant
$sphere $cube $cylinder $cone))
(pos (position val shapes)))
(if pos
(setf (gethash '$point_type *gr-options*) (- pos 1))
(merror "draw: illegal point type: ~M " val))))))
;; update string type options
;; --------------------------
(defun update-string (opt val)
(setf (gethash opt *gr-options*) ($sconcat val)))
;; update opacity option
;; ---------------------
(defun update-opacity (val)
(let ((value ($float val)))
(when (or (not (floatp value))
(> value 1)
(< value 0))
(merror "draw: illegal opacity value: ~M " val))
(setf (gethash '$opacity *gr-options*) value)))
;; update palette option
;; ---------------------
(defun update-palette (val)
; defined as $color, $gray, [f1,f2,f3], with -36<=fi<=36,
; or a list of triplets defining a user palette.
(cond ((member val '($color $gray))
(setf (gethash '$palette *gr-options*) val))
((and ($listp val)
(= ($length val) 3)
(every #'(lambda (x) (and (integerp x) (<= (abs x) 36)))
(cdr val)) )
(setf (gethash '$palette *gr-options*) (rest val)))
((and ($listp val) ; user defined palette without transparency
(not ($listp (cadr val)) ))
(let* ((palette (cdr val))
(n (length palette))
str color)
(setf (gethash '$palette *gr-options*)
(loop for k below n
do (setf str (atom-to-downcased-string (nth k palette)))
(cond ((correct-color-hex str)
(setf color (hex-to-numeric-list str)))
((correct-color-name str)
(setf color (hex-to-numeric-list (gethash str *color-table*))))
(t
(merror "draw: illegal color in palette description")))
collect color))))
((and ($listp val) ; user defined palette with transparency
(every #'(lambda (x) (and ($listp x) (= (length x) 3)))
(cdr val)))
(let* ((palette (cdr val))
(n (length palette))
str color transparency)
(setf (gethash '$palette *gr-options*)
(loop for k below n
do (setf str (atom-to-downcased-string ($first (nth k palette))))
(cond ((correct-color-hex str)
(setf color (hex-to-numeric-list str)))
((correct-color-name str)
(setf color (hex-to-numeric-list (gethash str *color-table*))))
(t
(merror "draw: illegal color in palette description")))
(setf transparency ($float ($second (nth k palette))))
(when (or (< transparency 0)
(> transparency 1)
(not (floatp transparency)))
(merror "draw: illegal transparency in palette description"))
collect (append color (list transparency))))))
(t
(merror "draw: illegal palette description: ~M" val))) )
;; update line_type and line-axes
;; Negative indices indicate the number of faces to be drawn in case of tubes.
;; Default number of faces is 8.
;; --------------------------------------------------------------------------
(defun update-linestyle (opt val)
(cond
((atom val)
(case val
($dots (setf (gethash opt *gr-options*) 0))
($solid (setf (gethash opt *gr-options*) 1))
($dashes (setf (gethash opt *gr-options*) 2))
($short_dashes (setf (gethash opt *gr-options*) 3))
($short_long_dashes (setf (gethash opt *gr-options*) 4))
($short_short_long_dashes (setf (gethash opt *gr-options*) 5))
($dot_dash (setf (gethash opt *gr-options*) 6))
($tube (setf (gethash opt *gr-options*) -8))
(otherwise
(if (numberp val)
(setf (gethash opt *gr-options*) val) (merror "draw: illegal line type: ~M" val)))))
((and ($listp val)
(= ($length val) 2)
(equal ($first val) '$tube)
(integerp ($second val))
(> ($second val) 2))
(setf (gethash opt *gr-options*) (- ($second val)) ) )
(t
(merror "draw: unknown line type: ~M" val))))
;; update points_joined option
;; ---------------------------
(defun update-pointsjoined (val)
(if (member val '(t nil $impulses))
(setf (gethash '$points_joined *gr-options*) val)
(merror "draw: illegal points_joined option: ~M " val)) )
;; update capping option
;; a list of two elements, false and/or true
;; -----------------------------------------
(defun update-capping (val)
(cond
((and ($listp val)
(= ($length val) 2)
(member ($first val) '(nil t))
(member ($second val) '(nil t)))
(setf (gethash '$capping *gr-options*) val))
((member val '(nil t))
(setf (gethash '$capping *gr-options*) (list '(mlist simp) val val)))
(t
(merror "draw: illegal capping: ~M " val))) )
(defun ini-local-option-variables ()
(setf ; global variables
*draw-transform-dimensions* 0
*draw-transform-f1* nil
*draw-transform-f2* nil
*draw-transform-f3* nil
*draw-enhanced3d-type* 0
*draw-enhanced3d-fun* nil
*draw-isolines-type* 0
*draw-isolines-fun* nil) )
;; Sets default values to global options
(defun ini-global-options ()
(setf ; global options
(gethash '$columns *gr-options*) 1
(gethash '$terminal *gr-options*) '$screen ; defined as screen, png, jpg, gif, svg,
; eps, eps_color, pdf, pdfcairo, wxt or
; aquaterm. A list of type [term, number]
; is also admitted if term is screen, wxt
; or aquaterm
(gethash '$key_pos *gr-options*) nil
(gethash '$dimensions *gr-options*) '(600 500)
(gethash '$file_name *gr-options*) "maxima_out"
(gethash '$gnuplot_file_name *gr-options*) (format nil "maxout~d.gnuplot" (getpid))
(gethash '$data_file_name *gr-options*) (format nil "data~d.gnuplot" (getpid))
(gethash '$delay *gr-options*) 5 ; delay for animated gif's, default 5*(1/100) sec
))
;; Sets new values to graphic options
(defun update-gr-option (opt val)
(case opt
($allocation
(update-allocation val))
($dimensions
(update-dimensions val))
($fill_density ; in range [0, 1]
(setf val ($float val))
(if (and (numberp val)
(>= val 0 )
(<= val 1 ))
(setf (gethash opt *gr-options*) val)
(merror "draw: fill_density must be a number in [0, 1]")))
(($line_width $head_length $head_angle $xaxis_width $yaxis_width $zaxis_width)
(update-positive-float opt val))
($xyplane ; defined as real number or false
(setf val ($float val))
(if (or (numberp val)
(null val ))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal xyplane allocation: ~M " val)))
($point_size ; defined as non negative numbers
(update-nonnegative-float opt val))
($points_joined ; defined as true, false or $impulses
(update-pointsjoined val))
($colorbox ; defined as true, false or string
(if (or (member val '(t nil))
(stringp val) )
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal colorbox option: ~M " val)) )
(($line_type $xaxis_type $yaxis_type $zaxis_type) ; defined as $solid or $dots
(update-linestyle opt val) )
($capping
(update-capping val))
($point_type
(update-pointtype val))
(($columns $nticks $adapt_depth $xu_grid $yv_grid $delay $x_voxel $y_voxel $z_voxel $font_size)
(update-positive-integer opt val))
(($contour_levels $isolines_levels) ; positive integer, increment or set
(update-contour-isolines opt val))
($opacity
(update-opacity val))
(($transparent $border $logx $logx_secondary $logy $logy_secondary
$logz $logcb $head_both
$xaxis_secondary $yaxis_secondary $axis_bottom $axis_left $axis_top
$axis_right $axis_3d $surface_hide $xaxis $yaxis $zaxis $unit_vectors
$xtics_rotate $ytics_rotate $xtics_secondary_rotate $ytics_secondary_rotate
$ztics_rotate $xtics_axis $ytics_axis $xtics_secondary_axis
$ytics_secondary_axis $ztics_axis $draw_realpart $wired_surface) ; true or false
(update-boolean-option opt val))
($filled_func ; true, false or an expression
(setf (gethash opt *gr-options*) val))
($transform
(update-transform val))
($enhanced3d
(update-enhanced3d val))
($isolines
(update-isolines val))
(($xtics $ytics $xtics_secondary $ytics_secondary $ztics $cbtics)
; $auto or t, $none or nil, number, increment, set, set of pairs
(cond ((member val '($none nil)) ; nil is maintained for back-portability
(setf (gethash opt *gr-options*) nil))
((member val '($auto t)) ; t is maintained for back-portability
(setf (gethash opt *gr-options*) "autofreq"))
((and (numberp (setf val ($float val))) ; increment
(> val 0 ))
(setf (gethash opt *gr-options*) val))
((and ($listp val) ; [ini,incr,end]
(= ($length val) 3)
(< (cadr val) (cadddr val))
(> (caddr val) 0)
(< (caddr val) (- (cadddr val) (cadr val))) )
(setf (gethash opt *gr-options*)
(format nil "~a,~a,~a" (cadr val) (caddr val) (cadddr val))))
((and ($setp val)
(every #'(lambda (z) (numberp z))
(cdr val)) ) ; {n1,n2,n3,...}
(setf
(gethash opt *gr-options*)
(do ((k (cdr val) (cdr k))
(str "" (concatenate 'string str (format nil "~a," (car k)))) )
((null k) (concatenate
'string
"("
(string-right-trim "," str)
")")))))
((and ($setp val)
(every #'(lambda (z) (and ($listp z)
(= ($length z) 2)
(numberp (caddr z)) ))
(cdr val)) ) ; {[lab1,n1],[lab2,n2],...}
(setf
(gethash opt *gr-options*)
(do ((k (cdr val) (cdr k))
(str "" (concatenate
'string
str
(format nil "'~a' ~a," (cadar k) (caddar k)))))
((null k) (concatenate
'string
"("
(string-right-trim "," str)
")")))))
(t
(merror "draw: illegal tics allocation: ~M" val)) ))
($terminal
(update-terminal val))
($key_pos
(update-key_pos val))
($zlabel_rotate
(if (member val '(t nil $auto))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal zlabel_rotate option: ~M" val)))
($head_type ; defined as $filled, $empty and $nofilled
(if (member val '($filled $empty $nofilled))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal head type for vectors: ~M" val)))
($contour ; defined as $none, $base, $surface, $both and $map
(if (member val '($none $base $surface $both $map))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal contour allocation: ~M" val)))
($proportional_axes ; defined as $none, $xy and $xyz
(if (member val '($none $xy $xyz))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal proportional_axes specification")))
($error_type ; defined as $x, $y and $xy
(if (member val '($x $y $xy $boxes))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal error_type specification")))
($label_alignment ; defined as $center, $left and $right
(if (member val '($center $left $right))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal label alignment: ~M" val)))
($label_orientation ; defined as $horizontal and $vertical
(if (member val '($horizontal $vertical))
(setf (gethash opt *gr-options*) val)
(merror "draw: illegal label orientation: ~M" val)))
(($key $file_name $xy_file $title $xlabel $ylabel $zlabel $xlabel_secondary $ylabel_secondary
$font $gnuplot_file_name $data_file_name)
(update-string opt val))
($user_preamble ; defined as a string or a Maxima list of strings
(let ((str ""))
(cond
(($atom val)
(setf str val))
(($listp val)
(dolist (st (rest val))
(if (not ($atom st))
(merror "draw: user preamble ~M should be a string" st))
(setf str (concatenate 'string
str
(format nil (if (string= str "") "~a" "~%~a") st)))))
(t (merror "draw: illegal user preamble especification")))
(setf (gethash opt *gr-options*) str)) )
(($xrange $yrange $xrange_secondary $yrange_secondary
$zrange $cbrange) ; defined as a Maxima list with two numbers in increasing order
(cond ((member val '($auto nil)) ; nil is maintained for back-portability
(setf (gethash opt *gr-options*) nil))
((or (not ($listp val))
(/= ($length val) 2))
(merror "draw: illegal range: ~M " val))
(t
(let ((fval1 ($float (cadr val)))
(fval2 ($float (caddr val))))
(cond
((or (not (floatp fval1))
(not (floatp fval2))
(< fval2 fval1))
(merror "draw: illegal values in range specification"))
((= ($length val) 2) ; it's a trick: length 2 => user change
(setf (gethash opt *gr-options*) (list fval1 fval2)))
(t ; should be length 3 or nil option => automatic computation of ranks
(setf (gethash opt *gr-options*) (list fval1 fval2 0)) )) ))) )
(($grid) ; defined as a Maxima list with two numbers.
; 0 0 means "off",
; >0 >0 means "on with n grid lines per tick",
(cond ((null val)
(setf (gethash opt *gr-options*) (list 0 0)))
((eq val t)
(setf (gethash opt *gr-options*) (list 1 1)))
((or (not ($listp val))
(/= ($length val) 2))
(merror "draw: illegal grid lines specification: ~M " val))
(t
(let ((fval1 ($float (cadr val)))
(fval2 ($float (caddr val))))
(cond
((or (not (floatp fval1))
(not (floatp fval2))
(< fval1 1)
(< fval2 1))
(merror "grid: illegal grid lines specification"))
(t
(setf (gethash opt *gr-options*) (list ($round fval1) ($round fval2))) )
) ))) )
(($ip_grid $ip_grid_in)
(if (not ($listp val))
(merror "draw: illegal value for grid")
(if (not (and (integerp ($first val))
(integerp ($second val))))
(merror "draw: illegal value for grid")
(setf (gethash opt *gr-options*) val))))
($palette
(update-palette val))
(($color $fill_color $xaxis_color $yaxis_color
$zaxis_color $background_color)
(update-color opt val))
($view
(update-view val))
($interpolate_color
(update-interpolate_color val))
; DEPRECATED OPTIONS
($tube_extremes
($print "Warning: 'tube_extremes' is deprecated, using 'capping' instead...")
(update-capping (substitute nil '$open (substitute t '$closed val))))
($file_bgcolor
($print "Warning: 'file_bgcolor' is deprecated, using 'background_color' instead...")
(update-color '$background_color val))
($rot_vertical
($print "Warning: 'rot_vertical' is deprecated, using 'view' instead...")
(update-view (list '(mlist) val (second (gethash '$view *gr-options*)))))
($rot_horizontal
($print "Warning: 'rot_horizontal' is deprecated, using 'view' instead...")
(update-view (list '(mlist) (first (gethash '$view *gr-options*)) val)))
($pic_width
($print "Warning: 'pic_width' is deprecated, using 'dimensions' instead...")
(update-dimensions (list '(mlist) val (second (gethash '$dimensions *gr-options*)))))
($pic_height
($print "Warning: 'pic_height' is deprecated, using 'dimensions' instead...")
(update-dimensions (list '(mlist) (first (gethash '$dimensions *gr-options*)) val)))
(($eps_width $pdf_width)
($print "Warning: 'eps_width' is deprecated, using 'dimensions' instead...")
(update-dimensions (list '(mlist) (* 100 val) (second (gethash '$dimensions *gr-options*)))))
(($eps_height $pdf_height)
($print "Warning: 'eps_height' is deprecated, using 'dimensions' instead...")
(update-dimensions (list '(mlist) (first (gethash '$dimensions *gr-options*)) (* 100 val))))
(otherwise (merror "draw: unknown option ~M " opt)) ) )
;;; OTHER COMMON GNUPLOT - VTK AUXILIARY FUNCTIONS
(defun near-equal (a b)
(let ((eps 10.0d-14))
(< (abs (- a b)) eps)))
;; Transforms arguments to make-scene-2d, make-scene-3d,
;; draw, and vtk3d to a unique list. With this piece of code,
;; gr2d, gr3d, draw, and model3d admit as arguments nested lists
;; of options and graphic objects
(defmacro listify-arguments (args)
`(rest ($flatten
($tree_reduce
'$append
(cons '(mlist)
(map
'list #'(lambda (z) (if ($listp z) z (list '(mlist) z)))
,args))))))
;; The following functions implement the marching cubes algorithm
;; for implicit functions in 3d.
(defvar *i3d_triangles*
'#(#(-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)
#(0 8 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)
#(0 1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)
#(1 8 3 9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 -1 -1)
#(1 3 8 9 1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)
#(0 9 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)
#(0 3 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)
#(-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)) )
; Copies multidimensional arrays.
(defun copy-array (array)
(let ((dims (array-dimensions array)))
(adjust-array
(make-array
dims
:element-type (array-element-type array)
:displaced-to array)
dims)))
; Calculates surface-edge intersection by interpolation
(defun edge-interpolation (x1 y1 z1 x2 y2 z2 v1 v2)
(cond ((or (< (abs v1) 0.00001)
(< (abs (- v1 v2)) 0.00001))
(list x1 y1 z1))
((< (abs v2) 0.00001)
(list x2 y2 z2))
(t
(let ((m (/ (- v1) (- v2 v1))))
(list
(+ x1 (* m (- x2 x1)))
(+ y1 (* m (- y2 y1)))
(+ z1 (* m (- z2 z1))))))))
(defmacro make-triangle-vertices (i1 j1 k1 i2 j2 k2 e1 e2)
`(edge-interpolation
(aref px ,i1) (aref py ,j1) (aref pz ,k1)
(aref px ,i2) (aref py ,j2) (aref pz ,k2)
(aref val ,e1) (aref val ,e2)))
(defun flatten (lis)
(cond ((atom lis) lis)
((listp (car lis))
(append (flatten (car lis)) (flatten (cdr lis))))
(t
(append (list (car lis)) (flatten (cdr lis))))))
(defun find-triangles (expr par1 xmin xmax par2 ymin ymax par3 zmin zmax)
(let* ((nx (get-option '$x_voxel))
(ny (get-option '$y_voxel))
(nz (get-option '$z_voxel))
(dx (/ (- xmax xmin) nx))
(dy (/ (- ymax ymin) ny))
(dz (/ (- zmax zmin) nz))
(fcn (coerce-float-fun (m- ($lhs expr) ($rhs expr)) `((mlist) ,par1 ,par2 ,par3)))
(vert '())
(px (make-array (+ nx 1) :element-type 'flonum))
(py (make-array (+ ny 1) :element-type 'flonum))
(pz (make-array (+ nz 1) :element-type 'flonum))
(oldval (make-array `(,(+ nx 1) ,(+ ny 1)) :element-type 'flonum))
(newval (make-array `(,(+ nx 1) ,(+ ny 1)) :element-type 'flonum)) )
; initialize coordinate arrays
(loop for i to nx do (setf (aref px i) (+ xmin (* i dx))))
(loop for j to ny do (setf (aref py j) (+ ymin (* j dy))))
(loop for k to nz do (setf (aref pz k) (+ zmin (* k dz))))
; initialize first layer
(loop for i to nx do
(loop for j to ny do
(let ((fxy (funcall fcn (aref px i) (aref py j) (aref pz 0))))
(if (floatp fxy)
(setf (aref oldval i j) fxy)
(merror "draw3d (implicit): non real value")))))
; begin triangularization process
(loop for k from 1 to nz do
; calculate node values in new layer
(loop for i to nx do
(loop for j to ny do
(let ((fxy (funcall fcn (aref px i) (aref py j) (aref pz k))))
(if (floatp fxy)
(setf (aref newval i j) fxy)
(merror "draw3d (implicit): check surface definition; non real value")))))
; analyze voxels in this slide
(loop for i below nx do
(loop for j below ny do
(let* (triangles
(cubidx 0)
(k-1 (- k 1))
(i+1 (+ i 1))
(j+1 (+ j 1))
(val (make-array 8 :element-type 'flonum
:initial-contents
`(,(aref oldval i j+1) ,(aref oldval i+1 j+1)
,(aref oldval i+1 j) ,(aref oldval i j)
,(aref newval i j+1) ,(aref newval i+1 j+1)
,(aref newval i+1 j) ,(aref newval i j)))))
(when (<= (aref val 0) 0.0) (setf cubidx (logior cubidx 1)))
(when (<= (aref val 1) 0.0) (setf cubidx (logior cubidx 2)))
(when (<= (aref val 2) 0.0) (setf cubidx (logior cubidx 4)))
(when (<= (aref val 3) 0.0) (setf cubidx (logior cubidx 8)))
(when (<= (aref val 4) 0.0) (setf cubidx (logior cubidx 16)))
(when (<= (aref val 5) 0.0) (setf cubidx (logior cubidx 32)))
(when (<= (aref val 6) 0.0) (setf cubidx (logior cubidx 64)))
(when (<= (aref val 7) 0.0) (setf cubidx (logior cubidx 128)))
(setf triangles (aref *i3d_triangles* cubidx)) ; edges intersecting the surface
(do ((e 0 (1+ e)))
((= (aref triangles e) -1) 'done)
(push
(case (aref triangles e)
(0 (make-triangle-vertices i j+1 k-1 i+1 j+1 k-1 0 1))
(1 (make-triangle-vertices i+1 j+1 k-1 i+1 j k-1 1 2))
(2 (make-triangle-vertices i+1 j k-1 i j k-1 2 3))
(3 (make-triangle-vertices i j k-1 i j+1 k-1 3 0))
(4 (make-triangle-vertices i j+1 k i+1 j+1 k 4 5))
(5 (make-triangle-vertices i+1 j+1 k i+1 j k 5 6))
(6 (make-triangle-vertices i+1 j k i j k 6 7))
(7 (make-triangle-vertices i j k i j+1 k 7 4))
(8 (make-triangle-vertices i j+1 k-1 i j+1 k 0 4))
(9 (make-triangle-vertices i+1 j+1 k-1 i+1 j+1 k 1 5))
(10 (make-triangle-vertices i+1 j k-1 i+1 j k 2 6))
(11 (make-triangle-vertices i j k-1 i j k 3 7)) )
vert)))))
; make oldval a copy of newval
(setf oldval (copy-array newval)))
vert))
;; This is the function to be called at Maxima level.
;; Some examples:
;; draw(gr2d(opt & obj))$ => a 2d plot, equivalent to draw2d(opt & obj)
;; draw(gr3d(opt & obj))$ => a 2d plot, equivalent to draw3d(opt & obj)
;; draw(gr2d(opt & obj),gr2d(opt & obj),gr3d(opt & obj),gr2d(opt & obj))$
;; => four plots in one column, one of them is a 3d plot
;; draw(terminal=png,columns=2,gr2d(opt & obj),gr3d(opt & obj))
;; => png file with two plots (2d and 3d) side by side
;; See bellow for $draw2d and $draw3d
(defun $draw (&rest args)
(cond ((member $draw_renderer '($gnuplot $gnuplot_pipes))
(apply 'draw_gnuplot args))
((member $draw_renderer '($vtk $vtk6 $vtk7))
(apply 'draw_vtk args))
(t
(merror "draw: unknown renderer ~M" $draw_renderer))))
;; Equivalent to draw2d(opt & obj)
(defun $draw2d (&rest args)
($draw (cons '($gr2d) args)) )
;; Equivalent to draw3d(opt & obj)
(defun $draw3d (&rest args)
(cond ((member $draw_renderer '($gnuplot $gnuplot_pipes))
(draw_gnuplot (cons '($gr3d) args)))
((member $draw_renderer '($vtk $vtk6 $vtk7))
(draw_vtk (cons '($gr3d) args)))
(t
(merror "draw: unknown renderer ~M" $draw_renderer))))
|