2 % feta-toevallig.mf -- implement Accidentals
4 % (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 % also show in other configuration wrt staff lines.
11 def draw_shifted_too =
13 fet_beginchar ("shifted too", "");
14 set_char_box (0, 0, 0, 0);
15 currentpicture := remember_pic;
17 draw_staff (-2, 2, 0.5);
24 % Accidentals from various sources, notably
26 % Baerenreiter edition of Schuberts `Auf dem Strom' (sharp, natural)
27 % F Hofmeister edition of Muellers `Etueden fuer Horn' (double sharp, flat)
32 % Naming for accidentals (including microtonal variants):
34 % SHARPBASE[.SLASHES.STEMS]
39 % sharp.slashslash.stem
45 fet_begingroup ("accidentals");
50 % * "stemslant" gives the direction of the stem's left boundary
51 % (needed for brushed stems, equals "up" for straight stems)
52 % * "extend" is used to make the stem longer or shorter (if negative);
53 % different kinds of accidentals need different values here
55 def draw_arrow (expr attach, stemwidth, stemslant, extend, pointingdown) =
57 save htip; % tip height
58 save wwing; % wing "radius"
59 save angle_wing_bot, angle_wing_top, angle_tip;
63 wwing:=0.26 stemwidth;
64 htip:=staff_space*0.85 + stafflinethickness - wwing;
66 % "flip" is used to reflect the arrow vertically if arrow points downward
69 flip=identity reflectedabout (origin, right);
74 z1=attach shifted ((-stemwidth/2),0);
75 upshift:=max(0, wwing + 0.1 staff_space + extend);
76 z2=z1 shifted (((unitvector stemslant) scaled upshift) transformed flip);
78 z7=attach shifted ((stemwidth/2),0);
79 z6=z7 shifted (((unitvector (-xpart stemslant, ypart stemslant))
80 scaled upshift) transformed flip);
81 (z2-z3)= (0.38 staff_space, 0.05 htip) transformed flip;
82 (z6-z5)=(-0.38 staff_space, 0.05 htip) transformed flip;
84 z4 =attach shifted ((-0.2 stemwidth, upshift+htip) transformed flip);
85 z4'=attach shifted (( 0.2 stemwidth, upshift+htip) transformed flip);
87 % angle_wing_bot is the angle at which the arc from z2 to z3a enters z3a
88 % angle_wing_top is the angle at which the arc from z3b to z4 leaves z3b
89 % angle_tip is the angle at which the arc from z4 to z4' leaves z4
94 z3a=z3 shifted ((((dir angle_wing_bot) rotated (-90))
95 scaled wwing) transformed flip);
96 z3b=z3 shifted ((((dir angle_wing_top) rotated 90)
97 scaled wwing) transformed flip);
99 z5a=z5 shifted ((((dir (180-angle_wing_bot)) rotated 90)
100 scaled wwing) transformed flip);
101 z5b=z5 shifted ((((dir (180-angle_wing_top)) rotated (-90))
102 scaled wwing) transformed flip);
105 pickup pencircle scaled 1;
107 -- z2{stemslant transformed flip}
108 .. {(-dir angle_wing_bot) transformed flip}z3a
109 .. z3b{(dir angle_wing_top) transformed flip}
110 .. z4{(dir angle_tip) transformed flip}
111 .. z4'{(dir (-angle_tip)) transformed flip}
112 ..{(dir (-angle_wing_top)) transformed flip}z5b
113 ..z5a{(-dir (-angle_wing_bot)) transformed flip}
114 ..z6{((-stemslant) reflectedabout (origin, up)) transformed flip}
118 labels(range 0 thru 7,4',3a,3b,5a,5b);
123 picture remember_pic;
125 save sharp_beamheight;
126 sharp_beamheight# := 0.3 staff_space# + stafflinethickness#;
129 % The beams of most sharps have horizontal endings (as if drawn with
130 % a square pen). [Wanske] does not mention this, so we'll just ignore
134 def draw_meta_sharp (expr width, offset) =
135 save beamwidth, beamslope;
141 define_whole_vertical_blacker_pixels (sharp_beamheight);
145 beamslope = sharp_beamheight / beamwidth;
147 pickup pencircle scaled 2 blot_diameter;
149 rt x2 - lft x1 = beamwidth;
150 z2 = z1 + whatever * (beamwidth, sharp_beamheight);
151 .5 [z1, z3] = (.5 w, offset);
153 top y2 - bot y3 = sharp_beamheight;
155 top y1 - bot y4 = sharp_beamheight;
157 ne = unitvector (z2 - z1);
158 nw_dist = (ne rotated 90) * blot_diameter;
161 ... (z1 + nw_dist){ne}
162 -- (z2 + nw_dist){ne}
165 ... (z3 - nw_dist){-ne}
166 -- (z4 - nw_dist){-ne}
174 def draw_sharp(expr arrowup, arrowdown) =
175 save stem, stemx, stemwidth;
176 save outer_space, interbeam;
177 save stemlength, extendleft, extendright, height, depth;
179 stemwidth# := stafflinethickness# + .05 staff_space#;
180 define_whole_blacker_pixels (stemwidth);
182 interbeam := 1.05 staff_space_rounded;
184 stemlength# := 1.5 staff_space#;
185 define_pixels (stemlength);
187 height# = stemlength#;
188 depth# = stemlength#;
192 height# := height# + 1.2 staff_space#;
193 extendright# := extendright# + 1.5 stafflinethickness#;
196 depth# := depth# + 1.2 staff_space#;
197 extendleft# := extendleft# + 1.5 stafflinethickness#;
199 define_pixels(extendleft, extendright);
200 set_char_box (extendleft#, 1.1 staff_space#, depth#, height#);
203 stemx := hround stem;
204 outer_space := hround ((w - stemx - stemwidth) / 2);
206 w := 2 outer_space + stemx + stemwidth;
207 d := d - feta_space_shift;
209 draw_meta_sharp (w, -.5 interbeam);
210 draw_meta_sharp (w, -.5 interbeam + vround interbeam);
212 % expand the charbox so that it encloses the whole arrow; this mustn't
213 % happen earlier because some commands above still rely on the old width
214 w := w + extendright;
216 pickup pencircle scaled stemwidth;
218 lft x5 = lft x6 = outer_space;
219 lft x7 = lft x8 = outer_space + stemx;
220 bot y5 = -stemlength;
221 top y6 = vround (1.5 staff_space - stem * beamslope);
222 bot y7 = -top y6 + feta_space_shift;
227 draw_gridline (z5, z6, stemwidth);
228 draw_gridline (z7, z8, stemwidth);
231 draw_arrow (z8, stemwidth, up,
232 +(stafflinethickness/2 + stemwidth/2), false);
235 draw_arrow (z5, stemwidth, up,
236 +(stafflinethickness/2 + stemwidth/2), true);
239 remember_pic := currentpicture;
241 draw_staff (-2, 2, 0);
245 fet_beginchar ("Sharp", "sharp");
246 draw_sharp (false, false);
253 fet_beginchar ("Arrowed Sharp (arrow up)", "sharp.arrowup");
254 draw_sharp (true, false);
261 fet_beginchar ("Arrowed Sharp (arrow down)", "sharp.arrowdown");
262 draw_sharp (false, true);
269 fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem");
270 save stem, stemwidth;
271 save outer_space, interbeam;
273 stemwidth# := stafflinethickness# + .05 staff_space#;
274 define_whole_blacker_pixels (stemwidth);
276 interbeam := 1.05 staff_space_rounded;
278 set_char_box (0, 0.7 staff_space#,
279 1.5 staff_space#, 1.5 staff_space#);
282 outer_space := hround ((w - stemwidth) / 2);
284 w := 2 outer_space + stemwidth;
285 d := d - feta_space_shift;
287 draw_meta_sharp (w, -.5 interbeam);
288 draw_meta_sharp (w, -.5 interbeam + vround interbeam);
290 pickup pencircle scaled stemwidth;
292 lft x5 = lft x6 = outer_space;
293 top y6 = vround (1.5 staff_space - .5 stem);
294 bot y5 = -top y6 + feta_space_shift;
298 draw_gridline (z5, z6, stemwidth);
300 remember_pic := currentpicture;
302 draw_staff (-2, 2, 0);
309 fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem");
310 save stem, stemx, stemwidth;
311 save outer_space, interbeam;
312 save sharp_beamheight;
314 sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
316 stemwidth# := stafflinethickness# + .05 staff_space#;
317 define_whole_blacker_pixels (stemwidth);
319 interbeam := 1.2 staff_space_rounded;
321 set_char_box (0, 1.1 staff_space#,
322 1.5 staff_space#, 1.5 staff_space#);
325 stemx := hround stem;
326 outer_space := hround ((w - stemx - stemwidth) / 2);
328 w := 2 outer_space + stemx + stemwidth;
329 d := d - feta_space_shift;
331 draw_meta_sharp (.88 w, -.5 interbeam);
332 draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam);
333 sharp_beamheight# := 1/.88 sharp_beamheight#;
334 draw_meta_sharp (w, 0);
336 pickup pencircle scaled stemwidth;
338 lft x5 = lft x6 = outer_space;
339 lft x7 = lft x8 = outer_space + stemx;
341 top y6 = vround (1.5 staff_space - stem * beamslope);
342 bot y7 = -top y6 + feta_space_shift;
347 draw_gridline (z5, z6, stemwidth);
348 draw_gridline (z7, z8, stemwidth);
350 remember_pic := currentpicture;
352 draw_staff (-2, 2, 0);
359 fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem");
360 save stem, stemx, stemwidth;
361 save outer_space, interbeam;
362 save sharp_beamheight;
364 sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
366 stemwidth# := stafflinethickness# + .05 staff_space#;
367 define_whole_blacker_pixels (stemwidth);
369 interbeam := 1.2 staff_space_rounded;
371 set_char_box (0, 0.95 staff_space#,
372 1.3 staff_space#, 1.3 staff_space#);
375 outer_space := hround ((w - stemwidth) / 2);
377 w := 2 outer_space + stemwidth;
378 d := d - feta_space_shift;
380 draw_meta_sharp (.8 w, -.5 interbeam);
381 draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam);
382 sharp_beamheight# := 1/.8 sharp_beamheight#;
383 draw_meta_sharp (w, 0);
385 pickup pencircle scaled stemwidth;
387 lft x5 = lft x6 = outer_space;
388 top y6 = vround (1.5 staff_space - .5 stem);
389 bot y5 = -top y6 + feta_space_shift;
392 draw_gridline (z5, z6, stemwidth);
394 remember_pic := currentpicture;
396 draw_staff (-2, 2, 0);
403 fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem");
404 save stem, stemx, stemwidth;
405 save outer_space, interbeam;
407 stemwidth# := stafflinethickness# + .05 staff_space#;
408 define_whole_blacker_pixels (stemwidth);
410 interbeam := 1.05 staff_space_rounded;
412 set_char_box (0, 1.6 staff_space#,
413 1.5 staff_space#, 1.5 staff_space#);
416 stemx := hround stem;
417 outer_space := hround ((w - 2 stemx - stemwidth) / 2);
419 w := 2 outer_space + 2 stemx + stemwidth;
420 d := d - feta_space_shift;
422 draw_meta_sharp (w, -.5 interbeam);
423 draw_meta_sharp (w, -.5 interbeam + vround interbeam);
425 pickup pencircle scaled stemwidth;
427 lft x5 = lft x6 = outer_space;
428 lft x7 = lft x8 = outer_space + stemx;
429 lft x9 = lft x10 = outer_space + 2 stemx;
431 top y6 = vround (1.5 staff_space - 2 stem * beamslope);
432 bot y9 = -top y6 + feta_space_shift;
437 labels (5, 6, 7, 8, 9, 10);
439 draw_gridline (z5, z6, stemwidth);
440 draw_gridline (z7, z8, stemwidth);
441 draw_gridline (z9, z10, stemwidth);
443 remember_pic := currentpicture;
445 draw_staff (-2, 2, 0);
453 % The stems of the natural are brushed (at least, in Barenreiter SCS)
456 def draw_natural (expr arrowup, arrowdown) =
457 save stemwidth, top_stem_thick;
458 save ne, pat_top, pat_bottom;
459 save depth, height, extendleft, extendright, stemlength;
460 save brush_scale_up, brush_scale_down;
462 path pat_top, pat_bottom;
464 top_stem_thick# = stafflinethickness# + .10 staff_space#;
465 stemwidth# = 0.09 staff_space# + .5 stafflinethickness#;
466 define_whole_blacker_pixels (top_stem_thick, stemwidth);
468 stemlength# = 1.5 staff_space#;
469 define_pixels (stemlength);
471 height# = stemlength#;
472 depth# = stemlength#;
476 extendleft# := 3 stafflinethickness#;
477 height# := height# + 1.2 staff_space#;
480 extendright# := 3.15 stafflinethickness#;
481 depth# := depth# + 1.2 staff_space#;
483 define_pixels (extendright);
485 set_char_box (extendleft#, 2/3 staff_space#, depth#, height#);
487 d := d - feta_space_shift;
489 pickup pencircle scaled stemwidth;
491 brush_scale_up := 1.0;
492 brush_scale_down := 1.0;
493 % to look nice, arrowed stems must be less brushed
495 brush_scale_up := 0.85;
498 brush_scale_down := 0.85;
501 penpos1 (top_stem_thick, 0);
502 penpos3 (top_stem_thick, 0);
503 penpos2 (stemwidth, 0);
504 penpos4 (stemwidth, 0);
505 % z1' and z3' are needed for the arrowed accidentals
506 penpos1' (top_stem_thick * brush_scale_up, 0);
507 penpos3' (top_stem_thick * brush_scale_down, 0);
514 y1 = y1' = stemlength;
515 y3 = y3' = -stemlength;
516 top y2 = vround (staff_space - 3/2 stafflinethickness);
517 y4 = -y2 + feta_space_shift;
519 pat_bottom := z4r{z4r - z1r}
522 fill simple_serif (z1'l, z1'r, -30)
526 pat_top := z2r{z2r - z3r}
529 fill simple_serif (z3'l, z3'r, 30)
533 ne = (x2 - x4, stafflinethickness);
535 z11' = z3l + whatever * (z2l - z3l);
536 y11' = vround (.5 (staff_space - stafflinethickness));
537 z11 = z11' + whatever * ne;
539 z12 = directionpoint -ne of pat_top;
540 z13 = z12 + whatever * ne;
542 z14 = z11 + whatever * ne;
545 z21' = z4r + whatever * (z1r - z4r);
546 y21' = -y11' + feta_space_shift;
547 z21 = z21' + whatever * ne;
549 z22 = directionpoint -ne of pat_bottom;
550 z23 = z22 + whatever * ne;
552 z24 = z21 + whatever * ne;
566 penlabels (1, 1', 2, 3, 3', 4);
567 labels (11, 11', 12, 13, 14, 21, 21', 22, 23, 24);
570 draw_arrow (z1, top_stem_thick * brush_scale_up,
571 z1'l-z4l, stafflinethickness/2, false);
574 draw_arrow (z3, top_stem_thick * brush_scale_down,
575 z2r-z3'r, stafflinethickness/2, true);
576 w := w + extendright;
579 remember_pic := currentpicture;
581 draw_staff (-2, 2, 0);
584 fet_beginchar ("Natural", "natural");
585 draw_natural (false, false);
592 fet_beginchar ("Natural", "natural.arrowup");
593 draw_natural (true, false);
600 fet_beginchar ("Natural", "natural.arrowdown");
601 draw_natural (false, true);
609 % Dedicated to my mom. (3/10/97)
611 % Mamma, ik hou van je; kom je alsjeblieft terug?
615 % TODO: remove crook_fatness
616 % TODO: document, simplify!
619 def draw_meta_flat (expr xcenter, w, crook_fatness, arrowup, arrowdown) =
621 save bottom_overshoot, bot_crook_dir;
622 save top_stem_thick, top_stem_thick_orig, bottom_stem_thick, hair, smaller_hole;
623 save top_crook_thinness;
626 pair center, bot_crook_dir;
627 save clearing, clearing_orig;
631 % the stem shouldn't reach the top staff line.
632 %% TODO: should take from height.
634 % TODO: parameterize this
636 if w >= 0.75 staff_space:
637 smaller_hole = 0.35 stafflinethickness;
641 crook_thinness = .7 stafflinethickness + .06 staff_space;
642 top_crook_thinness = 1 stafflinethickness + .065 staff_space;
643 clearing = 1.7 stafflinethickness;
644 clearing_orig = clearing;
646 clearing := 0.5 staff_space;
648 bottom_overshoot = stafflinethickness;
650 bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
651 top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
652 top_stem_thick_orig# = top_stem_thick#;
654 % to look nice, arrowed stems should be less brushed
655 top_stem_thick# := top_stem_thick#*0.80;
657 define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick,
658 top_stem_thick_orig);
660 if odd (top_stem_thick - bottom_stem_thick):
661 top_stem_thick := top_stem_thick - 1;
663 if odd (top_stem_thick_orig - bottom_stem_thick):
664 top_stem_thick_orig := top_stem_thick_orig - 1;
667 center = (xcenter, 0);
669 x1l = hround (xcenter - .5 top_stem_thick);
670 y1 = vround (2 staff_space - clearing);
671 x2l = hround (xcenter - .5 bottom_stem_thick);
672 y2 = -.5 staff_space - .5 stafflinethickness;
673 % z16 and the _orig variables are needed for arrowed accidentals because
674 % their inner part should be unchanged from plain ones but the points z3l,
675 % z3r and z10 depend on values that are different for arrowed accidentals
676 x16l = hround (xcenter - .5 top_stem_thick_orig);
677 y16 = vround (2 staff_space - clearing_orig);
679 penpos1 (top_stem_thick, 0);
680 penpos16 (top_stem_thick_orig, 0);
681 penpos2 (bottom_stem_thick, 0);
683 y3l = vfloor ((staff_space - stafflinethickness) / 2);
684 z3l = whatever [z2r, z1r];
685 z3r = .3 [z2r, (z16r shifted (0, clearing_orig - 1.7 stafflinethickness))]
689 % we insert z3l to get better conversion with mf2pt1
690 fill simple_serif (z1r, z1l, 30)
696 z10 = whatever [z2r, z16r] + (smaller_hole, 0);
697 y10 = -1/10 staff_space;
700 x11 = xcenter + bottom_overshoot / 3;
701 y11 = -vround (.5 (staff_space + stafflinethickness)
707 penpos4 (whatever, 53);
709 y4l - y4r = top_crook_thinness;
710 y5r = .15 staff_space;
711 x5l = hround (w + xcenter);
712 y4 = staff_space / 2;
713 x4r = .45 [x5r, x3r];
716 penpos5 (crook_fatness, -175);
718 bot_crook_dir = unitvector ((x5l, 0) - z11);
719 z8 = z11 + whatever * bot_crook_dir;
720 y8 = -staff_space / 2;
723 + whatever * bot_crook_dir
724 + crook_thinness * (bot_crook_dir rotated 90);
727 unfill z3r{z3r - z10}
730 .. z7{-bot_crook_dir}
754 draw_arrow (z1, top_stem_thick, z1l-z2l,
755 0.5stafflinethickness, false);
758 draw_arrow ((0.5[x2l,x2a],y2), x2a-x2l, up,
759 staff_space/2, true);
764 def draw_arrowed_meta_flat (expr xcenter, width, crook_fatness, arrowup, arrowdown) =
765 save depth, height, extendleft;
767 depth# = 0.6 staff_space#;
768 height# = 1.9 staff_space#;
769 extendleft# := 1.2 stafflinethickness#;
771 extendleft# := 3.45 stafflinethickness#;
772 height# := height# + 0.8 staff_space#;
775 extendleft# := 3.45 stafflinethickness#;
776 depth# := depth# + 1.6 staff_space#;
779 set_char_box (extendleft#, width, depth#, height#);
780 draw_meta_flat(xcenter, w, crook_fatness, arrowup, arrowdown);
784 % unfortunately, 600dpi is not enough to show the brush of the stem.
787 fet_beginchar ("Flat", "flat");
788 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, false, false);
789 penlabels (range 0 thru 11);
791 remember_pic := currentpicture;
793 draw_staff (-2, 2, 0);
800 fet_beginchar ("Arrowed Flat (up-arrow)", "flat.arrowup");
801 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, true, false);
802 penlabels (range 0 thru 23);
804 remember_pic := currentpicture;
806 draw_staff (-2, 2, 0.0);
813 fet_beginchar ("Arrowed Flat (down-arrow)", "flat.arrowdown");
814 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, false, true);
815 penlabels (range 0 thru 23);
817 remember_pic := currentpicture;
819 draw_staff (-2, 2, 0.0);
826 fet_beginchar ("Flat (slashed)", "flat.slash");
827 set_char_box (.4 staff_space#, .8 staff_space#,
828 0.6 staff_space#, 1.9 staff_space#);
830 draw_meta_flat (0, w, 0.31 staff_space, false, false);
834 save slope, slash_width;
839 z12 = z11 - (slash_width, slash_width * slope) / 2;
840 z13 = z11 + (slash_width, slash_width * slope) / 2;
841 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
842 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
844 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
845 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
859 remember_pic := currentpicture;
861 draw_staff (-2, 2, 0);
865 fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
866 set_char_box (.4 staff_space#, .8 staff_space#,
867 0.6 staff_space#, 1.9 staff_space#);
869 draw_meta_flat (0, w, 0.31 staff_space, false, false);
873 save slope, slash_width;
878 z12 = z11 - (slash_width, slash_width * slope) / 2;
879 z13 = z11 + (slash_width, slash_width * slope) / 2;
880 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
881 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
883 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
884 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
899 z22 = z21 - (slash_width, slash_width * slope) / 2;
900 z23 = z21 + (slash_width, slash_width * slope) / 2;
901 penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
902 penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
904 z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
905 z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
919 remember_pic := currentpicture;
921 draw_staff (-2, 2, 0);
925 fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
926 set_char_box (0, 1.6 staff_space#,
927 0.6 staff_space#, 1.9 staff_space#);
929 % This is a modified version of `draw_meta_flat'.
931 save crook_thinness, crook_fatness;
932 save bottom_overshoot, bot_crook_dir;
933 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
934 save top_crook_thinness;
937 pair center, bot_crook_dir;
946 % the stem shouldn't reach the top staff line.
947 %% TODO: should take from height.
949 % TODO: parameterize this
951 if wid >= 0.75 staff_space:
952 smaller_hole = 0.35 stafflinethickness;
956 clearing = 1.7 stafflinethickness;
957 crook_thinness = .7 stafflinethickness + .06 staff_space;
958 crook_fatness = 0.31 staff_space;
959 top_crook_thinness = 1 stafflinethickness + .065 staff_space;
960 bottom_overshoot = stafflinethickness;
962 bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
963 top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
964 define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
966 if odd (top_stem_thick - bottom_stem_thick):
967 top_stem_thick := top_stem_thick - 1;
972 x1l = hround (-.5 top_stem_thick);
973 y1 = vround (2 staff_space - clearing);
974 x2l = hround (-.5 bottom_stem_thick);
975 y2 = -.5 staff_space - .5 stafflinethickness;
977 penpos1 (top_stem_thick, 0);
978 penpos2 (bottom_stem_thick, 0);
980 y3l = vfloor ((staff_space - stafflinethickness) / 2);
981 z3l = whatever [z2r, z1r];
982 z3r = .3 [z2r, z1r] + (smaller_hole, 0);
985 z10 = whatever [z2r, z1r] + (smaller_hole, 0);
986 y10 = -1/10 staff_space;
989 x11 = bottom_overshoot / 3;
990 y11 = -vround (.5 (staff_space + stafflinethickness)
993 penpos4 (whatever, 53);
995 y4l - y4r = top_crook_thinness;
996 y5r = .15 staff_space;
998 y4 = staff_space / 2;
999 x4r = .45 [x5r, x3r];
1002 penpos5 (crook_fatness, -175);
1004 bot_crook_dir = unitvector ((x5l, 0) - z11);
1005 z8 = z11 + whatever * bot_crook_dir;
1006 y8 = -staff_space / 2;
1009 + whatever * bot_crook_dir
1010 + crook_thinness * (bot_crook_dir rotated 90);
1013 pat := z3r{z3r - z10}
1016 .. z7{-bot_crook_dir}
1021 unfill pat xscaled -1;
1024 .. z8{bot_crook_dir}
1029 -- simple_serif (z1r, z1l, 30)
1030 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
1033 currentpicture := currentpicture shifted (w/2, 0);
1035 remember_pic := currentpicture;
1037 draw_staff (-2, 2, 0);
1044 fet_beginchar ("Semi flat", "mirroredflat");
1045 set_char_box (1.2 stafflinethickness#, .8 staff_space#,
1046 0.6 staff_space#, 1.9 staff_space#);
1048 draw_meta_flat (0, w, 0.31 staff_space, false, false);
1049 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
1053 fet_beginchar ("Semi flat", "mirroredflat.backslash");
1054 set_char_box (.4 staff_space#, .8 staff_space#,
1055 0.6 staff_space#, 1.9 staff_space#);
1057 draw_meta_flat (0, w, 0.31 staff_space, false, false);
1061 save slope, slash_width;
1066 z12 = z11 - (slash_width, slash_width * slope) / 2;
1067 z13 = z11 + (slash_width, slash_width * slope) / 2;
1068 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
1069 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
1071 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
1072 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
1083 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
1089 fet_beginchar ("Double Flat", "flatflat");
1090 save left_wid, overlap, right_wid;
1096 set_char_box (1.2 stafflinethickness#,
1097 (left_wid + right_wid - overlap) * staff_space#,
1098 .6 staff_space#, 1.9 staff_space#);
1099 draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space, false, false);
1100 draw_meta_flat (hround ((left_wid - overlap) * staff_space),
1101 right_wid * staff_space, 1/3 staff_space, false, false);
1105 fet_beginchar ("3/4 Flat", "flatflat.slash");
1106 save left_wid, overlap, right_wid;
1112 set_char_box (1.2 stafflinethickness#,
1113 (left_wid + right_wid - overlap) * staff_space#,
1114 .6 staff_space#, 1.9 staff_space#);
1115 draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space, false, false);
1116 draw_meta_flat (hround ((left_wid - overlap) * staff_space),
1117 right_wid * staff_space, 1/3 staff_space, false, false);
1119 %% maybe we should clip part of the stems?
1120 %% or make the 1st flat smaller?
1122 pickup pencircle scaled 2 stafflinethickness;
1124 z12 = round (-.25 w - b, .55 staff_space) + feta_offset;
1125 z13 = round (.75 w, 1.45 staff_space) + feta_offset;
1126 penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
1127 penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
1129 z14 = z12 - stafflinethickness * unitvector (z13 - z12);
1130 z15 = z13 + stafflinethickness * unitvector (z13 - z12);
1144 remember_pic := currentpicture;
1146 draw_staff (-2, 2, 0);
1153 fet_beginchar ("Double Sharp", "doublesharp");
1154 save klaverblad, klaversteel;
1158 klaversteel = 1/15 staff_space;
1159 klaverblad = .4 staff_space - .5 stafflinethickness;
1161 set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
1163 z1 = (klaversteel, 0);
1164 z2 = (w / 2 - klaverblad / 10, h - klaverblad);
1166 z4 = z2 reflectedabout ((0, 0), (1, 1));
1167 z5 = z1 reflectedabout ((0, 0), (1, 1));
1169 labels (1, 2, 3, 4, 5);
1171 pickup pencircle scaled blot_diameter;
1173 x2 := hfloor (rt x2) - blot_diameter / 2;
1174 x3 := hfloor (rt x3) - blot_diameter / 2;
1175 y3 := vfloor (top y3) - blot_diameter / 2;
1176 y4 := vfloor (top y4) - blot_diameter / 2;
1178 pat = (rt z1){dir45}
1185 .. {dir 225}(top z5);
1187 -- reverse pat xscaled -1 shifted (-feta_eps, 0);
1189 % assure symmetry -- it's more important to center the glyph on the
1190 % staff line than centering it between staff lines, so we use
1191 % feta_shift, not feta_space_shift.
1192 h := h + feta_shift;
1194 fill pat shifted (0, feta_shift)
1195 -- reverse pat yscaled -1 shifted (0, -feta_eps)
1199 currentpicture := currentpicture shifted (hround (w / 2), 0);
1201 remember_pic := currentpicture;
1203 draw_staff (-2, 2, 0);
1213 leftindent := .2 staff_space;
1215 set_char_box (0, .5 staff_space# + stafflinethickness#,
1216 staff_space#, staff_space#);
1218 d := d - feta_shift;
1220 z1 = (leftindent, h);
1221 z2 = (w - stafflinethickness, .5 (h - d));
1222 z3 = (leftindent, -d);
1224 penpos1 (stafflinethickness, 35);
1225 penpos2 (.1 staff_space + stafflinethickness, 0);
1226 penpos3 (stafflinethickness, -35);
1229 .. simple_serif (z3l, z3r, 90)
1231 .. simple_serif (z1r, z1l, 90)
1237 fet_beginchar ("Right Parenthesis", "rightparen");
1239 penlabels (1, 2, 3);
1241 remember_pic := currentpicture;
1243 draw_staff (-2, 2, 0);
1250 fet_beginchar ("Left Parenthesis", "leftparen");
1253 currentpicture := currentpicture xscaled -1;
1255 set_char_box (charwd, charbp, chardp, charht);
1258 fet_endgroup ("accidentals");