summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/metafont/mftoeps/m2esamp/stereo.mf
blob: c3e85ec53fe041583a7104f4c8d78bb0d6c93c61 (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
%%%%
%%%% This file belongs to the MFTOEPS package.
%%%%
% ---
% STEREO.MF
% ---
input mftoeps;
input polygons;
eps_mode_setup;
% ---
def soft_polygon (expr n,a) = flex_polygon(n,a-180/n,a+180/n) enddef;
% ---
def write_paths(expr name) =
  find_BB for i:=1 upto objects: elem_path[i], endfor elem_path[objects];
  write_preamble name;
  for i:=1 upto objects:
   coeff:=
    if objects=1: 0 else: .5(1-cosd(((i-1)/(objects-1))[alpha1,alpha2])) fi;
   coeff:=if coeff>.5: 1 else: 0 fi;
   fix_fill_cmyk forsuffixes $:=cyan, magenta, yellow: coeff[$1,$2], endfor
    coeff[black1,black2];
   fill_C elem_path[i];
  endfor;
  write_postamble;
enddef;
% ---
for ch:=0,1:
 beginchar("0",117pt#, 117pt#, 0);
  path elem_path[\\];
  objects:=100; transitions:=7;
  pair cent[\\];
  sca1:=.5w; sca2:=.01w;
  skew1:=60; skew2:=0;
  alpha1:=0; alpha2:=transitions*360;
  cshift0:=-.02w; cshift1:=-cshift0;
  cent1:=(.5w,.5h);
  rot1:=0; rot2:=rot1+60;
  cent2:=(.5w+cshift[ch],.49h);
  cyan1:=0; magenta1:=0; yellow1:=0; black1:=1;
  cyan2:=0; magenta2:=0; yellow2:=0; black2:=0;
  for i:=1 upto objects:
   if objects=1: coeff:=0; else: coeff:=(i-1)/(objects-1); fi
   elem_path[i]:= soft_polygon(4,coeff[skew1,skew2])
    scaled (coeff[sca1,sca2])
    rotated (coeff[rot1,rot2]+30)
    shifted (coeff[cent1,cent2]);
  endfor
  write_paths(jobname & decimal(ch));
endchar;

endfor

end.