Debian Codegraph @

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

raw
1 % twoplustwo.mp
2 % L. Nobre G.
3 % 2006
4
5 def screenpath( expr CentrePoi, Width, Height, CorneRay ) =
6 begingroup
7 pair sp[];
8 sp0 = CentrePoi - 0.5*( Width*right + Height*up ) + CorneRay*down;
9 sp1 = CentrePoi + 0.5*( Width*right - Height*up ) + CorneRay*down;
10 sp2 = CentrePoi + 0.5*( Width*right - Height*up ) + CorneRay*right;
11 sp3 = CentrePoi + 0.5*( Width*right + Height*up ) + CorneRay*right;
12 sp4 = CentrePoi + 0.5*( Width*right + Height*up ) + CorneRay*up;
13 sp5 = CentrePoi - 0.5*( Width*right - Height*up ) + CorneRay*up;
14 sp6 = CentrePoi - 0.5*( Width*right - Height*up ) + CorneRay*left;
15 sp7 = CentrePoi - 0.5*( Width*right + Height*up ) + CorneRay*left;
16 ( sp0---sp1..sp2---sp3..sp4---sp5..sp6---sp7..cycle )
17 endgroup
18 enddef;
19
20 beginfig(1);
21 numeric u, i, j, k, l;
22 pen stdpen;
23 color bgcol, fgcol;
24 bgcol = 0.7white;
25 fgcol = 0.85*(blue+green);
26 stdpen = pencircle scaled 9pt;
27 u = 5cm;
28 for i=1 upto 5:
29 j := 90-72+i*72;
30 k := i+5;
31 l := k+5;
32 z[i] = u*dir(j);
33 z[k] = u*sind(18)*dir(j);
34 z[l] = u*sind(18)*dir(j+36)/cosd(36);
35 endfor;
36 path inip, inis, init, iniq, scrbord;
37 scrbord = screenpath( origin, 1.7u, 1.1u, 0.7u );
38 inip = z5---z2--z12{unitvector(z8-z2)}..{unitvector(z5-z9)}z14--cycle;
39 % inis = ( inip ) rotated 72;
40 % init = ( ( ( inip ) shifted -z5 ) yscaled -1 ) shifted z4;
41 % iniq = ( ( ( ( inip ) shifted -z2 ) yscaled -1 ) rotated 72 ) shifted z4;
42 % draw inip withpen pencircle scaled 3pt;
43 % draw inis;
44 % draw init;
45 % draw iniq;
46 fill inip withcolor fgcol;
47 draw inip withpen stdpen withcolor bgcol;
48 picture unitpic;
49 unitpic = currentpicture;
50 currentpicture := nullpicture;
51 fill scrbord withcolor bgcol;
52 draw ( ( ( ( unitpic ) shifted -z2 ) yscaled -1 ) rotated 72 ) shifted z4;
53 draw unitpic;
54 draw ( ( ( unitpic ) shifted -z5 ) yscaled -1 ) shifted z4;
55 draw ( unitpic ) rotated 72;
56 endfig;
57
58 end;
59