I am a newbie of metapost. Please forgive my question if it is too simple.

  1. Can we define a path for two parallel lines? As daleif explained below, the answer is no since it is not a connected entity.
  2. Can we define a path for a connected entity that cannot be drawn in one stroke? For example, the picture below. Now I can't build one path for it.

enter image description here

I regard path as a block (including many items) and you can do action on the path thus working on all the items in the path. For example, for the above image, if it can be defined as a path grid, we can define grid linetype for all lines by draw grid dashed dashpattern(on 1bp off 2bp on 10bp off 2bp);. We can also do transformation on path.

  • 1
    A path is a connected entity. Two parallel lines are probably either a function or made a the type picture (this is an entiry that can have many things)
    – daleif
    Oct 11, 2017 at 9:39
  • Can you be a but more specific about what you are trying to do? What sort of "actions" do you want to do to the path? And what do you mean by "But the path example from tutorial always has intersection points" ? which example? from which tutorial?
    – Thruston
    Oct 11, 2017 at 14:04
  • @ Thruston, I updated the post. As to tutorial, there are a lot, e.g., mpman.pdf, or this: tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html
    – warem
    Oct 12, 2017 at 5:36
  • You perhaps are interested in a picture object rather than a path. Also pictures can be manipulated.
    – egreg
    Oct 12, 2017 at 6:19
  • 1
    You can define a path for that shape, if you don’t mind repeating a segment. But there is no real need to do this. Just draw the segments separately. If you don’t want to repeat the dashpattern part then just learn how to use drawoptions.
    – Thruston
    Oct 12, 2017 at 22:02

1 Answer 1


Here's an example that shows how to use a picture variable as @egreg suggests:

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";


z1 = -z5 = 70 right;
z3 = 70 up;
z2 = whatever[z1,z3]; z2 = whatever * (z3-z1) rotated 90;
z4 = whatever[z3,z5]; z4 = whatever * (z5-z3) rotated 90;

picture truss;
truss = image(
draw z1--z3--z5--cycle;
draw origin -- z2;
draw origin -- z3;
draw origin -- z4;

draw truss slanted .4 shifted 84 up dashed withdots scaled 1/2 withcolor red;
draw truss dashed dashpattern(on 4 off 2 on 1/2 off 2);

  • Wonderful! It is more like a block I said in my post. Thank you for teaching how to use picture.
    – warem
    Oct 13, 2017 at 9:43

You must log in to answer this question.

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