summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/twoplustwo.mp
blob: 0aeb2f916d67becd96f914dc3db4712bca5a2bb7 (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
% twoplustwo.mp
% L. Nobre G. 
% 2006

def screenpath( expr CentrePoi, Width, Height, CorneRay ) =
  begingroup
    pair sp[];
    sp0 = CentrePoi - 0.5*( Width*right + Height*up ) + CorneRay*down;
    sp1 = CentrePoi + 0.5*( Width*right - Height*up ) + CorneRay*down;
    sp2 = CentrePoi + 0.5*( Width*right - Height*up ) + CorneRay*right;
    sp3 = CentrePoi + 0.5*( Width*right + Height*up ) + CorneRay*right;
    sp4 = CentrePoi + 0.5*( Width*right + Height*up ) + CorneRay*up;
    sp5 = CentrePoi - 0.5*( Width*right - Height*up ) + CorneRay*up;
    sp6 = CentrePoi - 0.5*( Width*right - Height*up ) + CorneRay*left;
    sp7 = CentrePoi - 0.5*( Width*right + Height*up ) + CorneRay*left;
    ( sp0---sp1..sp2---sp3..sp4---sp5..sp6---sp7..cycle )
  endgroup
enddef;
    
beginfig(1);
  numeric u, i, j, k, l;
  pen stdpen;
  color bgcol, fgcol;
  bgcol = 0.7white;
  fgcol = 0.85*(blue+green);
  stdpen = pencircle scaled 9pt;
  u = 5cm;
  for i=1 upto 5:
    j := 90-72+i*72;
    k := i+5;
    l := k+5;
    z[i] = u*dir(j);
    z[k] = u*sind(18)*dir(j);
    z[l] = u*sind(18)*dir(j+36)/cosd(36);
  endfor;
  path inip, inis, init, iniq, scrbord;
  scrbord = screenpath( origin, 1.7u, 1.1u, 0.7u );
  inip = z5---z2--z12{unitvector(z8-z2)}..{unitvector(z5-z9)}z14--cycle;
%  inis = ( inip ) rotated 72;
%  init = ( ( ( inip ) shifted -z5 ) yscaled -1 ) shifted z4;
%  iniq = ( ( ( ( inip ) shifted -z2 ) yscaled -1 ) rotated 72 ) shifted z4;
%  draw inip withpen pencircle scaled 3pt;
%  draw inis;
%  draw init;
%  draw iniq;
  fill inip withcolor fgcol;
  draw inip withpen stdpen withcolor bgcol;
  picture unitpic;
  unitpic = currentpicture;
  currentpicture := nullpicture;
  fill scrbord withcolor bgcol;
  draw ( ( ( ( unitpic ) shifted -z2 ) yscaled -1 ) rotated 72 ) shifted z4;
  draw unitpic;
  draw ( ( ( unitpic ) shifted -z5 ) yscaled -1 ) shifted z4;
  draw ( unitpic ) rotated 72;
endfig;

end;