diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
commit | ad547a6b5986815fda458221149728d9d9ab1d87 (patch) | |
tree | 16296910eb3eca724371474ea9aea3994dc69614 /Build/source/utils/asymptote/doc/FAQ | |
parent | 947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff) |
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/doc/FAQ')
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/Makefile | 40 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/asy-faq.bfnn | 1287 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/asy-faq.info | 1671 | ||||
-rwxr-xr-x | Build/source/utils/asymptote/doc/FAQ/bfnnconv.pl | 302 | ||||
-rwxr-xr-x | Build/source/utils/asymptote/doc/FAQ/install-sh | 520 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/m-ascii.pl | 189 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/m-html.pl | 344 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/m-info.pl | 226 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/m-lout.pl | 242 | ||||
-rw-r--r-- | Build/source/utils/asymptote/doc/FAQ/m-post.pl | 189 |
10 files changed, 5010 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/doc/FAQ/Makefile b/Build/source/utils/asymptote/doc/FAQ/Makefile new file mode 100644 index 00000000000..07d40b0ace4 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/Makefile @@ -0,0 +1,40 @@ +BFNNCONV = bfnnconv.pl m-ascii.pl m-html.pl m-info.pl m-lout.pl m-post.pl + +all: faq + +faq: $(BFNNCONV) asy-faq.bfnn + mkdir -p asy-faq.html + perl bfnnconv.pl asy-faq.bfnn + perl bfnnconv.pl asy-faq.bfnn + +clean: FORCE + -rm -f *~ core a.out *.lout *.ps *.info *.ascii *.xrefdb *.post + -rm -rf *.html + +install-all: install + +install: faq install-prebuilt + ${INSTALL} -d -m 755 $(docdir) $(docdir)/asy-faq.html + ${INSTALL} -p -m 644 asy-faq.ascii $(docdir) + ${INSTALL} -p -m 644 asy-faq.html/* $(docdir)/asy-faq.html + +install-prebuilt: + ${INSTALL} -d -m 755 $(infodir) + ${INSTALL} -p -m 644 asy-faq.info $(infodir) + -if test -z "$(DESTDIR)"; then \ + install-info --infodir=$(infodir) asy-faq.info; \ + fi + +install-info: faq install-prebuilt + +uninstall: uninstall-all + +uninstall-all: + -cd $(docdir)/asy-faq.html && rm -rf *.html + -cd $(docdir) && rmdir asy-faq.html && rm asy-faq.ascii + -install-info --remove --infodir=$(infodir) asy-faq.info + -rm -f $(infodir)/asy-faq.info + +distclean: FORCE clean + +FORCE: diff --git a/Build/source/utils/asymptote/doc/FAQ/asy-faq.bfnn b/Build/source/utils/asymptote/doc/FAQ/asy-faq.bfnn new file mode 100644 index 00000000000..a4dc8a0965c --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/asy-faq.bfnn @@ -0,0 +1,1287 @@ +\comment This is the source for the Asymptote FAQ list, in +\comment the Bizarre Format With No Name. It is turned into Lout +\comment input, HTML, plain ASCII and an Info document by a Perl script. +\comment +\comment The format and scripts come from the Linux FAQ, by +\comment Ian Jackson. +\set brieftitle Asymptote FAQ +\set author <A href="https://asymptote.sourceforge.io">Asymptote</A> +\set title Asymptote Frequently Asked Questions +\copyto ASCII + ASYMPTOTE FREQUENTLY ASKED QUESTIONS + `%perl use POSIX; POSIX::strftime("%Y-%m-%d", gmtime($ENV{SOURCE_DATE_EPOCH} || time))` + +\endcopy +\copyto INFO +INFO-DIR-SECTION Languages +START-INFO-DIR-ENTRY +* asymptote FAQ: (asy-faq). Asymptote Frequently Asked Questions. +END-INFO-DIR-ENTRY + + +File: asy-faq.info, Node: Top, Next: Question 1.1, Up: (dir) + + ASYMPTOTE FREQUENTLY ASKED QUESTIONS + `%perl use POSIX; POSIX::strftime("%Y-%m-%d", gmtime($ENV{SOURCE_DATE_EPOCH} || time))` + +\endcopy + +This is the list of Frequently Asked Questions about Asymptote (asy). + +\section Index + +\index + +\comment ###################################################################### + +\section About Asymptote + +\question 26jun:whatisasy What is Asymptote? + +Asymptote is a vector graphics language designed for +technical graphics, inspired by MetaPost but with IEEE floating-point numerics, +native three-dimensional graphics, Grayscale/RGB/CMYK colourspaces, and a +C++-like syntax. Unlike MetaPost, it natively supports multiple-segment paths +(and hence regions other than simply connected ones), tiling patterns, Gouraud + shading, tensor patch shading, and PostScript images. + +\question 22jun:whereisasy How do I obtain Asymptote? + +Binary releases are available for Linux, MacOS X, and Microsoft Windows +platforms, in addition to full source code, from the website +\docref{https://asymptote.sourceforge.io/\}. Many Linux distributions +(such as RedHat and Debian) now include an Asymptote package (check your +distribution's documentation for further information about this). + +\question 28jun:beforeasking Where can I ask questions about Asymptote? + +If you have a question, please try to find an answer in this FAQ, in the +extensive Asymptote documentation at +\docref{https://asymptote.sourceforge.io/doc/\}, or search the forum: +\docref{http://sourceforge.net/forum/forum.php?forum_id=409349\}. + +\question 02sep:whyasy Why was the name Asymptote chosen? + +Well, it isn't the perfect graphics package, but we do think it is getting there +asymptotically... + +\question 02sep:whycamp In the internal Asymptote source code, what does the name \courier{camp\} refer to? + +That was our original tentative name for this project, which stood for +"C's Answer to MetaPost" (the language that inspired Asymptote). +However, we eventually decided that the name \courier{Asymptote\} better +emphasizes the mathematical and graphical nature of this language. + +\comment ###################################################################### + +\section Questions about installation and setup + +\question 26jun:osx Is it possible to install Asymptote on Mac OS X? + +It is easy to compile Asymptote directly from the source code at +\docref{http://sourceforge.net/project/showfiles.php?group_id=120000\} +We recommend first upgrading to the latest GNU readline library, unless you +don't care about interactive readline support (in which case configure will +automatically detect and disable obsolete versions of the readline library). +Marius Schamschula also maintains a binary package for various MacOS X +platforms +\docref{http://www.hmug.org/pub/MacOS_X/X/Applications/Publishing/asymptote\}. + +\question 26jun:osxbadCPU Why do I get the error \courier{Bad CPU type in executable\} on installing Asymptote from the MAC OS binary? + +This means either that you have a binary distribution for another MAC +architecture, or (according to Marius Schamschula) that you may have a missing +library. The simplest solution is to compile Asymptote directly from the +official source: +\docref{http://sourceforge.net/project/showfiles.php?group_id=120000\}. + +\question 04nov:brokenpdftex What do I do if I get the error: \courier{Error: pdfetex (file pdftex.cfg): cannot open config file...texinfo.tex appears to be broken\}? + +Simply put \docref{https://asymptote.sourceforge.io/asymptote.pdf\} +in the directory \courier{doc\} and repeat the command \courier{make all\}. +Or, if you don't want to build a local copy of the documentation, simply +proceed with \courier{make install-asy\}. + +\question 04nov:brokentexinfo What do I do if I get the error: \courier{! Undefined control sequence. l.6 @copying\}? + +Either upgrade your \courier{texinfo\} package or follow one of the easy work arounds in \qref brokenpdftex. + +\question 27jun:latexintegration Is it possible to integrate Asymptote into LaTeX? + +Yes, see the example latexusage.tex. Dario Teixeira has also written a detailed +guide on the topic. You can download it from +\docref{http://dario.dse.nl/projects/asylatex/\}. + +Philippe Ivaldi has contributed an Asymptote mode for Emacs users +\docref{https://asymptote.sourceforge.io/doc/Editing-modes.html\}, +which includes a \courier{lasy-mode\} that allows one to compile and view +the output of one \\begin{asy}...\\end{asy} section at a time. + +\question 02sep:pdflatex Is it possible to integrate Asymptote into latex or pdflatex? + +Yes, as of version 1.14, Asymptote supports latex and pdflatex (both in +EPS/PDF and inline mode), as illustrated by the example +\courier{latexusage.tex\}: + +\verbatim +pdflatex latexusage +asy latexusage +pdflatex latexusage +\endverbatim + +\question 02sep:tkinterdepend Do I need the \courier{tkinter\} package to install an Asymptote rpm binary? + +No, you don't need \courier{tkinter\} unless you want to try out the GUI \courier{xasy\}. Try + +\verbatim +rpm -Uvh --nodeps asymptote-x.xx-1.i386.rpm +\endverbatim + +where \courier{x.xx\} represents the version number. + +\question 26jun:windir What does the path \courier{%USERPROFILE%\\.asy\\config.asy\} mean? + +That is the way that Microsoft Windows refers to the user profile directory. +There's nothing really to understand here, just put your configuration +commands in the file \courier{config.asy\} in a new folder \courier{%USERPROFILE%\\.asy\}. + +\question 25dec:escapechar Why do I get the error "string not terminated" when I try to set \courier{settings.dir="C:\\asymptote\\";\}? + +The backslash is an escape character here, so +\courier{\\"\} is interpreted as a verbatim quotation mark, leaving the string +without a terminating quotation mark. Fortunately, this is the +only escaped character in double-quoted strings. A final backslash isn't +needed here anyway, but should you really want one somewhere, you can say: +\courier{settings.dir="C:\\asymptote"+'\\\\';\}. + +\question 27jun:winglobal How do I change environment variables in Microsoft Windows, for example, in order to change the default PostScript viewer? + +While it is easier to set the corresponding Asymptote configuration +variable in your \courier{config.asy\} file, here is the procedure for changing +Microsoft Windows environment variables: + +Click on the [Start] button + +* RIGHT-click on 'My Computer' + +* Choose 'Properties' from the popup menu + +* Click the 'Advanced' tab + +* Click the 'Environment Variables' button. + +\question 02sep:convert Under Microsoft Windows XP, why do I get an error like "Invalid Parameter - 432x432"? + +This means that ImageMagick wasn't properly installed and you are using the +MSDOS convert program rather than the ImageMagick one. Or you may have +installed ImageMagick but ran Asymptote from an existing MSDOS window. +In that case, simply open a new window and try again. If that doesn't work, +check that + +\verbatim +convert --version +\endverbatim + +returns something like + +\verbatim +Version: ImageMagick 6.2.8 06/27/06 Q16 http://www.imagemagick.org +\endverbatim + +\question 26jun:miktex Why does Asymptote freeze upon trying to draw a label with my MikTex installation under Microsoft Windows? + +Likely, this means that latex and dvips are not in your default path. +Try adding the appropriate paths in your \courier{config.asy\} file, +for example: + +\verbatim +import settings; +latex="C:\Program Files\MiKTeX 2.7\miktex\bin\latex.exe"; +dvips="C:\Program Files\MiKTeX 2.7\miktex\bin\dvips.exe"; +\endverbatim + +\comment ##################################################################### + +\section Questions about paths + +\question 02sep:tensionsyntax Why do I get a syntax error message when I specify an integer value for the path tension? + +What is happening here is that + +\verbatim +draw((0,0)..tension 2..(0,50)..(100,100)); +\endverbatim + +is read as + +\verbatim +draw((0,0)..tension 2. .(0,50)..(100,100)); +\endverbatim + +So the first . after the two is treated as a decimal point. +Just put a space after the integer tension value: + +\verbatim +draw((0,0)..tension 2 ..(0,50)..(100,100)); +\endverbatim + +\question 27jun:dots Shouldn't dots always be the same size? + +From the documentation: + +"The dot command defined in the module plain draws a dot having a diameter +equal to an explicit pen linewidth or the default linewidth magnified by +dotfactor (6 by default)." + +Thus, when you use the default pen, the dot will have size 6*linewidth, +but when you give a pen with an explicit width specified, you will +have a dot of size linewidth. If you want the first case to behave like the +second, you may set dotfactor=1. + +\comment ##################################################################### + +\section Questions about labels + +\question 02sep:greek How do I get Greek letters like omega to show up in my labels? + +In (La)TeX, Greek letters can be obtained in math mode by prepending a +backslash to the letter name. So for a omega symbol, use "$\\omega$". Everything +between the dollar signs is considered to be a math formula. Uppercase Greek +letters can be used by capitalizing the first letter of the name: + +\verbatim +label("$\omega$",(0,0)); +label("$\Omega$",(20,0)); +\endverbatim + +\question 29jun:matlabels Can Asymptote use matrices as labels? + +Yes: +\verbatim +usepackage("amsmath"); +label("$\begin{matrix} 1 & 2 \\\ 1 & 1 \end{matrix}$",(0,0)); +\endverbatim + +\question 27jun:latexpackage How do I tell Asymptote to load a particular LaTeX package, like \courier{mathptmx\}? + +Put + +\verbatim +usepackage("mathptmx"); +\endverbatim + +at the beginning of your file. Note: to enable the Adobe Times Roman font +for text, you will also need to say: +\verbatim +defaultpen(TimesRoman()); +\endverbatim + + +\question 28jun:internatfonts How can I use international fonts in Asymptote labels? + +See \docref{https://asymptote.sourceforge.io/doc/Pens.html\}. + +\question 10jul:Fourier How can I use Fourier fonts? + +\verbatim +usepackage("fourier"); +defaultpen(font("T1","fut\textfamilyextension","m","n")); +\endverbatim + +\question 26jun:decsep Is there any way to change the default appearance of the decimal separator, using a comma instead of a dot? + +Just set your locale appropriately: + +\verbatim +locale("it_IT"); +usepackage("icomma"); +label(format(0.5)); +\endverbatim + +\question 02sep:rotatelabel How can I get a rotated label with the filled box rotated as well so that it fits the text? + +\verbatim +frame f; +label(f,"This is some text",white,Fill(blue)); +add(rotate(65)*f); +\endverbatim + + +\question 02sep:rotatelabel3D How can I rotate labels in a 3D figure? + +You need to first project the triple to a pair like this: + +\verbatim +import three; +size(100,100); + +draw(rotate(90,project(Z))*"A",O--X); +\endverbatim + +\question 02sep:fixedsize How can I draw some squares and circles of a fixed size and put a label in the middle of them? + +Fixed-size objects should be drawn on a separate picture and then added to +currentpicture. Here is one way (see also \docref{https://asymptote.sourceforge.io/gallery/subpictures.asy\} and \docref{https://asymptote.sourceforge.io/gallery/mosquito.asy\}): + +\verbatim +real u=2cm; + +picture square; +draw(square,scale(u)*shift(-0.5,-0.5)*unitsquare); + +picture circle; +draw(circle,scale(0.5u)*unitcircle); + +void add(picture pic=currentpicture, Label L, picture object, pair z) { +add(pic,object,z); +label(pic,L,z); +} + +add("square",square,(0,0)); +add("circle",circle,(5cm,0)); +\endverbatim + +\question 27jun:colorssaturation The binary operator * can be used to scale the color of a pen by a real number. Does this scaling factor have to be less than 1? + +The scaling factor can be greater than 1. But keep in mind that the rgb color +components saturate at 1. + +Try +\verbatim +write(cyan); write(0.8*cyan); write(1.5*cyan); +\endverbatim +and you will quickly see what is going on. + +To get a lighter cyan you can say white+cyan, +which yields rgb(0.5,1,1). If you want something even lighter specify the +rgb colors directly, +for example, rgb(0.9,1,1). + +Alternatively, work in cmyk colour space, which is nicer in that it handles +saturation separately from hue: + +0.1*Cyan is light and 0.9*Cyan is dark. +You can also say 0.1*cmyk(red). + +\question 05mar:commadecimalseparator Why is the space after the comma decimal separator in my locale so large? + +LaTeX is treating the comma as punctuation and not as a decimal separator. +The solution is to load the \courier{icomma\} package near the beginning of your file: +\verbatim +usepackage("icomma"); +\endverbatim + +\question 11mar:hyperref How can I prevent \courier{texpreamble("\\usepackage[pdftex]{hyperref}")\} from changing the page size? + +\verbatim +texpreamble("\usepackage[pdftex,setpagesize=false]{hyperref}"); +\endverbatim + +\comment ##################################################################### + +\section Questions about arrows + +\question 02sep:doublearrows How do I draw two arrows at arbitrary positions along a path? + +Assuming that at least one of the arrowheads is to be filled, you can do this: + +\verbatim +size(200); +path g = (0,0)..(1,3)..(3,0); +draw(g,Arrow(Relative(0.9))); +add(arrow(g,invisible,FillDraw(black),Relative(0.5))); +add(arrow(reverse(g),invisible,FillDraw(white,black),Relative(0.9))); +\endverbatim + +If both of the arrowheads are to be drawn with filltype NoFill, +one will need to create a specialized version of the arrow routine in +\courier{plain_arrows.asy\}: + +\verbatim +void arrow(frame f, arrowhead arrowhead=DefaultHead, + path g, pen p=currentpen, real size=0, + real angle=arrowangle, filltype filltype=arrowhead.defaultfilltype, + position position=EndPoint, bool forwards=true, + margin margin=NoMargin, bool center=false); +\endverbatim + +\question 02sep:reversearrow How do I reverse the direction of an arrowhead? + +Simply reverse the direction of the path. + +\verbatim +path g=((0,0)--(5cm,0)); +draw(reverse(g),Arrow(Relative(0.55))); +\endverbatim + +\question 02sep:reversearrow How do I change the size of all arrows? + +To override the arrowsize you can give every Arrow drawing attribute a real +size argument. If you want to do this globally, you can override the +pen-dependent arrowsize function like this: + +\verbatim +DefaultHead.size=new real(pen p=currentpen) {return 2mm;}; +\endverbatim + +\question 26jun:arrowhead Can I create other arrowhead styles? + +Yes, you can build custom arrowheads like this (see the predefined +arrowhead styles in \courier{plain_arrows.asy\} for further examples): + +\verbatim +arrowhead DotHead; +DotHead.head=new path(path g, position position=EndPoint, pen p=currentpen, + real size=0, real angle=arrowangle) { + if(size == 0) size=DotHead.size(p); + bool relative=position.relative; + real position=position.position.x; + if(relative) position=reltime(g,position); + path r=subpath(g,position,0); + pair x=point(r,0); + real t=arctime(r,size); + pair y=point(r,t); + return circle(0.5(x+y),0.5size); +}; + +size(100); +draw((0,0)..(1,1)..(2,0),Arrow(DotHead)); +dot((2,0),red); +\endverbatim + +If you submit your alternate arrowheads to the Forum or the Patch +Tracking System, we'll consider including them in a future release. + +\comment ##################################################################### + +\section Questions about 2D graphs + +\question 02sep:axisticks How can I draw x axis ticks on the right side, with the tick labels on the left side (relative to the axis path)? + +\verbatim +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis("$x$",RightTicks(Label(align=left))); +yaxis("$y$",RightTicks); +\endverbatim + +\question 02sep:axislabel How can I reposition the x axis label to three-quarters along the axis length? + +\verbatim +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis(Label("$x$",0.75),LeftTicks); +yaxis("$y$",RightTicks); +\endverbatim + +\question 02sep:axislabeldown How can I move the x axis label down 10bp? + +\verbatim +import graph; +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis(shift(0,-10)*"$x$",LeftTicks); +yaxis("$y$",RightTicks); +\endverbatim + +\question 02sep:threeaxispens Can I use different pens for the axis, the axis label, and the tick labels? + +Yes: + +\verbatim +import graph; +size(300,200,IgnoreAspect); + +xlimits(-50,50); +ylimits(0,100); + +xaxis(Label("$x$",MidPoint,red),Bottom,blue,LeftTicks(green)); +yaxis("$y$",Left,RightTicks); +\endverbatim + +\question 02sep:axislabelfont How can I change the font type of the axes label? + +\verbatim +import graph; +size(300,200,IgnoreAspect); + +xlimits(-50,50); +ylimits(0,100); + +xaxis("x",Bottom,Courier("m","n"),LeftTicks); +yaxis("$y$",Left,RightTicks); +\endverbatim + +\question 02sep:axisticklabelfont How can I change the font type of the tick labels on an axis? + +Tick labels are by default typeset in (TeX) math mode, so to use other +fonts you need to override the default tick format: + +\verbatim +import graph; +size(300,200,IgnoreAspect); + +xlimits(-50,50); +ylimits(0,100); + +xaxis("$x$",Bottom,LeftTicks("%.4g",Courier("m","n")+fontsize(12))); +yaxis("$y$",Left,RightTicks); +\endverbatim + +\question 26jun:overlappingticklabels How can I prevent axes tick labels from rendering on top of each other? + +Either: + +(i) give LeftTicks/RightTicks/Ticks the arguments beginlabel=false +and/or endlabel=false; + +(ii) explicitly remove specific ticks and their labels (drawing them manually; +see \docref{http://www.github.com/vectorgraphics/asymptote/base/graph.asy\} for the definition of NoZero): + +\verbatim +import graph; + +size(10cm); + +real f(real x) {return x^2;} + +draw(graph(f,-2,2)); + +xaxis(Ticks(NoZero)); +yaxis(Ticks(NoZero)); + +label("$0$",(0,0),SW); +\endverbatim + +(iii) explicitly remove specific tick labels and draw them manually +(see \docref{http://www.github.com/vectorgraphics/asymptote/base/graph.asy\} for the definition of NoZeroFormat): + +\verbatim +import graph; + +size(10cm); + +real f(real x) {return x^2;} + +draw(graph(f,-2,2)); + +xaxis(Ticks(NoZeroFormat)); +yaxis(Ticks(NoZeroFormat)); + +label("$0$",(0,0),SW); +\endverbatim + +(iv) use the xasy GUI to move overlapping labels; + +(v) change the Label argument of LeftTicks, RightTicks, or Ticks to: + +\verbatim +Label(currentpen+overwrite(Move)) +\endverbatim + +Solution (v) will move labels that might otherwise overwrite a previous +label. Other possible overwrite arguments are Allow (allows overlapping +labels; the default), Suppress (an overlapping label will not be written at +all), SuppressQuiet, and MoveQuiet. The last two achieve the same result as +the non-quiet types, but will not notify you which labels are overlapping. See: +\docref{https://asymptote.sourceforge.io/doc/Pens.html\}. + +In the case of a user-specified tick array, you can change which labels get +suppressed/moved by changing the order of array entries. + +\question 04nov:fixedsizegraphs How do I make the plot region of a graph, ignoring labels and legends, have a fixed size? + +Either: + +i) Specify an explicit unitsize, which overrides any call to \courier{size\}: +\verbatim +unitsize(x=1cm,y=2cm); +\endverbatim + +ii) Explicitly tell Asymptote to map the plot region to a specific size: +\verbatim +import graph; +real[] x={0,1,2,3}; +real[] y=x^2; +draw(graph(x,y),red); +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); + +size(5cm,5cm,point(SW),point(NE)); + +label("$f_\mathrm{T}$",point(N),2N); +\endverbatim + +iii) Specify the points in user coordinates that should correspond to a +given picture size: + +\verbatim +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); + +fixedscaling((-1.5,-0.5),(1.5,3.5)); +\endverbatim + +In this example, the user coordinate \courier{(-1.5,-0.5)\} will end up +being the lower left corner of the figure and \courier{(1.5,3.5)\} will be +the upper right corner. You can use this option to ensure multiple figures +have the same scaling and same resulting figure size (just ensure the two +coordinates given to \courier{fixedscaling()\} leaves room for any labels). + +See also +\docref{https://asymptote.sourceforge.io/doc/Frames-and-pictures.html\}. + +\question 26jun:graphlimits How can I plot a function f(x) within [0,1]x[0,2] without explicitly calculating the x values for which f(x) hits the boundary? + +Call \courier{limits\} with the \courier{Crop\} option before drawing the graph: +\verbatim +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +limits((0,0),(1,2),Crop); + +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); +\endverbatim + +See also \docref{https://asymptote.sourceforge.io/doc/graph.html\}. + +\question 26jun:custompalettes Is it possible to define customized palettes? + +Yes, you may generate your own pen[] array. For example: + +\verbatim +int NColors=32768; +pen[] MyPalette=new pen[NColors]; +real step=1/(NColors-1.0); +// Start at black: rgb(0,0,0) +// End at yellow: rgb(1,1,0) +for(int i=0; i < NColors; ++i) { + real rgval=i*step; + MyPalette[i]=rgb(rgval,rgval,0.0); +} +\endverbatim + +\question 26jun:factorial Is there an easy way to graph factorial functions nicely? + +The example below shows a continuous function and two methods for placing +markers at integer values of x: + +\verbatim +import graph; + +size(200,200,IgnoreAspect); + +real factorial(real t) {return gamma(t+1);} + +scale(Linear,Log); + +// Graph the factorial function. +draw(graph(factorial,0,10)); + +// Method 1: Draw nodes, but hide line +pair F(int t) {return (t,factorial(t));} +// Graph of factorial function from 0 to 10 +pair[] z=sequence(F,11); +draw(graph(z),invisible,marker(scale(0.8mm)*unitcircle,blue,Fill)); + +// Method 2: Nongraphing routines require explicit scaling: +pair dotloc(int t) {return Scale(F(t));} +pair[] dotlocs=sequence(dotloc,11); +dot(dotlocs); + +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); +\endverbatim + +\question 26jun:length How do I indicate that a certain length should be exactly the size I prescribe with no rescaling, within a picture which has its own size? + +Here's an easy way to do this. + +\verbatim +size(12cm,0); + +void distance(picture pic=currentpicture, pair A, pair B, Label L="", real n=0, + pen p=currentpen) +{ + real d=3mm; + path g=A--B; + transform T=shift(-n*d*unit(B-A)*I); + pic.add(new void(frame f, transform t) { + picture opic; + path G=T*t*g; + draw(opic,Label(L,Center,UnFill(1)),G,p,Arrows(NoFill),Bars,PenMargins); + add(f,opic.fit()); + }); + pic.addBox(min(g),max(g),T*min(p),T*max(p)); +} + +pair A=(0,0), B=(3,3); + +dot(A); +dot(B); + +distance(A,B,"$\ell$",1); +\endverbatim + +\question 26jun:log2 How can I make the y axis display base-2 logarithmic values? + +See the example \docref{https://asymptote.sourceforge.io/gallery/2D graphs/log2graph.asy\}. + +\question 27jun:align How can I align the x axes of two graphs on the same figure? + +An easy way to do this, if the axes to be aligned have the same scaling +and size, is illustrated in the example \docref{https://asymptote.sourceforge.io/gallery/2D graphs/alignedaxis.asy\}. + +Here is a more general solution to the problem of aligning two arbitrary axes. +One fits the second picture to a frame based on the horizontal scaling for +the first picture: + +\verbatim +import graph; + +real width=15cm; +real aspect=0.3; + +picture pic1,pic2; + +size(pic1,width,aspect*width,IgnoreAspect); +size(pic2,width,aspect*width,IgnoreAspect); + +scale(pic1,false); +scale(pic2,false); + +real xmin1=6; +real xmax1=9; +real xmin2=8; +real xmax2=16; + +real a1=1; +real a2=0.001; + +real f1(real x) {return a1*sin(x/2*pi);} +real f2(real x) {return a2*sin(x/4*pi);} + +draw(pic1,graph(pic1,f1,xmin1,xmax1)); +draw(pic2,graph(pic2,f2,xmin2,xmax2)); + +xaxis(pic1,Bottom,LeftTicks()); +yaxis(pic1,"$f_1(x)$",Left,RightTicks); + +xaxis(pic2,"$x$",Bottom,LeftTicks(Step=4)); +yaxis(pic2,"$f_2(x)$",Left,RightTicks); + +yequals(pic1,0,Dotted); +yequals(pic2,0,Dotted); + +pair min1=point(pic1,SW); +pair max1=point(pic1,NE); + +pair min2=point(pic2,SW); +pair max2=point(pic2,NE); + +real scale=(max1.x-min1.x)/(max2.x-min2.x); +real shift=min1.x/scale-min2.x; + +transform t1=pic1.calculateTransform(); +transform t2=pic2.calculateTransform(); +transform T=xscale(scale*t1.xx)*yscale(t2.yy); + +add(pic1.fit()); +real height=truepoint(N,user=false).y-truepoint(S,user=false).y; +add(shift(0,-height)*(shift(shift)*pic2).fit(T)); +\endverbatim + +\question 27jun:changeaxis How can I change the direction of the y-axis, such that negatives values are on the upper y-axis? + +Here is a simple example (see also the example \docref{https://asymptote.sourceforge.io/gallery/2D graphs/diatom.asy\} or the discussion +of Linear(-1) in the documentation): + +\verbatim +import graph; +size(250,200,IgnoreAspect); + +scale(Linear,Linear(-1)); + +draw(graph(log,0.1,10),red); + +xaxis("$x$",LeftTicks); +yaxis("$y$",RightTicks); +\endverbatim + +\question 27jun:functioncolor How can I fill a path with a function that defines the color of each location? + +Use \courier{functionshade\} with a PDF tex engine, as illustrated +by the example {functionshading.asy}. + +If you want to produce PostScript output, an approximate solution for now +would be to superimpose a fine grid and specify colors to +\courier{latticeshade\} that depend on position as a single pen[][] +lattice. Alternatively, it may be more efficient to use \courier{tensorshade}. + +\question 27jun:nonexplicitfun Is there a way to draw a function that is not explicitly given, such as (y - 2)^2 = x - 1 ? + +Yes, use the parametric form + +\verbatim +y=t +x=(t-2)^2+1 +\endverbatim + +See the example \docref{https://asymptote.sourceforge.io/gallery/2D graphs/parametricgraph.asy\}. + +\question 27jun:scalesecondaryaxis Is it possible to reverse or stretch an axis? + +The real scaling argument to Linear is used to stretch (or reverse) the axis. +To see the effect of axis stretching, be sure not to specify IgnoreAspect in +the picture size command. + +A secondary axis has the same length as the primary axis, so stretching cannot +have any effect. But one can still reverse the axis, with Linear(-1). + +\question 02sep:emptymarkers Why can't I use the UnFill option to draw graphs with empty markers? + +UnFill won't work here because it only affects the local frame the markers +are initially drawn on, before being added to currentpicture. +Here is a way of achieving the desired effect (assuming a white background): + +\verbatim +import graph; +size(10cm,0); +pair[] z={(0,0),(0.5,0.5),(1,1)}; +path g=graph(z); + +draw(shift(0,.5)*g,marker(scale(5)*unitcircle,FillDraw(white))); + +xaxis(BottomTop,LeftTicks); +yaxis(LeftRight,RightTicks); +\endverbatim + +\question 02sep:paletterange How can I force several images to use the same palette range (e.g. the entire 0-255 grayscale range)? + +The palette color space corresponds to a range of values specified by the +argument range, which can be \courier{Full\}, \courier{Automatic\} or an +explicit range \courier{Range(pair min, pair max)\}. Here \courier{Full} +specifies a range varying from the minimum to maximum values of the +function over the sampling interval, while \courier{Automatic\} selects +"nice" limits. + +\comment ##################################################################### + +\section Questions about programming + +\question 27jun:comporint Is Asymptote an interpreter or a compiler? + +Asymptote compiles Asymptote commands into its own virtual machine code. It +then runs this pseudocode on a virtual machine to produce PostScript code. + +\question 05sep:framepicture What is the difference between a frame and a picture? + +Frames are canvases for drawing in PostScript coordinates. While working +with frames directly is occasionally necessary for constructing deferred +drawing routines, pictures are usually more convenient to work with. +See \qref unitsizes. + +\question 05sep:pathguide What is the difference between a path and a guide? + +A path is a cubic spline with fixed endpoint conditions. + +A guide is an unresolved cubic spline (list of cubic-spline nodes and +control points). A guide is like a path except that the computation of the cubic +spline is deferred until drawing time (when it is resolved into a path); +this allows two guides with free endpoint conditions to be joined together +smoothly. + +\question 27jun:picarray What is a convenient way to declare and initialize an array of pictures? + +You could write yourself a routine such as: +\verbatim +picture[] picture(int n) { + picture[] pic; + for(int i=0; i < n; ++i) { + pic[i]=new picture; + size(pic[i],19cm,0); + } + return pic; +} + +picture[] pic=picture(6); +\endverbatim + +\question 27jun:genarrays Is there a way to define functions that act on arrays in general (i.e. work for arrays of any type)? + +Generic types aren't yet implemented. + +But for now you can at least say +\verbatim +typedef string T; +include F; + +typedef real T; +include F; +\endverbatim + +where \courier{F.asy\} contains some type-dependent code like +\verbatim +T[] operator $(T A, T B) {return new T[] {A,B};} +\endverbatim + +\question 27jun:cirdep Is there any way to declare structures ahead of their definition, e.g. where struct A performs some operation on struct B, but B contains an A member? + +Asymptote does not support forward declaration of types. You can, however, +nest structures, so that both types are visible for parts of the bodies of +both structure definitions. For example: + +\verbatim +struct B { + typedef void someroutine(B b); + + static struct A { + someroutine routine; + void operator init(someroutine routine) { + this.routine=routine; + } + } + + string test="Testing"; +} + +typedef B.A A; + +A a=B.A(new void(B b){write(b.test);}); + +B b; +a.routine(b); +\endverbatim + +\question 04nov:static Where are static variables in for loops allocated? + +In the example + +\verbatim +void f() { + for(int i=0; i < 3; ++i) { + static int n; + ++n; + write(n); + } +} + +f(); // Writes 1, 2, 3 +\endverbatim + +the static qualifier means that \courier{n\} is allocated not just outside +of the for loop, but also outside the function. This is clear if you call +\courier{f\} multiple times; there is still only one instance of \courier{n\}. + +The "level" of a variable (where it is allocated) has nothing to do with +the "scope" of a variable (how long it can be referred to by name). +The curly braces enclosing a block affect only a variable's scope, not +its level. + +Static modifiers are meaningless at the top level; they generate a warning +and are simply ignored: + +\verbatim +for(int i=0; i < 3; ++i) { + static int n; + ++n; + write(n); +} +// Writes warning about top-level static modifier and then 1, 1, 1 +\endverbatim + +Since version 1.22, non-static variables allocated in a loop body are allocated +anew every iteration. This is only noticable in obscure cases where a variable +in a loop is accessed in the closure of a function defined in the loop: + +\verbatim +int f(); + +for(int i=0; i < 10; ++i) { + int j=10*i; + if(i == 5) + f=new int() {return j;}; +} + +write(f()); // Writes 50 +\endverbatim + +Variables in the body of a loop last as long as that iteration of the loop, +unless they are kept alive by a function closure as in the example above. In a +function body, variables will last at least as long as the function call, though +because of closures and garbage collection, they may last longer than that. If +defined at the top level of a file or at the interactive prompt, they will last +at least until the end of the file or prompt's run. + +\question 26jun:debug Is there a debugger for asy? + +Yes, Asymptote includes a line-based debugger: + +\docref{https://asymptote.sourceforge.io/doc/Debugger.html\} + +\question 27jun:patches Do you accept patches for Asymptote? + +Yes, in fact we would prefer that users submit patches for customized features +(to \docref{http://sourceforge.net/tracker/?atid=685685&group_id=120000\}) +instead of relying on us to do all of the coding. Development will proceed +faster that way. + +\comment ##################################################################### + +\section Questions about differences between Asymptote and MetaPost + +\question 29jun:interp What is the equivalent of the MetaPost c[a,b] interpolation operator? + +\verbatim +interp(a,b,c); +\endverbatim + +\question 02sep:automaticscaling How does picture scaling differ in Asymptote and MetaPost? + +Asymptote includes an optional facility to do automatic scaling of pictures +to achieve a given overall picture size, whereas Metapost only supports manual +scaling. Asymptote defers drawing of objects drawn to pictures and +distinguishes between true-size objects and objects that should scale with +the picture size. The resulting linear programming problem is solved via +the Simplex method. + +See the \docref{https://asymptote.sourceforge.io/gallery/dimension.asy\} example for an example of how deferred drawing is +used to accomodate both user and true-size (PostScript) coordinates. + +\question 02sep:manualscaling How can I avoid automatic scaling of a picture? + +If you really like Metapost-style manual (hard-wired) scaling either: + +(i) use the default size(0,0) for the entire picture and do all of the +scaling by hand, just like in MetaPost; + +(ii) draw to a separate picture pic and add(pic.fit()); + +(iii) use frames. + +\question 23jun:mp3dots What is the equivalent of MetaPost ... command? + +The connector \courier{::\} is a macro for tension atleast 1: + +\verbatim +size(100); +pair z0=(0,0); +pair z1=(1,0.25); +pair z2=(2,0); +draw(z0{up}::z1{right}::z2{down}); +\endverbatim + +\question 23jun:mppickup What is the equivalent of the MetaPost pickup command? + +Just say, for example: + +\verbatim +currentpen=red; +\endverbatim + +\question 29aug:whatever What is the equivalent of the MetaPost whatever command? + +Asymptote does not implicitly solve linear equations and therefore does not +have the notion of a \courier{whatever\} unknown. Such a facility could +certainly be added (perhaps using the notation \courier{?=\} since +\courier{=\} means assignment). +However, the most common uses of \courier{whatever\} in MetaPost are covered by +functions like \courier{extension\} in \courier{math.asy\}: +\verbatim +pair extension(pair P, pair Q, pair p, pair q); +\endverbatim +this returns the intersection point of the extensions of the line segments +\courier{PQ\} and \courier{pq\}. We find using routines like +\courier{extension\} more explicit and less confusing to new users. But we +could be persuaded to add something similar if someone can justify the +need. In the meantime, one can always use the explicit built-in linear +solver \courier{solve\} (see +\docref{https://asymptote.sourceforge.io/doc/solve.html\}), which uses LU +decomposition. + +\question 23jun:lray What is the equivalent for the MetaPost command for \courier{lray - horiz*v - verti*u = whatever*(LightSource - R)\}, a system of three linear equations for three unknowns: \courier{horiz, verti, whatever\}? + +Since \courier{horiz*v+verti*u\} spans a plane, you could use +\verbatim +real intersect(vector P, vector Q, vector n, vector Z); +\endverbatim + +to find the intersection time for the line +\courier{lray-whatever*(LightSource - R)\} +and then extract the three desired values from there. (You'll still need to +use the built-in explicit linear solver to solve a 2x2 system to get +\courier{horiz\} and \courier{verti\}.) + +\question 27jun:unitsizes In MetaPost, it is possible to have a drawing remain the same size in different pictures by defining a unit \courier{u\} and explicitly multiply all the coordinates by \courier{u\}. Is there a better way to do this in Asymptote? + +Yes, Asymptote has a better way: you definitely don't want to manually scale +all of your coordinates. To make the user coordinates represent multiples +of exactly \courier{1cm\}: + +\verbatim +unitsize(1cm); +draw(unitsquare); +\endverbatim + +One can also specify different x and y unit sizes: + +\verbatim +unitsize(x=1cm,y=2cm); +draw(unitsquare); +\endverbatim + +Another way is to draw your fixed size object to a frame and add it to +currentpicture like this: + +\verbatim +path p=(0,0)--(1,0); +frame object; +draw(object,scale(100)*p); + +add(object); +add(object,(0,-10)); +\endverbatim + +To understand the difference between frames and pictures, try this: + +\verbatim +size(300,300); + +path p=(0,0)--(1,0); +picture object; +draw(object,scale(100)*p); + +add(object); +add(object,(0,-10)); // Adds truesize object to currentpicture +\endverbatim + +\question 28jun:tiles In MetaPost, one could produce tiling pictures by generating a picture, and then clipping the picture to a rectangle of fixed dimensions around the center of the picture. How is that done in Asymptote? + +If you are using currentpicture the way one would in MetaPost (drawing in +raw PostScript coordinates), you can simply do something like: + +\verbatim +fill((0,0)--(100,100)--(200,0)--cycle); + +pair center(picture pic=currentpicture) {return 0.5*(pic.min()+pic.max());} + +real height=100; +real width=100; +pair delta=0.5(width,height); +pair c=center(); +clip(box(c-delta,c+delta)); +\endverbatim + +However, drawing in PostScript coordinates is often inconvenient. Here's the +Asymptote way of doing the same thing, using deferred drawing: + +\verbatim +size(200,100); +fill((0,0)--(1,1)--(2,0)--cycle); + +void clip(picture pic=currentpicture, real width, real height) +{ + pic.clip(new void (frame f, transform) { + pair center=0.5(min(f)+max(f)); + pair delta=0.5(width,height); + clip(f,box(center-delta,center+delta)); + }); +} + +clip(100,100); +\endverbatim + +See also the discussion of tilings in the documentation: +\docref{https://asymptote.sourceforge.io/doc/Pens.html\}. + +\comment ###################################################################### + +\section Questions about output + +\question 27jun:psviewer How can I disable automatic invocation of the PS viewer after an asy file is done processing? + +It's actually not on by default, unless you happen to be using Microsoft +Windows (because that is what most Microsoft Windows users +expect). Microsoft Windows users can turn this feature off with the +command-line option -noV or by putting + +\verbatim +import settings; +interactiveView=false; +batchView=false; +\endverbatim + +in their \courier{config.asy\} file. See +\docref{https://asymptote.sourceforge.io/doc/Options.html\}. + +\question 26jun:jpeg How do I output jpeg images? + +If you have the ImageMagick convert program installed, simply type + +\verbatim +asy -f jpg test.asy +\endverbatim + +\question 27jun:embedbitmaps Can I embed bitmaps (photos) into my drawings and position and scale them? + +Convert them to eps format and use the graphic(string) function just like a +Label: + +\verbatim +label(graphic("file"),(0,0)); +\endverbatim + +See the example \docref{https://asymptote.sourceforge.io/gallery/orthocenter.asy\} and +\docref{https://asymptote.sourceforge.io/doc/label.html\}. + +\question 28jun:directpdf Does Asymptote support direct PDF output? + +Yes, PDF output can be produced by the -f pdf option or -tex pdflatex option. +This supports transparency, annotations, embedded movies, and U3D/PRC content. + +\question 28jun:bigpictures How to I produce large pictures of high quality in raster format (e.g. png, giff etc). + +Try using some of the options to convert, mainly -geometry and -density. For example: +\verbatim +convert -geometry 1000x3000 example.eps example.png +\endverbatim + +You can also change the default resolution of the image with: +\verbatim +convert -geometry 1000x3000 -density 300 -units PixelsPerInch example.eps example.png +\endverbatim +This does not change the number of pixels in the image, but just gives a hint +as to how large each pixel should be displayed. + +If you include the -density option without the -geometry option, convert will +keep the image size constant (so a 4cm x 3cm eps figure will generate a 4cm x +3cm png +image). + +\question 28jun:multipage Is it possible to produce multi-page documents with asymptote? + +Yes, simply call the newpage() function. This is used by the +\courier{slide.asy\} package to produce high-quality slide presentations +(easier to use than Prosper). + +\comment Here it ends! diff --git a/Build/source/utils/asymptote/doc/FAQ/asy-faq.info b/Build/source/utils/asymptote/doc/FAQ/asy-faq.info new file mode 100644 index 00000000000..dc69d1917e7 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/asy-faq.info @@ -0,0 +1,1671 @@ +Info file: asy-faq.info, -*-Text-*- +produced by bfnnconv.pl from the Bizarre Format With No Name. + +INFO-DIR-SECTION Languages +START-INFO-DIR-ENTRY +* asymptote FAQ: (asy-faq). Asymptote Frequently Asked Questions. +END-INFO-DIR-ENTRY + + +File: asy-faq.info, Node: Top, Next: Question 1.1, Up: (dir) + + ASYMPTOTE FREQUENTLY ASKED QUESTIONS + 2021-02-19 + +This is the list of Frequently Asked Questions about Asymptote (asy). + +Index + +* Menu: +* Section 1:: About Asymptote +* Section 2:: Questions about installation and setup +* Section 3:: Questions about paths +* Section 4:: Questions about labels +* Section 5:: Questions about arrows +* Section 6:: Questions about 2D graphs +* Section 7:: Questions about programming +* Section 8:: Questions about differences between Asymptote and + MetaPost +* Section 9:: Questions about output + +Section 1, About Asymptote +* Question 1.1:: What is Asymptote? +* Question 1.2:: How do I obtain Asymptote? +* Question 1.3:: Where can I ask questions about Asymptote? +* Question 1.4:: Why was the name Asymptote chosen? +* Question 1.5:: In the internal Asymptote source code, what does the + name camp refer to? + +Section 2, Questions about installation and setup +* Question 2.1:: Is it possible to install Asymptote on Mac OS X? +* Question 2.2:: Why do I get the error Bad CPU type in executable on + installing Asymptote from the MAC OS binary? +* Question 2.3:: What do I do if I get the error: Error: pdfetex (file + pdftex.cfg): cannot open config file...texinfo.tex + appears to be broken? +* Question 2.4:: What do I do if I get the error: ! Undefined control + sequence. l.6 @copying? +* Question 2.5:: Is it possible to integrate Asymptote into LaTeX? +* Question 2.6:: Is it possible to integrate Asymptote into latex or + pdflatex? +* Question 2.7:: Do I need the tkinter package to install an Asymptote + rpm binary? +* Question 2.8:: What does the path %USERPROFILE%\.asy\config.asy mean? +* Question 2.9:: Why do I get the error "string not terminated" when I + try to set settings.dir="C:\asymptote\";? +* Question 2.10:: How do I change environment variables in Microsoft + Windows, for example, in order to change the default + PostScript viewer? +* Question 2.11:: Under Microsoft Windows XP, why do I get an error like + "Invalid Parameter - 432x432"? +* Question 2.12:: Why does Asymptote freeze upon trying to draw a label + with my MikTex installation under Microsoft Windows? + +Section 3, Questions about paths +* Question 3.1:: Why do I get a syntax error message when I specify an + integer value for the path tension? +* Question 3.2:: Shouldn't dots always be the same size? + +Section 4, Questions about labels +* Question 4.1:: How do I get Greek letters like omega to show up in my + labels? +* Question 4.2:: Can Asymptote use matrices as labels? +* Question 4.3:: How do I tell Asymptote to load a particular LaTeX + package, like mathptmx? +* Question 4.4:: How can I use international fonts in Asymptote labels? +* Question 4.5:: How can I use Fourier fonts? +* Question 4.6:: Is there any way to change the default appearance of + the decimal separator, using a comma instead of a dot? +* Question 4.7:: How can I get a rotated label with the filled box + rotated as well so that it fits the text? +* Question 4.8:: How can I rotate labels in a 3D figure? +* Question 4.9:: How can I draw some squares and circles of a fixed + size and put a label in the middle of them? +* Question 4.10:: The binary operator * can be used to scale the color + of a pen by a real number. Does this scaling factor + have to be less than 1? +* Question 4.11:: Why is the space after the comma decimal separator in + my locale so large? +* Question 4.12:: How can I prevent + texpreamble("\usepackage[pdftex]{hyperref}") from + changing the page size? + +Section 5, Questions about arrows +* Question 5.1:: How do I draw two arrows at arbitrary positions along + a path? +* Question 5.2:: How do I reverse the direction of an arrowhead? +* Question 5.3:: How do I change the size of all arrows? +* Question 5.4:: Can I create other arrowhead styles? + +Section 6, Questions about 2D graphs +* Question 6.1:: How can I draw x axis ticks on the right side, with + the tick labels on the left side (relative to the axis + path)? +* Question 6.2:: How can I reposition the x axis label to + three-quarters along the axis length? +* Question 6.3:: How can I move the x axis label down 10bp? +* Question 6.4:: Can I use different pens for the axis, the axis label, + and the tick labels? +* Question 6.5:: How can I change the font type of the axes label? +* Question 6.6:: How can I change the font type of the tick labels on + an axis? +* Question 6.7:: How can I prevent axes tick labels from rendering on + top of each other? +* Question 6.8:: How do I make the plot region of a graph, ignoring + labels and legends, have a fixed size? +* Question 6.9:: How can I plot a function f(x) within [0,1]x[0,2] + without explicitly calculating the x values for which + f(x) hits the boundary? +* Question 6.10:: Is it possible to define customized palettes? +* Question 6.11:: Is there an easy way to graph factorial functions + nicely? +* Question 6.12:: How do I indicate that a certain length should be + exactly the size I prescribe with no rescaling, within + a picture which has its own size? +* Question 6.13:: How can I make the y axis display base-2 logarithmic + values? +* Question 6.14:: How can I align the x axes of two graphs on the same + figure? +* Question 6.15:: How can I change the direction of the y-axis, such + that negatives values are on the upper y-axis? +* Question 6.16:: How can I fill a path with a function that defines the + color of each location? +* Question 6.17:: Is there a way to draw a function that is not + explicitly given, such as (y - 2)^2 = x - 1 ? +* Question 6.18:: Is it possible to reverse or stretch an axis? +* Question 6.19:: Why can't I use the UnFill option to draw graphs with + empty markers? +* Question 6.20:: How can I force several images to use the same palette + range (e.g. the entire 0-255 grayscale range)? + +Section 7, Questions about programming +* Question 7.1:: Is Asymptote an interpreter or a compiler? +* Question 7.2:: What is the difference between a frame and a picture? +* Question 7.3:: What is the difference between a path and a guide? +* Question 7.4:: What is a convenient way to declare and initialize an + array of pictures? +* Question 7.5:: Is there a way to define functions that act on arrays + in general (i.e. work for arrays of any type)? +* Question 7.6:: Is there any way to declare structures ahead of their + definition, e.g. where struct A performs some + operation on struct B, but B contains an A member? +* Question 7.7:: Where are static variables in for loops allocated? +* Question 7.8:: Is there a debugger for asy? +* Question 7.9:: Do you accept patches for Asymptote? + +Section 8, Questions about differences between Asymptote and + MetaPost +* Question 8.1:: What is the equivalent of the MetaPost c[a,b] + interpolation operator? +* Question 8.2:: How does picture scaling differ in Asymptote and + MetaPost? +* Question 8.3:: How can I avoid automatic scaling of a picture? +* Question 8.4:: What is the equivalent of MetaPost ... command? +* Question 8.5:: What is the equivalent of the MetaPost pickup command? +* Question 8.6:: What is the equivalent of the MetaPost whatever + command? +* Question 8.7:: What is the equivalent for the MetaPost command for + lray - horiz*v - verti*u = whatever*(LightSource - R), + a system of three linear equations for three unknowns: + horiz, verti, whatever? +* Question 8.8:: In MetaPost, it is possible to have a drawing remain + the same size in different pictures by defining a unit + u and explicitly multiply all the coordinates by u. Is + there a better way to do this in Asymptote? +* Question 8.9:: In MetaPost, one could produce tiling pictures by + generating a picture, and then clipping the picture to + a rectangle of fixed dimensions around the center of + the picture. How is that done in Asymptote? + +Section 9, Questions about output +* Question 9.1:: How can I disable automatic invocation of the PS + viewer after an asy file is done processing? +* Question 9.2:: How do I output jpeg images? +* Question 9.3:: Can I embed bitmaps (photos) into my drawings and + position and scale them? +* Question 9.4:: Does Asymptote support direct PDF output? +* Question 9.5:: How to I produce large pictures of high quality in + raster format (e.g. png, giff etc). +* Question 9.6:: Is it possible to produce multi-page documents with + asymptote? + + + +File: asy-faq.info, Node: Section 1, Next: Section 2, Previous: Top, Up: Top + +About Asymptote + +* Menu: +* Question 1.1:: What is Asymptote? +* Question 1.2:: How do I obtain Asymptote? +* Question 1.3:: Where can I ask questions about Asymptote? +* Question 1.4:: Why was the name Asymptote chosen? +* Question 1.5:: In the internal Asymptote source code, what does the + name camp refer to? + + + +File: asy-faq.info, Node: Question 1.1, Next: Question 1.2, Previous: Top, Up: Section 1 + +Question 1.1. What is Asymptote? + +Asymptote is a vector graphics language designed for technical graphics, +inspired by MetaPost but with IEEE floating-point numerics, native +three-dimensional graphics, Grayscale/RGB/CMYK colourspaces, and a +C++-like syntax. Unlike MetaPost, it natively supports multiple-segment +paths (and hence regions other than simply connected ones), tiling +patterns, Gouraud shading, tensor patch shading, and PostScript images. + + +File: asy-faq.info, Node: Question 1.2, Next: Question 1.3, Previous: Question 1.1, Up: Section 1 + +Question 1.2. How do I obtain Asymptote? + +Binary releases are available for Linux, MacOS X, and Microsoft Windows +platforms, in addition to full source code, from the website +https://asymptote.sourceforge.io/. Many Linux distributions (such as +RedHat and Debian) now include an Asymptote package (check your +distribution's documentation for further information about this). + + +File: asy-faq.info, Node: Question 1.3, Next: Question 1.4, Previous: Question 1.2, Up: Section 1 + +Question 1.3. Where can I ask questions about Asymptote? + +If you have a question, please try to find an answer in this FAQ, in the +extensive Asymptote documentation at +https://asymptote.sourceforge.io/doc/, or search the forum: +http://sourceforge.net/forum/forum.php?forum_id=409349. + + +File: asy-faq.info, Node: Question 1.4, Next: Question 1.5, Previous: Question 1.3, Up: Section 1 + +Question 1.4. Why was the name Asymptote chosen? + +Well, it isn't the perfect graphics package, but we do think it is getting +there asymptotically... + + +File: asy-faq.info, Node: Question 1.5, Next: Question 2.1, Previous: Question 1.4, Up: Section 1 + +Question 1.5. In the internal Asymptote source code, what does the name camp refer to? + +That was our original tentative name for this project, which stood for +"C's Answer to MetaPost" (the language that inspired Asymptote). However, +we eventually decided that the name Asymptote better emphasizes the +mathematical and graphical nature of this language. + + +File: asy-faq.info, Node: Section 2, Next: Section 3, Previous: Section 1, Up: Top + +Questions about installation and setup + +* Menu: +* Question 2.1:: Is it possible to install Asymptote on Mac OS X? +* Question 2.2:: Why do I get the error Bad CPU type in executable on + installing Asymptote from the MAC OS binary? +* Question 2.3:: What do I do if I get the error: Error: pdfetex (file + pdftex.cfg): cannot open config file...texinfo.tex + appears to be broken? +* Question 2.4:: What do I do if I get the error: ! Undefined control + sequence. l.6 @copying? +* Question 2.5:: Is it possible to integrate Asymptote into LaTeX? +* Question 2.6:: Is it possible to integrate Asymptote into latex or + pdflatex? +* Question 2.7:: Do I need the tkinter package to install an Asymptote + rpm binary? +* Question 2.8:: What does the path %USERPROFILE%\.asy\config.asy mean? +* Question 2.9:: Why do I get the error "string not terminated" when I + try to set settings.dir="C:\asymptote\";? +* Question 2.10:: How do I change environment variables in Microsoft + Windows, for example, in order to change the default + PostScript viewer? +* Question 2.11:: Under Microsoft Windows XP, why do I get an error like + "Invalid Parameter - 432x432"? +* Question 2.12:: Why does Asymptote freeze upon trying to draw a label + with my MikTex installation under Microsoft Windows? + + + +File: asy-faq.info, Node: Question 2.1, Next: Question 2.2, Previous: Question 1.5, Up: Section 2 + +Question 2.1. Is it possible to install Asymptote on Mac OS X? + +It is easy to compile Asymptote directly from the source code at +http://sourceforge.net/project/showfiles.php?group_id=120000 We recommend +first upgrading to the latest GNU readline library, unless you don't care +about interactive readline support (in which case configure will +automatically detect and disable obsolete versions of the readline +library). Marius Schamschula also maintains a binary package for various +MacOS X platforms +http://www.hmug.org/pub/MacOS_X/X/Applications/Publishing/asymptote. + + +File: asy-faq.info, Node: Question 2.2, Next: Question 2.3, Previous: Question 2.1, Up: Section 2 + +Question 2.2. Why do I get the error Bad CPU type in executable on installing Asymptote from the MAC OS binary? + +This means either that you have a binary distribution for another MAC +architecture, or (according to Marius Schamschula) that you may have a +missing library. The simplest solution is to compile Asymptote directly +from the official source: +http://sourceforge.net/project/showfiles.php?group_id=120000. + + +File: asy-faq.info, Node: Question 2.3, Next: Question 2.4, Previous: Question 2.2, Up: Section 2 + +Question 2.3. What do I do if I get the error: Error: pdfetex (file pdftex.cfg): cannot open config file...texinfo.tex appears to be broken? + +Simply put https://asymptote.sourceforge.io/asymptote.pdf in the directory +doc and repeat the command make all. Or, if you don't want to build a +local copy of the documentation, simply proceed with make install-asy. + + +File: asy-faq.info, Node: Question 2.4, Next: Question 2.5, Previous: Question 2.3, Up: Section 2 + +Question 2.4. What do I do if I get the error: ! Undefined control sequence. l.6 @copying? + +Either upgrade your texinfo package or follow one of the easy work arounds +in *Note Question 2.3:: `What do I do if I get the error: Error: pdfetex +(file pdftex.cfg): cannot open config file...texinfo.tex appears to be +broken?'. + + +File: asy-faq.info, Node: Question 2.5, Next: Question 2.6, Previous: Question 2.4, Up: Section 2 + +Question 2.5. Is it possible to integrate Asymptote into LaTeX? + +Yes, see the example latexusage.tex. Dario Teixeira has also written a +detailed guide on the topic. You can download it from +http://dario.dse.nl/projects/asylatex/. + +Philippe Ivaldi has contributed an Asymptote mode for Emacs users +https://asymptote.sourceforge.io/doc/Editing-modes.html, which includes a +lasy-mode that allows one to compile and view the output of one +\begin{asy}...\end{asy} section at a time. + + +File: asy-faq.info, Node: Question 2.6, Next: Question 2.7, Previous: Question 2.5, Up: Section 2 + +Question 2.6. Is it possible to integrate Asymptote into latex or pdflatex? + +Yes, as of version 1.14, Asymptote supports latex and pdflatex (both in +EPS/PDF and inline mode), as illustrated by the example latexusage.tex: + +pdflatex latexusage +asy latexusage +pdflatex latexusage + +File: asy-faq.info, Node: Question 2.7, Next: Question 2.8, Previous: Question 2.6, Up: Section 2 + +Question 2.7. Do I need the tkinter package to install an Asymptote rpm binary? + +No, you don't need tkinter unless you want to try out the GUI xasy. Try + +rpm -Uvh --nodeps asymptote-x.xx-1.i386.rpm +where x.xx represents the version number. + + +File: asy-faq.info, Node: Question 2.8, Next: Question 2.9, Previous: Question 2.7, Up: Section 2 + +Question 2.8. What does the path %USERPROFILE%\.asy\config.asy mean? + +That is the way that Microsoft Windows refers to the user profile +directory. There's nothing really to understand here, just put your +configuration commands in the file config.asy in a new folder +%USERPROFILE%\.asy. + + +File: asy-faq.info, Node: Question 2.9, Next: Question 2.10, Previous: Question 2.8, Up: Section 2 + +Question 2.9. Why do I get the error "string not terminated" when I try to set settings.dir="C:\asymptote\";? + +The backslash is an escape character here, so \" is interpreted as a +verbatim quotation mark, leaving the string without a terminating +quotation mark. Fortunately, this is the only escaped character in +double-quoted strings. A final backslash isn't needed here anyway, but +should you really want one somewhere, you can say: +settings.dir="C:\asymptote"+'\\';. + + +File: asy-faq.info, Node: Question 2.10, Next: Question 2.11, Previous: Question 2.9, Up: Section 2 + +Question 2.10. How do I change environment variables in Microsoft Windows, for example, in order to change the default PostScript viewer? + +While it is easier to set the corresponding Asymptote configuration +variable in your config.asy file, here is the procedure for changing +Microsoft Windows environment variables: + +Click on the [Start] button + +* RIGHT-click on 'My Computer' + +* Choose 'Properties' from the popup menu + +* Click the 'Advanced' tab + +* Click the 'Environment Variables' button. + + +File: asy-faq.info, Node: Question 2.11, Next: Question 2.12, Previous: Question 2.10, Up: Section 2 + +Question 2.11. Under Microsoft Windows XP, why do I get an error like "Invalid Parameter - 432x432"? + +This means that ImageMagick wasn't properly installed and you are using +the MSDOS convert program rather than the ImageMagick one. Or you may have +installed ImageMagick but ran Asymptote from an existing MSDOS window. In +that case, simply open a new window and try again. If that doesn't work, +check that + +convert --version +returns something like + +Version: ImageMagick 6.2.8 06/27/06 Q16 http://www.imagemagick.org + +File: asy-faq.info, Node: Question 2.12, Next: Question 3.1, Previous: Question 2.11, Up: Section 2 + +Question 2.12. Why does Asymptote freeze upon trying to draw a label with my MikTex installation under Microsoft Windows? + +Likely, this means that latex and dvips are not in your default path. Try +adding the appropriate paths in your config.asy file, for example: + +import settings; +latex="C:\Program Files\MiKTeX 2.7\miktex\bin\latex.exe"; +dvips="C:\Program Files\MiKTeX 2.7\miktex\bin\dvips.exe"; + +File: asy-faq.info, Node: Section 3, Next: Section 4, Previous: Section 2, Up: Top + +Questions about paths + +* Menu: +* Question 3.1:: Why do I get a syntax error message when I specify an + integer value for the path tension? +* Question 3.2:: Shouldn't dots always be the same size? + + + +File: asy-faq.info, Node: Question 3.1, Next: Question 3.2, Previous: Question 2.12, Up: Section 3 + +Question 3.1. Why do I get a syntax error message when I specify an integer value for the path tension? + +What is happening here is that + +draw((0,0)..tension 2..(0,50)..(100,100)); +is read as + +draw((0,0)..tension 2. .(0,50)..(100,100)); +So the first . after the two is treated as a decimal point. Just put a +space after the integer tension value: + +draw((0,0)..tension 2 ..(0,50)..(100,100)); + +File: asy-faq.info, Node: Question 3.2, Next: Question 4.1, Previous: Question 3.1, Up: Section 3 + +Question 3.2. Shouldn't dots always be the same size? + +From the documentation: + +"The dot command defined in the module plain draws a dot having a diameter +equal to an explicit pen linewidth or the default linewidth magnified by +dotfactor (6 by default)." + +Thus, when you use the default pen, the dot will have size 6*linewidth, +but when you give a pen with an explicit width specified, you will have a +dot of size linewidth. If you want the first case to behave like the +second, you may set dotfactor=1. + + +File: asy-faq.info, Node: Section 4, Next: Section 5, Previous: Section 3, Up: Top + +Questions about labels + +* Menu: +* Question 4.1:: How do I get Greek letters like omega to show up in my + labels? +* Question 4.2:: Can Asymptote use matrices as labels? +* Question 4.3:: How do I tell Asymptote to load a particular LaTeX + package, like mathptmx? +* Question 4.4:: How can I use international fonts in Asymptote labels? +* Question 4.5:: How can I use Fourier fonts? +* Question 4.6:: Is there any way to change the default appearance of + the decimal separator, using a comma instead of a dot? +* Question 4.7:: How can I get a rotated label with the filled box + rotated as well so that it fits the text? +* Question 4.8:: How can I rotate labels in a 3D figure? +* Question 4.9:: How can I draw some squares and circles of a fixed + size and put a label in the middle of them? +* Question 4.10:: The binary operator * can be used to scale the color + of a pen by a real number. Does this scaling factor + have to be less than 1? +* Question 4.11:: Why is the space after the comma decimal separator in + my locale so large? +* Question 4.12:: How can I prevent + texpreamble("\usepackage[pdftex]{hyperref}") from + changing the page size? + + + +File: asy-faq.info, Node: Question 4.1, Next: Question 4.2, Previous: Question 3.2, Up: Section 4 + +Question 4.1. How do I get Greek letters like omega to show up in my labels? + +In (La)TeX, Greek letters can be obtained in math mode by prepending a +backslash to the letter name. So for a omega symbol, use "$\omega$". +Everything between the dollar signs is considered to be a math formula. +Uppercase Greek letters can be used by capitalizing the first letter of +the name: + +label("$\omega$",(0,0)); +label("$\Omega$",(20,0)); + +File: asy-faq.info, Node: Question 4.2, Next: Question 4.3, Previous: Question 4.1, Up: Section 4 + +Question 4.2. Can Asymptote use matrices as labels? + +Yes: +usepackage("amsmath"); +label("$\begin{matrix} 1 & 2 \\\ 1 & 1 \end{matrix}$",(0,0)); + +File: asy-faq.info, Node: Question 4.3, Next: Question 4.4, Previous: Question 4.2, Up: Section 4 + +Question 4.3. How do I tell Asymptote to load a particular LaTeX package, like mathptmx? + +Put + +usepackage("mathptmx"); +at the beginning of your file. Note: to enable the Adobe Times Roman font +for text, you will also need to say: +defaultpen(TimesRoman()); + +File: asy-faq.info, Node: Question 4.4, Next: Question 4.5, Previous: Question 4.3, Up: Section 4 + +Question 4.4. How can I use international fonts in Asymptote labels? + +See https://asymptote.sourceforge.io/doc/Pens.html. + + +File: asy-faq.info, Node: Question 4.5, Next: Question 4.6, Previous: Question 4.4, Up: Section 4 + +Question 4.5. How can I use Fourier fonts? + +usepackage("fourier"); +defaultpen(font("T1","fut\textfamilyextension","m","n")); + +File: asy-faq.info, Node: Question 4.6, Next: Question 4.7, Previous: Question 4.5, Up: Section 4 + +Question 4.6. Is there any way to change the default appearance of the decimal separator, using a comma instead of a dot? + +Just set your locale appropriately: + +locale("it_IT"); +usepackage("icomma"); +label(format(0.5)); + +File: asy-faq.info, Node: Question 4.7, Next: Question 4.8, Previous: Question 4.6, Up: Section 4 + +Question 4.7. How can I get a rotated label with the filled box rotated as well so that it fits the text? + +frame f; +label(f,"This is some text",white,Fill(blue)); +add(rotate(65)*f); + +File: asy-faq.info, Node: Question 4.8, Next: Question 4.9, Previous: Question 4.7, Up: Section 4 + +Question 4.8. How can I rotate labels in a 3D figure? + +You need to first project the triple to a pair like this: + +import three; +size(100,100); + +draw(rotate(90,project(Z))*"A",O--X); + +File: asy-faq.info, Node: Question 4.9, Next: Question 4.10, Previous: Question 4.8, Up: Section 4 + +Question 4.9. How can I draw some squares and circles of a fixed size and put a label in the middle of them? + +Fixed-size objects should be drawn on a separate picture and then added to +currentpicture. Here is one way (see also +https://asymptote.sourceforge.io/gallery/subpictures.asy and +https://asymptote.sourceforge.io/gallery/mosquito.asy): + +real u=2cm; + +picture square; +draw(square,scale(u)*shift(-0.5,-0.5)*unitsquare); + +picture circle; +draw(circle,scale(0.5u)*unitcircle); + +void add(picture pic=currentpicture, Label L, picture object, pair z) { +add(pic,object,z); +label(pic,L,z); +} + +add("square",square,(0,0)); +add("circle",circle,(5cm,0)); + +File: asy-faq.info, Node: Question 4.10, Next: Question 4.11, Previous: Question 4.9, Up: Section 4 + +Question 4.10. The binary operator * can be used to scale the color of a pen by a real number. Does this scaling factor have to be less than 1? + +The scaling factor can be greater than 1. But keep in mind that the rgb +color components saturate at 1. + +Try +write(cyan); write(0.8*cyan); write(1.5*cyan); +and you will quickly see what is going on. + +To get a lighter cyan you can say white+cyan, which yields rgb(0.5,1,1). +If you want something even lighter specify the rgb colors directly, for +example, rgb(0.9,1,1). + +Alternatively, work in cmyk colour space, which is nicer in that it +handles saturation separately from hue: + +0.1*Cyan is light and 0.9*Cyan is dark. You can also say 0.1*cmyk(red). + + +File: asy-faq.info, Node: Question 4.11, Next: Question 4.12, Previous: Question 4.10, Up: Section 4 + +Question 4.11. Why is the space after the comma decimal separator in my locale so large? + +LaTeX is treating the comma as punctuation and not as a decimal separator. +The solution is to load the icomma package near the beginning of your +file: +usepackage("icomma"); + +File: asy-faq.info, Node: Question 4.12, Next: Question 5.1, Previous: Question 4.11, Up: Section 4 + +Question 4.12. How can I prevent texpreamble("\usepackage[pdftex]{hyperref}") from changing the page size? + +texpreamble("\usepackage[pdftex,setpagesize=false]{hyperref}"); + +File: asy-faq.info, Node: Section 5, Next: Section 6, Previous: Section 4, Up: Top + +Questions about arrows + +* Menu: +* Question 5.1:: How do I draw two arrows at arbitrary positions along + a path? +* Question 5.2:: How do I reverse the direction of an arrowhead? +* Question 5.3:: How do I change the size of all arrows? +* Question 5.4:: Can I create other arrowhead styles? + + + +File: asy-faq.info, Node: Question 5.1, Next: Question 5.2, Previous: Question 4.12, Up: Section 5 + +Question 5.1. How do I draw two arrows at arbitrary positions along a path? + +Assuming that at least one of the arrowheads is to be filled, you can do +this: + +size(200); +path g = (0,0)..(1,3)..(3,0); +draw(g,Arrow(Relative(0.9))); +add(arrow(g,invisible,FillDraw(black),Relative(0.5))); +add(arrow(reverse(g),invisible,FillDraw(white,black),Relative(0.9))); +If both of the arrowheads are to be drawn with filltype NoFill, one will +need to create a specialized version of the arrow routine in +plain_arrows.asy: + +void arrow(frame f, arrowhead arrowhead=DefaultHead, + path g, pen p=currentpen, real size=0, + real angle=arrowangle, filltype filltype=arrowhead.defaultfilltype, + position position=EndPoint, bool forwards=true, + margin margin=NoMargin, bool center=false); + +File: asy-faq.info, Node: Question 5.2, Next: Question 5.3, Previous: Question 5.1, Up: Section 5 + +Question 5.2. How do I reverse the direction of an arrowhead? + +Simply reverse the direction of the path. + +path g=((0,0)--(5cm,0)); +draw(reverse(g),Arrow(Relative(0.55))); + +File: asy-faq.info, Node: Question 5.3, Next: Question 5.4, Previous: Question 5.2, Up: Section 5 + +Question 5.3. How do I change the size of all arrows? + +To override the arrowsize you can give every Arrow drawing attribute a +real size argument. If you want to do this globally, you can override the +pen-dependent arrowsize function like this: + +DefaultHead.size=new real(pen p=currentpen) {return 2mm;}; + +File: asy-faq.info, Node: Question 5.4, Next: Question 6.1, Previous: Question 5.3, Up: Section 5 + +Question 5.4. Can I create other arrowhead styles? + +Yes, you can build custom arrowheads like this (see the predefined +arrowhead styles in plain_arrows.asy for further examples): + +arrowhead DotHead; +DotHead.head=new path(path g, position position=EndPoint, pen p=currentpen, + real size=0, real angle=arrowangle) { + if(size == 0) size=DotHead.size(p); + bool relative=position.relative; + real position=position.position.x; + if(relative) position=reltime(g,position); + path r=subpath(g,position,0); + pair x=point(r,0); + real t=arctime(r,size); + pair y=point(r,t); + return circle(0.5(x+y),0.5size); +}; + +size(100); +draw((0,0)..(1,1)..(2,0),Arrow(DotHead)); +dot((2,0),red); +If you submit your alternate arrowheads to the Forum or the Patch +Tracking System, we'll consider including them in a future release. + + +File: asy-faq.info, Node: Section 6, Next: Section 7, Previous: Section 5, Up: Top + +Questions about 2D graphs + +* Menu: +* Question 6.1:: How can I draw x axis ticks on the right side, with + the tick labels on the left side (relative to the axis + path)? +* Question 6.2:: How can I reposition the x axis label to + three-quarters along the axis length? +* Question 6.3:: How can I move the x axis label down 10bp? +* Question 6.4:: Can I use different pens for the axis, the axis label, + and the tick labels? +* Question 6.5:: How can I change the font type of the axes label? +* Question 6.6:: How can I change the font type of the tick labels on + an axis? +* Question 6.7:: How can I prevent axes tick labels from rendering on + top of each other? +* Question 6.8:: How do I make the plot region of a graph, ignoring + labels and legends, have a fixed size? +* Question 6.9:: How can I plot a function f(x) within [0,1]x[0,2] + without explicitly calculating the x values for which + f(x) hits the boundary? +* Question 6.10:: Is it possible to define customized palettes? +* Question 6.11:: Is there an easy way to graph factorial functions + nicely? +* Question 6.12:: How do I indicate that a certain length should be + exactly the size I prescribe with no rescaling, within + a picture which has its own size? +* Question 6.13:: How can I make the y axis display base-2 logarithmic + values? +* Question 6.14:: How can I align the x axes of two graphs on the same + figure? +* Question 6.15:: How can I change the direction of the y-axis, such + that negatives values are on the upper y-axis? +* Question 6.16:: How can I fill a path with a function that defines the + color of each location? +* Question 6.17:: Is there a way to draw a function that is not + explicitly given, such as (y - 2)^2 = x - 1 ? +* Question 6.18:: Is it possible to reverse or stretch an axis? +* Question 6.19:: Why can't I use the UnFill option to draw graphs with + empty markers? +* Question 6.20:: How can I force several images to use the same palette + range (e.g. the entire 0-255 grayscale range)? + + + +File: asy-faq.info, Node: Question 6.1, Next: Question 6.2, Previous: Question 5.4, Up: Section 6 + +Question 6.1. How can I draw x axis ticks on the right side, with the tick labels on the left side (relative to the axis path)? + +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis("$x$",RightTicks(Label(align=left))); +yaxis("$y$",RightTicks); + +File: asy-faq.info, Node: Question 6.2, Next: Question 6.3, Previous: Question 6.1, Up: Section 6 + +Question 6.2. How can I reposition the x axis label to three-quarters along the axis length? + +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis(Label("$x$",0.75),LeftTicks); +yaxis("$y$",RightTicks); + +File: asy-faq.info, Node: Question 6.3, Next: Question 6.4, Previous: Question 6.2, Up: Section 6 + +Question 6.3. How can I move the x axis label down 10bp? + +import graph; +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis(shift(0,-10)*"$x$",LeftTicks); +yaxis("$y$",RightTicks); + +File: asy-faq.info, Node: Question 6.4, Next: Question 6.5, Previous: Question 6.3, Up: Section 6 + +Question 6.4. Can I use different pens for the axis, the axis label, and the tick labels? + +Yes: + +import graph; +size(300,200,IgnoreAspect); + +xlimits(-50,50); +ylimits(0,100); + +xaxis(Label("$x$",MidPoint,red),Bottom,blue,LeftTicks(green)); +yaxis("$y$",Left,RightTicks); + +File: asy-faq.info, Node: Question 6.5, Next: Question 6.6, Previous: Question 6.4, Up: Section 6 + +Question 6.5. How can I change the font type of the axes label? + +import graph; +size(300,200,IgnoreAspect); + +xlimits(-50,50); +ylimits(0,100); + +xaxis("x",Bottom,Courier("m","n"),LeftTicks); +yaxis("$y$",Left,RightTicks); + +File: asy-faq.info, Node: Question 6.6, Next: Question 6.7, Previous: Question 6.5, Up: Section 6 + +Question 6.6. How can I change the font type of the tick labels on an axis? + +Tick labels are by default typeset in (TeX) math mode, so to use other +fonts you need to override the default tick format: + +import graph; +size(300,200,IgnoreAspect); + +xlimits(-50,50); +ylimits(0,100); + +xaxis("$x$",Bottom,LeftTicks("%.4g",Courier("m","n")+fontsize(12))); +yaxis("$y$",Left,RightTicks); + +File: asy-faq.info, Node: Question 6.7, Next: Question 6.8, Previous: Question 6.6, Up: Section 6 + +Question 6.7. How can I prevent axes tick labels from rendering on top of each other? + +Either: + +(i) give LeftTicks/RightTicks/Ticks the arguments beginlabel=false and/or +endlabel=false; + +(ii) explicitly remove specific ticks and their labels (drawing them +manually; see +http://www.github.com/vectorgraphics/asymptote/base/graph.asy for the +definition of NoZero): + +import graph; + +size(10cm); + +real f(real x) {return x^2;} + +draw(graph(f,-2,2)); + +xaxis(Ticks(NoZero)); +yaxis(Ticks(NoZero)); + +label("$0$",(0,0),SW); +(iii) explicitly remove specific tick labels and draw them manually (see +http://www.github.com/vectorgraphics/asymptote/base/graph.asy for the +definition of NoZeroFormat): + +import graph; + +size(10cm); + +real f(real x) {return x^2;} + +draw(graph(f,-2,2)); + +xaxis(Ticks(NoZeroFormat)); +yaxis(Ticks(NoZeroFormat)); + +label("$0$",(0,0),SW); +(iv) use the xasy GUI to move overlapping labels; + +(v) change the Label argument of LeftTicks, RightTicks, or Ticks to: + +Label(currentpen+overwrite(Move)) +Solution (v) will move labels that might otherwise overwrite a previous +label. Other possible overwrite arguments are Allow (allows overlapping +labels; the default), Suppress (an overlapping label will not be written +at all), SuppressQuiet, and MoveQuiet. The last two achieve the same +result as the non-quiet types, but will not notify you which labels are +overlapping. See: https://asymptote.sourceforge.io/doc/Pens.html. + +In the case of a user-specified tick array, you can change which labels +get suppressed/moved by changing the order of array entries. + + +File: asy-faq.info, Node: Question 6.8, Next: Question 6.9, Previous: Question 6.7, Up: Section 6 + +Question 6.8. How do I make the plot region of a graph, ignoring labels and legends, have a fixed size? + +Either: + +i) Specify an explicit unitsize, which overrides any call to size: +unitsize(x=1cm,y=2cm); +ii) Explicitly tell Asymptote to map the plot region to a specific size: +import graph; +real[] x={0,1,2,3}; +real[] y=x^2; +draw(graph(x,y),red); +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); + +size(5cm,5cm,point(SW),point(NE)); + +label("$f_\mathrm{T}$",point(N),2N); +iii) Specify the points in user coordinates that should correspond to a +given picture size: + +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); + +fixedscaling((-1.5,-0.5),(1.5,3.5)); +In this example, the user coordinate (-1.5,-0.5) will end up being the +lower left corner of the figure and (1.5,3.5) will be the upper right +corner. You can use this option to ensure multiple figures have the same +scaling and same resulting figure size (just ensure the two coordinates +given to fixedscaling() leaves room for any labels). + +See also https://asymptote.sourceforge.io/doc/Frames-and-pictures.html. + + +File: asy-faq.info, Node: Question 6.9, Next: Question 6.10, Previous: Question 6.8, Up: Section 6 + +Question 6.9. How can I plot a function f(x) within [0,1]x[0,2] without explicitly calculating the x values for which f(x) hits the boundary? + +Call limits with the Crop option before drawing the graph: +import graph; + +size(250,200,IgnoreAspect); + +draw(graph(exp,-1,1),red); + +limits((0,0),(1,2),Crop); + +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); +See also https://asymptote.sourceforge.io/doc/graph.html. + + +File: asy-faq.info, Node: Question 6.10, Next: Question 6.11, Previous: Question 6.9, Up: Section 6 + +Question 6.10. Is it possible to define customized palettes? + +Yes, you may generate your own pen[] array. For example: + +int NColors=32768; +pen[] MyPalette=new pen[NColors]; +real step=1/(NColors-1.0); +// Start at black: rgb(0,0,0) +// End at yellow: rgb(1,1,0) +for(int i=0; i < NColors; ++i) { + real rgval=i*step; + MyPalette[i]=rgb(rgval,rgval,0.0); +} + +File: asy-faq.info, Node: Question 6.11, Next: Question 6.12, Previous: Question 6.10, Up: Section 6 + +Question 6.11. Is there an easy way to graph factorial functions nicely? + +The example below shows a continuous function and two methods for placing +markers at integer values of x: + +import graph; + +size(200,200,IgnoreAspect); + +real factorial(real t) {return gamma(t+1);} + +scale(Linear,Log); + +// Graph the factorial function. +draw(graph(factorial,0,10)); + +// Method 1: Draw nodes, but hide line +pair F(int t) {return (t,factorial(t));} +// Graph of factorial function from 0 to 10 +pair[] z=sequence(F,11); +draw(graph(z),invisible,marker(scale(0.8mm)*unitcircle,blue,Fill)); + +// Method 2: Nongraphing routines require explicit scaling: +pair dotloc(int t) {return Scale(F(t));} +pair[] dotlocs=sequence(dotloc,11); +dot(dotlocs); + +xaxis("$x$",BottomTop,LeftTicks); +yaxis("$y$",LeftRight,RightTicks); + +File: asy-faq.info, Node: Question 6.12, Next: Question 6.13, Previous: Question 6.11, Up: Section 6 + +Question 6.12. How do I indicate that a certain length should be exactly the size I prescribe with no rescaling, within a picture which has its own size? + +Here's an easy way to do this. + +size(12cm,0); + +void distance(picture pic=currentpicture, pair A, pair B, Label L="", real n=0, + pen p=currentpen) +{ + real d=3mm; + path g=A--B; + transform T=shift(-n*d*unit(B-A)*I); + pic.add(new void(frame f, transform t) { + picture opic; + path G=T*t*g; + draw(opic,Label(L,Center,UnFill(1)),G,p,Arrows(NoFill),Bars,PenMargins); + add(f,opic.fit()); + }); + pic.addBox(min(g),max(g),T*min(p),T*max(p)); +} + +pair A=(0,0), B=(3,3); + +dot(A); +dot(B); + +distance(A,B,"$\ell$",1); + +File: asy-faq.info, Node: Question 6.13, Next: Question 6.14, Previous: Question 6.12, Up: Section 6 + +Question 6.13. How can I make the y axis display base-2 logarithmic values? + +See the example https://asymptote.sourceforge.io/gallery/2D +graphs/log2graph.asy. + + +File: asy-faq.info, Node: Question 6.14, Next: Question 6.15, Previous: Question 6.13, Up: Section 6 + +Question 6.14. How can I align the x axes of two graphs on the same figure? + +An easy way to do this, if the axes to be aligned have the same scaling +and size, is illustrated in the example +https://asymptote.sourceforge.io/gallery/2D graphs/alignedaxis.asy. + +Here is a more general solution to the problem of aligning two arbitrary +axes. One fits the second picture to a frame based on the horizontal +scaling for the first picture: + +import graph; + +real width=15cm; +real aspect=0.3; + +picture pic1,pic2; + +size(pic1,width,aspect*width,IgnoreAspect); +size(pic2,width,aspect*width,IgnoreAspect); + +scale(pic1,false); +scale(pic2,false); + +real xmin1=6; +real xmax1=9; +real xmin2=8; +real xmax2=16; + +real a1=1; +real a2=0.001; + +real f1(real x) {return a1*sin(x/2*pi);} +real f2(real x) {return a2*sin(x/4*pi);} + +draw(pic1,graph(pic1,f1,xmin1,xmax1)); +draw(pic2,graph(pic2,f2,xmin2,xmax2)); + +xaxis(pic1,Bottom,LeftTicks()); +yaxis(pic1,"$f_1(x)$",Left,RightTicks); + +xaxis(pic2,"$x$",Bottom,LeftTicks(Step=4)); +yaxis(pic2,"$f_2(x)$",Left,RightTicks); + +yequals(pic1,0,Dotted); +yequals(pic2,0,Dotted); + +pair min1=point(pic1,SW); +pair max1=point(pic1,NE); + +pair min2=point(pic2,SW); +pair max2=point(pic2,NE); + +real scale=(max1.x-min1.x)/(max2.x-min2.x); +real shift=min1.x/scale-min2.x; + +transform t1=pic1.calculateTransform(); +transform t2=pic2.calculateTransform(); +transform T=xscale(scale*t1.xx)*yscale(t2.yy); + +add(pic1.fit()); +real height=truepoint(N,user=false).y-truepoint(S,user=false).y; +add(shift(0,-height)*(shift(shift)*pic2).fit(T)); + +File: asy-faq.info, Node: Question 6.15, Next: Question 6.16, Previous: Question 6.14, Up: Section 6 + +Question 6.15. How can I change the direction of the y-axis, such that negatives values are on the upper y-axis? + +Here is a simple example (see also the example +https://asymptote.sourceforge.io/gallery/2D graphs/diatom.asy or the +discussion of Linear(-1) in the documentation): + +import graph; +size(250,200,IgnoreAspect); + +scale(Linear,Linear(-1)); + +draw(graph(log,0.1,10),red); + +xaxis("$x$",LeftTicks); +yaxis("$y$",RightTicks); + +File: asy-faq.info, Node: Question 6.16, Next: Question 6.17, Previous: Question 6.15, Up: Section 6 + +Question 6.16. How can I fill a path with a function that defines the color of each location? + +Use functionshade with a PDF tex engine, as illustrated by the example +{functionshading.asy}. + +If you want to produce PostScript output, an approximate solution for now +would be to superimpose a fine grid and specify colors to latticeshade +that depend on position as a single pen[][] lattice. Alternatively, it may +be more efficient to use tensorshade}. + + +File: asy-faq.info, Node: Question 6.17, Next: Question 6.18, Previous: Question 6.16, Up: Section 6 + +Question 6.17. Is there a way to draw a function that is not explicitly given, such as (y - 2)^2 = x - 1 ? + +Yes, use the parametric form + +y=t +x=(t-2)^2+1 +See the example https://asymptote.sourceforge.io/gallery/2D +graphs/parametricgraph.asy. + + +File: asy-faq.info, Node: Question 6.18, Next: Question 6.19, Previous: Question 6.17, Up: Section 6 + +Question 6.18. Is it possible to reverse or stretch an axis? + +The real scaling argument to Linear is used to stretch (or reverse) the +axis. To see the effect of axis stretching, be sure not to specify +IgnoreAspect in the picture size command. + +A secondary axis has the same length as the primary axis, so stretching +cannot have any effect. But one can still reverse the axis, with +Linear(-1). + + +File: asy-faq.info, Node: Question 6.19, Next: Question 6.20, Previous: Question 6.18, Up: Section 6 + +Question 6.19. Why can't I use the UnFill option to draw graphs with empty markers? + +UnFill won't work here because it only affects the local frame the markers +are initially drawn on, before being added to currentpicture. Here is a +way of achieving the desired effect (assuming a white background): + +import graph; +size(10cm,0); +pair[] z={(0,0),(0.5,0.5),(1,1)}; +path g=graph(z); + +draw(shift(0,.5)*g,marker(scale(5)*unitcircle,FillDraw(white))); + +xaxis(BottomTop,LeftTicks); +yaxis(LeftRight,RightTicks); + +File: asy-faq.info, Node: Question 6.20, Next: Question 7.1, Previous: Question 6.19, Up: Section 6 + +Question 6.20. How can I force several images to use the same palette range (e.g. the entire 0-255 grayscale range)? + +The palette color space corresponds to a range of values specified by the +argument range, which can be Full, Automatic or an explicit range +Range(pair min, pair max). Here Full} specifies a range varying from the +minimum to maximum values of the function over the sampling interval, +while Automatic selects "nice" limits. + + +File: asy-faq.info, Node: Section 7, Next: Section 8, Previous: Section 6, Up: Top + +Questions about programming + +* Menu: +* Question 7.1:: Is Asymptote an interpreter or a compiler? +* Question 7.2:: What is the difference between a frame and a picture? +* Question 7.3:: What is the difference between a path and a guide? +* Question 7.4:: What is a convenient way to declare and initialize an + array of pictures? +* Question 7.5:: Is there a way to define functions that act on arrays + in general (i.e. work for arrays of any type)? +* Question 7.6:: Is there any way to declare structures ahead of their + definition, e.g. where struct A performs some + operation on struct B, but B contains an A member? +* Question 7.7:: Where are static variables in for loops allocated? +* Question 7.8:: Is there a debugger for asy? +* Question 7.9:: Do you accept patches for Asymptote? + + + +File: asy-faq.info, Node: Question 7.1, Next: Question 7.2, Previous: Question 6.20, Up: Section 7 + +Question 7.1. Is Asymptote an interpreter or a compiler? + +Asymptote compiles Asymptote commands into its own virtual machine code. +It then runs this pseudocode on a virtual machine to produce PostScript +code. + + +File: asy-faq.info, Node: Question 7.2, Next: Question 7.3, Previous: Question 7.1, Up: Section 7 + +Question 7.2. What is the difference between a frame and a picture? + +Frames are canvases for drawing in PostScript coordinates. While working +with frames directly is occasionally necessary for constructing deferred +drawing routines, pictures are usually more convenient to work with. See +*Note Question 8.8:: `In MetaPost, it is possible to have a drawing remain +the same size in different pictures by defining a unit u and explicitly +multiply all the coordinates by u. Is there a better way to do this in +Asymptote?'. + + +File: asy-faq.info, Node: Question 7.3, Next: Question 7.4, Previous: Question 7.2, Up: Section 7 + +Question 7.3. What is the difference between a path and a guide? + +A path is a cubic spline with fixed endpoint conditions. + +A guide is an unresolved cubic spline (list of cubic-spline nodes and +control points). A guide is like a path except that the computation of the +cubic spline is deferred until drawing time (when it is resolved into a +path); this allows two guides with free endpoint conditions to be joined +together smoothly. + + +File: asy-faq.info, Node: Question 7.4, Next: Question 7.5, Previous: Question 7.3, Up: Section 7 + +Question 7.4. What is a convenient way to declare and initialize an array of pictures? + +You could write yourself a routine such as: +picture[] picture(int n) { + picture[] pic; + for(int i=0; i < n; ++i) { + pic[i]=new picture; + size(pic[i],19cm,0); + } + return pic; +} + +picture[] pic=picture(6); + +File: asy-faq.info, Node: Question 7.5, Next: Question 7.6, Previous: Question 7.4, Up: Section 7 + +Question 7.5. Is there a way to define functions that act on arrays in general (i.e. work for arrays of any type)? + +Generic types aren't yet implemented. + +But for now you can at least say +typedef string T; +include F; + +typedef real T; +include F; +where F.asy contains some type-dependent code like +T[] operator $(T A, T B) {return new T[] {A,B};} + +File: asy-faq.info, Node: Question 7.6, Next: Question 7.7, Previous: Question 7.5, Up: Section 7 + +Question 7.6. Is there any way to declare structures ahead of their definition, e.g. where struct A performs some operation on struct B, but B contains an A member? + +Asymptote does not support forward declaration of types. You can, however, +nest structures, so that both types are visible for parts of the bodies of +both structure definitions. For example: + +struct B { + typedef void someroutine(B b); + + static struct A { + someroutine routine; + void operator init(someroutine routine) { + this.routine=routine; + } + } + + string test="Testing"; +} + +typedef B.A A; + +A a=B.A(new void(B b){write(b.test);}); + +B b; +a.routine(b); + +File: asy-faq.info, Node: Question 7.7, Next: Question 7.8, Previous: Question 7.6, Up: Section 7 + +Question 7.7. Where are static variables in for loops allocated? + +In the example + +void f() { + for(int i=0; i < 3; ++i) { + static int n; + ++n; + write(n); + } +} + +f(); // Writes 1, 2, 3 +the static qualifier means that n is allocated not just outside of the for +loop, but also outside the function. This is clear if you call f multiple +times; there is still only one instance of n. + +The "level" of a variable (where it is allocated) has nothing to do with +the "scope" of a variable (how long it can be referred to by name). The +curly braces enclosing a block affect only a variable's scope, not its +level. + +Static modifiers are meaningless at the top level; they generate a warning +and are simply ignored: + +for(int i=0; i < 3; ++i) { + static int n; + ++n; + write(n); +} +// Writes warning about top-level static modifier and then 1, 1, 1 +Since version 1.22, non-static variables allocated in a loop body are +allocated anew every iteration. This is only noticable in obscure cases +where a variable in a loop is accessed in the closure of a function +defined in the loop: + +int f(); + +for(int i=0; i < 10; ++i) { + int j=10*i; + if(i == 5) + f=new int() {return j;}; +} + +write(f()); // Writes 50 +Variables in the body of a loop last as long as that iteration of the +loop, unless they are kept alive by a function closure as in the example +above. In a function body, variables will last at least as long as the +function call, though because of closures and garbage collection, they may +last longer than that. If defined at the top level of a file or at the +interactive prompt, they will last at least until the end of the file or +prompt's run. + + +File: asy-faq.info, Node: Question 7.8, Next: Question 7.9, Previous: Question 7.7, Up: Section 7 + +Question 7.8. Is there a debugger for asy? + +Yes, Asymptote includes a line-based debugger: + +https://asymptote.sourceforge.io/doc/Debugger.html + + +File: asy-faq.info, Node: Question 7.9, Next: Question 8.1, Previous: Question 7.8, Up: Section 7 + +Question 7.9. Do you accept patches for Asymptote? + +Yes, in fact we would prefer that users submit patches for customized +features (to http://sourceforge.net/tracker/?atid=685685&group_id=120000) +instead of relying on us to do all of the coding. Development will proceed +faster that way. + + +File: asy-faq.info, Node: Section 8, Next: Section 9, Previous: Section 7, Up: Top + +Questions about differences between Asymptote and MetaPost + +* Menu: +* Question 8.1:: What is the equivalent of the MetaPost c[a,b] + interpolation operator? +* Question 8.2:: How does picture scaling differ in Asymptote and + MetaPost? +* Question 8.3:: How can I avoid automatic scaling of a picture? +* Question 8.4:: What is the equivalent of MetaPost ... command? +* Question 8.5:: What is the equivalent of the MetaPost pickup command? +* Question 8.6:: What is the equivalent of the MetaPost whatever + command? +* Question 8.7:: What is the equivalent for the MetaPost command for + lray - horiz*v - verti*u = whatever*(LightSource - R), + a system of three linear equations for three unknowns: + horiz, verti, whatever? +* Question 8.8:: In MetaPost, it is possible to have a drawing remain + the same size in different pictures by defining a unit + u and explicitly multiply all the coordinates by u. Is + there a better way to do this in Asymptote? +* Question 8.9:: In MetaPost, one could produce tiling pictures by + generating a picture, and then clipping the picture to + a rectangle of fixed dimensions around the center of + the picture. How is that done in Asymptote? + + + +File: asy-faq.info, Node: Question 8.1, Next: Question 8.2, Previous: Question 7.9, Up: Section 8 + +Question 8.1. What is the equivalent of the MetaPost c[a,b] interpolation operator? + +interp(a,b,c); + +File: asy-faq.info, Node: Question 8.2, Next: Question 8.3, Previous: Question 8.1, Up: Section 8 + +Question 8.2. How does picture scaling differ in Asymptote and MetaPost? + +Asymptote includes an optional facility to do automatic scaling of +pictures to achieve a given overall picture size, whereas Metapost only +supports manual scaling. Asymptote defers drawing of objects drawn to +pictures and distinguishes between true-size objects and objects that +should scale with the picture size. The resulting linear programming +problem is solved via the Simplex method. + +See the https://asymptote.sourceforge.io/gallery/dimension.asy example for +an example of how deferred drawing is used to accomodate both user and +true-size (PostScript) coordinates. + + +File: asy-faq.info, Node: Question 8.3, Next: Question 8.4, Previous: Question 8.2, Up: Section 8 + +Question 8.3. How can I avoid automatic scaling of a picture? + +If you really like Metapost-style manual (hard-wired) scaling either: + +(i) use the default size(0,0) for the entire picture and do all of the +scaling by hand, just like in MetaPost; + +(ii) draw to a separate picture pic and add(pic.fit()); + +(iii) use frames. + + +File: asy-faq.info, Node: Question 8.4, Next: Question 8.5, Previous: Question 8.3, Up: Section 8 + +Question 8.4. What is the equivalent of MetaPost ... command? + +The connector :: is a macro for tension atleast 1: + +size(100); +pair z0=(0,0); +pair z1=(1,0.25); +pair z2=(2,0); +draw(z0{up}::z1{right}::z2{down}); + +File: asy-faq.info, Node: Question 8.5, Next: Question 8.6, Previous: Question 8.4, Up: Section 8 + +Question 8.5. What is the equivalent of the MetaPost pickup command? + +Just say, for example: + +currentpen=red; + +File: asy-faq.info, Node: Question 8.6, Next: Question 8.7, Previous: Question 8.5, Up: Section 8 + +Question 8.6. What is the equivalent of the MetaPost whatever command? + +Asymptote does not implicitly solve linear equations and therefore does +not have the notion of a whatever unknown. Such a facility could certainly +be added (perhaps using the notation ?= since = means assignment). +However, the most common uses of whatever in MetaPost are covered by +functions like extension in math.asy: +pair extension(pair P, pair Q, pair p, pair q); +this returns the intersection point of the extensions of the line segments +PQ and pq. We find using routines like extension more explicit and less +confusing to new users. But we could be persuaded to add something similar +if someone can justify the need. In the meantime, one can always use the +explicit built-in linear solver solve (see +https://asymptote.sourceforge.io/doc/solve.html), which uses LU +decomposition. + + +File: asy-faq.info, Node: Question 8.7, Next: Question 8.8, Previous: Question 8.6, Up: Section 8 + +Question 8.7. What is the equivalent for the MetaPost command for lray - horiz*v - verti*u = whatever*(LightSource - R), a system of three linear equations for three unknowns: horiz, verti, whatever? + +Since horiz*v+verti*u spans a plane, you could use +real intersect(vector P, vector Q, vector n, vector Z); +to find the intersection time for the line lray-whatever*(LightSource - +R) and then extract the three desired values from there. (You'll still +need to use the built-in explicit linear solver to solve a 2x2 system to +get horiz and verti.) + + +File: asy-faq.info, Node: Question 8.8, Next: Question 8.9, Previous: Question 8.7, Up: Section 8 + +Question 8.8. In MetaPost, it is possible to have a drawing remain the same size in different pictures by defining a unit u and explicitly multiply all the coordinates by u. Is there a better way to do this in Asymptote? + +Yes, Asymptote has a better way: you definitely don't want to manually +scale all of your coordinates. To make the user coordinates represent +multiples of exactly 1cm: + +unitsize(1cm); +draw(unitsquare); +One can also specify different x and y unit sizes: + +unitsize(x=1cm,y=2cm); +draw(unitsquare); +Another way is to draw your fixed size object to a frame and add it to +currentpicture like this: + +path p=(0,0)--(1,0); +frame object; +draw(object,scale(100)*p); + +add(object); +add(object,(0,-10)); +To understand the difference between frames and pictures, try this: + +size(300,300); + +path p=(0,0)--(1,0); +picture object; +draw(object,scale(100)*p); + +add(object); +add(object,(0,-10)); // Adds truesize object to currentpicture + +File: asy-faq.info, Node: Question 8.9, Next: Question 9.1, Previous: Question 8.8, Up: Section 8 + +Question 8.9. In MetaPost, one could produce tiling pictures by generating a picture, and then clipping the picture to a rectangle of fixed dimensions around the center of the picture. How is that done in Asymptote? + +If you are using currentpicture the way one would in MetaPost (drawing in +raw PostScript coordinates), you can simply do something like: + +fill((0,0)--(100,100)--(200,0)--cycle); + +pair center(picture pic=currentpicture) {return 0.5*(pic.min()+pic.max());} + +real height=100; +real width=100; +pair delta=0.5(width,height); +pair c=center(); +clip(box(c-delta,c+delta)); +However, drawing in PostScript coordinates is often inconvenient. Here's +the Asymptote way of doing the same thing, using deferred drawing: + +size(200,100); +fill((0,0)--(1,1)--(2,0)--cycle); + +void clip(picture pic=currentpicture, real width, real height) +{ + pic.clip(new void (frame f, transform) { + pair center=0.5(min(f)+max(f)); + pair delta=0.5(width,height); + clip(f,box(center-delta,center+delta)); + }); +} + +clip(100,100); +See also the discussion of tilings in the documentation: +https://asymptote.sourceforge.io/doc/Pens.html. + + +File: asy-faq.info, Node: Section 9, Previous: Section 8, Up: Top + +Questions about output + +* Menu: +* Question 9.1:: How can I disable automatic invocation of the PS + viewer after an asy file is done processing? +* Question 9.2:: How do I output jpeg images? +* Question 9.3:: Can I embed bitmaps (photos) into my drawings and + position and scale them? +* Question 9.4:: Does Asymptote support direct PDF output? +* Question 9.5:: How to I produce large pictures of high quality in + raster format (e.g. png, giff etc). +* Question 9.6:: Is it possible to produce multi-page documents with + asymptote? + + + +File: asy-faq.info, Node: Question 9.1, Next: Question 9.2, Previous: Question 8.9, Up: Section 9 + +Question 9.1. How can I disable automatic invocation of the PS viewer after an asy file is done processing? + +It's actually not on by default, unless you happen to be using Microsoft +Windows (because that is what most Microsoft Windows users expect). +Microsoft Windows users can turn this feature off with the command-line +option -noV or by putting + +import settings; +interactiveView=false; +batchView=false; +in their config.asy file. See +https://asymptote.sourceforge.io/doc/Options.html. + + +File: asy-faq.info, Node: Question 9.2, Next: Question 9.3, Previous: Question 9.1, Up: Section 9 + +Question 9.2. How do I output jpeg images? + +If you have the ImageMagick convert program installed, simply type + +asy -f jpg test.asy + +File: asy-faq.info, Node: Question 9.3, Next: Question 9.4, Previous: Question 9.2, Up: Section 9 + +Question 9.3. Can I embed bitmaps (photos) into my drawings and position and scale them? + +Convert them to eps format and use the graphic(string) function just like +a Label: + +label(graphic("file"),(0,0)); +See the example https://asymptote.sourceforge.io/gallery/orthocenter.asy +and https://asymptote.sourceforge.io/doc/label.html. + + +File: asy-faq.info, Node: Question 9.4, Next: Question 9.5, Previous: Question 9.3, Up: Section 9 + +Question 9.4. Does Asymptote support direct PDF output? + +Yes, PDF output can be produced by the -f pdf option or -tex pdflatex +option. This supports transparency, annotations, embedded movies, and +U3D/PRC content. + + +File: asy-faq.info, Node: Question 9.5, Next: Question 9.6, Previous: Question 9.4, Up: Section 9 + +Question 9.5. How to I produce large pictures of high quality in raster format (e.g. png, giff etc). + +Try using some of the options to convert, mainly -geometry and -density. +For example: +convert -geometry 1000x3000 example.eps example.png +You can also change the default resolution of the image with: +convert -geometry 1000x3000 -density 300 -units PixelsPerInch example.eps example.png +This does not change the number of pixels in the image, but just gives a +hint as to how large each pixel should be displayed. + +If you include the -density option without the -geometry option, convert +will keep the image size constant (so a 4cm x 3cm eps figure will +generate a 4cm x 3cm png image). + + +File: asy-faq.info, Node: Question 9.6, Previous: Question 9.5, Up: Section 9 + +Question 9.6. Is it possible to produce multi-page documents with asymptote? + +Yes, simply call the newpage() function. This is used by the slide.asy +package to produce high-quality slide presentations (easier to use than +Prosper). + diff --git a/Build/source/utils/asymptote/doc/FAQ/bfnnconv.pl b/Build/source/utils/asymptote/doc/FAQ/bfnnconv.pl new file mode 100755 index 00000000000..35a636b55e5 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/bfnnconv.pl @@ -0,0 +1,302 @@ +#!/usr/bin/perl -- +# Copyright (C) 1993-1995 Ian Jackson. + +# This file 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, or (at your option) +# any later version. + +# It 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. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# (Note: I do not consider works produced using these BFNN processing +# tools to be derivative works of the tools, so they are NOT covered +# by the GPL. However, I would appreciate it if you credited me if +# appropriate in any documents you format using BFNN.) + +@outputs=('ascii','info','html'); + +while ($ARGV[0] =~ m/^\-/) { + $_= shift(@ARGV); + if (m/^-only/) { + @outputs= (shift(@ARGV)); + } else { + warn "unknown option `$_' ignored"; + } +} + +$prefix= $ARGV[0]; +$prefix= 'stdin' unless length($prefix); +$prefix =~ s/\.bfnn$//; + +if (open(O,"$prefix.xrefdb")) { + @xrefdb= <O>; + close(O); +} else { + warn "no $prefix.xrefdb ($!)"; +} + +$section= -1; +for $thisxr (@xrefdb) { + $_= $thisxr; + chop; + if (m/^Q (\w+) ((\d+)\.(\d+)) (.*)$/) { + $qrefn{$1}= $2; + $qreft{$1}= $5; + $qn2ref{$3,$4}= $1; + $maxsection= $3; + $maxquestion[$3]= $4; + } elsif (m/^S (\d+) /) { + $maxsection= $1; + $sn2title{$1}=$'; + } +} + +open(U,">$prefix.xrefdb-new"); + +for $x (@outputs) { require("./m-$x.pl"); } + +&call('init'); + +while (<>) { + chop; + next if m/^\\comment\b/; + if (!m/\S/) { + &call('endpara'); + next; + } + if (s/^\\section +//) { + $line= $_; + $section++; $question=0; + print U "S $section $line\n"; + $|=1; print "S$section",' 'x10,"\r"; $|=0; + &call('endpara'); + &call('startmajorheading',"$section", + "Section $section", + $section<$maxsection ? "Section ".($section+1) : '', + $section>1 ? 'Section '.($section-1) : 'Top'); + &text($line); + &call('endmajorheading'); + if ($section) { + &call('endpara'); + &call('startindex'); + for $thisxr (@xrefdb) { + $_= $thisxr; + chop; + if (m/^Q (\w+) (\d+)\.(\d+) (.*)$/) { + $ref= $1; $num1= $2; $num2= $3; $text= $4; + next unless $num1 == $section; + &call('startindexitem',$ref,"Q$num1.$num2","Question $num1.$num2"); + &text($text); + &call('endindexitem'); + } + } + &call('endindex'); + } + } elsif (s/^\\question \d{2}[a-z]{3}((:\w+)?) +//) { + $line= $_; + $question++; + $qrefstring= $1; + $qrefstring= "q_${section}_$question" unless $qrefstring =~ s/^://; + print U "Q $qrefstring $section.$question $line\n"; + $|=1; print "Q$section.$question",' 'x10,"\r"; $|=0; + &call('endpara'); + &call('startminorheading',$qrefstring, + "Question $section.$question", + $question < $maxquestion[$section] ? "Question $section.".($question+1) : + $section < $maxsection ? "Question ".($section+1).".1" : '', + $question > 1 ? "Question $section.".($question-1) : + $section > 1 ? "Question ".($section-1).'.'.($maxquestion[$section-1]) : + 'Top', + "Section $section"); + &text("Question $section.$question. $line"); + &call('endminorheading'); + } elsif (s/^\\only +//) { + @saveoutputs= @outputs; + @outputs=(); + for $x (split(/\s+/,$_)) { + push(@outputs,$x) if grep($x eq $_, @saveoutputs); + } + } elsif (s/^\\endonly$//) { + @outputs= @saveoutputs; + } elsif (s/^\\copyto +//) { + $fh= $'; + while(<>) { + last if m/^\\endcopy$/; + while (s/^([^\`]*)\`//) { + print $fh $1; + m/([^\\])\`/ || warn "`$_'"; + $_= $'; + $cmd= $`.$1; + if($cmd =~ s/^%perl //) { + $it= eval($cmd); + } else { + $it= `$cmd`; chop $it; + } + print $fh $it; + } + print $fh $_; + } + } elsif (m/\\index$/) { + &call('startindex'); + for $thisxr (@xrefdb) { + $_= $thisxr; + chop; + if (m/^Q (\w+) (\d+\.\d+) (.*)$/) { + $ref= $1; $num= $2; $text= $3; + &call('startindexitem',$ref,"Q$num","Question $num"); + &text($text); + &call('endindexitem'); + } elsif (m/^S (\d+) (.*)$/) { + $num= $1; $text= $2; + next unless $num; + &call('startindexmainitem',"s_$num", + "Section $num.","Section $num"); + &text($text); + &call('endindexitem'); + } else { + warn $_; + } + } + &call('endindex'); + } elsif (m/^\\call-(\w+) +(\w+)\s*(.*)$/) { + $fn= $1.'_'.$2; + eval { &$fn($3); }; + warn $@ if length($@); + } elsif (m/^\\call +(\w+)\s*(.*)$/) { + eval { &call($1,$2); }; + warn $@ if length($@); + } elsif (s/^\\set +(\w+)\s*//) { + $svalue= $'; $svari= $1; + eval("\$user_$svari=\$svalue"); $@ && warn "setting $svalue failed: $@\n"; + } elsif (m/^\\verbatim$/) { + &call('startverbatim'); + while (<>) { + chop; + last if m/^\\endverbatim$/; + &call('verbatim',$_); + } + &call('endverbatim'); + } else { + s/\.$/\. /; + &text($_." "); + } +} + +print ' 'x25,"\r"; +&call('finish'); +rename("$prefix.xrefdb-new","$prefix.xrefdb") || warn "rename xrefdb: $!"; +exit 0; + + +sub text { + local($in,$rhs,$word,$refn,$reft,$fn,$style); + $in= "$holdover$_[0]"; + $holdover= ''; + while ($in =~ m/\\/) { +#print STDERR ">$`##$'\n"; + $rhs=$'; + &call('text',$`); + $_= $rhs; + if (m/^\w+ $/) { + $holdover= "\\$&"; + $in= ''; + } elsif (s/^fn\s+([^\s\\]*\w)//) { + $in= $_; + $word= $1; + &call('courier'); + &call('text',$word); + &call('endcourier'); + } elsif (s/^tab\s+(\d+)\s+//) { + $in= $_; &call('tab',$1); + } elsif (s/^nl\s+//) { + $in= $_; &call('newline'); + } elsif (s/^qref\s+(\w+)//) { + $refn= $qrefn{$1}; + $reft= $qreft{$1}; + if (!length($refn)) { + warn "unknown question `$1'"; + } + $in= "$`\\pageref:$1:$refn:$reft\\endpageref.$_"; + } elsif (s/^pageref:(\w+):([^:\n]+)://) { + $in= $_; + &call('pageref',$1,$2); + } elsif (s/^endpageref\.//) { + $in= $_; &call('endpageref'); + } elsif (s/^(\w+)\{//) { + $in= $_; $fn= $1; + eval { &call("$fn"); }; + if (length($@)) { warn $@; $fn= 'x'; } + push(@styles,$fn); + } elsif (s/^\}//) { + $in= $_; + $fn= pop(@styles); + if ($fn ne 'x') { &call("end$fn"); } + } elsif (s/^\\//) { + $in= $_; + &call('text',"\\"); + } elsif (s,^(\w+)\s+([-A-Za-z0-9.\@:/]*\w),,) { +#print STDERR "**$&**$_\n"; + $in= $_; + $style=$1; $word= $2; + &call($style); + &call('text',$word); + &call("end$style"); + } else { + warn "unknown control `\\$_'"; + $in= $_; + } + } + &call('text',$in); +} + + +sub call { + local ($fnbase, @callargs) = @_; + local ($coutput); + for $coutput (@outputs) { + if ($fnbase eq 'text' && eval("\@${coutput}_cmds")) { +#print STDERR "special handling text (@callargs) for $coutput\n"; + $evstrg= "\$${coutput}_args[\$#${coutput}_args].=\"\@callargs\""; + eval($evstrg); + length($@) && warn "call adding for $coutput (($evstrg)): $@"; + } else { + $fntc= $coutput.'_'.$fnbase; + &$fntc(@callargs); + } + } +} + + +sub recurse { + local (@outputs) = $coutput; + local ($holdover); + &text($_[0]); +} + + +sub arg { +#print STDERR "arg($_[0]) from $coutput\n"; + $cmd= $_[0]; + eval("push(\@${coutput}_cmds,\$cmd); push(\@${coutput}_args,'')"); + length($@) && warn "arg setting up for $coutput: $@"; +} + +sub endarg { +#print STDERR "endarg($_[0]) from $coutput\n"; + $evstrg= "\$${coutput}_cmd= \$cmd= pop(\@${coutput}_cmds); ". + "\$${coutput}_arg= \$arg= pop(\@${coutput}_args); "; + eval($evstrg); + length($@) && warn "endarg extracting for $coutput (($evstrg)): $@"; +#print STDERR ">call $coutput $cmd $arg< (($evstrg))\n"; + $evstrg= "&${coutput}_do_${cmd}(\$arg)"; + eval($evstrg); + length($@) && warn "endarg running ${coutput}_do_${cmd} (($evstrg)): $@"; +} diff --git a/Build/source/utils/asymptote/doc/FAQ/install-sh b/Build/source/utils/asymptote/doc/FAQ/install-sh new file mode 100755 index 00000000000..6781b987bdb --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/install-sh @@ -0,0 +1,520 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2009-04-28.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/Build/source/utils/asymptote/doc/FAQ/m-ascii.pl b/Build/source/utils/asymptote/doc/FAQ/m-ascii.pl new file mode 100644 index 00000000000..d05f8ed80d2 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/m-ascii.pl @@ -0,0 +1,189 @@ +## ASCII output +# Copyright (C) 1993-1995 Ian Jackson. + +# This file 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, or (at your option) +# any later version. + +# It 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. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# (Note: I do not consider works produced using these BFNN processing +# tools to be derivative works of the tools, so they are NOT covered +# by the GPL. However, I would appreciate it if you credited me if +# appropriate in any documents you format using BFNN.) + +sub ascii_init { + open(ASCII,">$prefix.ascii"); +} + +sub ascii_startmajorheading { + print ASCII '='x79,"\n\n"; + $ascii_status= 'h'; + &ascii_text($_[0] ? "Section $_[0]. " : ''); +} + +sub ascii_startminorheading { + print ASCII '-'x79,"\n\n"; + $ascii_status= 'h'; +} + +sub ascii_italic { &ascii_text('*'); } +sub ascii_enditalic { $ascii_para .= '*'; } + +sub ascii_email { &ascii_text('<'); } sub ascii_endemail { &ascii_text('>'); } + +sub ascii_ftpon { } sub ascii_endftpon { } +sub ascii_ftpin { } sub ascii_endftpin { } +sub ascii_docref { } sub ascii_enddocref { } +sub ascii_courier { } sub ascii_endcourier { } +sub ascii_newsgroup { } sub ascii_endnewsgroup { } +sub ascii_ftpsilent { $ascii_ignore++; } +sub ascii_endftpsilent { $ascii_ignore--; } + +sub ascii_text { + return if $ascii_ignore; + if ($ascii_status eq '') { + $ascii_status= 'p'; + } + $ascii_para .= $_[0]; +} + +sub ascii_tab { + local ($n) = $_[0]-length($ascii_para); + $ascii_para .= ' 'x$n if $n>0; +} + +sub ascii_newline { + return unless $ascii_status eq 'p'; + &ascii_writepara; +} + +sub ascii_writepara { + local ($thisline, $thisword, $rest); + for (;;) { + last unless $ascii_para =~ m/\S/; + $thisline= $ascii_indentstring; + for (;;) { + last unless $ascii_para =~ m/^(\s*\S+)/; + unless (length($1) + length($thisline) < 75 || + length($thisline) == length($ascii_indentstring)) { + last; + } + $thisline .= $1; + $ascii_para= $'; + } + $ascii_para =~ s/^\s*//; + print ASCII $thisline,"\n"; + $ascii_indentstring= $ascii_nextindent; + last unless length($ascii_para); + } + $ascii_status= ''; $ascii_para= ''; +} + +sub ascii_endpara { + return unless $ascii_status eq 'p'; + &ascii_writepara; + print ASCII "\n"; +} + +sub ascii_endheading { + $ascii_para =~ s/\s*$//; + print ASCII "$ascii_para\n\n"; + $ascii_status= ''; + $ascii_para= ''; +} + +sub ascii_endmajorheading { &ascii_endheading(@_); } +sub ascii_endminorheading { &ascii_endheading(@_); } + +sub ascii_startverbatim { + $ascii_vstatus= $ascii_status; + &ascii_writepara; +} + +sub ascii_verbatim { + print ASCII $_[0],"\n"; +} + +sub ascii_endverbatim { + $ascii_status= $ascii_vstatus; +} + +sub ascii_finish { + close(ASCII); +} + +sub ascii_startindex { $ascii_status= ''; } +sub ascii_endindex { $ascii_status= 'p'; } + +sub ascii_endindexitem { + printf ASCII " %-11s %-.66s\n",$ascii_left,$ascii_para; + $ascii_status= 'p'; + $ascii_para= ''; +} + +sub ascii_startindexitem { + $ascii_left= $_[1]; +} + +sub ascii_startindexmainitem { + $ascii_left= $_[1]; + print ASCII "\n" if $ascii_status eq 'p'; +} + +sub ascii_startindent { + $ascii_istatus= $ascii_status; + &ascii_writepara; + $ascii_indentstring= " $ascii_indentstring"; + $ascii_nextindent= " $ascii_nextindent"; +} + +sub ascii_endindent { + $ascii_indentstring =~ s/^ //; + $ascii_nextindent =~ s/^ //; + $ascii_status= $ascii_istatus; +} + +sub ascii_startpackedlist { $ascii_plc=0; } +sub ascii_endpackedlist { &ascii_newline if !$ascii_plc; } +sub ascii_packeditem { + &ascii_newline if !$ascii_plc; + &ascii_tab($ascii_plc*40+5); + $ascii_plc= !$ascii_plc; +} + +sub ascii_startlist { + &ascii_endpara; + $ascii_indentstring= " $ascii_indentstring"; + $ascii_nextindent= " $ascii_nextindent"; +} + +sub ascii_endlist { + &ascii_endpara; + $ascii_indentstring =~ s/^ //; + $ascii_nextindent =~ s/^ //; +} + +sub ascii_item { + &ascii_newline; + $ascii_indentstring =~ s/ $/* /; +} + +sub ascii_pageref { + &ascii_text("Q$_[1] \`"); +} + +sub ascii_endpageref { + &ascii_text("'"); +} + +1; diff --git a/Build/source/utils/asymptote/doc/FAQ/m-html.pl b/Build/source/utils/asymptote/doc/FAQ/m-html.pl new file mode 100644 index 00000000000..77cc2575040 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/m-html.pl @@ -0,0 +1,344 @@ +## HTML output +# Copyright (C) 1993-1995 Ian Jackson. +# Modified by John Bowman 02Sep06: simply docref usage + +# This file 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, or (at your option) +# any later version. + +# It 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. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# (Note: I do not consider works produced using these BFNN processing +# tools to be derivative works of the tools, so they are NOT covered +# by the GPL. However, I would appreciate it if you credited me if +# appropriate in any documents you format using BFNN.) + +use POSIX; + +%saniarray= ('<','lt', '>','gt', '&','amp', '"','quot'); + +sub html_init { + $html_prefix = './'.$prefix; + $html_prefix =~ s:^\.//:/:; + system('rm','-r',"$html_prefix.html"); + system('mkdir',"$html_prefix.html"); + open(HTML,">$html_prefix.html/index.html"); + print HTML "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"; + print HTML "<html>\n"; + $html_needpara= -1; + $html_end=''; + my $epoch=$ENV{SOURCE_DATE_EPOCH} || time; + $html_date=POSIX::strftime("%Y-%m-%d", gmtime($epoch)); + $html_year=POSIX::strftime("%Y", gmtime($epoch)); +} + +sub html_startup { + print HTML <<END; +<head><title> +$user_title +</title> +<link rev="made" href="mailto:$user_authormail"> +<link rel="Contents" href="index.html"> +<link rel="Start" href="index.html"> +<META name="description" + content="Frequently asked questions and answers (FAQ) for Asymptote."> +<link rel="Bookmark" title="Asymptote FAQ" href="index.html"> +<LINK rel="Bookmark" title="Asymptote Home Page" + href="https://asymptote.sourceforge.io"> +<LINK rel="Bookmark" title="Asymptote Manual" + href="https://asymptote.sourceforge.io/doc/"> +</head><body text="#000000" bgcolor="#FFFFFF"><h1> +$user_title +</h1> +END + &html_readrefs($_[0]); + if (length($user_copyrightref)) { + local ($refn) = $qrefn{$user_copyrightref}; + if (!length($refn)) { + warn "unknown question (copyright) `$user_copyrightref'"; + } + $refn =~ m/(\d+)\.(\d+)/; + local ($s,$n) = ($1,$2); + $html_copyrighthref= ($s == $html_sectionn)?'':"section$s.html"; + $html_copyrighthref.= "#$qn2ref{$s,$n}"; + } +} + +sub html_close { + print HTML $html_end,"<address>\n$user_author\n"; + print HTML "- $html_date\n</address><br>\n"; + print HTML "Extracted from $user_title,\n"; + print HTML "<A href=\"$html_copyrighthref\">" if length($html_copyrighthref); + print HTML "Copyright © $html_year $user_copyholder."; + print HTML "</A>" if length($html_copyrighthref); + print HTML "\n</body></html>\n"; + close(HTML); +} + +sub html_startmajorheading { + local ($ref, $this,$next,$back) = @_; + local ($nextt,$backt); + $this =~ s/^Section /section/; $html_sectionn= $ref; + $next =~ s/^Section /section/ && ($nextt= $sn2title{$'}); + $back =~ s/^Section /section/ ? ($backt= $sn2title{$'}) : ($back=''); + if ($html_sectionn) { + &html_close; + open(HTML,">$html_prefix.html/$this.html"); + print HTML "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"; + print HTML "<html>\n"; + $html_end= "<hr>\n"; + $html_end.= "Next: <a href=\"$next.html\" rel=precedes>$nextt</a>.<br>\n" + if $next; + $html_end.= "Back: <a href=\"$back.html\" rev=precedes>$backt</a>.<br>\n" + if $back; + $html_end.= "<a href=\"index.html\" rev=subdocument>"; + $html_end.= "Return to contents</a>.<p>\n"; + print HTML <<END; +<head><title> +$user_brieftitle - Section $html_sectionn +</title> +<link rev="made" href="mailto:$user_authormail"> +<link rel="Contents" href="index.html"> +<link rel="Start" href="index.html"> +END + print HTML "<link rel=\"Next\" href=\"$next.html\">" if $next; + print HTML "<link rel=\"Previous\" href=\"$back.html\">" if $back; + print HTML <<END; +<link rel="Bookmark" title="Asymptote FAQ" href="index.html"> +</head><body text="#000000" bgcolor="#FFFFFF"><h1> +$user_brieftitle - Section $html_sectionn <br> +END + $html_needpara= -1; + } + else { + print HTML "\n<h1>\n"; + $html_needpara=-1; + } +} + +sub html_endmajorheading { + print HTML "\n</h1>\n\n"; + $html_needpara=-1; +} + +sub html_startminorheading { + local ($ref, $this) = @_; + $html_needpara=0; + $this =~ m/^Question (\d+)\.(\d+)/; + local ($s,$n) = ($1,$2); + print HTML "\n<h2><A name=\"$qn2ref{$s,$n}\">\n"; +} + +sub html_endminorheading { + print HTML "\n</A></h2>\n\n"; + $html_needpara=-1; +} + +sub html_newsgroup { &arg('newsgroup'); } +sub html_endnewsgroup { &endarg('newsgroup'); } +sub html_do_newsgroup { + print HTML "<A href=\"news:$_[0]\"><code>$_[0]</code></A>"; +} + +sub html_email { &arg('email'); } +sub html_endemail { &endarg('email'); } +sub html_do_email { + print HTML "<A href=\"mailto:$_[0]\"><code>$_[0]</code></A>"; +} + +sub html_courier { print HTML "<code>" ; } +sub html_endcourier { print HTML "</code>"; } +sub html_italic { print HTML "<i>" ; } +sub html_enditalic { print HTML "</i>" ; } + +sub html_docref { &arg('docref'); } +sub html_enddocref { &endarg('docref'); } +sub html_do_docref { + if (!defined($html_refval{$_[0]})) { +# Modified by John Bowman 02Sep06: interpret the argument as an html reference +# warn "undefined HTML reference $_[0]"; +# $html_refval{$n}='UNDEFINED'; + print HTML "<A href=\"$_[0]\">"; + } else { + print HTML "<A href=\"$html_refval{$_[0]}\">"; + } + &recurse($_[0]); + print HTML "</A>"; +} + +sub html_readrefs { + local ($p); + open(HTMLREFS,"<$_[0]") || (warn("failed to open HTML refs $_[0]: $!"),return); + while(<HTMLREFS>) { + next if m/^\\\s/; + s/\s*\n$//; + if (s/^\\prefix\s*//) { + $p= $'; next; + } elsif (s/^\s*(\S.*\S)\s*\\\s*//) { + $_=$1; $v=$'; + s/\\\\/\\/g; + $html_refval{$_}= $p.$v; + } else { + warn("cannot understand line in HTML refs >$_<"); + } + } + close(HTMLREFS); +} + +sub html_ftpsilent { &arg('ftpsilent'); } +sub html_endftpsilent { &endarg('ftpsilent'); } +sub html_do_ftpsilent { + if ($_[0] =~ m/:/) { + $html_ftpsite= $`; + $html_ftpdir= $'.'/'; + } else { + $html_ftpsite= $_[0]; + $html_ftpdir= ''; + } +} + +sub html_ftpon { &arg('ftpon'); } +sub html_endftpon { &endarg('ftpon'); } +sub html_do_ftpon { +#print STDERR "ftpon($_[0])\n"; + $html_ftpsite= $_[0]; $html_ftpdir= ''; + print HTML "<code>"; + &recurse($_[0]); + print HTML "</code>"; +} + +sub html_ftpin { &arg('ftpin'); } +sub html_endftpin { &endarg('ftpin'); } +sub html_do_ftpin { +#print STDERR "ftpin($_[0])\n"; + print HTML "<A href=\"ftp://$html_ftpsite$html_ftpdir$_[0]\"><code>"; + &recurse($_[0]); + print HTML "</code></A>"; +} + +sub html_text { + print HTML "\n<p>\n" if $html_needpara > 0; + $html_needpara=0; + $html_stuff= &html_sanitise($_[0]); + while ($html_stuff =~ s/^(.{40,70}) //) { + print HTML "$1\n"; + } + print HTML $html_stuff; +} + +sub html_tab { + $htmltabignore++ || warn "html tab ignored"; +} + +sub html_newline { print HTML "<br>\n" ; } +sub html_startverbatim { print HTML "<pre>\n" ; } +sub html_verbatim { print HTML &html_sanitise($_[0]),"\n"; } +sub html_endverbatim { print HTML "</pre>\n" ; $html_needpara= -1; } + +sub html_endpara { + $html_needpara || $html_needpara++; +} + +sub html_finish { + &html_close; +} + +sub html_startindex { + print HTML "<ul>\n"; +} + +sub html_endindex { + print HTML "</ul><hr>\n"; +} + +sub html_startindexitem { + local ($ref,$qval) = @_; + $qval =~ m/Q(\d+)\.(\d+)/; + local ($s,$n) = ($1,$2); + print HTML "<li><a href=\""; + print HTML ($s == $html_sectionn)?'':"section$s.html"; + print HTML "#$qn2ref{$s,$n}\" rel=subdocument>Q$s.$n. "; + $html_indexunhead=''; +} + +sub html_startindexmainitem { + local ($ref,$s) = @_; + $s =~ m/\d+/; $s= $&; + print HTML "<br><br>" if ($s > 1); + print HTML "<li><b><font size=\"+2\"><a href=\"section$s.html\" rel=subdocument>Section $s. "; + $html_indexunhead='</font></b>'; +} + +sub html_endindexitem { + print HTML "</a>$html_indexunhead\n"; +} + +sub html_startlist { + print HTML "\n"; + $html_itemend="<ul>"; +} + +sub html_endlist { + print HTML "$html_itemend\n</ul>\n"; + $html_needpara=-1 +} + +sub html_item { + print HTML "$html_itemend\n<li>"; + $html_itemend=""; + $html_needpara=-1; +} + +sub html_startpackedlist { + print HTML "\n"; + $html_itemend="<dir>"; +} + +sub html_endpackedlist { + print HTML "$html_itemend\n</dir>\n"; + $html_needpara=-1; +} + +sub html_packeditem { + print HTML "$html_itemend\n<li>"; + $html_itemend=""; + $html_needpara=-1; +} + +sub html_startindent { print HTML "<blockquote>\n"; } +sub html_endindent { print HTML "</blockquote>\n"; } + +sub html_pageref { + local ($ref,$sq) = @_; + $sq =~ m/(\d+)\.(\d+)/; + local ($s,$n) = ($1,$2); + print HTML "<A href=\""; + print HTML ($s == $html_sectionn)?'':"section$s.html"; + print HTML "#$qn2ref{$s,$n}\">Q$sq \`"; +} + +sub html_endpageref { + print HTML "'</A>"; +} + +sub html_sanitise { + local ($in) = @_; + local ($out); + while ($in =~ m/[<>&"]/) { + $out.= $`. '&'. $saniarray{$&}. ';'; + $in=$'; + } + $out.= $in; + $out; +} + +1; diff --git a/Build/source/utils/asymptote/doc/FAQ/m-info.pl b/Build/source/utils/asymptote/doc/FAQ/m-info.pl new file mode 100644 index 00000000000..cfa2515ae11 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/m-info.pl @@ -0,0 +1,226 @@ +## Info output +# Copyright (C) 1993-1995 Ian Jackson. + +# This file 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, or (at your option) +# any later version. + +# It 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. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# (Note: I do not consider works produced using these BFNN processing +# tools to be derivative works of the tools, so they are NOT covered +# by the GPL. However, I would appreciate it if you credited me if +# appropriate in any documents you format using BFNN.) + +sub info_init { + open(INFO,">$prefix.info"); + print INFO <<END; +Info file: $prefix.info, -*-Text-*- +produced by bfnnconv.pl from the Bizarre Format With No Name. + +END +} + +sub info_heading { + # refstring Node Next Previous Up + print INFO "\nFile: $prefix.info, Node: $_[1]"; + print INFO ", Next: $_[2]" if length($_[2]); + print INFO ", Previous: $_[3]" if length($_[3]); + print INFO ", Up: $_[4]" if length($_[4]); + print INFO "\n\n"; + $info_status= ''; +} + +sub info_startmajorheading { + return if $_[0] eq '0'; + &info_heading('s_'.$_[0],@_[1..$#_],'Top'); +} + +sub info_startminorheading { + &info_heading(@_); +} + +sub info_italic { &info_text('*'); } +sub info_enditalic { $info_para .= '*'; } + +sub info_email { &info_text('<'); } sub info_endemail { &info_text('>'); } + +sub info_ftpon { } sub info_endftpon { } +sub info_ftpin { } sub info_endftpin { } +sub info_docref { } sub info_enddocref { } +sub info_courier { } sub info_endcourier { } +sub info_newsgroup { } sub info_endnewsgroup { } +sub info_ftpsilent { $info_ignore++; } +sub info_endftpsilent { $info_ignore--; } + +sub info_text { + return if $info_ignore; + if ($info_status eq '') { + $info_status= 'p'; + } + $info_para .= $_[0]; +} + +sub info_tab { + local ($n) = $_[0]-length($info_para); + $info_para .= ' 'x$n if $n>0; +} + +sub info_newline { + return unless $info_status eq 'p'; + print INFO &info_writepara; +} + +sub info_writepara { + local ($thisline, $thisword, $rest, $output); + for (;;) { + last unless $info_para =~ m/\S/; + $thisline= $info_indentstring; + for (;;) { + last unless $info_para =~ m/^(\s*\S+)/; + unless (length($1) + length($thisline) < 75 || + length($thisline) == length($info_indentstring)) { + last; + } + $thisline .= $1; + $info_para= $'; + } + $info_para =~ s/^\s*//; + $output.= $thisline."\n"; + $info_indentstring= $info_nextindent; + last unless length($info_para); + } + $info_status= ''; $info_para= ''; + return $output; +} + +sub info_endpara { + return unless $info_status eq 'p'; + print INFO &info_writepara; + print INFO "\n"; +} + +sub info_endheading { + $info_para =~ s/\s*$//; + print INFO "$info_para\n\n"; + $info_status= ''; + $info_para= ''; +} + +sub info_endmajorheading { &info_endheading(@_); } +sub info_endminorheading { &info_endheading(@_); } + +sub info_startverbatim { + print INFO &info_writepara; +} + +sub info_verbatim { + print INFO $_[0],"\n"; +} + +sub info_endverbatim { + $info_status= $info_vstatus; +} + +sub info_finish { + close(INFO); +} + +sub info_startindex { + &info_endpara; + $info_moredetail= ''; + $info_status= ''; +} + +sub info_endindex { + print INFO "$info_moredetail\n" if length($info_moredetail); +} + +sub info_endindexitem { + $info_indentstring= sprintf("* %-17s ",$info_label.'::'); + $info_nextindent= ' 'x20; + local ($txt); + $txt= &info_writepara; + if ($info_main) { + print INFO $label.$txt; + $txt =~ s/^.{20}//; + $info_moredetail.= $txt; + } else { + $info_moredetail.= $label.$txt; + } + $info_indentstring= $info_nextindent= ''; + $info_status='p'; +} + +sub info_startindexitem { + print INFO "* Menu:\n" if $info_status eq ''; + $info_status= ''; + $info_label= $_[2]; + $info_main= 0; +} + +sub info_startindexmainitem { + print INFO "* Menu:\n" if $info_status eq ''; + $info_label= $_[2]; + $info_main= 1; + $info_moredetail .= "\n$_[2], "; + $info_status= ''; +} + +sub info_startindent { + $info_istatus= $info_status; + print INFO &info_writepara; + $info_indentstring= " $info_indentstring"; + $info_nextindent= " $info_nextindent"; +} + +sub info_endindent { + $info_indentstring =~ s/^ //; + $info_nextindent =~ s/^ //; + $info_status= $info_istatus; +} + +sub info_startpackedlist { $info_plc=0; } +sub info_endpackedlist { &info_newline if !$info_plc; } +sub info_packeditem { + &info_newline if !$info_plc; + &info_tab($info_plc*40+5); + $info_plc= !$info_plc; +} + +sub info_startlist { + $info_istatus= $info_status; + print INFO &info_writepara; + $info_indentstring= " $info_indentstring"; + $info_nextindent= " $info_nextindent"; +} + +sub info_endlist { + $info_indentstring =~ s/^ //; + $info_nextindent =~ s/^ //; + $info_status= $info_lstatus; +} + +sub info_item { + &info_newline; + $info_indentstring =~ s/ $/* /; +} + +sub info_pageref { + &info_text("*Note Question $_[1]:: \`"); +} + +sub info_endpageref { + &info_text("'"); +} + +1; diff --git a/Build/source/utils/asymptote/doc/FAQ/m-lout.pl b/Build/source/utils/asymptote/doc/FAQ/m-lout.pl new file mode 100644 index 00000000000..5c44852c750 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/m-lout.pl @@ -0,0 +1,242 @@ +## Lout output +# Copyright (C) 1993-1995 Ian Jackson. + +# This file 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, or (at your option) +# any later version. + +# It 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. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# (Note: I do not consider works produced using these BFNN processing +# tools to be derivative works of the tools, so they are NOT covered +# by the GPL. However, I would appreciate it if you credited me if +# appropriate in any documents you format using BFNN.) + +sub lout_init { + open(LOUT,">$prefix.lout"); + chop($dprint= `date '+%d %B %Y'`); + $dprint =~ s/^0//; +} + +sub lout_startup { + local ($lbs) = &lout_sanitise($user_brieftitle); + print LOUT <<END; +\@SysInclude{ fontdefs } +\@SysInclude{ langdefs } +\@SysInclude{ dl } +\@SysInclude{ docf } +\@Use { \@DocumentLayout + \@OddTop { \@Null } + \@EvenTop { \@Null } + \@StartOddTop { \@Null } + \@StartEvenTop { \@Null } + \@OddFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } } + \@EvenFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } } + \@StartOddFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } } + \@StartEvenFoot { { $lbs } \@Centre{ - \@PageNum - } \@Right{ $dprint } } + \@ParaGap { 1.70vx } + \@InitialBreak { 1.0fx ragged hyphen } +} +\@Use { \@OrdinaryLayout } +END + $lout_textstatus= 'p'; +} + +sub lout_pageref { + print LOUT "Q$_[1] (page {\@PageOf{$_[0]}}) "; + &lout_text("\`"); +} + +sub lout_endpageref { + &lout_text("'"); +} + +sub lout_finish { + print LOUT "\@End \@Text\n"; + close(L); +} + +sub lout_startmajorheading { + $lout_styles .= 'h'; + print LOUT <<END +\@CNP +{ + newpath 0 ysize 0.3 ft sub moveto + xsize 0 rlineto + 0 0.2 ft rlineto + xsize neg 0 rlineto + closepath fill +} \@Graphic { //1.6f \@HAdjust \@Heading{ +END + ; + $endh= "}\n{\@PageMark s_$_[0]}\n/1.0fo\n"; + &lout_text($_[0] ? "Section $_[0]. " : ''); +} + +sub lout_startminorheading { + $lout_styles .= 'h'; + print LOUT "//0.2f \@CNP {\@PageMark $_[0]} \@Heading{\n"; + $endh= ''; +} + +sub lout_endheading { + $lout_styles =~ s/.$//; print LOUT "}\n$endh"; + $lout_status= 'p'; +} + +sub lout_endmajorheading { &lout_endheading(@_); } +sub lout_endminorheading { &lout_endheading(@_); } + +sub lout_courier { + $lout_styles .= 'f'; + print LOUT "{{0.7 1.0} \@Scale {Courier Bold} \@Font {"; +} + +sub lout_endcourier { + $lout_styles =~ s/.$//; print LOUT "}}"; +} + +sub lout_italic { $lout_styles .= 'f'; print LOUT "{Slope \@Font {"; } +sub lout_enditalic { $lout_styles =~ s/.$//; print LOUT "}}"; } + +sub lout_startindent { $lout_styles .= 'i'; print LOUT "\@IndentedDisplay {\n"; } + +sub lout_endindent { + &lout_endpara; + $lout_styles =~ s/.$//; print LOUT "}\n\@LP\n"; +} + +sub lout_startpackedlist { $lout_plc=-1; } +sub lout_endpackedlist { &lout_newline if !$lout_plc; } +sub lout_packeditem { + &lout_newline if !$lout_plc; + &lout_tab(($lout_plc>0)*40+5); + $lout_plc= !$lout_plc; +} + +sub lout_startlist { + &lout_endpara; + print LOUT "\@RawIndentedList style {\@Bullet} indent {0.5i} gap {1.1vx}\n"; + $lout_styles .= 'l'; + $lout_status= ''; +} + +sub lout_endlist { + &lout_endpara; + print LOUT "\@EndList\n\n"; + $lout_styles =~ s/.$//; +} + +sub lout_item { + &lout_endpara; + print LOUT "\@ListItem{"; + $lout_styles.= 'I'; +} + +sub lout_startindex { + print LOUT "//0.0fe\n"; +} + +sub lout_endindex { + $lout_status='p'; +} + +sub lout_startindexmainitem { + $lout_marker= $_[0]; + $lout_status= ''; + print LOUT "//0.3vx Bold \@Font \@HAdjust { \@HContract { { $_[1] } |3cx {"; + $lout_iiendheight= '1.00'; + $lout_styles .= 'X'; +} + +sub lout_startindexitem { + $lout_marker= $_[0]; + print LOUT "\@HAdjust { \@HContract { { $_[1] } |3cx {"; + $lout_iiendheight= '0.95'; + $lout_styles .= 'X'; +} + +sub lout_endindexitem { + print LOUT "} } |0c \@PageOf { $lout_marker } } //${lout_iiendheight}vx\n"; + $lout_styles =~ s/.$//; +} + +sub lout_email { &lout_courier; &lout_text('<'); } +sub lout_endemail { &lout_text('>'); &lout_endcourier; } + +sub lout_ftpon { &lout_courier; } sub lout_endftpon { &lout_endcourier; } +sub lout_ftpin { &lout_courier; } sub lout_endftpin { &lout_endcourier; } +sub lout_docref { } sub lout_enddocref { } +sub lout_ftpsilent { $lout_ignore++; } +sub lout_endftpsilent { $lout_ignore--; } + +sub lout_newsgroup { &lout_courier; } +sub lout_endnewsgroup { &lout_endcourier; } + +sub lout_text { + return if $lout_ignore; + $lout_status= 'p'; + $_= &lout_sanitise($_[0]); + s/ $/\n/ unless $lout_styles =~ m/[fhX]/; + print LOUT $_; +} + +sub lout_tab { + local ($size) = $_[0]*0.5; + print LOUT " |${size}ft "; +} + +sub lout_newline { + print LOUT " //1.0vx\n"; +} + +sub lout_sanitise { + local ($in) = @_; + local ($out); + $in= ' '.$in.' '; + $out=''; + while ($in =~ m/(\s)(\S*[\@\/|\\\"\^\&\{\}\#]\S*)(\s)/) { + $out .= $`.$1; + $in = $3.$'; + $_= $2; + s/[\\\"]/\\$&/g; + $out .= '"'.$_.'"'; + } + $out .= $in; + $out =~ s/^ //; $out =~ s/ $//; + $out; +} + +sub lout_endpara { + return if $lout_status eq ''; + if ($lout_styles eq '') { + print LOUT "\@LP\n\n"; + } elsif ($lout_styles =~ s/I$//) { + print LOUT "}\n"; + } + $lout_status= ''; +} + +sub lout_startverbatim { + print LOUT "//0.4f\n\@RawIndentedDisplay lines \@Break". + " { {0.7 1.0} \@Scale {Courier Bold} \@Font {\n"; +} + +sub lout_verbatim { + $_= $_[0]; + s/^\s*//; + print LOUT &lout_sanitise($_),"\n"; +} + +sub lout_endverbatim { print LOUT "}\n}\n//0.4f\n"; } + +1; diff --git a/Build/source/utils/asymptote/doc/FAQ/m-post.pl b/Build/source/utils/asymptote/doc/FAQ/m-post.pl new file mode 100644 index 00000000000..e41c8d84fe4 --- /dev/null +++ b/Build/source/utils/asymptote/doc/FAQ/m-post.pl @@ -0,0 +1,189 @@ +## POST output +# Copyright (C) 1993-1995 Ian Jackson. + +# This file 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, or (at your option) +# any later version. + +# It 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. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# (Note: I do not consider works produced using these BFNN processing +# tools to be derivative works of the tools, so they are NOT covered +# by the GPL. However, I would appreciate it if you credited me if +# appropriate in any documents you format using BFNN.) + +sub post_init { + open(POST,">$prefix.post"); +} + +sub post_startmajorheading { + print POST '='x79,"\n\n"; + $post_status= 'h'; + &post_text($_[0] ? "Section $_[0]. " : ''); +} + +sub post_startminorheading { + print POST '-'x77,"\n\n"; + $post_status= 'h'; +} + +sub post_italic { &post_text('*'); } +sub post_enditalic { $post_para .= '*'; } + +sub post_email { &post_text('<'); } sub post_endemail { &post_text('>'); } + +sub post_ftpon { } sub post_endftpon { } +sub post_ftpin { } sub post_endftpin { } +sub post_docref { } sub post_enddocref { } +sub post_courier { } sub post_endcourier { } +sub post_newsgroup { } sub post_endnewsgroup { } +sub post_ftpsilent { $post_ignore++; } +sub post_endftpsilent { $post_ignore--; } + +sub post_text { + return if $post_ignore; + if ($post_status eq '') { + $post_status= 'p'; + } + $post_para .= $_[0]; +} + +sub post_tab { + local ($n) = $_[0]-length($post_para); + $post_para .= ' 'x$n if $n>0; +} + +sub post_newline { + return unless $post_status eq 'p'; + &post_writepara; +} + +sub post_writepara { + local ($thisline, $thisword, $rest); + for (;;) { + last unless $post_para =~ m/\S/; + $thisline= $post_indentstring; + for (;;) { + last unless $post_para =~ m/^(\s*\S+)/; + unless (length($1) + length($thisline) < 75 || + length($thisline) == length($post_indentstring)) { + last; + } + $thisline .= $1; + $post_para= $'; + } + $post_para =~ s/^\s*//; + print POST $thisline,"\n"; + $post_indentstring= $post_nextindent; + last unless length($post_para); + } + $post_status= ''; $post_para= ''; +} + +sub post_endpara { + return unless $post_status eq 'p'; + &post_writepara; + print POST "\n"; +} + +sub post_endheading { + $post_para =~ s/\s*$//; + print POST "$post_para\n\n"; + $post_status= ''; + $post_para= ''; +} + +sub post_endmajorheading { &post_endheading(@_); } +sub post_endminorheading { &post_endheading(@_); } + +sub post_startverbatim { + $post_vstatus= $post_status; + &post_writepara; +} + +sub post_verbatim { + print POST $_[0],"\n"; +} + +sub post_endverbatim { + $post_status= $post_vstatus; +} + +sub post_finish { + close(POST); +} + +sub post_startindex { $post_status= ''; } +sub post_endindex { $post_status= 'p'; } + +sub post_endindexitem { + printf POST " %-11s %-.66s\n",$post_left,$post_para; + $post_status= 'p'; + $post_para= ''; +} + +sub post_startindexitem { + $post_left= $_[1]; +} + +sub post_startindexmainitem { + $post_left= $_[1]; + print POST "\n" if $post_status eq 'p'; +} + +sub post_startindent { + $post_istatus= $post_status; + &post_writepara; + $post_indentstring= " $post_indentstring"; + $post_nextindent= " $post_nextindent"; +} + +sub post_endindent { + $post_indentstring =~ s/^ //; + $post_nextindent =~ s/^ //; + $post_status= $post_istatus; +} + +sub post_startpackedlist { $post_plc=0; } +sub post_endpackedlist { &post_newline if !$post_plc; } +sub post_packeditem { + &post_newline if !$post_plc; + &post_tab($post_plc*40+5); + $post_plc= !$post_plc; +} + +sub post_startlist { + &post_endpara; + $post_indentstring= " $post_indentstring"; + $post_nextindent= " $post_nextindent"; +} + +sub post_endlist { + &post_endpara; + $post_indentstring =~ s/^ //; + $post_nextindent =~ s/^ //; +} + +sub post_item { + &post_newline; + $post_indentstring =~ s/ $/* /; +} + +sub post_pageref { + &post_text("Q$_[1] \`"); +} + +sub post_endpageref { + &post_text("'"); +} + +1; |