4

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.

3
  • This is one of the problems of using a pacakge that generates the 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 in tikz directly. I would need to have an idea of what the diagram looks like to offer more specific advice. Oct 17, 2012 at 0:29
  • I'm really not sure what is wanted here as an answer, so I've closed. Please edit and request reopening.
    – Joseph Wright
    Jul 7, 2013 at 7:58
  • 1
    Reopened on request from answerer May 20, 2015 at 21:24

1 Answer 1

3

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);

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .