3 % Dedicated to my mom. (3/10/97)
5 % Mamma, ik hou van je; kom je alsjeblieft terug?
9 % TODO: remove crook_fatness
10 % TODO: document, simplify!
13 def draw_meta_flat (expr xcenter, w, crook_fatness, arrowup, arrowdown) =
15 save bottom_overshoot, bot_crook_dir;
16 save top_stem_thick, top_stem_thick_orig;
17 save bottom_stem_thick, hair, smaller_hole;
18 save top_crook_thinness;
21 pair center, bot_crook_dir;
22 save clearing, clearing_orig;
26 % the stem shouldn't reach the top staff line.
27 %% TODO: should take from height.
29 % TODO: parameterize this
31 if w >= 0.75 staff_space:
32 smaller_hole = 0.35 stafflinethickness;
36 crook_thinness = .7 stafflinethickness + .06 staff_space;
37 top_crook_thinness = 1 stafflinethickness + .065 staff_space;
38 clearing = 1.7 stafflinethickness;
39 clearing_orig = clearing;
41 clearing := 0.5 staff_space;
43 bottom_overshoot = stafflinethickness;
45 bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
46 top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
47 top_stem_thick_orig# = top_stem_thick#;
49 % to look nice, arrowed stems should be less brushed
50 top_stem_thick# := top_stem_thick# * 0.8;
52 define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick,
55 if odd (top_stem_thick - bottom_stem_thick):
56 top_stem_thick := top_stem_thick - 1;
58 if odd (top_stem_thick_orig - bottom_stem_thick):
59 top_stem_thick_orig := top_stem_thick_orig - 1;
62 center = (xcenter, 0);
64 x1l = hround (xcenter - .5 top_stem_thick);
65 y1 = vround (2 staff_space - clearing);
66 x2l = hround (xcenter - .5 bottom_stem_thick);
67 y2 = -.5 staff_space - .5 stafflinethickness;
68 % z16 and the `*_orig' variables are needed for arrowed accidentals
69 % because their inner part should be unchanged from plain ones but
70 % the points z3l, z3r, and z10 depend on values that are different
71 % for arrowed accidentals
72 x16l = hround (xcenter -.5 top_stem_thick_orig);
73 y16 = vround (2 staff_space - clearing_orig);
75 penpos1 (top_stem_thick, 0);
76 penpos16 (top_stem_thick_orig, 0);
77 penpos2 (bottom_stem_thick, 0);
79 y3l = vfloor ((staff_space - stafflinethickness) / 2);
80 z3l = whatever [z2r, z1r];
82 (z16r shifted (0, clearing_orig - 1.7 stafflinethickness))]
86 % we insert z3l to get better conversion with mf2pt1
87 fill simple_serif (z1r, z1l, 30)
93 z10 = whatever [z2r, z16r] + (smaller_hole, 0);
94 y10 = -1/10 staff_space;
97 x11 = xcenter + bottom_overshoot / 3;
98 y11 = -vround (.5 (staff_space + stafflinethickness)
104 penpos4 (whatever, 53);
106 y4l - y4r = top_crook_thinness;
107 y5r = .15 staff_space;
108 x5l = hround (w + xcenter);
109 y4 = staff_space / 2;
110 x4r = .45 [x5r, x3r];
113 penpos5 (crook_fatness, -175);
115 bot_crook_dir = unitvector ((x5l, 0) - z11);
116 z8 = z11 + whatever * bot_crook_dir;
117 y8 = -staff_space / 2;
120 + whatever * bot_crook_dir
121 + crook_thinness * (bot_crook_dir rotated 90);
124 unfill z3r{z3r - z10}
127 .. z7{-bot_crook_dir}
151 draw_arrow (z1, top_stem_thick, z1l - z2l,
152 0.5 stafflinethickness, false);
155 draw_arrow ((0.5 [x2l, x2a], y2), x2a - x2l, up,
156 staff_space / 2, true);
161 def draw_arrowed_meta_flat (expr xcenter, width, crook_fatness,
162 arrowup, arrowdown) =
163 save depth, height, extendleft;
165 depth# = 0.6 staff_space#;
166 height# = 1.9 staff_space#;
167 extendleft# := 1.2 stafflinethickness#;
169 extendleft# := 3.45 stafflinethickness#;
170 height# := height# + 0.8 staff_space#;
173 extendleft# := 3.45 stafflinethickness#;
174 depth# := depth# + 1.6 staff_space#;
177 set_char_box (extendleft#, width, depth#, height#);
178 draw_meta_flat(xcenter, w, crook_fatness, arrowup, arrowdown);
182 % unfortunately, 600dpi is not enough to show the brush of the stem.
185 fet_beginchar ("Flat", "flat");
186 draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
188 penlabels (range 0 thru 11);
190 draw_staff_if_debugging (-2, 2);
194 fet_beginchar ("Arrowed Flat (arrow up)", "flat.arrowup");
195 draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
197 penlabels (range 0 thru 23);
199 draw_staff_if_debugging (-2, 2);
203 fet_beginchar ("Arrowed Flat (arrow down)", "flat.arrowdown");
204 draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
206 penlabels (range 0 thru 23);
208 draw_staff_if_debugging (-2, 2);
212 fet_beginchar ("Arrowed Flat (arrow up and down)", "flat.arrowboth");
213 draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
215 penlabels (range 0 thru 23);
217 draw_staff_if_debugging (-2, 2);
221 fet_beginchar ("Flat (slashed)", "flat.slash");
222 set_char_box (.4 staff_space#, .8 staff_space#,
223 0.6 staff_space#, 1.9 staff_space#);
225 draw_meta_flat (0, w, 0.31 staff_space, false, false);
229 save slope, slash_width;
234 z12 = z11 - (slash_width, slash_width * slope) / 2;
235 z13 = z11 + (slash_width, slash_width * slope) / 2;
236 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
237 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
239 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
240 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
254 draw_staff_if_debugging (-2, 2);
258 fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
259 set_char_box (.4 staff_space#, .8 staff_space#,
260 0.6 staff_space#, 1.9 staff_space#);
262 draw_meta_flat (0, w, 0.31 staff_space, false, false);
266 save slope, slash_width;
271 z12 = z11 - (slash_width, slash_width * slope) / 2;
272 z13 = z11 + (slash_width, slash_width * slope) / 2;
273 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
274 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
276 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
277 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
292 z22 = z21 - (slash_width, slash_width * slope) / 2;
293 z23 = z21 + (slash_width, slash_width * slope) / 2;
294 penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
295 penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
297 z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
298 z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
312 draw_staff_if_debugging (-2, 2);
316 fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
317 set_char_box (0, 1.6 staff_space#,
318 0.6 staff_space#, 1.9 staff_space#);
320 % This is a modified version of `draw_meta_flat'.
322 save crook_thinness, crook_fatness;
323 save bottom_overshoot, bot_crook_dir;
324 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
325 save top_crook_thinness;
328 pair center, bot_crook_dir;
337 % the stem shouldn't reach the top staff line.
338 %% TODO: should take from height.
340 % TODO: parameterize this
342 if wid >= 0.75 staff_space:
343 smaller_hole = 0.35 stafflinethickness;
347 clearing = 1.7 stafflinethickness;
348 crook_thinness = .7 stafflinethickness + .06 staff_space;
349 crook_fatness = 0.31 staff_space;
350 top_crook_thinness = 1 stafflinethickness + .065 staff_space;
351 bottom_overshoot = stafflinethickness;
353 bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
354 top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
355 define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
357 if odd (top_stem_thick - bottom_stem_thick):
358 top_stem_thick := top_stem_thick - 1;
363 x1l = hround (-.5 top_stem_thick);
364 y1 = vround (2 staff_space - clearing);
365 x2l = hround (-.5 bottom_stem_thick);
366 y2 = -.5 staff_space - .5 stafflinethickness;
368 penpos1 (top_stem_thick, 0);
369 penpos2 (bottom_stem_thick, 0);
371 y3l = vfloor ((staff_space - stafflinethickness) / 2);
372 z3l = whatever [z2r, z1r];
373 z3r = .3 [z2r, z1r] + (smaller_hole, 0);
376 z10 = whatever [z2r, z1r] + (smaller_hole, 0);
377 y10 = -1/10 staff_space;
380 x11 = bottom_overshoot / 3;
381 y11 = -vround (.5 (staff_space + stafflinethickness)
384 penpos4 (whatever, 53);
386 y4l - y4r = top_crook_thinness;
387 y5r = .15 staff_space;
389 y4 = staff_space / 2;
390 x4r = .45 [x5r, x3r];
393 penpos5 (crook_fatness, -175);
395 bot_crook_dir = unitvector ((x5l, 0) - z11);
396 z8 = z11 + whatever * bot_crook_dir;
397 y8 = -staff_space / 2;
400 + whatever * bot_crook_dir
401 + crook_thinness * (bot_crook_dir rotated 90);
404 pat := z3r{z3r - z10}
407 .. z7{-bot_crook_dir}
412 unfill pat xscaled -1;
420 -- simple_serif (z1r, z1l, 30)
421 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
424 currentpicture := currentpicture shifted (w/2, 0);
426 draw_staff_if_debugging (-2, 2);
430 fet_beginchar ("Semi flat", "mirroredflat");
431 set_char_box (1.2 stafflinethickness#, .8 staff_space#,
432 0.6 staff_space#, 1.9 staff_space#);
434 draw_meta_flat (0, w, 0.31 staff_space, false, false);
435 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
439 fet_beginchar ("Semi flat", "mirroredflat.backslash");
440 set_char_box (.4 staff_space#, .8 staff_space#,
441 0.6 staff_space#, 1.9 staff_space#);
443 draw_meta_flat (0, w, 0.31 staff_space, false, false);
447 save slope, slash_width;
452 z12 = z11 - (slash_width, slash_width * slope) / 2;
453 z13 = z11 + (slash_width, slash_width * slope) / 2;
454 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
455 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
457 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
458 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
469 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
475 fet_beginchar ("Double Flat", "flatflat");
476 save left_wid, overlap, right_wid;
482 set_char_box (1.2 stafflinethickness#,
483 (left_wid + right_wid - overlap) * staff_space#,
484 .6 staff_space#, 1.9 staff_space#);
485 draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space,
487 draw_meta_flat (hround ((left_wid - overlap) * staff_space),
488 right_wid * staff_space, 1/3 staff_space,
493 fet_beginchar ("3/4 Flat", "flatflat.slash");
494 save left_wid, overlap, right_wid;
500 set_char_box (1.2 stafflinethickness#,
501 (left_wid + right_wid - overlap) * staff_space#,
502 .6 staff_space#, 1.9 staff_space#);
503 draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space,
505 draw_meta_flat (hround ((left_wid - overlap) * staff_space),
506 right_wid * staff_space, 1/3 staff_space,
509 %% maybe we should clip part of the stems?
510 %% or make the 1st flat smaller?
512 pickup pencircle scaled 2 stafflinethickness;
514 z12 = round (-.25 w - b, .55 staff_space) + feta_offset;
515 z13 = round (.75 w, 1.45 staff_space) + feta_offset;
516 penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
517 penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
519 z14 = z12 - stafflinethickness * unitvector (z13 - z12);
520 z15 = z13 + stafflinethickness * unitvector (z13 - z12);
534 draw_staff_if_debugging (-2, 2);