summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/graphene.mp
blob: 8bab59cb0aa2dcaca1044c8467d7868be0f06cd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
% graphene.mp
% L. Nobre G.
% 2011

input featpost3Dplus2D;

f := (9,13,7);
Spread := 23;

beginfig(1);
  numeric s, c, rs, rc, i, j;
  boolean isodd;
  color ua, ub, uc, ta, tb;
  path t;
  s = 0.5;
  c = sqrt(3)/2;
  rs = 0.23;
  rc = 0.15;
  ua = (-s,c,0);
  ub = (s,c,0);
  uc = (1,0,0);
  isodd = true;
  j = 1;
  ta = (-4.5,-5,0);
  t = rigorousfearpath( ta, rs );
  unfill t; draw t;
  forever:
    if isodd:
      tb := ta + ua;
      rigorousdisc( 0, true, ta+rs*ua, rc, ua*(1-2*rs));
    else:
      tb := ta + ub;
      rigorousdisc( 0, true, ta+rs*ub, rc, ub*(1-2*rs));
    fi;
    t := rigorousfearpath( tb, rs );
    unfill t; draw t;
    isodd := not isodd;
    ta := tb;
    j := incr( j );
    exitif j>11;
  endfor;
  for i=1 upto 6:
    for j=1 upto 6: 
      if isodd:
	ta := ((i-1)*1.5-4.5,(j-1)*2*c-5+c,0);
      else:
	ta := ((i-1)*1.5-4.5,(j-1)*2*c-5,0);
      fi;
      tb := ta + uc;
      rigorousdisc( 0, true, ta+rs*uc, rc, uc*(1-2*rs));
    endfor;
    j := 1;
    if isodd:
      ta := ((i-1)*1.5-3,j-6,0);
    else:
      ta := ((i-1)*1.5-3.5,j-6,0);
    fi;    
    t := rigorousfearpath( ta, rs );
    unfill t; draw t;
    forever:
      if isodd:
	tb := ta + ua;
	rigorousdisc( 0, true, ta+rs*ua, rc, ua*(1-2*rs));
      else:
	tb := ta + ub;
	rigorousdisc( 0, true, ta+rs*ub, rc, ub*(1-2*rs));
      fi;
      t := rigorousfearpath( tb, rs );
      unfill t; draw t;
      isodd := not isodd;
      ta := tb;
      j := incr( j );
      exitif j>11;
    endfor;
  endfor;
endfig;

end.