2 % feta-bolletjes.mf -- implement noteheads
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 % & Juergen Reuter <reuter@ipd.uka.de>
18 % Most beautiful noteheads are pronounced, not circular,
19 % and not even symmetric.
20 % These examples are inspired by [Wanske]; see literature list.
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 save black_notehead_width, noteheight;
29 save slash_thick, slash_slope, overdone_heads;
30 numeric black_notehead_width, noteheight, slash_thick;
33 fet_begingroup ("noteheads");
36 % Slope of slash. From scm/grob-description.scm. How to auto-copy?
39 % Thickness of slash lines. Quarter notes get 1.5slt width.
40 slash_thick# := 2/3 * 0.48 staff_space#;
44 % Hand-engraved music often has balls extending above and below
45 % the lines. If you like that, modify overdone heads (unit:
46 % stafflinethickness).
49 noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;
51 define_pixels (slash_thick);
52 define_whole_vertical_pixels (noteheight);
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 % SLANT moves both extrema on the long axis (by SLANT * ELLIPTICITY,
58 % so SLANT = -1, puts the extreme on the long axis next to the short
62 def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
67 pat := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
68 (-ellipticity, 0), (slant * ellipticity, -1.0),
70 pat := pat rotated tilt;
72 save top_point, right_point;
73 pair top_point, right_point;
75 top_point := directionpoint left of pat;
76 right_point := directionpoint up of pat;
80 scaling# = noteheight# / (2 ypart (top_point));
81 width# := 2 xpart (right_point) * scaling#;
82 define_pixels (scaling, width);
84 set_char_box (0, width#, noteheight# / 2, noteheight# / 2);
86 d := d - feta_space_shift;
89 charwy := ypart (right_point) * scaling#;
92 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
94 width := hround width;
104 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
109 pat := superellipse ((ellipticity, 0), (0, 1.0),
110 (-ellipticity, 0), (0, -1.0),
112 pat := pat rotated tilt;
114 save top_point, right_point;
115 pair top_point, right_point;
117 top_point := directionpoint left of pat;
118 right_point := directionpoint up of pat;
120 save height, scaling;
122 height# = staff_space# + stafflinethickness# - clearance;
123 scaling# = height# / (2 ypart (top_point));
124 define_pixels (scaling);
125 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
127 if test_outlines = 1:
137 % dimensions aren't entirely right.
140 save stemthick, fudge;
142 stemthick# = 2 stafflinethickness#;
143 define_whole_blacker_pixels (stemthick);
145 fudge = hround (blot_diameter / 2);
147 draw_outside_ellipse (1.80, 0, 0.707, 0);
148 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
150 pickup pencircle scaled stemthick;
162 draw_gridline (z1, z2, stemthick);
163 draw_gridline (z3, z4, stemthick);
167 fet_beginchar ("Brevis notehead", "s-1");
170 draw_staff (-2, 2, 0);
175 fet_beginchar ("Brevis notehead", "s-1");
178 draw_staff (-2, 2, 0.5);
183 fet_beginchar ("Whole notehead", "s0");
184 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
185 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
186 0.68, 2 stafflinethickness#);
188 draw_staff (-2, 2, 0);
193 fet_beginchar ("Whole notehead", "s0");
194 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
196 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
197 0.68, 2 stafflinethickness#);
199 draw_staff (-2, 2, 0.5);
204 fet_beginchar ("Half notehead", "s1");
205 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
206 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
208 draw_staff (-2, 2, 0);
213 fet_beginchar ("Half notehead", "s1");
214 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
216 undraw_inside_ellipse (3.25, 33, 0.81,
217 2.5 stafflinethickness#);
219 draw_staff (-2, 2, 0.5);
224 fet_beginchar ("Quart notehead", "s2");
225 % used to have 32. With 31, they are slightly bolder.
226 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0);
227 black_notehead_width# := charwd;
229 draw_staff (-2, 2, 0);
234 fet_beginchar ("Quart notehead", "s2");
235 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
238 draw_staff (-2, 2, 0.5);
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 fet_beginchar ("Whole diamondhead", "s0diamond");
247 draw_outside_ellipse (1.80, 0, 0.495, 0);
248 undraw_inside_ellipse (1.30, 125, 0.6,
249 .4 staff_space# + stafflinethickness#);
251 draw_staff (-2, 2, 0);
256 fet_beginchar ("Whole diamondhead", "s0diamond");
257 draw_outside_ellipse (1.80, 0, 0.495, 0);
258 undraw_inside_ellipse (1.30, 125, 0.6,
259 .4 staff_space# + stafflinethickness#);
261 draw_staff (-2, 2, 0.5);
266 fet_beginchar ("Half diamondhead", "s1diamond");
267 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
268 undraw_inside_ellipse (3.5, 33, 0.80,
269 .3 staff_space# + 1.5 stafflinethickness#);
271 draw_staff (-2, 2, 0);
276 fet_beginchar ("Half diamondhead", "s1diamond");
277 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
278 undraw_inside_ellipse (3.5, 33, 0.80,
280 + 1.5 stafflinethickness#);
282 draw_staff (-2, 2, 0.5);
287 fet_beginchar ("Quart diamondhead", "s2diamond");
288 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
290 draw_staff (-2, 2, 0);
295 fet_beginchar ("Quart diamondhead", "s2diamond");
296 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
298 draw_staff (-2, 2, 0.5);
303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 vardef penposx@# (expr d) =
316 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
317 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
322 def define_triangle_shape (expr stemdir) =
323 save triangle_a, triangle_b, triangle_c;
324 save triangle_out_a, triangle_out_b, triangle_out_c;
325 save triangle_in, triangle_out;
326 save width, depth, height;
327 save origin, left_up_dir;
328 save exact_left_point, exact_right_point, exact_down_point;
330 path triangle_a, triangle_b, triangle_c;
331 path triangle_out_a, triangle_out_b, triangle_out_c;
332 path triangle_in, triangle_out;
333 pair origin, left_up_dir;
334 pair exact_down_point, exact_left_point, exact_right_point;
337 pen_thick# = stafflinethickness# + .1 staff_space#;
338 define_pixels (llap);
339 define_blacker_pixels (pen_thick);
341 left_up_dir = llap# * dir (90 + tilt);
343 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
346 exact_left_point := origin + (left_up_dir xscaled xs);
347 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
348 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
350 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
351 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
352 width# = xpart (exact_right_point - exact_left_point)
355 set_char_box (0, width#, depth#, height#);
357 % Formerly, the shape has simply been drawn with an elliptical pen
358 % (`scaled pen_thick xsaled xs'), but the envelope of such a curve
359 % is of 6th degree. For the sake of mf2pt1, we approximate it.
361 pickup pencircle scaled pen_thick xscaled xs;
363 z0 = (hround_pixels (xpart origin), 0);
365 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
366 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
367 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
369 z12 = caveness [.5[z1, z2], z3];
370 z23 = caveness [.5[z2, z3], z1];
371 z31 = caveness [.5[z3, z1], z2];
373 triangle_a = z1 .. z12 .. z2;
374 triangle_b = z2 .. z23 .. z3;
375 triangle_c = z3 .. z31 .. z1;
377 penposx1 (angle (direction 0 of triangle_a) - 90);
378 penposx2 (angle (direction 0 of triangle_b) - 90);
379 penposx3 (angle (direction 0 of triangle_c) - 90);
381 penposx1' (angle (direction infinity of triangle_c) + 90);
382 penposx2' (angle (direction infinity of triangle_a) + 90);
383 penposx3' (angle (direction infinity of triangle_b) + 90);
385 penposx12 (angle (z12 - z0));
386 penposx23 (angle (z23 - z0));
387 penposx31 (angle (z31 - z0));
389 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
390 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
391 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
404 triangle_out_a = z1r .. z12r .. z2'l;
405 triangle_out_b = z2r .. z23r .. z3'l;
406 triangle_out_c = z3r .. z31r .. z1'l;
408 triangle_out = top z1
410 .. z1r{direction 0 of triangle_out_a}
412 & {direction infinity of triangle_out_a}z2'l
415 .. z2r{direction 0 of triangle_out_b}
417 & {direction infinity of triangle_out_b}z3'l
420 .. z3r{direction 0 of triangle_out_c}
422 & {direction infinity of triangle_out_c}z1'l
425 labels (0, 10, 20, 30);
426 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
430 charwy := ypart exact_right_point;
431 charwx := xpart exact_right_point;
433 charwy := -ypart exact_down_point;
434 charwx := (width# - xpart exact_down_point);
439 def draw_whole_triangle_head =
445 llap# = 3/4 noteheight#;
449 define_triangle_shape (1);
455 fet_beginchar ("Whole trianglehead", "s0triangle");
456 draw_whole_triangle_head;
458 draw_staff (-2, 2, 0);
463 fet_beginchar ("Whole trianglehead", "s0triangle");
464 draw_whole_triangle_head;
466 draw_staff (-2, 2, 0.5);
471 def draw_small_triangle_head (expr dir) =
477 llap# = 2/3 noteheight#;
480 define_triangle_shape (dir);
484 filldraw triangle_out;
485 unfilldraw triangle_in;
489 fet_beginchar ("Half trianglehead", "d1triangle");
490 draw_small_triangle_head (-1);
492 draw_staff (-2, 2, 0);
496 fet_beginchar ("Half trianglehead", "u1triangle");
497 draw_small_triangle_head (1);
499 draw_staff (-2, 2, 0.5);
503 def draw_closed_triangle_head (expr dir) =
509 llap# = 2/3 noteheight#;
512 define_triangle_shape (dir);
517 fet_beginchar ("Quart trianglehead", "u2triangle");
518 draw_closed_triangle_head (1);
520 draw_staff (-2, 2, 0);
524 fet_beginchar ("Quart trianglehead", "d2triangle");
525 draw_closed_triangle_head (-1);
527 draw_staff (-2, 2, 0.5);
531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533 % Slash heads are for indicating improvisation. They are
534 % twice as high as normal heads.
536 def draw_slash (expr hwid_hash) =
540 exact_height = staff_space# + stafflinethickness# / 2;
542 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
543 exact_height, exact_height);
552 pickup pencircle scaled blot_diameter;
557 lft x2 = 2 h / slash_slope;
564 ne_dir := unitvector (z3 - z4);
576 if hwid_hash > 2 slash_thick#:
579 th = slash_thick - blot_diameter;
584 z6 - z5 = whatever * ne_dir;
585 z8 - z7 = whatever * ne_dir;
587 z5 = z1 + whatever * ne_dir + th * (ne_dir rotated -90);
588 z8 = z4 + whatever * ne_dir + th * (ne_dir rotated 90);
596 labels (range 1 thru 10);
600 fet_beginchar ("Whole slashhead", "s0slash");
601 draw_slash (4 slash_thick# + 0.5 staff_space#);
603 draw_staff (-2, 2, 0);
607 fet_beginchar ("Half slashhead", "s1slash");
608 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
610 draw_staff (-2, 2, 0);
614 fet_beginchar ("Quart slashhead", "s2slash");
615 draw_slash (1.5 slash_thick#);
617 draw_staff (-2, 2, 0);
621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623 % `thick' is the distance between the NE/SW parallel lines in the cross
624 % (distance between centres of lines) in multiples of stafflinethickness
626 def draw_cross (expr thick) =
628 save horz_dist, vert_dist;
629 save crz_in, crz_out;
632 path crz_in, crz_out;
634 pen_thick# := 1.2 stafflinethickness#;
635 thickness# := thick * stafflinethickness#;
636 define_pixels (thickness);
637 define_blacker_pixels (pen_thick);
639 pickup pencircle scaled pen_thick;
644 ne_dir := unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
647 z4 - z5 = whatever * ne_dir;
649 z6 - z3 = whatever * ne_dir;
650 z3 - z4 = whatever * (ne_dir yscaled -1);
652 z4 - z3 = whatever * (ne_dir) + (ne_dir rotated -90) * thickness;
655 x1 = charwd / 2 - .5 pen_thick#;
656 z1 = whatever * ne_dir
657 + thick / 2 * stafflinethickness# * (ne_dir rotated -90);
659 % labels (1, 2, 3, 4, 5, 6);
661 nw_dir = unitvector (z3 - z4);
663 vert_dist = 0.5 pen_thick / cosd (angle (ne_dir));
664 horz_dist = 0.5 pen_thick / sind (angle (ne_dir));
670 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
671 x5 := hfloor (x5' + horz_dist) - horz_dist;
672 y6 := vfloor (y6' + vert_dist) - vert_dist;
674 crz_out = (z6 + up * vert_dist)
675 -- (z3 + nw_dir * 0.5 pen_thick){ne_dir}
677 .. (z3 + ne_dir * 0.5 pen_thick){-nw_dir}
678 -- (z4 + ne_dir * 0.5 pen_thick){-nw_dir}
680 .. (z4 - nw_dir * 0.5 pen_thick){-ne_dir}
681 -- (z5 + right * horz_dist);
682 crz_out := crz_out shifted (0, feta_shift)
683 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
685 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
689 x4 := hround (x4' - horz_dist) + horz_dist;
690 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
691 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
693 crz_in = (bot z6){right}
694 .. (z6 - nw_dir * 0.5 pen_thick){ne_dir}
695 -- (z3 + down * vert_dist)
696 -- (z4 + left * horz_dist)
697 -- (z5 + nw_dir * 0.5 pen_thick){-ne_dir}
699 crz_in := crz_in shifted (0, feta_shift)
700 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
702 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
707 currentpicture := currentpicture shifted (hround (w / 2), 0);
710 charwy := y1 + feta_shift;
712 z12 = (charwx * hppp, y1 * vppp);
718 fet_beginchar ("Whole Crossed notehead", "s0cross");
721 wid# := black_notehead_width# + 4 stafflinethickness#;
722 hei# := noteheight# + stafflinethickness#;
724 set_char_box (0, wid#, hei# / 2, hei# / 2);
728 remember_pic := currentpicture;
730 draw_staff (-2, 2, 0);
735 fet_beginchar ("Whole Crossed notehead", "s0cross");
738 wid# := black_notehead_width# + 4 stafflinethickness#;
739 hei# := noteheight# + stafflinethickness#;
741 set_char_box (0, wid#, hei# / 2, hei# / 2);
743 currentpicture := remember_pic;
745 draw_staff (-2, 2, 0.5);
750 fet_beginchar ("Half Crossed notehead", "s1cross");
753 wid# := black_notehead_width# + 2 stafflinethickness#;
754 hei# := noteheight# + stafflinethickness# / 2;
756 set_char_box (0, wid#, hei# / 2, hei# / 2);
760 remember_pic := currentpicture;
762 draw_staff (-2, 2, 0);
767 fet_beginchar ("Half Crossed notehead", "s1cross");
770 wid# := black_notehead_width# + 2 stafflinethickness#;
771 hei# := noteheight# + stafflinethickness# / 2;
773 set_char_box (0, wid#, hei# / 2, hei# / 2);
775 currentpicture := remember_pic;
777 draw_staff (-2, 2, 0.5);
782 fet_beginchar ("Crossed notehead", "s2cross");
783 wid# := black_notehead_width#;
785 set_char_box (0, wid#, hei# / 2, hei# / 2);
789 remember_pic := currentpicture;
791 draw_staff (-2, 2, 0);
796 fet_beginchar ("Crossed notehead", "s2cross");
797 wid# := black_notehead_width#;
799 set_char_box (0, wid#, hei# / 2, hei# / 2);
801 currentpicture := remember_pic;
803 draw_staff (-2, 2, 0.5);
808 fet_beginchar ("X-Circled notehead", "s2xcircle");
810 save cthick, cxd, cyd, dy;
812 wid# := black_notehead_width# * sqrt (sqrt2);
813 hei# := noteheight# * sqrt (sqrt2);
815 set_char_box (0, wid#, hei# / 2, hei# / 2);
817 d := d - feta_space_shift;
819 cthick# := (1.2 + 1/4) * stafflinethickness#;
820 define_blacker_pixels (cthick);
823 cyd := h + d - cthick / 2;
827 pickup pencircle scaled cthick;
829 fill fullcircle xscaled (cxd + cthick)
830 yscaled (cyd + cthick)
832 unfill fullcircle xscaled (cxd - cthick)
833 yscaled (cyd - cthick)
836 xpos := .5 cxd / sqrt2;
837 ypos := .5 cyd / sqrt2;
839 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
840 draw (-xpos + w / 2, -ypos + dy) -- (xpos + w / 2, ypos + dy);
842 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
843 draw (-xpos + w / 2, ypos + dy) -- (xpos + w / 2, -ypos + dy);
848 z12 = (charwx * hppp, charwy * vppp);
851 remember_pic := currentpicture;
853 draw_staff (-2, 2, 0);
858 fet_beginchar ("X-Circled notehead", "s2xcircle");
860 save cthick, cxr, cyr;
862 wid# := black_notehead_width# * sqrt (sqrt2);
863 hei# := noteheight# * sqrt (sqrt2);
865 set_char_box (0, wid#, hei# / 2, hei# / 2);
867 currentpicture := remember_pic;
869 draw_staff (-2, 2, 0.5);
879 save solfa_pen_thick;
880 solfa_pen_thick# = 2 stafflinethickness#;
881 define_blacker_pixels (solfa_pen_thick);
884 def draw_do_head (expr width_factor, dir) =
886 save left_dist, right_dist;
888 pair left_dist, right_dist;
890 set_char_box (0, width_factor * noteheight#,
891 0.5 noteheight#, 0.5 noteheight#);
893 pickup pencircle scaled solfa_pen_thick;
902 left_dist = (unitvector (z3 - z1) rotated 90) * 0.5 solfa_pen_thick;
903 right_dist = (unitvector (z2 - z3) rotated 90) * 0.5 solfa_pen_thick;
905 p_in := (((z1 - left_dist) -- (z3 - left_dist)) intersectionpoint
907 -- ((top z1 -- top z2) intersectionpoint
908 ((z2 - right_dist) -- (z3 - right_dist)))
909 -- (((z2 - right_dist) -- (z3 - right_dist)) intersectionpoint
910 ((z1 - left_dist) -- (z3 - left_dist)))
916 .. (z2 + right_dist){z3 - z2}
917 -- (z3 + right_dist){z3 - z2}
919 .. (z3 + left_dist){z1 - z3}
920 -- (z1 + left_dist){z1 - z3}
928 charwy := -chardp + 0.5 stafflinethickness#;
935 fet_beginchar ("Whole dohead", "s0do");
936 draw_do_head (1.8, 1);
942 fet_beginchar ("Half dohead", "d1do");
943 draw_do_head (1.5, -1);
949 fet_beginchar ("Half dohead", "s1do");
950 draw_do_head (1.5, 1);
956 fet_beginchar ("Quart dohead", "d2do");
957 draw_do_head (1.55, -1);
962 fet_beginchar ("Quart dohead", "s2do");
963 draw_do_head (1.55, 1);
969 % re - flat top, curved bottom:
970 % (0,h/2) {dir -90} .. (w/2,-h/2) .. {dir 90} (w,h/2) -- cycle;
971 % (broader along the base and with more vertical sides for half and
973 % stem attachment: h/2
976 def draw_re_head (expr width_factor, dir) =
980 set_char_box (0, width_factor * noteheight#,
981 0.5 noteheight#, 0.5 noteheight#);
983 pickup pencircle scaled solfa_pen_thick;
990 y2 = curve_start [y3, y1];
998 labels (range 1 thru 5);
1000 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1004 -- (z5 + 0.5 solfa_pen_thick * (-1, -1))
1017 charwy := curve_start [-chardp, charht];
1025 fet_beginchar ("Whole rehead", "s0re");
1026 draw_re_head (1.8, 1);
1032 fet_beginchar ("Half up rehead", "u1re");
1033 draw_re_head (1.5, 1);
1039 fet_beginchar ("Half down rehead", "d1re");
1040 draw_re_head (1.5, -1);
1046 fet_beginchar ("Quart rehead", "u2re");
1047 draw_re_head (1.55, 1);
1052 fet_beginchar ("Quart rehead", "d2re");
1053 draw_re_head (1.55, -1);
1058 def draw_mi_head (expr width_factor) =
1059 save path_out, path_in;
1060 save ne_dist, se_dist, ne, se;
1061 path path_out, path_in;
1062 pair ne_dist, se_dist, ne, se;
1064 set_char_box (0, width_factor * noteheight#,
1065 0.5 noteheight#, 0.5 noteheight#);
1067 pickup pencircle scaled solfa_pen_thick;
1078 z6 - z5 = whatever * (z2 - z1);
1079 z8 - z7 = whatever * (z2 - z1);
1080 z8 - z5 = whatever * (z4 - z1);
1081 z6 - z7 = whatever * (z4 - z1);
1083 ne = unitvector (z4 - z1);
1084 se = unitvector (z1 - z2);
1086 ne_dist = (ne rotated 90) * 0.5 solfa_pen_thick;
1087 se_dist = (se rotated 90) * 0.5 solfa_pen_thick;
1089 z5 = whatever [z1, z4] - ne_dist;
1090 z5 = whatever [z1, z2] - 1.5 se_dist;
1092 z5 - z1 = -(z7 - z3);
1094 labels (range 1 thru 8);
1103 .. (z1 + se_dist){-se}
1104 -- (z2 + se_dist){-se}
1106 .. (z2 - ne_dist){ne}
1107 -- (z3 - ne_dist){ne}
1109 .. (z3 - se_dist){se}
1110 -- (z4 - se_dist){se}
1112 .. (z4 + ne_dist){-ne}
1113 -- (z1 + ne_dist){-ne}
1118 fet_beginchar ("Whole mihead", "s0mi");
1125 fet_beginchar ("Half mihead", "s1mi");
1132 fet_beginchar ("Quart mihead", "s2mi");
1133 draw_mi_head (1.65);
1138 def draw_fa_head (expr width_factor) =
1139 set_char_box (0, width_factor * noteheight#,
1140 0.5 noteheight#, 0.5 noteheight#);
1142 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1143 path p_down_in, p_down_out, p_up_in, p_up_out;
1146 pickup pencircle scaled solfa_pen_thick;
1159 labels (1, 2, 3, 4);
1161 nw = unitvector (z1 - z3);
1162 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1164 p_up_in := (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1166 -- (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1168 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1171 p_up_out := lft z1{down}
1172 .. (z1 + nw_dist){-nw}
1173 -- (z3 + nw_dist){-nw}
1181 p_down_in := p_up_in rotated 180 shifted (w, 0);
1182 p_down_out := p_up_out rotated 180 shifted (w, 0);
1189 fet_beginchar ("Whole fa up head", "d0fa");
1196 fet_beginchar ("Whole fa down head", "u0fa");
1203 fet_beginchar ("half fa up head", "d1fa");
1210 fet_beginchar ("Half fa down head", "u1fa");
1217 fet_beginchar ("Quarter fa up head", "u2fa");
1218 draw_fa_head (1.55);
1223 fet_beginchar ("Quarter fa down head", "d2fa");
1224 draw_fa_head (1.55);
1229 def draw_la_head (expr width_factor) =
1230 set_char_box (0, width_factor * noteheight#,
1231 0.5 noteheight#, 0.5 noteheight#);
1235 pickup pencircle scaled solfa_pen_thick;
1248 labels (range 1 thru 4);
1250 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1251 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1252 -- (z3 + 0.5 solfa_pen_thick * (-1, 1))
1253 -- (z4 + 0.5 solfa_pen_thick * (1, 1))
1268 fet_beginchar ("Whole lahead", "s0la");
1275 fet_beginchar ("Half lahead", "s1la");
1282 fet_beginchar ("Quart lahead", "s2la");
1283 draw_la_head (1.55);
1288 def draw_ti_head (expr width_factor, dir) =
1289 set_char_box (0, width_factor * noteheight#,
1290 0.5 noteheight#, 0.5 noteheight#);
1291 save p_in, p_out, p_top;
1292 save nw_dist, sw_dist, nw, sw;
1293 path p_in, p_out, p_top;
1294 pair nw_dist, sw_dist, nw, sw;
1298 pickup pencircle scaled solfa_pen_thick;
1303 y2 = cone_height [y1, y3];
1309 labels (range 1 thru 4);
1311 nw = unitvector (z2 - z1);
1312 sw = unitvector (z1 - z4);
1314 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1315 sw_dist = (sw rotated 90) * 0.5 solfa_pen_thick;
1317 p_top := (z2 - sw_dist)
1321 p_in := (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1322 ((z1 - sw_dist) -- (z4 - sw_dist)))
1323 -- (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1324 ((z2 + sw_dist) .. {right}(bot z3)))
1326 .. (((bot z3){right} .. (z4 + nw_dist)) intersectionpoint
1327 ((z1 - sw_dist) -- (z4 - sw_dist)))
1334 .. (z2 - sw_dist){direction 0 of p_top}
1336 & {direction infinity of p_top}(z4 - nw_dist)
1343 charwy := cone_height [-chardp, charht];
1350 fet_beginchar ("Whole up tihead", "s0ti");
1351 draw_ti_head (1.8, 1);
1357 fet_beginchar ("Half up tihead", "u1ti");
1358 draw_ti_head (1.5, 1);
1364 fet_beginchar ("Half down tihead", "d1ti");
1365 draw_ti_head (1.5, -1);
1371 fet_beginchar ("Quart up tihead", "u2ti");
1372 draw_ti_head (1.55, 1);
1377 fet_beginchar ("Quart down tihead", "d2ti");
1378 draw_ti_head (1.55, -1);
1383 fet_endgroup ("noteheads");
1387 % we derive black_notehead_width# from the quarter head,
1388 % so we have to define black_notehead_width (pixel qty)
1389 % after the black_notehead_width# itself.
1391 % Let's keep it outside the group as well.
1394 define_pixels (black_notehead_width);