6 proofrulethickness 1pt#;
7 makegrid(0pt,0pt for i:=-5pt step 1pt until 5pt: ,i endfor)
8 (0pt,0pt for i:=-5pt step 1pt until 5pt: ,i endfor);
9 proofrulethickness .1pt#;
10 makegrid(0pt,0pt for i:=-4.8pt step .2pt until 4.8pt: ,i endfor)
11 (0pt,0pt for i:=-4.8pt step .2pt until 4.8pt: ,i endfor);
16 tracingequations := tracingonline := 1;
24 def scaledabout(expr point, scale) =
25 shifted -point scaled scale shifted point
30 % make a local (restored after endgroup) copy of t_var
32 def local_copy(text type, t_var)=
43 % Urgh! Want to do parametric types
46 def del_picture_stack=
47 save save_picture_stack, picture_stack_idx;
50 % better versions of Taupin/Egler savepic cmds
53 def make_picture_stack =
54 % override previous stack.
56 picture save_picture_stack[];
57 numeric picture_stack_idx;
58 picture_stack_idx := 0;
59 def push_picture(expr p) =
60 save_picture_stack[picture_stack_idx] := p ;
61 picture_stack_idx := picture_stack_idx + 1;
63 def pop_picture = save_picture_stack[decr picture_stack_idx] enddef;
64 def top_picture = save_picture_stack[picture_stack_idx] enddef;
69 % why can't I delete individual pens?
73 numeric pen_stack_idx;
75 def push_pen(expr p) =
76 save_pen_stack[pen_stack_idx] := p ;
77 pen_stack_idx := pen_stack_idx +1;
79 def pop_pen = save_pen_stack[decr pen_stack_idx] enddef;
80 def top_pen = save_pen_stack[pen_stack_idx] enddef;
83 save save_pen_stack, pen_stack_idx;
90 def simple_serif(expr p,q, a)=
91 p{dir(angle(q-p) -a)} .. q{ - dir(angle(p -q) + a)}
97 % err_x: drift of y axis at top
98 % err_y: drift of x axis at right
99 def distorted_ellipse(expr a,b,err_y,err_x,super) =
100 superellipse((a,err_x),(-err_y,b),(-a,-err_x),(err_y,-b),super);
103 def draw_brush(expr a,w,b,v) =
106 penpos3(w,angle(z2-z1)+90);
107 penpos4(w,angle(z2-z1));
108 penpos5(v,angle(z1-z2)+90);
109 penpos6(v,angle(z1-z2));
113 fill z3r{z3r-z5l}..z4l..{z5r-z3l}z3l..z5r{z5r-z3l}..z6l..{z3r-z5l}z5l..cycle;
116 def brush(expr a,w,b,v) =
126 def balled_crook(expr a, w, balldiam, stem) =
129 penpos1(balldiam/2,-90);
130 penpos2(balldiam/2,0);
131 penpos3(balldiam/2,90);
132 penpos4(balldiam/2,180);
133 x4r=xpart a-w; y3r=ypart a+balldiam/4;
137 x5=x4r+9/8balldiam; y5r=y1r;
139 x6l=xpart a; y6l=ypart a;
140 penstroke z1e..z2e..z3e..z4e..z1e..z5e{right}..z6e;
141 penlabels(1,2,3,4,5,6);
146 currentpicture := currentpicture yscaled -1;
147 set_char_box(charbp, charwd, charht, chardp);
152 currentpicture := currentpicture scaled -1;
153 set_char_box(charwd, charbp, charht, chardp);
158 % center_factor: typically .5, the larger, the larger the radius of the bulb
159 % radius factor: how much the bulb curves inward
161 def draw_bulb(expr turndir, zl, zr, bulb_rad, radius_factor)=
167 z0 = zr + bulb_rad * (zl-zr)/length(zr -zl);
170 z1 = z0 + radius_factor* rad * dir(ang + turndir* 100);
171 z2 = z0 + rad * dir(ang + turndir*300);
173 fill zr{dir (ang + turndir* 90)} .. z1 .. z2 -- cycle;