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 ("Arrowed Sharp (arrow down)", "sharp.arrowboth");
270 draw_sharp (true, true);
277 fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem");
278 save stem, stemwidth;
279 save outer_space, interbeam;
281 stemwidth# := stafflinethickness# + .05 staff_space#;
282 define_whole_blacker_pixels (stemwidth);
284 interbeam := 1.05 staff_space_rounded;
286 set_char_box (0, 0.7 staff_space#,
287 1.5 staff_space#, 1.5 staff_space#);
290 outer_space := hround ((w - stemwidth) / 2);
292 w := 2 outer_space + stemwidth;
293 d := d - feta_space_shift;
295 draw_meta_sharp (w, -.5 interbeam);
296 draw_meta_sharp (w, -.5 interbeam + vround interbeam);
298 pickup pencircle scaled stemwidth;
300 lft x5 = lft x6 = outer_space;
301 top y6 = vround (1.5 staff_space - .5 stem);
302 bot y5 = -top y6 + feta_space_shift;
306 draw_gridline (z5, z6, stemwidth);
308 remember_pic := currentpicture;
310 draw_staff (-2, 2, 0);
317 fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem");
318 save stem, stemx, stemwidth;
319 save outer_space, interbeam;
320 save sharp_beamheight;
322 sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
324 stemwidth# := stafflinethickness# + .05 staff_space#;
325 define_whole_blacker_pixels (stemwidth);
327 interbeam := 1.2 staff_space_rounded;
329 set_char_box (0, 1.1 staff_space#,
330 1.5 staff_space#, 1.5 staff_space#);
333 stemx := hround stem;
334 outer_space := hround ((w - stemx - stemwidth) / 2);
336 w := 2 outer_space + stemx + stemwidth;
337 d := d - feta_space_shift;
339 draw_meta_sharp (.88 w, -.5 interbeam);
340 draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam);
341 sharp_beamheight# := 1/.88 sharp_beamheight#;
342 draw_meta_sharp (w, 0);
344 pickup pencircle scaled stemwidth;
346 lft x5 = lft x6 = outer_space;
347 lft x7 = lft x8 = outer_space + stemx;
349 top y6 = vround (1.5 staff_space - stem * beamslope);
350 bot y7 = -top y6 + feta_space_shift;
355 draw_gridline (z5, z6, stemwidth);
356 draw_gridline (z7, z8, stemwidth);
358 remember_pic := currentpicture;
360 draw_staff (-2, 2, 0);
367 fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem");
368 save stem, stemx, stemwidth;
369 save outer_space, interbeam;
370 save sharp_beamheight;
372 sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
374 stemwidth# := stafflinethickness# + .05 staff_space#;
375 define_whole_blacker_pixels (stemwidth);
377 interbeam := 1.2 staff_space_rounded;
379 set_char_box (0, 0.95 staff_space#,
380 1.3 staff_space#, 1.3 staff_space#);
383 outer_space := hround ((w - stemwidth) / 2);
385 w := 2 outer_space + stemwidth;
386 d := d - feta_space_shift;
388 draw_meta_sharp (.8 w, -.5 interbeam);
389 draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam);
390 sharp_beamheight# := 1/.8 sharp_beamheight#;
391 draw_meta_sharp (w, 0);
393 pickup pencircle scaled stemwidth;
395 lft x5 = lft x6 = outer_space;
396 top y6 = vround (1.5 staff_space - .5 stem);
397 bot y5 = -top y6 + feta_space_shift;
400 draw_gridline (z5, z6, stemwidth);
402 remember_pic := currentpicture;
404 draw_staff (-2, 2, 0);
411 fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem");
412 save stem, stemx, stemwidth;
413 save outer_space, interbeam;
415 stemwidth# := stafflinethickness# + .05 staff_space#;
416 define_whole_blacker_pixels (stemwidth);
418 interbeam := 1.05 staff_space_rounded;
420 set_char_box (0, 1.6 staff_space#,
421 1.5 staff_space#, 1.5 staff_space#);
424 stemx := hround stem;
425 outer_space := hround ((w - 2 stemx - stemwidth) / 2);
427 w := 2 outer_space + 2 stemx + stemwidth;
428 d := d - feta_space_shift;
430 draw_meta_sharp (w, -.5 interbeam);
431 draw_meta_sharp (w, -.5 interbeam + vround interbeam);
433 pickup pencircle scaled stemwidth;
435 lft x5 = lft x6 = outer_space;
436 lft x7 = lft x8 = outer_space + stemx;
437 lft x9 = lft x10 = outer_space + 2 stemx;
439 top y6 = vround (1.5 staff_space - 2 stem * beamslope);
440 bot y9 = -top y6 + feta_space_shift;
445 labels (5, 6, 7, 8, 9, 10);
447 draw_gridline (z5, z6, stemwidth);
448 draw_gridline (z7, z8, stemwidth);
449 draw_gridline (z9, z10, stemwidth);
451 remember_pic := currentpicture;
453 draw_staff (-2, 2, 0);
461 % The stems of the natural are brushed (at least, in Barenreiter SCS)
464 def draw_natural (expr arrowup, arrowdown) =
465 save stemwidth, top_stem_thick;
466 save ne, pat_top, pat_bottom;
467 save depth, height, extendleft, extendright, stemlength;
468 save brush_scale_up, brush_scale_down;
470 path pat_top, pat_bottom;
472 top_stem_thick# = stafflinethickness# + .10 staff_space#;
473 stemwidth# = 0.09 staff_space# + .5 stafflinethickness#;
474 define_whole_blacker_pixels (top_stem_thick, stemwidth);
476 stemlength# = 1.5 staff_space#;
477 define_pixels (stemlength);
479 height# = stemlength#;
480 depth# = stemlength#;
484 extendleft# := 3 stafflinethickness#;
485 height# := height# + 1.2 staff_space#;
488 extendright# := 3.15 stafflinethickness#;
489 depth# := depth# + 1.2 staff_space#;
491 define_pixels (extendright);
493 set_char_box (extendleft#, 2/3 staff_space#, depth#, height#);
495 d := d - feta_space_shift;
497 pickup pencircle scaled stemwidth;
499 brush_scale_up := 1.0;
500 brush_scale_down := 1.0;
501 % to look nice, arrowed stems must be less brushed
503 brush_scale_up := 0.85;
506 brush_scale_down := 0.85;
509 penpos1 (top_stem_thick, 0);
510 penpos3 (top_stem_thick, 0);
511 penpos2 (stemwidth, 0);
512 penpos4 (stemwidth, 0);
513 % z1' and z3' are needed for the arrowed accidentals
514 penpos1' (top_stem_thick * brush_scale_up, 0);
515 penpos3' (top_stem_thick * brush_scale_down, 0);
522 y1 = y1' = stemlength;
523 y3 = y3' = -stemlength;
524 top y2 = vround (staff_space - 3/2 stafflinethickness);
525 y4 = -y2 + feta_space_shift;
527 pat_bottom := z4r{z4r - z1r}
530 fill simple_serif (z1'l, z1'r, -30)
534 pat_top := z2r{z2r - z3r}
537 fill simple_serif (z3'l, z3'r, 30)
541 ne = (x2 - x4, stafflinethickness);
543 z11' = z3l + whatever * (z2l - z3l);
544 y11' = vround (.5 (staff_space - stafflinethickness));
545 z11 = z11' + whatever * ne;
547 z12 = directionpoint -ne of pat_top;
548 z13 = z12 + whatever * ne;
550 z14 = z11 + whatever * ne;
553 z21' = z4r + whatever * (z1r - z4r);
554 y21' = -y11' + feta_space_shift;
555 z21 = z21' + whatever * ne;
557 z22 = directionpoint -ne of pat_bottom;
558 z23 = z22 + whatever * ne;
560 z24 = z21 + whatever * ne;
574 penlabels (1, 1', 2, 3, 3', 4);
575 labels (11, 11', 12, 13, 14, 21, 21', 22, 23, 24);
578 draw_arrow (z1, top_stem_thick * brush_scale_up,
579 z1'l-z4l, stafflinethickness/2, false);
582 draw_arrow (z3, top_stem_thick * brush_scale_down,
583 z2r-z3'r, stafflinethickness/2, true);
584 w := w + extendright;
587 remember_pic := currentpicture;
589 draw_staff (-2, 2, 0);
592 fet_beginchar ("Natural", "natural");
593 draw_natural (false, false);
600 fet_beginchar ("Natural", "natural.arrowup");
601 draw_natural (true, false);
608 fet_beginchar ("Natural", "natural.arrowdown");
609 draw_natural (false, true);
616 fet_beginchar ("Natural", "natural.arrowboth");
617 draw_natural (true, true);
625 % Dedicated to my mom. (3/10/97)
627 % Mamma, ik hou van je; kom je alsjeblieft terug?
631 % TODO: remove crook_fatness
632 % TODO: document, simplify!
635 def draw_meta_flat (expr xcenter, w, crook_fatness, arrowup, arrowdown) =
637 save bottom_overshoot, bot_crook_dir;
638 save top_stem_thick, top_stem_thick_orig, bottom_stem_thick, hair, smaller_hole;
639 save top_crook_thinness;
642 pair center, bot_crook_dir;
643 save clearing, clearing_orig;
647 % the stem shouldn't reach the top staff line.
648 %% TODO: should take from height.
650 % TODO: parameterize this
652 if w >= 0.75 staff_space:
653 smaller_hole = 0.35 stafflinethickness;
657 crook_thinness = .7 stafflinethickness + .06 staff_space;
658 top_crook_thinness = 1 stafflinethickness + .065 staff_space;
659 clearing = 1.7 stafflinethickness;
660 clearing_orig = clearing;
662 clearing := 0.5 staff_space;
664 bottom_overshoot = stafflinethickness;
666 bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
667 top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
668 top_stem_thick_orig# = top_stem_thick#;
670 % to look nice, arrowed stems should be less brushed
671 top_stem_thick# := top_stem_thick#*0.80;
673 define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick,
674 top_stem_thick_orig);
676 if odd (top_stem_thick - bottom_stem_thick):
677 top_stem_thick := top_stem_thick - 1;
679 if odd (top_stem_thick_orig - bottom_stem_thick):
680 top_stem_thick_orig := top_stem_thick_orig - 1;
683 center = (xcenter, 0);
685 x1l = hround (xcenter - .5 top_stem_thick);
686 y1 = vround (2 staff_space - clearing);
687 x2l = hround (xcenter - .5 bottom_stem_thick);
688 y2 = -.5 staff_space - .5 stafflinethickness;
689 % z16 and the _orig variables are needed for arrowed accidentals because
690 % their inner part should be unchanged from plain ones but the points z3l,
691 % z3r and z10 depend on values that are different for arrowed accidentals
692 x16l = hround (xcenter - .5 top_stem_thick_orig);
693 y16 = vround (2 staff_space - clearing_orig);
695 penpos1 (top_stem_thick, 0);
696 penpos16 (top_stem_thick_orig, 0);
697 penpos2 (bottom_stem_thick, 0);
699 y3l = vfloor ((staff_space - stafflinethickness) / 2);
700 z3l = whatever [z2r, z1r];
701 z3r = .3 [z2r, (z16r shifted (0, clearing_orig - 1.7 stafflinethickness))]
705 % we insert z3l to get better conversion with mf2pt1
706 fill simple_serif (z1r, z1l, 30)
712 z10 = whatever [z2r, z16r] + (smaller_hole, 0);
713 y10 = -1/10 staff_space;
716 x11 = xcenter + bottom_overshoot / 3;
717 y11 = -vround (.5 (staff_space + stafflinethickness)
723 penpos4 (whatever, 53);
725 y4l - y4r = top_crook_thinness;
726 y5r = .15 staff_space;
727 x5l = hround (w + xcenter);
728 y4 = staff_space / 2;
729 x4r = .45 [x5r, x3r];
732 penpos5 (crook_fatness, -175);
734 bot_crook_dir = unitvector ((x5l, 0) - z11);
735 z8 = z11 + whatever * bot_crook_dir;
736 y8 = -staff_space / 2;
739 + whatever * bot_crook_dir
740 + crook_thinness * (bot_crook_dir rotated 90);
743 unfill z3r{z3r - z10}
746 .. z7{-bot_crook_dir}
770 draw_arrow (z1, top_stem_thick, z1l-z2l,
771 0.5stafflinethickness, false);
774 draw_arrow ((0.5[x2l,x2a],y2), x2a-x2l, up,
775 staff_space/2, true);
780 def draw_arrowed_meta_flat (expr xcenter, width, crook_fatness, arrowup, arrowdown) =
781 save depth, height, extendleft;
783 depth# = 0.6 staff_space#;
784 height# = 1.9 staff_space#;
785 extendleft# := 1.2 stafflinethickness#;
787 extendleft# := 3.45 stafflinethickness#;
788 height# := height# + 0.8 staff_space#;
791 extendleft# := 3.45 stafflinethickness#;
792 depth# := depth# + 1.6 staff_space#;
795 set_char_box (extendleft#, width, depth#, height#);
796 draw_meta_flat(xcenter, w, crook_fatness, arrowup, arrowdown);
800 % unfortunately, 600dpi is not enough to show the brush of the stem.
803 fet_beginchar ("Flat", "flat");
804 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, false, false);
805 penlabels (range 0 thru 11);
807 remember_pic := currentpicture;
809 draw_staff (-2, 2, 0);
816 fet_beginchar ("Arrowed Flat (up-arrow)", "flat.arrowup");
817 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, true, false);
818 penlabels (range 0 thru 23);
820 remember_pic := currentpicture;
822 draw_staff (-2, 2, 0.0);
829 fet_beginchar ("Arrowed Flat (down-arrow)", "flat.arrowdown");
830 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, false, true);
831 penlabels (range 0 thru 23);
833 remember_pic := currentpicture;
835 draw_staff (-2, 2, 0.0);
842 fet_beginchar ("Arrowed Flat (down-arrow)", "flat.arrowboth");
843 draw_arrowed_meta_flat(0, 0.8 staff_space#, 0.31 staff_space, true, true);
844 penlabels (range 0 thru 23);
846 remember_pic := currentpicture;
848 draw_staff (-2, 2, 0.0);
855 fet_beginchar ("Flat (slashed)", "flat.slash");
856 set_char_box (.4 staff_space#, .8 staff_space#,
857 0.6 staff_space#, 1.9 staff_space#);
859 draw_meta_flat (0, w, 0.31 staff_space, false, false);
863 save slope, slash_width;
868 z12 = z11 - (slash_width, slash_width * slope) / 2;
869 z13 = z11 + (slash_width, slash_width * slope) / 2;
870 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
871 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
873 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
874 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
888 remember_pic := currentpicture;
890 draw_staff (-2, 2, 0);
894 fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
895 set_char_box (.4 staff_space#, .8 staff_space#,
896 0.6 staff_space#, 1.9 staff_space#);
898 draw_meta_flat (0, w, 0.31 staff_space, false, false);
902 save slope, slash_width;
907 z12 = z11 - (slash_width, slash_width * slope) / 2;
908 z13 = z11 + (slash_width, slash_width * slope) / 2;
909 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
910 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
912 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
913 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
928 z22 = z21 - (slash_width, slash_width * slope) / 2;
929 z23 = z21 + (slash_width, slash_width * slope) / 2;
930 penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
931 penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
933 z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
934 z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
948 remember_pic := currentpicture;
950 draw_staff (-2, 2, 0);
954 fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
955 set_char_box (0, 1.6 staff_space#,
956 0.6 staff_space#, 1.9 staff_space#);
958 % This is a modified version of `draw_meta_flat'.
960 save crook_thinness, crook_fatness;
961 save bottom_overshoot, bot_crook_dir;
962 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
963 save top_crook_thinness;
966 pair center, bot_crook_dir;
975 % the stem shouldn't reach the top staff line.
976 %% TODO: should take from height.
978 % TODO: parameterize this
980 if wid >= 0.75 staff_space:
981 smaller_hole = 0.35 stafflinethickness;
985 clearing = 1.7 stafflinethickness;
986 crook_thinness = .7 stafflinethickness + .06 staff_space;
987 crook_fatness = 0.31 staff_space;
988 top_crook_thinness = 1 stafflinethickness + .065 staff_space;
989 bottom_overshoot = stafflinethickness;
991 bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
992 top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
993 define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
995 if odd (top_stem_thick - bottom_stem_thick):
996 top_stem_thick := top_stem_thick - 1;
1001 x1l = hround (-.5 top_stem_thick);
1002 y1 = vround (2 staff_space - clearing);
1003 x2l = hround (-.5 bottom_stem_thick);
1004 y2 = -.5 staff_space - .5 stafflinethickness;
1006 penpos1 (top_stem_thick, 0);
1007 penpos2 (bottom_stem_thick, 0);
1009 y3l = vfloor ((staff_space - stafflinethickness) / 2);
1010 z3l = whatever [z2r, z1r];
1011 z3r = .3 [z2r, z1r] + (smaller_hole, 0);
1012 x3r := hceiling x3r;
1014 z10 = whatever [z2r, z1r] + (smaller_hole, 0);
1015 y10 = -1/10 staff_space;
1016 x10 := hceiling x10;
1018 x11 = bottom_overshoot / 3;
1019 y11 = -vround (.5 (staff_space + stafflinethickness)
1020 + bottom_overshoot);
1022 penpos4 (whatever, 53);
1024 y4l - y4r = top_crook_thinness;
1025 y5r = .15 staff_space;
1027 y4 = staff_space / 2;
1028 x4r = .45 [x5r, x3r];
1031 penpos5 (crook_fatness, -175);
1033 bot_crook_dir = unitvector ((x5l, 0) - z11);
1034 z8 = z11 + whatever * bot_crook_dir;
1035 y8 = -staff_space / 2;
1038 + whatever * bot_crook_dir
1039 + crook_thinness * (bot_crook_dir rotated 90);
1042 pat := z3r{z3r - z10}
1045 .. z7{-bot_crook_dir}
1050 unfill pat xscaled -1;
1053 .. z8{bot_crook_dir}
1058 -- simple_serif (z1r, z1l, 30)
1059 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
1062 currentpicture := currentpicture shifted (w/2, 0);
1064 remember_pic := currentpicture;
1066 draw_staff (-2, 2, 0);
1073 fet_beginchar ("Semi flat", "mirroredflat");
1074 set_char_box (1.2 stafflinethickness#, .8 staff_space#,
1075 0.6 staff_space#, 1.9 staff_space#);
1077 draw_meta_flat (0, w, 0.31 staff_space, false, false);
1078 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
1082 fet_beginchar ("Semi flat", "mirroredflat.backslash");
1083 set_char_box (.4 staff_space#, .8 staff_space#,
1084 0.6 staff_space#, 1.9 staff_space#);
1086 draw_meta_flat (0, w, 0.31 staff_space, false, false);
1090 save slope, slash_width;
1095 z12 = z11 - (slash_width, slash_width * slope) / 2;
1096 z13 = z11 + (slash_width, slash_width * slope) / 2;
1097 penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
1098 penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
1100 z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
1101 z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
1112 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
1118 fet_beginchar ("Double Flat", "flatflat");
1119 save left_wid, overlap, right_wid;
1125 set_char_box (1.2 stafflinethickness#,
1126 (left_wid + right_wid - overlap) * staff_space#,
1127 .6 staff_space#, 1.9 staff_space#);
1128 draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space, false, false);
1129 draw_meta_flat (hround ((left_wid - overlap) * staff_space),
1130 right_wid * staff_space, 1/3 staff_space, false, false);
1134 fet_beginchar ("3/4 Flat", "flatflat.slash");
1135 save left_wid, overlap, right_wid;
1141 set_char_box (1.2 stafflinethickness#,
1142 (left_wid + right_wid - overlap) * staff_space#,
1143 .6 staff_space#, 1.9 staff_space#);
1144 draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space, false, false);
1145 draw_meta_flat (hround ((left_wid - overlap) * staff_space),
1146 right_wid * staff_space, 1/3 staff_space, false, false);
1148 %% maybe we should clip part of the stems?
1149 %% or make the 1st flat smaller?
1151 pickup pencircle scaled 2 stafflinethickness;
1153 z12 = round (-.25 w - b, .55 staff_space) + feta_offset;
1154 z13 = round (.75 w, 1.45 staff_space) + feta_offset;
1155 penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
1156 penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
1158 z14 = z12 - stafflinethickness * unitvector (z13 - z12);
1159 z15 = z13 + stafflinethickness * unitvector (z13 - z12);
1173 remember_pic := currentpicture;
1175 draw_staff (-2, 2, 0);
1182 fet_beginchar ("Double Sharp", "doublesharp");
1183 save klaverblad, klaversteel;
1187 klaversteel = 1/15 staff_space;
1188 klaverblad = .4 staff_space - .5 stafflinethickness;
1190 set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
1192 z1 = (klaversteel, 0);
1193 z2 = (w / 2 - klaverblad / 10, h - klaverblad);
1195 z4 = z2 reflectedabout ((0, 0), (1, 1));
1196 z5 = z1 reflectedabout ((0, 0), (1, 1));
1198 labels (1, 2, 3, 4, 5);
1200 pickup pencircle scaled blot_diameter;
1202 x2 := hfloor (rt x2) - blot_diameter / 2;
1203 x3 := hfloor (rt x3) - blot_diameter / 2;
1204 y3 := vfloor (top y3) - blot_diameter / 2;
1205 y4 := vfloor (top y4) - blot_diameter / 2;
1207 pat = (rt z1){dir45}
1214 .. {dir 225}(top z5);
1216 -- reverse pat xscaled -1 shifted (-feta_eps, 0);
1218 % assure symmetry -- it's more important to center the glyph on the
1219 % staff line than centering it between staff lines, so we use
1220 % feta_shift, not feta_space_shift.
1221 h := h + feta_shift;
1223 fill pat shifted (0, feta_shift)
1224 -- reverse pat yscaled -1 shifted (0, -feta_eps)
1228 currentpicture := currentpicture shifted (hround (w / 2), 0);
1230 remember_pic := currentpicture;
1232 draw_staff (-2, 2, 0);
1242 leftindent := .2 staff_space;
1244 set_char_box (0, .5 staff_space# + stafflinethickness#,
1245 staff_space#, staff_space#);
1247 d := d - feta_shift;
1249 z1 = (leftindent, h);
1250 z2 = (w - stafflinethickness, .5 (h - d));
1251 z3 = (leftindent, -d);
1253 penpos1 (stafflinethickness, 35);
1254 penpos2 (.1 staff_space + stafflinethickness, 0);
1255 penpos3 (stafflinethickness, -35);
1258 .. simple_serif (z3l, z3r, 90)
1260 .. simple_serif (z1r, z1l, 90)
1266 fet_beginchar ("Right Parenthesis", "rightparen");
1268 penlabels (1, 2, 3);
1270 remember_pic := currentpicture;
1272 draw_staff (-2, 2, 0);
1279 fet_beginchar ("Left Parenthesis", "leftparen");
1282 currentpicture := currentpicture xscaled -1;
1284 set_char_box (charwd, charbp, chardp, charht);
1287 fet_endgroup ("accidentals");