1 % Feta (not the Font-En-Tja) music font -- implement noteheads
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2011 Jan Nieuwenhuizen <janneke@gnu.org>
5 % & Han-Wen Nienhuys <hanwen@xs4all.nl>
6 % & Juergen Reuter <reuter@ipd.uka.de>
9 % LilyPond is free software: you can redistribute it and/or modify
10 % it under the terms of the GNU General Public License as published by
11 % the Free Software Foundation, either version 3 of the License, or
12 % (at your option) any later version.
14 % LilyPond is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 % GNU General Public License for more details.
19 % You should have received a copy of the GNU General Public License
20 % along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
29 % Most beautiful noteheads are pronounced, not circular,
30 % and not even symmetric.
31 % These examples are inspired by [Wanske]; see literature list.
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 save half_notehead_width, whole_notehead_width;
40 save solfa_noteheight;
42 numeric whole_notehead_width;
43 numeric half_notehead_width;
45 fet_begingroup ("noteheads");
49 % solfa heads should not overlap on chords.
51 solfa_noteheight# := staff_space# - stafflinethickness#;
53 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
58 pat := superellipse ((ellipticity, 0), (0, 1.0),
59 (-ellipticity, 0), (0, -1.0),
61 pat := pat rotated tilt;
63 save top_point, right_point;
64 pair top_point, right_point;
66 top_point := directionpoint left of pat;
67 right_point := directionpoint up of pat;
71 height# = staff_space# + stafflinethickness# - clearance;
72 scaling# = height# / (2 ypart (top_point));
73 define_pixels (scaling);
74 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
86 % dimensions aren't entirely right.
88 def draw_longa (expr up) =
89 save stemthick, fudge;
91 stemthick# = 2 stafflinethickness#;
92 define_whole_blacker_pixels (stemthick);
94 fudge = hround (blot_diameter / 2);
96 draw_outside_ellipse (1.80, 0, 0.707, 0);
97 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
99 pickup pencircle scaled stemthick;
109 top y4 = h + 3.0 staff_space;
112 bot y1 = -d - 3.0 staff_space;
123 draw_gridline (z1, z2, stemthick);
124 draw_gridline (z3, z4, stemthick);
130 fet_beginchar ("Longa notehead", "uM2");
133 draw_staff (-2, 2, 0);
137 fet_beginchar ("Longa notehead", "dM2");
140 draw_staff (-2, 2, 0);
145 fet_beginchar ("Longa notehead", "uM2");
148 draw_staff (-2, 2, 0.5);
152 fet_beginchar ("Longa notehead", "dM2");
155 draw_staff (-2, 2, 0.5);
160 def draw_brevis (expr linecount, line_thickness_multiplier) =
161 save stemthick, fudge;
163 stemthick# = line_thickness_multiplier * 2 * stafflinethickness#;
164 define_whole_blacker_pixels (stemthick);
166 % Breves of smaller design sizes should have their lines
167 % farther apart (the overlap should be smaller).
168 fudge = hround (blot_diameter *
169 min (max (-0.15, (0.8 - (20 / (design_size + 4)) + .1 linecount)), 0.3));
171 draw_outside_ellipse (1.80, 0, 0.707, 0);
172 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
174 pickup pencircle scaled stemthick;
176 % Breves of smaller design sizes should have their lines longer.
177 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
179 % Line lengths between 0.72 and 0.77 are not nice
180 % because they are neither separate nor connected
181 % when there is an interval of fourth.
182 if line_length < 0.75:
183 quanted_line_length := min (0.72, line_length);
185 quanted_line_length := max (0.77, line_length);
188 bot y1 = -quanted_line_length * staff_space;
189 top y2 = quanted_line_length * staff_space;
198 % Breves of smaller design sizes should have their lines
200 line_distance := (1.95 - 0.008 * design_size) * stemthick;
201 for i := 0 step 1 until linecount - 1:
202 draw_gridline (z1 - (i * line_distance, 0),
203 z2 - (i * line_distance, 0),
205 draw_gridline (z3 + (i * line_distance, 0),
206 z4 + (i * line_distance, 0),
212 fet_beginchar ("Brevis notehead", "sM1");
215 draw_staff (-2, 2, 0);
220 fet_beginchar ("Brevis notehead", "sM1");
223 draw_staff (-2, 2, 0.5);
228 fet_beginchar ("Double-lined brevis notehead", "sM1double");
229 draw_brevis (2, 0.8);
231 draw_staff (-2, 2, 0);
236 fet_beginchar ("Double-lined brevis notehead", "sM1double");
237 draw_brevis (2, 0.8);
239 draw_staff (-2, 2, 0.5);
244 fet_beginchar ("Whole notehead", "s0");
245 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
246 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
247 0.68, 2 stafflinethickness#);
249 whole_notehead_width# := charwd;
251 draw_staff (-2, 2, 0);
256 fet_beginchar ("Whole notehead", "s0");
257 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
259 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
260 0.68, 2 stafflinethickness#);
262 draw_staff (-2, 2, 0.5);
267 fet_beginchar ("Half notehead", "s1");
268 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
269 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
271 half_notehead_width# := charwd;
273 draw_staff (-2, 2, 0);
278 fet_beginchar ("Half notehead", "s1");
279 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
281 undraw_inside_ellipse (3.25, 33, 0.81,
282 2.5 stafflinethickness#);
284 draw_staff (-2, 2, 0.5);
289 fet_beginchar ("Quarter notehead", "s2");
291 draw_staff (-2, 2, 0);
296 fet_beginchar ("Quarter notehead", "s2");
297 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
300 draw_staff (-2, 2, 0.5);
305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 fet_beginchar ("Whole diamondhead", "s0diamond");
309 draw_outside_ellipse (1.80, 0, 0.495, 0);
310 undraw_inside_ellipse (1.30, 125, 0.6,
311 .4 staff_space# + stafflinethickness#);
313 draw_staff (-2, 2, 0);
318 fet_beginchar ("Whole diamondhead", "s0diamond");
319 draw_outside_ellipse (1.80, 0, 0.495, 0);
320 undraw_inside_ellipse (1.30, 125, 0.6,
321 .4 staff_space# + stafflinethickness#);
323 draw_staff (-2, 2, 0.5);
328 fet_beginchar ("Half diamondhead", "s1diamond");
329 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
330 undraw_inside_ellipse (3.5, 33, 0.80,
331 .3 staff_space# + 1.5 stafflinethickness#);
333 draw_staff (-2, 2, 0);
338 fet_beginchar ("Half diamondhead", "s1diamond");
339 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
340 undraw_inside_ellipse (3.5, 33, 0.80,
342 + 1.5 stafflinethickness#);
344 draw_staff (-2, 2, 0.5);
349 fet_beginchar ("Quarter diamondhead", "s2diamond");
350 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
352 draw_staff (-2, 2, 0);
357 fet_beginchar ("Quarter diamondhead", "s2diamond");
358 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
360 draw_staff (-2, 2, 0.5);
365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 vardef penposx@# (expr d) =
378 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
379 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
385 % UGH: xs not declared as argument.
387 def define_triangle_shape (expr stemdir) =
388 save triangle_a, triangle_b, triangle_c;
389 save triangle_out_a, triangle_out_b, triangle_out_c;
390 save triangle_in, triangle_out;
391 save width, depth, height;
392 save origin, left_up_dir;
393 save exact_left_point, exact_right_point, exact_down_point;
395 path triangle_a, triangle_b, triangle_c;
396 path triangle_out_a, triangle_out_b, triangle_out_c;
397 path triangle_in, triangle_out;
398 pair origin, left_up_dir;
399 pair exact_down_point, exact_left_point, exact_right_point;
402 pen_thick# = stafflinethickness# + .1 staff_space#;
403 define_pixels (llap);
404 define_blacker_pixels (pen_thick);
406 left_up_dir = llap# * dir (90 + tilt);
408 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
411 exact_left_point := origin + (left_up_dir xscaled xs);
412 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
413 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
415 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
416 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
417 width# = xpart (exact_right_point - exact_left_point)
420 set_char_box (0, width#, depth#, height#);
422 % Formerly, the shape has simply been drawn with an elliptical pen
423 % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
424 % is of 6th degree. For the sake of mf2pt1, we approximate it.
426 pickup pencircle scaled pen_thick xscaled xs;
428 z0 = (hround_pixels (xpart origin), 0);
430 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
431 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
432 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
434 z12 = caveness [.5[z1, z2], z3];
435 z23 = caveness [.5[z2, z3], z1];
436 z31 = caveness [.5[z3, z1], z2];
438 triangle_a = z1 .. z12 .. z2;
439 triangle_b = z2 .. z23 .. z3;
440 triangle_c = z3 .. z31 .. z1;
442 penposx1 (angle (direction 0 of triangle_a) - 90);
443 penposx2 (angle (direction 0 of triangle_b) - 90);
444 penposx3 (angle (direction 0 of triangle_c) - 90);
446 penposx1' (angle (direction infinity of triangle_c) + 90);
447 penposx2' (angle (direction infinity of triangle_a) + 90);
448 penposx3' (angle (direction infinity of triangle_b) + 90);
450 penposx12 (angle (z12 - z0));
451 penposx23 (angle (z23 - z0));
452 penposx31 (angle (z31 - z0));
454 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
455 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
456 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
469 triangle_out_a = z1r .. z12r .. z2'l;
470 triangle_out_b = z2r .. z23r .. z3'l;
471 triangle_out_c = z3r .. z31r .. z1'l;
473 triangle_out = top z1
475 .. z1r{direction 0 of triangle_out_a}
477 & {direction infinity of triangle_out_a}z2'l
480 .. z2r{direction 0 of triangle_out_b}
482 & {direction infinity of triangle_out_b}z3'l
485 .. z3r{direction 0 of triangle_out_c}
487 & {direction infinity of triangle_out_c}z1'l
490 labels (0, 10, 20, 30);
491 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
495 charwy := ypart exact_right_point;
496 charwx := xpart exact_right_point + .5 pen_thick# * xs;
498 charwy := -ypart exact_down_point;
499 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
504 def draw_whole_triangle_head =
510 llap# = 3/4 noteheight#;
514 define_triangle_shape (1);
520 fet_beginchar ("Whole trianglehead", "s0triangle");
521 draw_whole_triangle_head;
523 draw_staff (-2, 2, 0);
528 fet_beginchar ("Whole trianglehead", "s0triangle");
529 draw_whole_triangle_head;
531 draw_staff (-2, 2, 0.5);
536 def draw_small_triangle_head (expr dir) =
542 llap# = 2/3 noteheight#;
545 define_triangle_shape (dir);
549 filldraw triangle_out;
550 unfilldraw triangle_in;
554 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
555 draw_small_triangle_head (-1);
557 draw_staff (-2, 2, 0);
561 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
562 draw_small_triangle_head (1);
564 draw_staff (-2, 2, 0.5);
568 def draw_closed_triangle_head (expr dir) =
574 llap# = 2/3 noteheight#;
577 define_triangle_shape (dir);
582 fet_beginchar ("Quarter trianglehead (upstem)", "u2triangle");
583 draw_closed_triangle_head (1);
585 draw_staff (-2, 2, 0);
589 fet_beginchar ("Quarter trianglehead (downstem)", "d2triangle");
590 draw_closed_triangle_head (-1);
592 draw_staff (-2, 2, 0.5);
596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 % Slash heads are for indicating improvisation. They are
599 % twice as high as normal heads.
601 def draw_slash (expr hwid_hash) =
605 exact_height = staff_space# + stafflinethickness# / 2;
607 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
608 exact_height, exact_height);
617 pickup pencircle scaled blot_diameter;
622 lft x2 = 2 h / slash_slope;
629 ne = unitvector (z3 - z4);
630 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
633 .. (z1 + nw_dist){ne}
634 -- (z2 + nw_dist){ne}
637 .. (z3 - nw_dist){-ne}
638 -- (z4 - nw_dist){-ne}
642 if hwid_hash > 2 slash_thick#:
645 th = slash_thick - blot_diameter;
650 z6 - z5 = whatever * ne;
651 z8 - z7 = whatever * ne;
653 z5 = z1 + whatever * ne + th * (ne rotated -90);
654 z8 = z4 + whatever * ne + th * (ne rotated 90);
662 labels (range 1 thru 10);
666 fet_beginchar ("Whole slashhead", "s0slash");
667 draw_slash (4 slash_thick# + 0.5 staff_space#);
669 draw_staff (-2, 2, 0);
673 fet_beginchar ("Half slashhead", "s1slash");
674 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
676 draw_staff (-2, 2, 0);
680 fet_beginchar ("Quarter slashhead", "s2slash");
681 draw_slash (1.5 slash_thick#);
683 draw_staff (-2, 2, 0);
687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689 % `thick' is the distance between the NE/SW parallel lines in the cross
690 % (distance between centres of lines) in multiples of stafflinethickness
692 def draw_cross (expr thick) =
694 save ne_dist, nw_dist, rt_dist, up_dist;
695 save crz_in, crz_out;
698 pair ne_dist, nw_dist, rt_dist, up_dist;
699 path crz_in, crz_out;
701 pen_thick# := 1.2 stafflinethickness#;
702 thickness# := thick * stafflinethickness#;
703 define_pixels (thickness);
704 define_blacker_pixels (pen_thick);
706 pickup pencircle scaled pen_thick;
711 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
714 z4 - z5 = whatever * ne;
716 z6 - z3 = whatever * ne;
717 z3 - z4 = whatever * (ne yscaled -1);
719 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
722 x1 = charwd / 2 - .5 pen_thick#;
724 + thick / 2 * stafflinethickness# * (ne rotated -90);
726 % labels (1, 2, 3, 4, 5, 6);
728 nw = unitvector (z3 - z4);
730 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
731 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
732 nw_dist = (ne rotated 90) * 0.5 pen_thick;
733 ne_dist = (nw rotated -90) * 0.5 pen_thick;
739 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
740 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
741 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
743 crz_out = (z6 + up_dist)
744 -- (z3 + nw_dist){ne}
746 .. (z3 + ne_dist){-nw}
747 -- (z4 + ne_dist){-nw}
749 .. (z4 - nw_dist){-ne}
751 crz_out := crz_out shifted (0, feta_shift)
752 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
754 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
758 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
759 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
760 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
762 crz_in = (bot z6){right}
763 .. (z6 - nw_dist){ne}
766 -- (z5 + nw_dist){-ne}
768 crz_in := crz_in shifted (0, feta_shift)
769 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
771 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
776 currentpicture := currentpicture shifted (hround (w / 2), 0);
779 charwy := y1 + feta_shift;
781 z12 = (charwx * hppp, y1 * vppp);
787 fet_beginchar ("Whole Crossed notehead", "s0cross");
790 wid# := black_notehead_width# + 4 stafflinethickness#;
791 hei# := noteheight# + stafflinethickness#;
793 set_char_box (0, wid#, hei# / 2, hei# / 2);
797 remember_pic := currentpicture;
799 draw_staff (-2, 2, 0);
804 fet_beginchar ("Whole Crossed notehead", "s0cross");
807 wid# := black_notehead_width# + 4 stafflinethickness#;
808 hei# := noteheight# + stafflinethickness#;
810 set_char_box (0, wid#, hei# / 2, hei# / 2);
812 currentpicture := remember_pic;
814 draw_staff (-2, 2, 0.5);
819 fet_beginchar ("Half Crossed notehead", "s1cross");
822 wid# := black_notehead_width# + 2 stafflinethickness#;
823 hei# := noteheight# + stafflinethickness# / 2;
825 set_char_box (0, wid#, hei# / 2, hei# / 2);
829 remember_pic := currentpicture;
831 draw_staff (-2, 2, 0);
836 fet_beginchar ("Half Crossed notehead", "s1cross");
839 wid# := black_notehead_width# + 2 stafflinethickness#;
840 hei# := noteheight# + stafflinethickness# / 2;
842 set_char_box (0, wid#, hei# / 2, hei# / 2);
844 currentpicture := remember_pic;
846 draw_staff (-2, 2, 0.5);
851 fet_beginchar ("Crossed notehead", "s2cross");
852 wid# := black_notehead_width#;
854 set_char_box (0, wid#, hei# / 2, hei# / 2);
858 remember_pic := currentpicture;
860 draw_staff (-2, 2, 0);
865 fet_beginchar ("Crossed notehead", "s2cross");
866 wid# := black_notehead_width#;
868 set_char_box (0, wid#, hei# / 2, hei# / 2);
870 currentpicture := remember_pic;
872 draw_staff (-2, 2, 0.5);
877 fet_beginchar ("X-Circled notehead", "s2xcircle");
879 save cthick, cxd, cyd, dy;
881 wid# := black_notehead_width# * sqrt (sqrt2);
882 hei# := noteheight# * sqrt (sqrt2);
884 set_char_box (0, wid#, hei# / 2, hei# / 2);
886 d := d - feta_space_shift;
888 cthick# := (1.2 + 1/4) * stafflinethickness#;
889 define_blacker_pixels (cthick);
892 cyd := h + d - cthick / 2;
896 pickup pencircle scaled cthick;
898 fill fullcircle xscaled (cxd + cthick)
899 yscaled (cyd + cthick)
901 unfill fullcircle xscaled (cxd - cthick)
902 yscaled (cyd - cthick)
905 xpos := .5 cxd / sqrt2;
906 ypos := .5 cyd / sqrt2;
908 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
909 draw (-xpos + w / 2, -ypos + dy)
910 -- (xpos + w / 2, ypos + dy);
912 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
913 draw (-xpos + w / 2, ypos + dy)
914 -- (xpos + w / 2, -ypos + dy);
919 z12 = (charwx * hppp, charwy * vppp);
922 remember_pic := currentpicture;
924 draw_staff (-2, 2, 0);
929 fet_beginchar ("X-Circled notehead", "s2xcircle");
931 save cthick, cxr, cyr;
933 wid# := black_notehead_width# * sqrt (sqrt2);
934 hei# := noteheight# * sqrt (sqrt2);
936 set_char_box (0, wid#, hei# / 2, hei# / 2);
938 currentpicture := remember_pic;
940 draw_staff (-2, 2, 0.5);
950 % Note: For whole and half notes, the `fill' curve (p_out) is offset from
951 % the points that specify the outer geometry, because we need to add
952 % the rounding. In contrast, the inner curve is not offset, because
953 % there is no rounding.
955 % This means that to get a line of thick_factor * pen_thickness,
956 % we need to offset the inner curve by
958 % (thick_factor - 0.5) * pen_thickness
962 % (2 * thick_factor - 1) * half_pen_thickness
964 save solfa_pen_thick;
965 solfa_pen_thick# = 1.3 stafflinethickness#;
966 define_blacker_pixels (solfa_pen_thick);
968 save solfa_pen_radius;
969 solfa_pen_radius = 0.5 solfa_pen_thick;
971 save solfa_base_notewidth;
972 solfa_base_notewidth# := black_notehead_width#;
974 solfa_whole_width := 1.0;
975 solfa_half_width := 1.0;
976 solfa_quarter_width := 1.0;
981 % Triangle with base parallel to staff lines.
984 def draw_do_head (expr width_factor, dir, thickness_factor) =
986 save left_dist, right_dist, bottom_dist;
988 pair left_dist, right_dist, bottom_dist;
990 set_char_box (0, width_factor * solfa_base_notewidth#,
991 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
993 bottom_thick_factor := 2 * thickness_factor - 1;
994 % no different thickness for left side if we want uniform thickness
995 if thickness_factor = 1:
996 left_thick_factor := 1;
998 left_thick_factor := 0.7 * bottom_thick_factor;
1002 pen_radius := min (solfa_pen_radius,
1003 (h + d) / (3 * (1 + bottom_thick_factor)));
1005 pickup pencircle scaled (2 * pen_radius);
1014 left_dist = (unitvector (z3 - z1) rotated 90) * pen_radius;
1015 right_dist = (unitvector (z2 - z3) rotated 90) * pen_radius;
1016 bottom_dist = (0,1) * pen_radius;
1020 save point_a, point_b, point_c;
1021 pair point_a, point_b, point_c;
1023 pa := (z1 - left_thick_factor * left_dist)
1024 -- (z3 - left_thick_factor * left_dist);
1025 pb := (z1 + bottom_thick_factor * bottom_dist)
1026 -- (z2 + bottom_thick_factor * bottom_dist);
1027 pc := (z2 - right_dist)
1028 -- (z3 - right_dist);
1030 point_a := pa intersectionpoint pb;
1031 point_b := pb intersectionpoint pc;
1032 point_c := pc intersectionpoint pa;
1042 .. (z2 + right_dist){z3 - z2}
1043 -- (z3 + right_dist){z3 - z2}
1045 .. (z3 + left_dist){z1 - z3}
1046 -- (z1 + left_dist){z1 - z3}
1053 charwy := -chardp + 0.5 stafflinethickness#;
1063 fet_beginchar ("Whole dohead", "s0do");
1064 draw_do_head (solfa_whole_width, 1, do_weight);
1070 fet_beginchar ("Half dohead", "d1do");
1071 draw_do_head (solfa_half_width, -1, do_weight);
1077 fet_beginchar ("Half dohead", "u1do");
1078 draw_do_head (solfa_half_width, 1, do_weight);
1084 fet_beginchar ("Quarter dohead", "d2do");
1085 draw_do_head (solfa_quarter_width, -1, do_weight);
1090 fet_beginchar ("Quarter dohead", "u2do");
1091 draw_do_head (solfa_quarter_width, 1, do_weight);
1096 fet_beginchar ("Whole thin dohead", "s0doThin");
1097 draw_do_head (solfa_whole_width, 1, 1);
1103 fet_beginchar ("Half thin dohead", "d1doThin");
1104 draw_do_head (solfa_half_width, -1, 1);
1110 fet_beginchar ("Half thin dohead", "u1doThin");
1111 draw_do_head (solfa_half_width, 1, 1);
1117 fet_beginchar ("Quarter thin dohead", "d2doThin");
1118 draw_do_head (solfa_quarter_width, -1, 1);
1123 fet_beginchar ("Quarter thin dohead", "u2doThin");
1124 draw_do_head (solfa_quarter_width, 1, 1);
1130 % re - flat top, curved bottom:
1134 % .. {dir 90} (w,h/2)
1137 % (broader along the base and with more vertical sides for half and
1140 % Note: According to some shape-note singers, there should be no size
1141 % differences for half and whole notes, contrary to the comment above.
1142 % Consequently, we have made them all the same width.
1144 % stem attachment: h/2
1146 def draw_re_head (expr width_factor, dir, thickness_factor) =
1150 set_char_box (0, width_factor * solfa_base_notewidth#,
1151 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1154 offset = (2 * thickness_factor - 1);
1161 pen_radius := min (solfa_pen_radius,
1162 (h + d) * (1-curve_start) / (1+ offset));
1164 pickup pencircle scaled (2 * pen_radius);
1169 y2 = curve_start [y3, y1];
1177 labels (range 1 thru 5);
1179 p_in := (z1 + pen_radius * (1, -1 * offset))
1181 .. ((top z3) + (0, offset * pen_radius))
1183 -- (z5 + pen_radius * (-1, -1 * offset))
1196 charwy := curve_start [-chardp, charht];
1207 fet_beginchar ("Whole rehead", "s0re");
1208 draw_re_head (solfa_whole_width, 1, re_weight);
1214 fet_beginchar ("Half up rehead", "u1re");
1215 draw_re_head (solfa_half_width, 1, re_weight);
1221 fet_beginchar ("Half down rehead", "d1re");
1222 draw_re_head (solfa_half_width, -1, re_weight);
1228 fet_beginchar ("Quarter up rehead", "u2re");
1229 draw_re_head (solfa_quarter_width, 1, re_weight);
1234 fet_beginchar ("Quarter down rehead", "d2re");
1235 draw_re_head (solfa_quarter_width, -1, re_weight);
1240 fet_beginchar ("Whole thin rehead", "s0reThin");
1241 draw_re_head (solfa_whole_width, 1, 1);
1247 fet_beginchar ("Half up thin rehead", "u1reThin");
1248 draw_re_head (solfa_half_width, 1, 1);
1254 fet_beginchar ("Half down thin rehead", "d1reThin");
1255 draw_re_head (solfa_half_width, -1, 1);
1261 fet_beginchar ("Quarter thin rehead", "u2reThin");
1262 draw_re_head (solfa_quarter_width, 1, 1);
1267 fet_beginchar ("Quarter thin rehead", "d2reThin");
1268 draw_re_head (solfa_quarter_width, -1, 1);
1273 %%%% mi head -- diamond shape
1275 % two versions, depending on whether the `strong' lines are on the nw & se
1278 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1279 save path_out, path_in;
1280 save ne_dist, se_dist, ne, se;
1281 save path_a, path_b, path_c, path_d;
1282 path path_out, path_in;
1283 pair ne_dist, se_dist, ne, se;
1284 path path_a, path_b, path_c, path_d;
1288 set_char_box (0, width_factor * solfa_base_notewidth#,
1289 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1292 offset := 2 * thickness_factor - 1;
1296 note_diagonal := w / 2 ++ (h + d) / 2;
1300 pen_radius := min (solfa_pen_radius,
1301 .3 * note_diagonal / (1 + offset));
1303 pickup pencircle scaled (2 * pen_radius);
1314 % inner sides are parallel to outer sides
1315 z6 - z5 = whatever * (z2 - z1);
1316 z8 - z7 = whatever * (z4 - z3);
1317 z8 - z5 = whatever * (z4 - z1);
1318 z7 - z6 = whatever * (z3 - z2);
1320 ne = unitvector (z4 - z1);
1321 se = unitvector (z2 - z1);
1323 ne_dist = (ne rotated 90) * pen_radius;
1324 se_dist = (se rotated 90) * pen_radius;
1326 path_a := (z1 + se_dist)
1328 path_b := (z2 + (ne_dist * offset))
1329 -- (z3 + (ne_dist * offset));
1330 path_c := (z3 - se_dist)
1332 path_d := (z4 - (ne_dist * offset))
1333 -- (z1 - (ne_dist * offset));
1335 z5 = path_a intersectionpoint path_d;
1336 z7 = path_b intersectionpoint path_c;
1338 labels (range 1 thru 8);
1347 path_in := inner_path;
1349 path_in := inner_path reflectedabout (z2, z4);
1352 path_out := lft z1 {down}
1353 .. (z1 - se_dist){se}
1354 -- (z2 - se_dist){se}
1356 .. (z2 - ne_dist){ne}
1357 -- (z3 - ne_dist){ne}
1359 .. (z3 + se_dist){-se}
1360 -- (z4 + se_dist){-se}
1362 .. (z4 + ne_dist){-ne}
1363 -- (z1 + ne_dist){-ne}
1368 save mi_weight, mi_width;
1372 fet_beginchar ("Whole mihead", "s0mi");
1373 draw_mi_head (mi_width * solfa_whole_width, mi_weight, false);
1379 fet_beginchar ("Half mihead", "s1mi");
1380 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1386 fet_beginchar ("Quarter mihead", "s2mi");
1387 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1392 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1393 draw_mi_head (mi_width * solfa_whole_width, mi_weight, true);
1399 fet_beginchar ("Half mirror mihead", "s1miMirror");
1400 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1406 fet_beginchar ("Quarter mirror mihead", "s2miMirror");
1407 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1412 fet_beginchar ("Whole thin mihead", "s0miThin");
1413 draw_mi_head (mi_width * solfa_whole_width, 1, false);
1419 fet_beginchar ("Half thin mihead", "s1miThin");
1420 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1426 fet_beginchar ("Quarter thin mihead", "s2miThin");
1427 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1434 % Right triangle, hypotenuse from nw to se corner. Stem attaches on
1435 % vertical side in direction of horizontal side.
1437 def draw_fa_head (expr width_factor, thickness_factor) =
1438 set_char_box (0, width_factor * solfa_base_notewidth#,
1439 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1441 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1442 path p_down_in, p_down_out, p_up_in, p_up_out;
1443 save path_a, path_b, path_c;
1444 path path_a, path_b, path_c;
1448 offset := 2 * thickness_factor - 1;
1451 pen_radius := min (solfa_pen_radius,
1452 .33 * (h + d) / (1 + offset));
1454 pickup pencircle scaled (2 * pen_radius);
1467 labels (1, 2, 3, 4);
1469 nw = unitvector (z1 - z3);
1470 nw_dist = (nw rotated 90) * pen_radius;
1472 path_a := (z1 - (0,1) * offset * pen_radius)
1473 -- (z2 - (0,1) * offset * pen_radius);
1474 path_b := (z2 - (1,0) * pen_radius)
1475 -- (z3 - (1,0) * pen_radius);
1476 path_c := (z3 - nw_dist)
1479 p_up_in := (path_a intersectionpoint path_b)
1480 -- (path_b intersectionpoint path_c)
1481 -- (path_c intersectionpoint path_a)
1484 p_up_out := lft z1{down}
1485 .. (z1 + nw_dist){-nw}
1486 -- (z3 + nw_dist){-nw}
1494 p_down_in := p_up_in rotated 180 shifted (w, 0);
1495 p_down_out := p_up_out rotated 180 shifted (w, 0);
1504 fet_beginchar ("Whole fa up head", "u0fa");
1505 draw_fa_head (solfa_whole_width, fa_weight);
1511 fet_beginchar ("Whole fa down head", "d0fa");
1512 draw_fa_head (solfa_whole_width, fa_weight);
1518 fet_beginchar ("half fa up head", "u1fa");
1519 draw_fa_head (solfa_half_width, fa_weight);
1525 fet_beginchar ("Half fa down head", "d1fa");
1526 draw_fa_head (solfa_half_width, fa_weight);
1532 fet_beginchar ("Quarter fa up head", "u2fa");
1533 draw_fa_head (solfa_quarter_width, fa_weight);
1538 fet_beginchar ("Quarter fa down head", "d2fa");
1539 draw_fa_head (solfa_quarter_width, fa_weight);
1544 fet_beginchar ("Whole thin fa up head", "u0faThin");
1545 draw_fa_head (solfa_whole_width, 1);
1551 fet_beginchar ("Whole thin fa down head", "d0faThin");
1552 draw_fa_head (solfa_whole_width, 1);
1558 fet_beginchar ("half thin fa up head", "u1faThin");
1559 draw_fa_head (solfa_half_width, 1);
1565 fet_beginchar ("Half thin fa down head", "d1faThin");
1566 draw_fa_head (solfa_half_width, 1);
1572 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1573 draw_fa_head (solfa_quarter_width, 1);
1578 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1579 draw_fa_head (solfa_quarter_width, 1);
1587 % Note: sol head is the same shape as a standard music head, and doesn't
1588 % vary from style to style. However, width is constant with duration,
1589 % so we can't just use the standard note font.
1591 def draw_sol_head (expr filled) =
1592 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1594 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1596 draw_staff (-2, 2, 0);
1599 fet_beginchar ("Whole solhead", "s0sol");
1600 draw_sol_head ( false);
1604 fet_beginchar ("Half solhead", "s1sol");
1605 draw_sol_head ( false);
1609 fet_beginchar ("Quarter solhead", "s2sol");
1610 draw_sol_head ( true);
1618 def draw_la_head (expr width_factor, thickness_factor) =
1619 set_char_box (0, width_factor * solfa_base_notewidth#,
1620 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1625 offset := 2 * thickness_factor - 1;
1628 pen_radius := min (solfa_pen_radius,
1629 .35 * (h + d) / (1 + offset));
1631 pickup pencircle scaled (2 * pen_radius);
1644 labels (range 1 thru 4);
1646 p_in := (z1 + pen_radius * (1, -offset))
1647 -- (z2 + pen_radius * (-1, -offset))
1648 -- (z3 + pen_radius * (-1, offset))
1649 -- (z4 + pen_radius * (1, offset))
1667 fet_beginchar ("Whole lahead", "s0la");
1668 draw_la_head (solfa_whole_width, la_weight);
1674 fet_beginchar ("Half lahead", "s1la");
1675 draw_la_head (solfa_half_width, la_weight);
1681 fet_beginchar ("Quarter lahead", "s2la");
1682 draw_la_head (solfa_quarter_width, la_weight);
1687 fet_beginchar ("Whole thin lahead", "s0laThin");
1688 draw_la_head (solfa_whole_width, 1);
1694 fet_beginchar ("Half thin lahead", "s1laThin");
1695 draw_la_head (solfa_half_width, 1);
1701 fet_beginchar ("Quarter lahead", "s2laThin");
1702 draw_la_head (solfa_quarter_width, 1);
1709 % `Snow-cone', V with rounded top.
1711 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1712 set_char_box (0, width_factor * solfa_base_notewidth#,
1713 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1714 save p_in, p_out, p_top, p_top_in;
1715 path p_in, p_out, p_top, p_top_in;
1720 offset := 2 * thickness_factor - 1;
1723 pen_radius := min (solfa_pen_radius,
1724 .4 * (h + d) / (1 + offset));
1726 pickup pencircle scaled (2 * pen_radius);
1731 y2 = cone_height [y1, y3];
1737 y5 = y1 + offset * pen_radius;
1739 labels (range 1 thru 4);
1741 save nw_dist, sw_dist, nw, sw;
1742 pair nw_dist, sw_dist, nw, sw;
1744 nw = unitvector (z2 - z1);
1745 sw = unitvector (z1 - z4);
1747 nw_dist = (nw rotated 90) * pen_radius;
1748 sw_dist = (sw rotated 90) * pen_radius;
1750 p_top := (z2 + nw * pen_radius)
1752 .. (z4 - sw * pen_radius);
1754 p_top_in := (z2 - nw * offset * pen_radius)
1755 .. (z3 - (0,1) * pen_radius) {right}
1756 .. (z4 + sw * offset * pen_radius);
1758 save path_a, path_b;
1759 path path_a, path_b;
1765 z6 = path_a intersectionpoint p_top_in;
1766 z7 = path_b intersectionpoint p_top_in;
1778 .. (z2 + nw * pen_radius){direction 0 of p_top}
1780 & {direction infinity of p_top}(z4 - sw * pen_radius)
1787 charwy := cone_height [-chardp, charht];
1797 fet_beginchar ("Whole up tihead", "s0ti");
1798 draw_ti_head (solfa_whole_width, 1, ti_weight);
1804 fet_beginchar ("Half up tihead", "u1ti");
1805 draw_ti_head (solfa_half_width, 1, ti_weight);
1811 fet_beginchar ("Half down tihead", "d1ti");
1812 draw_ti_head (solfa_half_width, -1, ti_weight);
1818 fet_beginchar ("Quarter up tihead", "u2ti");
1819 draw_ti_head (solfa_quarter_width, 1, ti_weight);
1824 fet_beginchar ("Quarter down tihead", "d2ti");
1825 draw_ti_head (solfa_quarter_width, -1, ti_weight);
1830 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1831 draw_ti_head (solfa_whole_width, 1, 1);
1837 fet_beginchar ("Half thin up tihead", "u1tiThin");
1838 draw_ti_head (solfa_half_width, 1, 1);
1844 fet_beginchar ("Half thin down tihead", "d1tiThin");
1845 draw_ti_head (solfa_half_width, -1, 1);
1851 fet_beginchar ("Quarter thin up tihead", "u2tiThin");
1852 draw_ti_head (solfa_quarter_width, 1, 1);
1857 fet_beginchar ("Quarter thin down tihead", "d2tiThin");
1858 draw_ti_head (solfa_quarter_width, -1, 1);
1863 %%%%%% Funk shape note heads
1865 % Funk heads are narrower than Aiken and Sacred Harp, so we need a new
1868 funk_notehead_width := 0.75;
1872 % Parabolic on one side, vertical line on other
1873 % Has up and down shapes for *all* notes
1875 def draw_Funk_do_head (expr width_factor, thickness_factor) =
1876 set_char_box (0, width_factor * solfa_base_notewidth#,
1877 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1880 offset := 2 * thickness_factor - 1;
1883 pen_radius := min (solfa_pen_radius,
1884 .3 * (h + d) / (1 + offset));
1886 pickup pencircle scaled (2 * pen_radius);
1897 x4 = x1 - pen_radius;
1898 y4 = y1 + offset * pen_radius;
1901 x5 = x2 + pen_radius;
1904 y6 = y3 - offset * pen_radius;
1906 save p_up_in, p_up_out, p_down_in, p_down_out;
1907 path p_up_in, p_up_out, p_down_in, p_down_out;
1909 p_down_in := z4{left}
1914 p_down_out := bot z1{left}
1921 p_up_in := p_down_in rotated 180 shifted (w,0);
1922 p_up_out := p_down_out rotated 180 shifted (w,0);
1927 save funk_do_weight;
1928 funk_do_weight := 1.7;
1930 fet_beginchar ("Whole up Funk dohead", "u0doFunk");
1931 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1937 fet_beginchar ("Whole down Funk dohead", "d0doFunk");
1938 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1944 fet_beginchar ("Half up Funk dohead", "u1doFunk");
1945 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1951 fet_beginchar ("Half down Funk dohead", "d1doFunk");
1952 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1958 fet_beginchar ("Quarter up Funk dohead", "u2doFunk");
1959 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1964 fet_beginchar ("Quarter down Funk dohead", "d2doFunk");
1965 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1972 % Has up and down shapes for *all* notes
1974 def draw_Funk_re_head (expr width_factor, thickness_factor) =
1975 set_char_box (0, width_factor * solfa_base_notewidth#,
1976 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1979 offset := 2 * thickness_factor - 1;
1982 pen_radius := min (solfa_pen_radius,
1983 .3 * (h + d) / (1 + offset));
1985 pickup pencircle scaled (2 * pen_radius);
1996 x3 := curve_in [x1, x2];
2004 save ne, se, ne_perp, se_perp;
2005 pair ne, se, ne_perp, se_perp;
2007 ne := unitvector (z2 - z1);
2008 se := unitvector (z4 - z1);
2009 ne_perp := ne rotated 90;
2010 se_perp := se rotated 90;
2012 save path_a, path_b, path_c, path_d;
2013 path path_a, path_b, path_c, path_d;
2014 save arrow_a_perp, arrow_b_perp;
2015 pair arrow_a_perp, arrow_b_perp;
2018 path_d := z2 .. z3{down} .. z4;
2019 arrow_a_perp = unitvector (direction 0 of path_d rotated 90)
2021 arrow_b_perp = unitvector (direction 2 of path_d rotated 90)
2024 path_b := (z1 + se_perp * pen_radius)
2025 -- z4 + se_perp * offset * pen_radius;
2026 path_a := (z1 - ne_perp * pen_radius)
2027 -- z2 - ne_perp * offset * pen_radius;
2028 path_c := z2 - arrow_a_perp
2030 .. z4 - arrow_b_perp;
2032 z5 = path_a intersectionpoint path_b;
2033 z7 = path_a intersectionpoint path_c;
2034 z8 = path_b intersectionpoint path_c;
2036 save p_up_in, p_down_in, p_up_out, p_down_out;
2037 path p_up_in, p_down_in, p_up_out, p_down_out;
2045 p_down_out := lft z1{up}
2046 .. (z1 + ne_perp * pen_radius){ne}
2047 -- (z2 + ne_perp * pen_radius){ne}
2050 .. (z2 + arrow_a_perp)
2052 .. (z4 + arrow_b_perp)
2055 .. z4 - se_perp * pen_radius
2056 -- z1 - se_perp * pen_radius
2059 p_up_in := p_down_in rotated 180 shifted (w, 0);
2060 p_up_out := p_down_out rotated 180 shifted (w, 0);
2065 save funk_re_weight;
2066 funk_re_weight = 1.7;
2068 fet_beginchar ("Whole up Funk rehead", "u0reFunk");
2069 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2075 fet_beginchar ("Whole down Funk rehead", "d0reFunk");
2076 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2082 fet_beginchar ("Half up Funk rehead", "u1reFunk");
2083 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2089 fet_beginchar ("Half down Funk rehead", "d1reFunk");
2090 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2096 fet_beginchar ("Quarter up Funk rehead", "u2reFunk");
2097 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2102 fet_beginchar ("Quarter down Funk rehead", "d2reFunk");
2103 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2110 % Has up and down shapes for all hollow notes
2112 save funk_mi_width, funk_mi_weight;
2113 funk_mi_width := 1.2;
2114 funk_mi_weight := 1.9;
2116 fet_beginchar ("Whole up Funk mihead", "u0miFunk");
2117 draw_mi_head (funk_mi_width * funk_notehead_width,
2118 funk_mi_weight, false);
2124 fet_beginchar ("Whole down Funk mihead", "d0miFunk");
2125 draw_mi_head (funk_mi_width * funk_notehead_width,
2126 funk_mi_weight, true);
2132 fet_beginchar ("Half up Funk mihead", "u1miFunk");
2133 draw_mi_head (funk_mi_width * funk_notehead_width,
2134 funk_mi_weight, false);
2140 fet_beginchar ("Half down Funk mihead", "d1miFunk");
2141 draw_mi_head (funk_mi_width * funk_notehead_width,
2142 funk_mi_weight, true);
2148 fet_beginchar ("Quarter Funk mihead", "s2miFunk");
2149 draw_mi_head (funk_mi_width * funk_notehead_width,
2150 funk_mi_weight, false);
2157 % Does it rotate for whole notes?
2158 % Same as other shape note systems
2159 % Need special notes because of special width
2161 save funk_fa_weight;
2162 funk_fa_weight := 1.9;
2164 fet_beginchar ("Whole up Funk fahead", "u0faFunk");
2165 draw_fa_head (funk_notehead_width, funk_fa_weight);
2171 fet_beginchar ("Whole down Funk fahead", "d0faFunk");
2172 draw_fa_head (funk_notehead_width, funk_fa_weight);
2178 fet_beginchar ("Half up Funk fahead", "u1faFunk");
2179 draw_fa_head (funk_notehead_width, funk_fa_weight);
2185 fet_beginchar ("Half down Funk fahead", "d1faFunk");
2186 draw_fa_head (funk_notehead_width, funk_fa_weight);
2192 fet_beginchar ("Quarter up Funk fahead", "u2faFunk");
2193 draw_fa_head (funk_notehead_width, funk_fa_weight);
2198 fet_beginchar ("Quarter down Funk fahead", "d2faFunk");
2199 draw_fa_head (funk_notehead_width, funk_fa_weight);
2204 %%%%%% Funk sol head is the same as the others
2205 % Need special character because of skinnier head
2207 def draw_Funk_sol_head (expr filled) =
2210 noteheight# := solfa_noteheight#;
2211 draw_outside_ellipse (1.2, 34, 0.71, 0.);
2213 undraw_inside_ellipse (1.9, 33, 0.74, 5.5 stafflinethickness#);
2215 draw_staff (-2, 2, 0);
2220 fet_beginchar ("Whole Funk solhead", "s0solFunk");
2221 draw_Funk_sol_head ( false);
2225 fet_beginchar ("Half Funk solhead", "s1solFunk");
2226 draw_Funk_sol_head ( false);
2230 fet_beginchar ("Quarter Funk solhead", "s2solFunk");
2231 draw_Funk_sol_head ( true);
2237 % Same as for other shape notes
2238 % Smaller width requires special characters
2240 save funk_la_weight;
2241 funk_la_weight := 1.9;
2243 fet_beginchar ("Whole Funk lahead", "s0laFunk");
2244 draw_la_head (funk_notehead_width, funk_notehead_width);
2250 fet_beginchar ("Half Funk lahead", "s1laFunk");
2251 draw_la_head (funk_notehead_width, funk_notehead_width);
2257 fet_beginchar ("Quarter Funk lahead", "s2laFunk");
2258 draw_la_head (funk_notehead_width, funk_notehead_width);
2264 % `Sideways snow cone'.
2265 % Rotates for all notes.
2267 def draw_Funk_ti_head (expr width_factor, thickness_factor) =
2268 set_char_box (0, width_factor * solfa_base_notewidth#,
2269 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2274 offset := 2 * thickness_factor - 1;
2277 pen_radius := min (solfa_pen_radius,
2278 .33 * (h + d) / (1 + offset));
2280 pickup pencircle scaled (2 * pen_radius);
2285 x2 = cone_width [x1, x3];
2294 save nw_dist, sw_dist, ne, se;
2295 pair nw_dist, sw_dist, ne, se;
2297 ne = unitvector (z2 - z1);
2298 se = unitvector (z4 - z1);
2300 nw_dist = (ne rotated 90) * pen_radius ;
2301 sw_dist = (se rotated -90) * pen_radius;
2303 save path_a, path_b;
2304 path path_a, path_b;
2305 path_a := z1 - nw_dist
2306 -- z2 - offset * nw_dist;
2307 path_b := z1 - sw_dist
2308 -- z4 - offset * sw_dist;
2310 save path_right, path_right_in;
2311 path path_right, path_right_in;
2312 path_right := (z2 + ne * pen_radius)
2314 .. (z4 + se * pen_radius);
2316 path_right_in := (z2 - ne * pen_radius)
2318 .. (z4 - se * pen_radius);
2320 z5 = path_a intersectionpoint path_b;
2321 z6 = path_a intersectionpoint path_right_in;
2322 z7 = path_b intersectionpoint path_right_in;
2324 save p_up_in, p_down_in, p_up_out, p_down_out;
2325 path p_up_in, p_down_in, p_up_out, p_down_out;
2333 p_down_out := lft z1
2337 .. (z2 + ne * pen_radius){direction 0 of path_right}
2339 & {direction infinity of path_right}(z4 + se * pen_radius)
2345 p_up_in := p_down_in rotated 180 shifted (w, 0);
2346 p_up_out := p_down_out rotated 180 shifted (w, 0);
2350 save funk_ti_weight;
2351 funk_ti_weight := 1.6;
2353 fet_beginchar ("Whole up Funk tihead", "u0tiFunk");
2354 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2360 fet_beginchar ("Whole down Funk tihead", "d0tiFunk");
2361 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2367 fet_beginchar ("Half up Funk tihead", "u1tiFunk");
2368 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2374 fet_beginchar ("Half down Funk tihead", "d1tiFunk");
2375 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2381 fet_beginchar ("Quarter up Funk tihead", "u2tiFunk");
2382 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2387 fet_beginchar ("Quarter down Funk tihead", "d2tiFunk");
2388 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2393 %%%%%% Walker shape note heads
2395 % Walker heads are narrow like Funk heads, so use funk_notehead_width.
2398 %%%%%% Walker do head
2400 % Trapezoid, with largest side on stem side
2402 def draw_Walker_do_head (expr width_factor, dir, thickness_factor) =
2403 set_char_box (0, width_factor * solfa_base_notewidth#,
2404 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2406 pickup pencircle scaled solfa_pen_thick;
2409 offset := 2 * thickness_factor - 1;
2411 % adjust width so stem can be centered
2412 if .5w <> good.x .5w: change_width; fi
2416 scaling# = charwd / w;
2421 x1 = inset [x4, x3];
2424 x2 = inset [x3, x4];
2433 labels (range 1 thru 4);
2435 save left_dir, left_perp, right_dir, right_perp;
2436 pair left_dir, left_perp, right_dir, right_perp;
2438 left_dir = unitvector(z1 - z4);
2439 left_perp = (left_dir rotated 90) * solfa_pen_radius;
2440 right_dir = unitvector(z3 - z2);
2441 right_perp = (right_dir rotated 90) * solfa_pen_radius;
2443 save path_a, path_b, path_c, path_d;
2444 path path_a, path_b, path_c, path_d;
2446 path_a := (z4 - left_perp)
2447 -- (z1 - left_perp);
2448 path_b := (z1 - (0, offset*solfa_pen_radius))
2449 -- (z2 - (0, offset*solfa_pen_radius));
2450 path_c := (z2 - right_perp)
2451 -- (z3 - right_perp);
2452 path_d := (z3 + (0, offset*solfa_pen_radius))
2453 -- (z4 + (0, offset*solfa_pen_radius));
2458 p_in := (path_a intersectionpoint path_b)
2459 -- (path_b intersectionpoint path_c)
2460 -- (path_c intersectionpoint path_d)
2461 -- (path_d intersectionpoint path_a)
2464 p_out := top z1{right}
2466 .. z2 + right_perp {right_dir}
2467 -- z3 + right_perp {right_dir}
2470 .. z4 + left_perp {left_dir}
2471 .. z1 + left_perp {left_dir}
2474 charwx := scaling# * (w/2 + solfa_pen_radius);
2475 charwy := scaling# * y2 ;
2478 p_in := p_in rotated 180 shifted (w,0);
2479 p_out := p_out rotated 180 shifted (w,0);
2484 save walker_do_weight;
2485 walker_do_weight := 1.5;
2487 fet_beginchar ("Whole Walker dohead", "s0doWalker");
2488 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2494 fet_beginchar ("Half up Walker dohead", "u1doWalker");
2495 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2501 fet_beginchar ("Half down Walker dohead", "d1doWalker");
2502 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2508 fet_beginchar ("Quarter up Walker dohead", "u2doWalker");
2509 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2514 fet_beginchar ("Quarter down Walker dohead", "d2doWalker");
2515 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2520 %%%%%% Walker re head
2521 % Parabolic on one side, shallow parabola on other
2522 % Has up and down shapes for *all* notes
2524 def draw_Walker_re_head (expr width_factor, thickness_factor) =
2525 set_char_box (0, width_factor * solfa_base_notewidth#,
2526 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2529 offset := 2 * thickness_factor - 1;
2532 pen_radius := min (solfa_pen_radius,
2533 .3 * (h + d) / (1 + offset));
2535 pickup pencircle scaled (2 * pen_radius);
2538 dish_factor := 0.20;
2549 x4 = dish_factor [x1, x2];
2553 y5 = y1 + offset * pen_radius;
2556 x6 = x2 + pen_radius;
2559 y7 = y3 - offset * pen_radius;
2562 x8 = x4 - pen_radius;
2564 save path_a, path_d;
2565 path path_a, path_d;
2567 save p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2568 pair p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2570 path_a := z3 .. z4{down} .. z1;
2572 p_a_start_dir := unitvector(direction 0 of path_a);
2573 p_a_end_dir := unitvector(direction infinity of path_a);
2574 p_a_start_perp := (p_a_start_dir rotated 90) * pen_radius;
2575 p_a_end_perp := (p_a_end_dir rotated 90) * pen_radius;
2577 path_d := (z3 - p_a_start_perp){p_a_start_dir}
2579 ..(z1 - p_a_end_perp){p_a_end_dir};
2581 save path_b, path_c;
2582 path path_b, path_c;
2584 path_b := z5 {left} .. z6{up};
2585 path_c := z7 {left} .. z6{down};
2587 z9 = path_d intersectionpoint path_b;
2588 z10 = path_d intersectionpoint path_c;
2590 labels (range 1 thru 4);
2592 save p_up_in, p_up_out, p_down_in, p_down_out;
2593 path p_up_in, p_up_out, p_down_in, p_down_out;
2596 ... {right} z10 {p_a_start_dir}
2598 .. {p_a_end_dir} z9 {left}
2601 p_down_out := lft z2{up}
2604 .. (z3 + p_a_start_perp){p_a_start_dir}
2606 .. (z1 + p_a_end_perp) {p_a_end_dir}
2611 p_up_in := p_down_in rotated 180 shifted (w,0);
2612 p_up_out := p_down_out rotated 180 shifted (w,0);
2616 save walker_re_weight;
2617 walker_re_weight := 1.2;
2619 fet_beginchar ("Whole Walker rehead", "s0reWalker");
2620 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2626 fet_beginchar ("Half up Walker rehead", "u1reWalker");
2627 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2633 fet_beginchar ("Half down Walker rehead", "d1reWalker");
2634 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2640 fet_beginchar ("Quarter up Walker rehead", "u2reWalker");
2641 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2646 fet_beginchar ("Quarter down Walker rehead", "d2reWalker");
2647 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2652 %%%%%% Walker mi head
2654 % Symmetric for all hollow notes
2656 save walker_mi_width, walker_mi_weight;
2657 walker_mi_width := 1.2;
2658 walker_mi_weight := 1.5;
2660 fet_beginchar ("Whole Walker mihead", "s0miWalker");
2661 draw_mi_head (walker_mi_width * funk_notehead_width,
2662 walker_mi_weight, true);
2668 fet_beginchar ("Half Walker mihead", "s1miWalker");
2669 draw_mi_head (walker_mi_width * funk_notehead_width,
2670 walker_mi_weight, true);
2676 fet_beginchar ("Quarter Walker mihead", "s2miWalker");
2677 draw_mi_head (walker_mi_width * funk_notehead_width,
2678 walker_mi_weight, true);
2685 % Does not rotate for whole notes
2686 % Whole rotation is different from Funk, so special notes
2688 %%%%%% Funk sol head is the same as the others
2689 % Need special character because of skinnier head
2691 save walker_fa_weight;
2692 walker_fa_weight := 1.5;
2694 fet_beginchar ("Whole Walker fahead", "s0faWalker");
2695 draw_fa_head (funk_notehead_width, walker_fa_weight);
2701 fet_beginchar ("Half up Walker fahead", "u1faWalker");
2702 draw_fa_head (funk_notehead_width, walker_fa_weight);
2708 fet_beginchar ("Half down Walker fahead", "d1faWalker");
2709 draw_fa_head (funk_notehead_width, walker_fa_weight);
2715 fet_beginchar ("Quarter up Walker fahead", "u2faWalker");
2716 draw_fa_head (funk_notehead_width, walker_fa_weight);
2721 fet_beginchar ("Quarter down Walker fahead", "d2faWalker");
2722 draw_fa_head (funk_notehead_width, walker_fa_weight);
2728 % Same as Funk, no special notes
2731 %%%%%% Walker la head
2733 % Lighter weight requires separate notes
2735 save walker_la_weight;
2736 walker_la_weight := 1.5;
2738 fet_beginchar ("Whole Walker lahead", "s0laWalker");
2739 draw_la_head (funk_notehead_width, walker_la_weight);
2745 fet_beginchar ("Half Funk lahead", "s1laWalker");
2746 draw_la_head (funk_notehead_width, walker_la_weight);
2752 fet_beginchar ("Quarter Funk lahead", "s2laWalker");
2753 draw_la_head (funk_notehead_width, walker_la_weight);
2758 %%%%%% Walker ti head
2759 % Triangular arrowhead
2760 % Rotates for all but whole notes
2762 def draw_Walker_ti_head (expr width_factor, thickness_factor) =
2763 set_char_box (0, width_factor * solfa_base_notewidth#,
2764 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2767 offset := 2 * thickness_factor - 1;
2770 pen_radius := min (solfa_pen_radius,
2771 .3 * (h + d) / (1 + offset));
2773 pickup pencircle scaled (2 * pen_radius);
2785 labels (range 1 thru 4);
2787 save nw_dist, sw_dist, ne, se;
2788 pair nw_dist, sw_dist, ne, se;
2790 ne = unitvector (z2 - z1);
2791 se = unitvector (z3 - z1);
2793 nw_dist = (ne rotated 90) * pen_radius ;
2794 sw_dist = (se rotated -90) * pen_radius;
2797 save path_a, path_b, path_c;
2798 path path_a, path_b, path_c;
2799 path_a := z2 - nw_dist * offset
2800 -- z1 - nw_dist * offset;
2801 path_b := z3 - sw_dist * offset
2802 -- z1 - sw_dist * offset;
2803 path_c := z2 + left * pen_radius
2804 -- z3 + left * pen_radius;
2806 z4 = path_a intersectionpoint path_b;
2807 z5 = path_a intersectionpoint path_c;
2808 z6 = path_b intersectionpoint path_c;
2810 save p_up_in, p_down_in, p_up_out, p_down_out;
2811 path p_up_in, p_down_in, p_up_out, p_down_out;
2818 p_down_out := lft z1{up}
2819 .. (z1 + nw_dist){ne}
2820 -- (z2 + nw_dist){ne}
2825 .. (z3 + sw_dist){- se}
2826 .. (z1 + sw_dist){- se}
2829 p_up_in := p_down_in rotated 180 shifted (w, 0);
2830 p_up_out := p_down_out rotated 180 shifted (w, 0);
2834 save walker_ti_weight;
2835 walker_ti_weight := 1.4;
2837 fet_beginchar ("Whole Walker tihead", "s0tiWalker");
2838 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2844 fet_beginchar ("Half up Walker tihead", "u1tiWalker");
2845 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2851 fet_beginchar ("Half down Walker tihead", "d1tiWalker");
2852 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2858 fet_beginchar ("Quarter up Walker tihead", "u2tiWalker");
2859 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2864 fet_beginchar ("Quarter down Walker tihead", "d2tiWalker");
2865 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2869 fet_endgroup ("noteheads");
2873 % we derive black_notehead_width# from the quarter head,
2874 % so we have to define black_notehead_width (pixel qty)
2875 % after the black_notehead_width# itself.
2877 % Let's keep it outside the group as well.
2880 define_pixels (black_notehead_width);