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
|
pickup pencircle scaled thick;
knot_pen := savepen;
pickup pencircle scaled thin;
thin_pen := savepen;
numeric a[];
a1 := angle(sqwid#, sqht#);
a2 := 180 - a1;
a3 := 180 + a1;
a4 := 360 - a1;
pair x[]ll, x[]rr, x[]c;
pair y[]ll, y[]rr, y[]c;
path parp_.l, parp_.r, parp_.c, parp_.ll, parp_.rr;
def llrrexp(expr max_num) =
for ii := 0 upto max_num:
z[ii].c = z[ii];
z[ii].ll = indist[z[ii].l, z[ii].r];
z[ii].rr = indist[z[ii].r, z[ii].l];
endfor;
enddef;
def penstroke text t =
forsuffixes e = c,l,r,ll,rr: parp_.e:=t; endfor
if cycle parp_.l: cyclestroke_
else:
unfill parp_.ll -- reverse parp_.rr -- cycle;
cullit;
forsuffixes e = c,l,r,ll,rr:
if knotstyle.e = 2:
pickup knot_pen; draw parp_.e;
elseif knotstyle.e = 1:
pickup thin_pen; draw parp_.e;
elseif knotstyle.e = -1:
pickup thin_pen; undraw parp_.e;
elseif knotstyle.e = -2:
pickup knot_pen; undraw parp_.e;
fi
endfor
if knotstyle.solid = 1:
fill parp_.l -- reverse parp_.r -- cycle;
elseif knotstyle.solid = 2:
fill parp_.ll -- reverse parp_.rr -- cycle;
elseif knotstyle.solid = 3:
fill parp_.ll -- reverse parp_.l -- cycle;
fill parp_.rr -- reverse parp_.r -- cycle;
fi
cullit;
fi
enddef;
input tri
|