diff options
Diffstat (limited to 'fonts/knot/do2knots.mf')
-rw-r--r-- | fonts/knot/do2knots.mf | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/fonts/knot/do2knots.mf b/fonts/knot/do2knots.mf new file mode 100644 index 0000000000..bfcece09b8 --- /dev/null +++ b/fonts/knot/do2knots.mf @@ -0,0 +1,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 |