2 % feta-bolletjes.mf -- implement noteheads
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@xs4all.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 half_notehead_width, whole_notehead_width, slash_thick;
30 save slash_slope, overdone_heads, solfa_noteheight;
34 numeric black_notehead_width;
35 numeric whole_notehead_width;
36 numeric half_notehead_width;
39 fet_begingroup ("noteheads");
42 % Slope of slash. From scm/grob-description.scm. How to auto-copy?
45 % Thickness of slash lines. Quarter notes get 1.5slt width.
46 slash_thick# := 2/3 * 0.48 staff_space#;
50 % Hand-engraved music often has balls extending above and below
51 % the lines. If you like that, modify overdone heads (unit:
52 % stafflinethickness).
55 noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;
59 % solfa heads should not overlap on chords.
61 solfa_noteheight# := staff_space# - stafflinethickness#;
63 define_pixels (slash_thick);
64 define_whole_vertical_pixels (noteheight);
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 % SLANT moves both extrema on the long axis (by SLANT * ELLIPTICITY,
70 % so SLANT = -1, puts the extreme on the long axis next to the short
74 def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
79 pat := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
80 (-ellipticity, 0), (slant * ellipticity, -1.0),
82 pat := pat rotated tilt;
84 save top_point, right_point;
85 pair top_point, right_point;
87 top_point := directionpoint left of pat;
88 right_point := directionpoint up of pat;
92 scaling# = noteheight# / (2 ypart (top_point));
93 width# := 2 xpart (right_point) * scaling#;
94 define_pixels (scaling, width);
96 set_char_box (0, width#, noteheight# / 2, noteheight# / 2);
98 d := d - feta_space_shift;
101 charwy := ypart (right_point) * scaling#;
104 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
106 width := hround width;
108 if test_outlines = 1:
116 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
121 pat := superellipse ((ellipticity, 0), (0, 1.0),
122 (-ellipticity, 0), (0, -1.0),
124 pat := pat rotated tilt;
126 save top_point, right_point;
127 pair top_point, right_point;
129 top_point := directionpoint left of pat;
130 right_point := directionpoint up of pat;
132 save height, scaling;
134 height# = staff_space# + stafflinethickness# - clearance;
135 scaling# = height# / (2 ypart (top_point));
136 define_pixels (scaling);
137 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
139 if test_outlines = 1:
149 % dimensions aren't entirely right.
152 save stemthick, fudge;
154 stemthick# = 2 stafflinethickness#;
155 define_whole_blacker_pixels (stemthick);
157 fudge = hround (blot_diameter / 2);
159 draw_outside_ellipse (1.80, 0, 0.707, 0);
160 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
162 pickup pencircle scaled stemthick;
174 draw_gridline (z1, z2, stemthick);
175 draw_gridline (z3, z4, stemthick);
179 fet_beginchar ("Brevis notehead", "s-1");
182 draw_staff (-2, 2, 0);
187 fet_beginchar ("Brevis notehead", "s-1");
190 draw_staff (-2, 2, 0.5);
195 fet_beginchar ("Whole notehead", "s0");
196 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
197 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
198 0.68, 2 stafflinethickness#);
200 whole_notehead_width# := charwd;
202 draw_staff (-2, 2, 0);
207 fet_beginchar ("Whole notehead", "s0");
208 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
210 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
211 0.68, 2 stafflinethickness#);
213 draw_staff (-2, 2, 0.5);
220 fet_beginchar ("Half notehead", "s1");
221 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
222 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
224 half_notehead_width# := charwd;
226 draw_staff (-2, 2, 0);
231 fet_beginchar ("Half notehead", "s1");
232 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
234 undraw_inside_ellipse (3.25, 33, 0.81,
235 2.5 stafflinethickness#);
237 draw_staff (-2, 2, 0.5);
242 fet_beginchar ("Quart notehead", "s2");
243 % used to have 32. With 31, they are slightly bolder.
244 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0);
245 black_notehead_width# := charwd;
247 draw_staff (-2, 2, 0);
251 fet_beginchar ("Quart notehead", "s2");
252 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
255 draw_staff (-2, 2, 0.5);
260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
263 fet_beginchar ("Whole diamondhead", "s0diamond");
264 draw_outside_ellipse (1.80, 0, 0.495, 0);
265 undraw_inside_ellipse (1.30, 125, 0.6,
266 .4 staff_space# + stafflinethickness#);
268 draw_staff (-2, 2, 0);
273 fet_beginchar ("Whole diamondhead", "s0diamond");
274 draw_outside_ellipse (1.80, 0, 0.495, 0);
275 undraw_inside_ellipse (1.30, 125, 0.6,
276 .4 staff_space# + stafflinethickness#);
278 draw_staff (-2, 2, 0.5);
283 fet_beginchar ("Half diamondhead", "s1diamond");
284 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
285 undraw_inside_ellipse (3.5, 33, 0.80,
286 .3 staff_space# + 1.5 stafflinethickness#);
288 draw_staff (-2, 2, 0);
293 fet_beginchar ("Half diamondhead", "s1diamond");
294 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
295 undraw_inside_ellipse (3.5, 33, 0.80,
297 + 1.5 stafflinethickness#);
299 draw_staff (-2, 2, 0.5);
304 fet_beginchar ("Quart diamondhead", "s2diamond");
305 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
307 draw_staff (-2, 2, 0);
312 fet_beginchar ("Quart diamondhead", "s2diamond");
313 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
315 draw_staff (-2, 2, 0.5);
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323 vardef penposx@# (expr d) =
333 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
334 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
341 % UGH : xs not declared as argument.
343 def define_triangle_shape (expr stemdir) =
344 save triangle_a, triangle_b, triangle_c;
345 save triangle_out_a, triangle_out_b, triangle_out_c;
346 save triangle_in, triangle_out;
347 save width, depth, height;
348 save origin, left_up_dir;
349 save exact_left_point, exact_right_point, exact_down_point;
351 path triangle_a, triangle_b, triangle_c;
352 path triangle_out_a, triangle_out_b, triangle_out_c;
353 path triangle_in, triangle_out;
354 pair origin, left_up_dir;
355 pair exact_down_point, exact_left_point, exact_right_point;
358 pen_thick# = stafflinethickness# + .1 staff_space#;
359 define_pixels (llap);
360 define_blacker_pixels (pen_thick);
362 left_up_dir = llap# * dir (90 + tilt);
364 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
367 exact_left_point := origin + (left_up_dir xscaled xs);
368 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
369 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
371 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
372 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
373 width# = xpart (exact_right_point - exact_left_point)
376 set_char_box (0, width#, depth#, height#);
378 % Formerly, the shape has simply been drawn with an elliptical pen
379 % (`scaled pen_thick xsaled xs'), but the envelope of such a curve
380 % is of 6th degree. For the sake of mf2pt1, we approximate it.
382 pickup pencircle scaled pen_thick xscaled xs;
384 z0 = (hround_pixels (xpart origin), 0);
386 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
387 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
388 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
390 z12 = caveness [.5[z1, z2], z3];
391 z23 = caveness [.5[z2, z3], z1];
392 z31 = caveness [.5[z3, z1], z2];
394 triangle_a = z1 .. z12 .. z2;
395 triangle_b = z2 .. z23 .. z3;
396 triangle_c = z3 .. z31 .. z1;
398 penposx1 (angle (direction 0 of triangle_a) - 90);
399 penposx2 (angle (direction 0 of triangle_b) - 90);
400 penposx3 (angle (direction 0 of triangle_c) - 90);
402 penposx1' (angle (direction infinity of triangle_c) + 90);
403 penposx2' (angle (direction infinity of triangle_a) + 90);
404 penposx3' (angle (direction infinity of triangle_b) + 90);
406 penposx12 (angle (z12 - z0));
407 penposx23 (angle (z23 - z0));
408 penposx31 (angle (z31 - z0));
410 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
411 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
412 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
425 triangle_out_a = z1r .. z12r .. z2'l;
426 triangle_out_b = z2r .. z23r .. z3'l;
427 triangle_out_c = z3r .. z31r .. z1'l;
429 triangle_out = top z1
431 .. z1r{direction 0 of triangle_out_a}
433 & {direction infinity of triangle_out_a}z2'l
436 .. z2r{direction 0 of triangle_out_b}
438 & {direction infinity of triangle_out_b}z3'l
441 .. z3r{direction 0 of triangle_out_c}
443 & {direction infinity of triangle_out_c}z1'l
447 labels (0, 10, 20, 30);
448 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
452 charwy := ypart exact_right_point;
453 charwx := xpart exact_right_point + .5 pen_thick# * xs;
455 charwy := -ypart exact_down_point;
456 charwx := (width# - (xpart exact_down_point - 0.5 * xs * pen_thick#));
461 def draw_whole_triangle_head =
467 llap# = 3/4 noteheight#;
471 define_triangle_shape (1);
477 fet_beginchar ("Whole trianglehead", "s0triangle");
478 draw_whole_triangle_head;
480 draw_staff (-2, 2, 0);
485 fet_beginchar ("Whole trianglehead", "s0triangle");
486 draw_whole_triangle_head;
488 draw_staff (-2, 2, 0.5);
493 def draw_small_triangle_head (expr dir) =
499 llap# = 2/3 noteheight#;
502 define_triangle_shape (dir);
506 filldraw triangle_out;
507 unfilldraw triangle_in;
511 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
512 draw_small_triangle_head (-1);
514 draw_staff (-2, 2, 0);
518 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
519 draw_small_triangle_head (1);
521 draw_staff (-2, 2, 0.5);
525 def draw_closed_triangle_head (expr dir) =
531 llap# = 2/3 noteheight#;
534 define_triangle_shape (dir);
539 fet_beginchar ("Quart trianglehead (upstem)", "u2triangle");
540 draw_closed_triangle_head (1);
542 draw_staff (-2, 2, 0);
546 fet_beginchar ("Quart trianglehead (downstem)", "d2triangle");
547 draw_closed_triangle_head (-1);
549 draw_staff (-2, 2, 0.5);
553 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
555 % Slash heads are for indicating improvisation. They are
556 % twice as high as normal heads.
558 def draw_slash (expr hwid_hash) =
562 exact_height = staff_space# + stafflinethickness# / 2;
564 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
565 exact_height, exact_height);
574 pickup pencircle scaled blot_diameter;
579 lft x2 = 2 h / slash_slope;
586 ne = unitvector (z3 - z4);
587 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
590 .. (z1 + nw_dist){ne}
591 -- (z2 + nw_dist){ne}
594 .. (z3 - nw_dist){-ne}
595 -- (z4 - nw_dist){-ne}
599 if hwid_hash > 2 slash_thick#:
602 th = slash_thick - blot_diameter;
607 z6 - z5 = whatever * ne;
608 z8 - z7 = whatever * ne;
610 z5 = z1 + whatever * ne + th * (ne rotated -90);
611 z8 = z4 + whatever * ne + th * (ne rotated 90);
619 labels (range 1 thru 10);
623 fet_beginchar ("Whole slashhead", "s0slash");
624 draw_slash (4 slash_thick# + 0.5 staff_space#);
626 draw_staff (-2, 2, 0);
630 fet_beginchar ("Half slashhead", "s1slash");
631 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
633 draw_staff (-2, 2, 0);
637 fet_beginchar ("Quart slashhead", "s2slash");
638 draw_slash (1.5 slash_thick#);
640 draw_staff (-2, 2, 0);
644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
646 % `thick' is the distance between the NE/SW parallel lines in the cross
647 % (distance between centres of lines) in multiples of stafflinethickness
649 def draw_cross (expr thick) =
651 save ne_dist, nw_dist, rt_dist, up_dist;
652 save crz_in, crz_out;
655 pair ne_dist, nw_dist, rt_dist, up_dist;
656 path crz_in, crz_out;
658 pen_thick# := 1.2 stafflinethickness#;
659 thickness# := thick * stafflinethickness#;
660 define_pixels (thickness);
661 define_blacker_pixels (pen_thick);
663 pickup pencircle scaled pen_thick;
668 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
671 z4 - z5 = whatever * ne;
673 z6 - z3 = whatever * ne;
674 z3 - z4 = whatever * (ne yscaled -1);
676 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
679 x1 = charwd / 2 - .5 pen_thick#;
681 + thick / 2 * stafflinethickness# * (ne rotated -90);
683 % labels (1, 2, 3, 4, 5, 6);
685 nw = unitvector (z3 - z4);
687 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
688 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
689 nw_dist = (ne rotated 90) * 0.5 pen_thick;
690 ne_dist = (nw rotated -90) * 0.5 pen_thick;
696 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
697 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
698 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
700 crz_out = (z6 + up_dist)
701 -- (z3 + nw_dist){ne}
703 .. (z3 + ne_dist){-nw}
704 -- (z4 + ne_dist){-nw}
706 .. (z4 - nw_dist){-ne}
708 crz_out := crz_out shifted (0, feta_shift)
709 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
711 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
715 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
716 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
717 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
719 crz_in = (bot z6){right}
720 .. (z6 - nw_dist){ne}
723 -- (z5 + nw_dist){-ne}
725 crz_in := crz_in shifted (0, feta_shift)
726 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
728 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
733 currentpicture := currentpicture shifted (hround (w / 2), 0);
736 charwy := y1 + feta_shift;
738 z12 = (charwx * hppp, y1 * vppp);
744 fet_beginchar ("Whole Crossed notehead", "s0cross");
747 wid# := black_notehead_width# + 4 stafflinethickness#;
748 hei# := noteheight# + stafflinethickness#;
750 set_char_box (0, wid#, hei# / 2, hei# / 2);
754 remember_pic := currentpicture;
756 draw_staff (-2, 2, 0);
761 fet_beginchar ("Whole Crossed notehead", "s0cross");
764 wid# := black_notehead_width# + 4 stafflinethickness#;
765 hei# := noteheight# + stafflinethickness#;
767 set_char_box (0, wid#, hei# / 2, hei# / 2);
769 currentpicture := remember_pic;
771 draw_staff (-2, 2, 0.5);
776 fet_beginchar ("Half Crossed notehead", "s1cross");
779 wid# := black_notehead_width# + 2 stafflinethickness#;
780 hei# := noteheight# + stafflinethickness# / 2;
782 set_char_box (0, wid#, hei# / 2, hei# / 2);
786 remember_pic := currentpicture;
788 draw_staff (-2, 2, 0);
793 fet_beginchar ("Half Crossed notehead", "s1cross");
796 wid# := black_notehead_width# + 2 stafflinethickness#;
797 hei# := noteheight# + stafflinethickness# / 2;
799 set_char_box (0, wid#, hei# / 2, hei# / 2);
801 currentpicture := remember_pic;
803 draw_staff (-2, 2, 0.5);
808 fet_beginchar ("Crossed notehead", "s2cross");
809 wid# := black_notehead_width#;
811 set_char_box (0, wid#, hei# / 2, hei# / 2);
815 remember_pic := currentpicture;
817 draw_staff (-2, 2, 0);
822 fet_beginchar ("Crossed notehead", "s2cross");
823 wid# := black_notehead_width#;
825 set_char_box (0, wid#, hei# / 2, hei# / 2);
827 currentpicture := remember_pic;
829 draw_staff (-2, 2, 0.5);
834 fet_beginchar ("X-Circled notehead", "s2xcircle");
836 save cthick, cxd, cyd, dy;
838 wid# := black_notehead_width# * sqrt (sqrt2);
839 hei# := noteheight# * sqrt (sqrt2);
841 set_char_box (0, wid#, hei# / 2, hei# / 2);
843 d := d - feta_space_shift;
845 cthick# := (1.2 + 1/4) * stafflinethickness#;
846 define_blacker_pixels (cthick);
849 cyd := h + d - cthick / 2;
853 pickup pencircle scaled cthick;
855 fill fullcircle xscaled (cxd + cthick)
856 yscaled (cyd + cthick)
858 unfill fullcircle xscaled (cxd - cthick)
859 yscaled (cyd - cthick)
862 xpos := .5 cxd / sqrt2;
863 ypos := .5 cyd / sqrt2;
865 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
866 draw (-xpos + w / 2, -ypos + dy) -- (xpos + w / 2, ypos + dy);
868 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
869 draw (-xpos + w / 2, ypos + dy) -- (xpos + w / 2, -ypos + dy);
874 z12 = (charwx * hppp, charwy * vppp);
877 remember_pic := currentpicture;
879 draw_staff (-2, 2, 0);
884 fet_beginchar ("X-Circled notehead", "s2xcircle");
886 save cthick, cxr, cyr;
888 wid# := black_notehead_width# * sqrt (sqrt2);
889 hei# := noteheight# * sqrt (sqrt2);
891 set_char_box (0, wid#, hei# / 2, hei# / 2);
893 currentpicture := remember_pic;
895 draw_staff (-2, 2, 0.5);
905 save solfa_pen_thick;
906 solfa_pen_thick# = 1.75 stafflinethickness#;
907 define_blacker_pixels (solfa_pen_thick);
910 save solfa_base_notewidth;
911 solfa_base_notewidth# := black_notehead_width#;
913 solfa_whole_width := whole_notehead_width# / black_notehead_width#;
914 solfa_half_width := half_notehead_width# / black_notehead_width#;
915 solfa_quarter_width := 1.0;
917 def draw_do_head (expr width_factor, dir) =
919 save left_dist, right_dist;
921 pair left_dist, right_dist;
923 set_char_box (0, width_factor * solfa_base_notewidth#,
924 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
926 pickup pencircle scaled solfa_pen_thick;
935 left_dist = (unitvector (z3 - z1) rotated 90) * 0.5 solfa_pen_thick;
936 right_dist = (unitvector (z2 - z3) rotated 90) * 0.5 solfa_pen_thick;
938 p_in := (((z1 - left_dist) -- (z3 - left_dist)) intersectionpoint
940 -- ((top z1 -- top z2) intersectionpoint
941 ((z2 - right_dist) -- (z3 - right_dist)))
942 -- (((z2 - right_dist) -- (z3 - right_dist)) intersectionpoint
943 ((z1 - left_dist) -- (z3 - left_dist)))
949 .. (z2 + right_dist){z3 - z2}
950 -- (z3 + right_dist){z3 - z2}
952 .. (z3 + left_dist){z1 - z3}
953 -- (z1 + left_dist){z1 - z3}
961 charwy := -chardp + 0.5 stafflinethickness#;
968 fet_beginchar ("Whole dohead", "s0do");
969 draw_do_head (solfa_whole_width, 1);
975 fet_beginchar ("Half dohead", "d1do");
976 draw_do_head (solfa_half_width, -1);
982 fet_beginchar ("Half dohead", "u1do");
983 draw_do_head (solfa_half_width, 1);
989 fet_beginchar ("Quart dohead", "d2do");
990 draw_do_head (solfa_quarter_width, -1);
995 fet_beginchar ("Quart dohead", "u2do");
996 draw_do_head (solfa_quarter_width, 1);
1002 % re - flat top, curved bottom:
1003 % (0,h/2) {dir -90} .. (w/2,-h/2) .. {dir 90} (w,h/2) -- cycle;
1004 % (broader along the base and with more vertical sides for half and
1006 % stem attachment: h/2
1009 def draw_re_head (expr width_factor, dir) =
1013 set_char_box (0, width_factor * solfa_base_notewidth#,
1014 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1016 pickup pencircle scaled solfa_pen_thick;
1023 y2 = curve_start [y3, y1];
1031 labels (range 1 thru 5);
1033 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1037 -- (z5 + 0.5 solfa_pen_thick * (-1, -1))
1050 charwy := curve_start [-chardp, charht];
1058 fet_beginchar ("Whole rehead", "s0re");
1059 draw_re_head (solfa_whole_width, 1);
1065 fet_beginchar ("Half up rehead", "u1re");
1066 draw_re_head (solfa_half_width, 1);
1072 fet_beginchar ("Half down rehead", "d1re");
1073 draw_re_head (solfa_half_width, -1);
1079 fet_beginchar ("Quart rehead", "u2re");
1080 draw_re_head (solfa_quarter_width, 1);
1085 fet_beginchar ("Quart rehead", "d2re");
1086 draw_re_head (solfa_quarter_width, -1);
1091 def draw_mi_head (expr width_factor) =
1092 save path_out, path_in;
1093 save ne_dist, se_dist, ne, se;
1094 path path_out, path_in;
1095 pair ne_dist, se_dist, ne, se;
1097 set_char_box (0, width_factor * solfa_base_notewidth#,
1098 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1100 pickup pencircle scaled solfa_pen_thick;
1111 z6 - z5 = whatever * (z2 - z1);
1112 z8 - z7 = whatever * (z2 - z1);
1113 z8 - z5 = whatever * (z4 - z1);
1114 z6 - z7 = whatever * (z4 - z1);
1116 ne = unitvector (z4 - z1);
1117 se = unitvector (z1 - z2);
1119 ne_dist = (ne rotated 90) * 0.5 solfa_pen_thick;
1120 se_dist = (se rotated 90) * 0.5 solfa_pen_thick;
1122 z5 = whatever [z1, z4] - ne_dist;
1123 z5 = whatever [z1, z2] - 1.5 se_dist;
1125 z5 - z1 = -(z7 - z3);
1127 labels (range 1 thru 8);
1136 .. (z1 + se_dist){-se}
1137 -- (z2 + se_dist){-se}
1139 .. (z2 - ne_dist){ne}
1140 -- (z3 - ne_dist){ne}
1142 .. (z3 - se_dist){se}
1143 -- (z4 - se_dist){se}
1145 .. (z4 + ne_dist){-ne}
1146 -- (z1 + ne_dist){-ne}
1151 fet_beginchar ("Whole mihead", "s0mi");
1152 draw_mi_head (solfa_whole_width);
1158 fet_beginchar ("Half mihead", "s1mi");
1159 draw_mi_head (solfa_quarter_width);
1165 fet_beginchar ("Quart mihead", "s2mi");
1166 draw_mi_head (solfa_quarter_width);
1171 def draw_fa_head (expr width_factor) =
1172 set_char_box (0, width_factor * solfa_base_notewidth#,
1173 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1175 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1176 path p_down_in, p_down_out, p_up_in, p_up_out;
1179 pickup pencircle scaled solfa_pen_thick;
1192 labels (1, 2, 3, 4);
1194 nw = unitvector (z1 - z3);
1195 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1197 p_up_in := (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1199 -- (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1201 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1204 p_up_out := lft z1{down}
1205 .. (z1 + nw_dist){-nw}
1206 -- (z3 + nw_dist){-nw}
1214 p_down_in := p_up_in rotated 180 shifted (w, 0);
1215 p_down_out := p_up_out rotated 180 shifted (w, 0);
1222 fet_beginchar ("Whole fa up head", "u0fa");
1223 draw_fa_head (solfa_whole_width);
1229 fet_beginchar ("Whole fa down head", "d0fa");
1230 draw_fa_head (solfa_whole_width);
1236 fet_beginchar ("half fa up head", "u1fa");
1237 draw_fa_head (solfa_half_width);
1243 fet_beginchar ("Half fa down head", "d1fa");
1244 draw_fa_head (solfa_half_width);
1250 fet_beginchar ("Quarter fa up head", "u2fa");
1251 draw_fa_head (solfa_quarter_width);
1256 fet_beginchar ("Quarter fa down head", "d2fa");
1257 draw_fa_head (solfa_quarter_width);
1262 def draw_la_head (expr width_factor) =
1263 set_char_box (0, width_factor * solfa_base_notewidth#,
1264 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1268 pickup pencircle scaled solfa_pen_thick;
1281 labels (range 1 thru 4);
1283 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1284 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1285 -- (z3 + 0.5 solfa_pen_thick * (-1, 1))
1286 -- (z4 + 0.5 solfa_pen_thick * (1, 1))
1301 fet_beginchar ("Whole lahead", "s0la");
1302 draw_la_head (solfa_whole_width);
1308 fet_beginchar ("Half lahead", "s1la");
1309 draw_la_head (solfa_half_width);
1315 fet_beginchar ("Quart lahead", "s2la");
1316 draw_la_head (solfa_quarter_width);
1321 def draw_ti_head (expr width_factor, dir) =
1322 set_char_box (0, width_factor * solfa_base_notewidth#,
1323 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1324 save p_in, p_out, p_top;
1325 save nw_dist, sw_dist, nw, sw;
1326 path p_in, p_out, p_top;
1327 pair nw_dist, sw_dist, nw, sw;
1331 pickup pencircle scaled solfa_pen_thick;
1336 y2 = cone_height [y1, y3];
1342 labels (range 1 thru 4);
1344 nw = unitvector (z2 - z1);
1345 sw = unitvector (z1 - z4);
1347 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1348 sw_dist = (sw rotated 90) * 0.5 solfa_pen_thick;
1350 p_top := (z2 - sw_dist)
1354 p_in := (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1355 ((z1 - sw_dist) -- (z4 - sw_dist)))
1356 -- (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1357 ((z2 + sw_dist) .. {right}(bot z3)))
1359 .. (((bot z3){right} .. (z4 + nw_dist)) intersectionpoint
1360 ((z1 - sw_dist) -- (z4 - sw_dist)))
1367 .. (z2 - sw_dist){direction 0 of p_top}
1369 & {direction infinity of p_top}(z4 - nw_dist)
1376 charwy := cone_height [-chardp, charht];
1383 fet_beginchar ("Whole up tihead", "s0ti");
1384 draw_ti_head (solfa_whole_width, 1);
1390 fet_beginchar ("Half up tihead", "u1ti");
1391 draw_ti_head (solfa_half_width, 1);
1397 fet_beginchar ("Half down tihead", "d1ti");
1398 draw_ti_head (solfa_half_width, -1);
1404 fet_beginchar ("Quart up tihead", "u2ti");
1405 draw_ti_head (solfa_quarter_width, 1);
1410 fet_beginchar ("Quart down tihead", "d2ti");
1411 draw_ti_head (solfa_quarter_width, -1);
1416 fet_endgroup ("noteheads");
1420 % we derive black_notehead_width# from the quarter head,
1421 % so we have to define black_notehead_width (pixel qty)
1422 % after the black_notehead_width# itself.
1424 % Let's keep it outside the group as well.
1427 define_pixels (black_notehead_width);