summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/metafont/mftoeps/m2esamp/clipcir.mf
blob: 50cf091764a477b5ad7dc8a83439760fd4bfc8ec (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
%%%%
%%%% This file belongs to the MFTOEPS package.
%%%%
% ---
% CLIPCIR.MF
% ---
input mftoeps; eps_mode_setup;
% ---
def ^ = ** enddef; % syntactic sugar
primarydef i // n = % ditto
 (if n=0: 0 else: i/n fi)
% why not to divide by 0?
enddef;
def shifted_accordingly(expr i,j,n,D)=
 shifted ((i//n)[1/2D,w-1/2D],(j//n)[1/2D,w-1/2D])
enddef;
% ---
w#=16mm#; h#=16mm#; define_pixels(w,h);
for N:=1,2,3,4: % 5, 6, ..., infinity
 set_BB 0,0,w,h;
 write_preamble jobname & decimal(N);
 D:=2w;
 for n:=0 for q:=1 upto N-1: , 2^q-1 endfor:
% i.e., |for n:=0, 2^1-1, 2^2-1, ..., 2^(N-1)-1:|
  path p[], q[]; D:=1/2D; k:=-1;
  for i:=0 upto n: for j:=0 upto n:
   k:=k+1;
   p[k]=fullcircle scaled D
    shifted_accordingly(i,j,n,D);
   q[k]=reverse fullcircle scaled 1/3D
    shifted_accordingly(i,j,n,D);
  endfor; endfor;
  clip_C p0, q0 for i:=1 upto k: , p[i], q[i] endfor;
 endfor;
 fill_C unitsquare scaled w;
 write_postamble;
endfor;
% ---
end.