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;
20 def draw_staff(expr first, last, offset)=
21 pickup pencircle scaled stafflinethickness;
22 for i:= first step 1 until last:
23 draw (- staff_space, (i + offset) * staff_space) .. (4 staff_space,( i+ offset)* staff_space);
32 def scaledabout(expr point, scale) =
33 shifted -point scaled scale shifted point
38 % make a local (restored after endgroup) copy of t_var
40 def local_copy(text type, t_var)=
51 % Urgh! Want to do parametric types
54 def del_picture_stack=
55 save save_picture_stack, picture_stack_idx;
58 % better versions of Taupin/Egler savepic cmds
61 def make_picture_stack =
62 % override previous stack.
64 picture save_picture_stack[];
65 numeric picture_stack_idx;
66 picture_stack_idx := 0;
67 def push_picture(expr p) =
68 save_picture_stack[picture_stack_idx] := p ;
69 picture_stack_idx := picture_stack_idx + 1;
71 def pop_picture = save_picture_stack[decr picture_stack_idx] enddef;
72 def top_picture = save_picture_stack[picture_stack_idx] enddef;
77 % why can't I delete individual pens?
81 numeric pen_stack_idx;
83 def push_pen(expr p) =
84 save_pen_stack[pen_stack_idx] := p ;
85 pen_stack_idx := pen_stack_idx +1;
87 def pop_pen = save_pen_stack[decr pen_stack_idx] enddef;
88 def top_pen = save_pen_stack[pen_stack_idx] enddef;
91 save save_pen_stack, pen_stack_idx;
98 def soft_penstroke text t =
99 forsuffixes e = l,r: path_.e:=t; endfor
103 fill path_.l .. tension1.5 .. reverse path_.r .. tension1.5 .. cycle
107 def simple_serif(expr p,q, a)=
108 p{dir(angle(q-p) -a)} .. q{ - dir(angle(p -q) + a)}
114 % err_x: drift of y axis at top
115 % err_y: drift of x axis at right
116 def distorted_ellipse(expr a,b,err_y,err_x,super) =
117 superellipse((a,err_x),(-err_y,b),(-a,-err_x),(err_y,-b),super);
122 def draw_rounded_block (expr bottom_left, top_right, roundness) =
124 round = floor min(roundness,xpart (top_right-bottom_left),
125 ypart (top_right-bottom_left));
128 pickup pencircle scaled round;
132 z2+(round/2,round/2) = top_right;
133 z4-(round/2,round/2) = bottom_left;
138 fill bot z1 .. rt z1 --- rt z2 .. top z2 ---
139 top z3 .. lft z3 --- lft z4 .. bot z4 --- cycle;
145 def draw_block (expr bottom_left, top_right) =
146 draw_rounded_block (bottom_left, top_right, blot_diameter);
149 def draw_gridline (expr bottom_left,top_right,thickness) =
150 draw_rounded_block (bottom_left-(thickness/2,thickness/2),
151 top_right+(thickness/2,thickness/2),
156 def draw_brush(expr a,w,b,v) =
159 penpos3(w,angle(z2-z1)+90);
160 penpos4(w,angle(z2-z1));
161 penpos5(v,angle(z1-z2)+90);
162 penpos6(v,angle(z1-z2));
166 fill z3r{z3r-z5l}..z4l..{z5r-z3l}z3l..z5r{z5r-z3l}..z6l..{z3r-z5l}z5l..cycle;
174 % alpha = start direction.
175 % beta = which side to turn to.
176 % flare = diameter of the bulb
177 % line = diameter of line attachment
178 % direction = is ink on left or right side (1 or -1)
180 def flare_path(expr pos,alpha,beta,line,flare, direction) =
183 penpos1(line,180+beta+alpha);
185 penpos2(flare,180+beta+alpha);
187 penpos3(flare,0+alpha);
188 z3l=z1r+(1/2+0.43)*flare*dir(alpha+beta);
191 z4=z2r- line * dir(alpha);
197 p:=z1r{dir(alpha)}..z3r{dir(180+alpha-beta)}..z2l{dir(alpha+180)}
198 ..z3l{dir(180+alpha+beta)}..tension t
199 ..z4{dir(180+alpha+beta)}..z1l{dir(alpha+180)};
209 def flare_path_t(expr pos,alpha,beta,line, flare, bulb, direction) =
212 penpos1(line, 180+beta+alpha);
214 penpos2(bulb, 180+beta+alpha);
216 penpos3(bulb, 0+alpha);
217 save taille,roundness;
221 z3r = z1 + flare * (dir (alpha) + dir (alpha +beta));
222 z4= z2r - taille * line * dir(alpha)
223 + roundness * line *dir (alpha - beta)
231 p:=z1r{dir(alpha)}..z3r{dir(180+alpha-beta)}..z2l{dir(alpha+180)}
232 ..z3l{dir(180+alpha+beta)}..tension t
233 ..z4{dir(180+alpha+beta)}
234 ..z1l{dir(alpha+180)};
245 def brush(expr a,w,b,v) =
253 % Draw a (rest) crook, starting at thickness STEM in point A,
254 % ending a ball W to the left, diameter BALLDIAM
255 % ypart of the center of the ball is BALLDIAM/4 lower than ypart A
257 def balled_crook(expr a, w, balldiam, stem) =
260 penpos1(balldiam/2,-90);
261 penpos2(balldiam/2,0);
262 penpos3(balldiam/2,90);
263 penpos4(balldiam/2,180);
264 x4r=xpart a-w; y3r=ypart a+balldiam/4;
268 x5=x4r+9/8balldiam; y5r=y1r;
270 x6l=xpart a; y6l=ypart a;
271 penstroke z1e..z2e..z3e..z4e..z1e..z5e{right}..z6e;
272 penlabels(1,2,3,4,5,6);
278 currentpicture := currentpicture yscaled -1;
279 set_char_box(charbp, charwd, charht, chardp);
284 currentpicture := currentpicture scaled -1;
285 set_char_box(charwd, charbp, charht, chardp);
290 % center_factor: typically .5, the larger, the larger the radius of the bulb
291 % radius factor: how much the bulb curves inward
293 def draw_bulb(expr turndir, zl, zr, bulb_rad, radius_factor)=
300 % don't get near infinity
301 %z0 = zr + bulb_rad * (zl-zr)/length(zr -zl);
302 z0 = zr + bulb_rad /length(zr -zl) * (zl-zr);
306 z1 = z0 + radius_factor* rad * dir(ang + turndir* 100);
307 z2 = z0 + rad * dir(ang + turndir*300);
309 fill zr{dir (ang + turndir* 90)} .. z1 .. z2 -- cycle;