Debian Codegraph @

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

raw
1 % graphene.mp
2 % L. Nobre G.
3 % 2011
4
5 prologues := 1;
6
7 input featpost3Dplus2D;
8
9 f := (9,13,7);
10 Spread := 15;
11
12 beginfig(1);
13 numeric s, c, rs, rc, i, j;
14 boolean isodd;
15 color ua, ub, uc, ta, tb;
16 path t;
17 s = 0.5;
18 c = sqrt(3)/2;
19 rs = 0.23;
20 rc = 0.15;
21 ua = (-s,c,0);
22 ub = (s,c,0);
23 uc = (1,0,0);
24 fill VGAborder withcolor 0.65white;
25 isodd = true;
26 j = 1;
27 ta = (-4.5,-5,0);
28 t = rigorousfearpath( ta, rs );
29 unfill t; draw t;
30 forever:
31 if isodd:
32 tb := ta + ua;
33 rigorousdisc( 0, true, ta+rs*ua, rc, ua*(1-2*rs));
34 else:
35 tb := ta + ub;
36 rigorousdisc( 0, true, ta+rs*ub, rc, ub*(1-2*rs));
37 fi;
38 t := rigorousfearpath( tb, rs );
39 unfill t; draw t;
40 isodd := not isodd;
41 ta := tb;
42 j := incr( j );
43 exitif j>11;
44 endfor;
45 for i=1 upto 6:
46 for j=1 upto 6:
47 if isodd:
48 ta := ((i-1)*1.5-4.5,(j-1)*2*c-5+c,0);
49 else:
50 ta := ((i-1)*1.5-4.5,(j-1)*2*c-5,0);
51 fi;
52 tb := ta + uc;
53 rigorousdisc( 0, true, ta+rs*uc, rc, uc*(1-2*rs));
54 endfor;
55 j := 1;
56 if isodd:
57 ta := ((i-1)*1.5-3,j-6,0);
58 else:
59 ta := ((i-1)*1.5-3.5,j-6,0);
60 fi;
61 t := rigorousfearpath( ta, rs );
62 unfill t; draw t;
63 forever:
64 if isodd:
65 tb := ta + ua;
66 rigorousdisc( 0, true, ta+rs*ua, rc, ua*(1-2*rs));
67 else:
68 tb := ta + ub;
69 rigorousdisc( 0, true, ta+rs*ub, rc, ub*(1-2*rs));
70 fi;
71 t := rigorousfearpath( tb, rs );
72 unfill t; draw t;
73 isodd := not isodd;
74 ta := tb;
75 j := incr( j );
76 exitif j>11;
77 endfor;
78 endfor;
79 endfig;
80
81 end.