summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/ruler.mp
blob: 0736abf47ed4b2e0bfcba9788435fc138c540f46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
% add a ruler along the left hand and lower edges 
% of the bounding box of the currentpicture
path B, p; pair o; B = bbox currentpicture;
for s=-1, 1:
  p := subpath (0, s) of B;
  a := arclength p;
  o := if s < 0: left else: down fi;
  for i=0 upto 3:
    exitif not known u[i];
    for j=0 upto floor(a/u[i]):
      pair t; t = point arctime j*u[i] of p of p;
      draw (origin -- (7 - 2i) * o) shifted t;
      if i=0: label(decimal j, t shifted 12 o); fi
    endfor
  endfor
  draw p;
endfor