Symptote: the Vector Graphics Language
Total Page:16
File Type:pdf, Size:1020Kb
Asymptote: the Vector Graphics Language For version 2.70 symptotesymptote This file documents Asymptote, version 2.70. https://asymptote.sourceforge.io Copyright c 2004-20 Andy Hammerlindl, John Bowman, and Tom Prince. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Lesser General Public License (see the file LICENSE in the top-level source directory). i Table of Contents 1 Description::::::::::::::::::::::::::::::::::::::: 1 2 Installation::::::::::::::::::::::::::::::::::::::: 3 2.1 UNIX binary distributions :::::::::::::::::::::::::::::::::::::: 3 2.2 MacOS X binary distributions :::::::::::::::::::::::::::::::::: 3 2.3 Microsoft Windows ::::::::::::::::::::::::::::::::::::::::::::: 3 2.4 Configuring::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 2.5 Search paths ::::::::::::::::::::::::::::::::::::::::::::::::::: 6 2.6 Compiling from UNIX source ::::::::::::::::::::::::::::::::::: 6 2.7 Editing modes :::::::::::::::::::::::::::::::::::::::::::::::::: 7 2.8 Git ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 2.9 Uninstall ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 3 Tutorial :::::::::::::::::::::::::::::::::::::::::: 9 3.1 Drawing in batch mode ::::::::::::::::::::::::::::::::::::::::: 9 3.2 Drawing in interactive mode :::::::::::::::::::::::::::::::::::: 9 3.3 Figure size :::::::::::::::::::::::::::::::::::::::::::::::::::: 10 3.4 Labels::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 3.5 Paths ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 4 Drawing commands :::::::::::::::::::::::::::: 14 4.1 draw :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 14 4.2 fill :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 16 4.3 clip ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 18 4.4 label :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 18 5 Bezier curves ::::::::::::::::::::::::::::::::::: 22 6 Programming ::::::::::::::::::::::::::::::::::: 24 6.1 Data types :::::::::::::::::::::::::::::::::::::::::::::::::::: 24 6.2 Paths and guides :::::::::::::::::::::::::::::::::::::::::::::: 31 6.3 Pens :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 38 6.4 Transforms :::::::::::::::::::::::::::::::::::::::::::::::::::: 46 6.5 Frames and pictures ::::::::::::::::::::::::::::::::::::::::::: 47 6.6 Files :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 53 6.7 Variable initializers :::::::::::::::::::::::::::::::::::::::::::: 56 6.8 Structures ::::::::::::::::::::::::::::::::::::::::::::::::::::: 57 6.9 Operators ::::::::::::::::::::::::::::::::::::::::::::::::::::: 61 6.9.1 Arithmetic & logical operators :::::::::::::::::::::::::::: 61 6.9.2 Self & prefix operators :::::::::::::::::::::::::::::::::::: 62 6.9.3 User-defined operators :::::::::::::::::::::::::::::::::::: 63 ii 6.10 Implicit scaling ::::::::::::::::::::::::::::::::::::::::::::::: 63 6.11 Functions :::::::::::::::::::::::::::::::::::::::::::::::::::: 64 6.11.1 Default arguments ::::::::::::::::::::::::::::::::::::::: 66 6.11.2 Named arguments ::::::::::::::::::::::::::::::::::::::: 66 6.11.3 Rest arguments:::::::::::::::::::::::::::::::::::::::::: 67 6.11.4 Mathematical functions :::::::::::::::::::::::::::::::::: 69 6.12 Arrays ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 70 6.12.1 Slices:::::::::::::::::::::::::::::::::::::::::::::::::::: 77 6.13 Casts :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 78 6.14 Import ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 79 6.15 Static :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 82 7 LaTeX usage ::::::::::::::::::::::::::::::::::::: 85 8 Base modules ::::::::::::::::::::::::::::::::::: 90 8.1 plain ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 90 8.2 simplex::::::::::::::::::::::::::::::::::::::::::::::::::::::: 90 8.3 math :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 90 8.4 interpolate :::::::::::::::::::::::::::::::::::::::::::::::::: 91 8.5 geometry:::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 8.6 trembling :::::::::::::::::::::::::::::::::::::::::::::::::::: 91 8.7 stats ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 8.8 patterns:::::::::::::::::::::::::::::::::::::::::::::::::::::: 92 8.9 markers::::::::::::::::::::::::::::::::::::::::::::::::::::::: 92 8.10 map :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 94 8.11 tree ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 94 8.12 binarytree :::::::::::::::::::::::::::::::::::::::::::::::::: 94 8.13 drawtree :::::::::::::::::::::::::::::::::::::::::::::::::::: 95 8.14 syzygy ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 95 8.15 feynman:::::::::::::::::::::::::::::::::::::::::::::::::::::: 95 8.16 roundedpath ::::::::::::::::::::::::::::::::::::::::::::::::: 96 8.17 animation ::::::::::::::::::::::::::::::::::::::::::::::::::: 96 8.18 embed :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 96 8.19 slide :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.20 MetaPost :::::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.21 babel :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.22 labelpath ::::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.23 labelpath3 :::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.24 annotate :::::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.25 CAD :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 98 8.26 graph :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 98 8.27 palette :::::::::::::::::::::::::::::::::::::::::::::::::::: 128 8.28 three ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 133 8.29 obj ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 147 8.30 graph3:::::::::::::::::::::::::::::::::::::::::::::::::::::: 147 8.31 grid3 ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 151 8.32 solids:::::::::::::::::::::::::::::::::::::::::::::::::::::: 152 iii 8.33 tube :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 153 8.34 flowchart :::::::::::::::::::::::::::::::::::::::::::::::::: 154 8.35 contour :::::::::::::::::::::::::::::::::::::::::::::::::::: 156 8.36 contour3 ::::::::::::::::::::::::::::::::::::::::::::::::::: 162 8.37 smoothcontour3 :::::::::::::::::::::::::::::::::::::::::::: 162 8.38 slopefield ::::::::::::::::::::::::::::::::::::::::::::::::: 163 8.39 ode ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 164 9 Command-line options ::::::::::::::::::::::: 165 10 Interactive mode::::::::::::::::::::::::::::: 170 11 Graphical User Interface :::::::::::::::::::: 172 11.1 GUI installation::::::::::::::::::::::::::::::::::::::::::::: 172 11.2 GUI usage :::::::::::::::::::::::::::::::::::::::::::::::::: 172 12 PostScript to Asymptote ::::::::::::::::::::: 173 13 Help :::::::::::::::::::::::::::::::::::::::::: 174 14 Debugger ::::::::::::::::::::::::::::::::::::: 175 15 Acknowledgments ::::::::::::::::::::::::::: 176 Index :::::::::::::::::::::::::::::::::::::::::::::: 177 1 1 Description Asymptote is a powerful descriptive vector graphics language that provides a mathematical coordinate-based framework for technical drawing. Labels and equations are typeset with LaTeX, for overall document consistency, yielding the same high-quality level of typesetting that LaTeX provides for scientific text. By default it produces PostScript output, but it can also generate PDF, SVG, WebGL, PRC, and any format that the ImageMagick package can produce. You can even try it out in your Web browser without installing it, using the Asymptote Web Application: http://asymptote.ualberta.ca A major advantage of Asymptote over other graphics packages is that it is a high-level programming language, as opposed to just a graphics program: it can therefore exploit the best features of the script (command-driven) and graphical-user-interface (GUI) methods for producing figures. The rudimentary GUI xasy included with the package allows one to move script-generated objects around. To make Asymptote accessible to the average user, this GUI is currently being developed into a full-fledged interface that can generate objects directly. However, the script portion of the language is now ready for general use by users who are willing to learn a few simple Asymptote graphics commands (see Chapter 4 [Drawing commands], page 14). Asymptote is mathematically oriented (e.g. one can use complex multiplication to rotate a vector) and uses LaTeX to do the typesetting of labels. This is an important feature for scientific applications. It was inspired by an earlier drawing program (with a weaker syntax and capabilities) called MetaPost. The Asymptote vector graphics language provides: a standard for typesetting mathematical figures, just asE T X/LaTeX is the de-facto • standard for typesetting equations. LaTeX typesetting of labels, for overall document consistency; • the ability to generate and embed 3D vector WebGL graphics within HTML files; • the ability to generate and embed 3D vector PRC graphics within PDF files; • a natural coordinate-based framework for technical drawing, inspired by MetaPost, • with a much cleaner, powerful C++-like programming syntax; compilation of figures into virtual machine code for speed, without sacrificing portabil- • ity; the power of a script-based language coupled to the convenience of a GUI; • customization using its own C++-like graphics programming language; • sensible defaults for graphical features, with the ability to override; • a high-level mathematically