Debian Codegraph @

texmf-dist/doc/metapost/featpost/example/trebuchet.mp

raw
1 % trebuchet.mp
2 % L. Nobre G.
3 % 2014
4
5 %prologues := 1;
6 %outputformat := "png";
7 %outputformatoptions := "format=rgb antialias=best";
8 %hppp := 0.25;
9 %vppp := 0.25;
10
11 beginfig(1);
12 numeric i, s, a, u, h, t;
13 pair pi, pj, pk;
14 u = 9mm;
15 h = 5u;
16 a = 0.039u;
17 s = 5;
18 draw (0,-h) for i=s-90 step s until 90:
19 ..(h*(2*cosd(i),sind(i)))
20 endfor --cycle;
21 draw origin--(2h,0);
22 t = 0;
23 forever:
24 t := incr(t);
25 i := h-0.5*a*t**2;
26 exitif i<-h;
27 pi := (0,i);
28 pj := (h+-+i,0);
29 pk := 2[pi,pj];
30 if i<0:
31 draw pj withpen pencircle scaled 0.17u;
32 fi;
33 draw pi--pk withcolor 0.5white;
34 endfor;
35 endfig;
36 end.