I'm just learning how to use Asymptote. I've rendered a somewhat complex diagram including several paths and circles, simply using commands like draw((1,2)..(3,4))
, but now I'd like to repeat that diagram several times at different centerpoints. So either I need to assign the list of commands to a subroutine, or somehow assign them to a variable which I can call the draw
method on. The documentation is inexplicably mute on this question.
1 Answer
In asymptote
you may accomplish this by drawing on a picture
other than currentpicture
. Here I create and draw on picture
p
. picture
p
is then drawn on currentpicture
using the add
command, with transformations applied. The asymptote
manual has a section on the use of pictures.
unitsize(1cm);
picture p;
draw(p, scale(1,2)*unitsquare);
label(p, "$A$", (1,0), NW);
fill(p, scale(0.3,0.3)*unitcircle, red);
add(p);
add(shift(2,1)*p);
add(shift(2,-1)*rotate(-90)*scale(2)*p);
tikz
macro calls. Packages like this are only useful for one-of diagrams (and only if they are really complicated). You would need to go thru the output, and change the coordinates such that they are relative to an origin. Then you could easily repeat the figure, and customize it on a per use. Unless your diagram is extremely complicated you are better off doing it intikz
directly. I would need to have an idea of what the diagram looks like to offer more specific advice.