summaryrefslogtreecommitdiff
path: root/fonts/bartel-chess-fonts/other-sources/tt.mf
blob: 326cb3a92041ef09aecd33cca07ff8b28116e6fc (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
def OneCurl (expr a,da, b,db, above, pangle) =
  begingroup
    save dx, dy, p;
    pair dx; dx= b-a;
    pair dy; dy= dx rotated 90;
    pair p;   p= (a+.5dx+above*dy);
    a{da} .. {dx rotated pangle}p  & 
    p{dx rotated -pangle} .. {db}b
  endgroup
enddef;

def CurlIt(expr tp,	% the path
		n,	% how often
		above,  % the peak above the path
		pangle  % the direction at the peak
	) =	

  begingroup
    save dl; pair dl[];
    save dr; pair dr[];
    save i,l,r,ll,rr,delta;
    numeric i,l,r,delta

    i= 0;
    l= 0;
    r= length(tp);
    delta= length(tp)/n;
    forever:
      if i = n-i:
        z0l[i] = z0r[i] = point .5length(tp) of tp;
        dl[i]  = dr[i]  = direction .5length(tp) of tp;
      else:
	numeric ll; 
	if i=0: ll = l else: ll = l-(n-i)*.06delta fi;
        z0l[i] = good.lft (point ll of tp);
	dl[i]  = direction ll of tp;
	numeric rr; 
	if i=0: rr = r else: rr = r+(n-i)*.06delta fi;
	z0r[i] = good.rt  (point rr of tp);
	dr[i]  = direction rr of tp;
      fi
      exitif r-l < eps;
      i:= incr i;
      l:= l+delta;
      r:= r-delta;
    endfor;
    for i:= incr i step 1 until n:
      z0l[i] = z0r[n-i];
      z0r[i] = z0l[n-i];
      dl[i]  = dr[n-i];
      dr[i]  = dl[n-i];
    endfor;

    OneCurl(z0l0, dl0, z0l1, dl1, above, pangle)
    for i:= 2 step 1 until n:
      & OneCurl(z0l[i-1], dl[i-1], z0l[i], dl[i], above, pangle)
    endfor
  endgroup
enddef;

z0l = (10,10);
z0r = (200, 10);
z0  = .5[z0l,z0r] shifted 30up;

draw CurlIt(z0l .. z0 .. z0r, 5, 0.1, 30);
undraw(z0l3);
showit;

:map q :w:!mf