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, gap;
163 stemthick# = line_thickness_multiplier * 2 * stafflinethickness#;
164 define_whole_blacker_pixels (stemthick);
166 % double-lined breves of smaller design sizes should have
167 % bigger gap between the lines.
168 gap# := (0.95 - 0.008 * design_size) * stemthick#;
170 % Breves of smaller design sizes should have their lines farther
171 % apart (the overlap with notehead ellipsoid should be smaller).
172 fudge = hround (blot_diameter
175 - (20 / (design_size + 4))
179 draw_outside_ellipse (1.80, 0, 0.707, 0);
180 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
182 set_char_box (stemthick# * linecount + gap# * (linecount - 1),
183 width# + stemthick# * linecount + gap# * (linecount - 1),
188 pickup pencircle scaled stemthick;
190 % Breves of smaller design sizes should have their lines longer.
191 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
193 % Line lengths between 0.72 and 0.77 are not nice
194 % because they are neither separate nor connected
195 % when there is an interval of fourth.
196 if line_length < 0.75:
197 quanted_line_length := min (0.72, line_length);
199 quanted_line_length := max (0.77, line_length);
202 bot y1 = -quanted_line_length * staff_space;
203 top y2 = quanted_line_length * staff_space;
207 fudge + lft x3 = width;
212 for i := 0 step 1 until linecount - 1:
213 line_distance := i * (gap + stemthick);
214 draw_gridline (z1 - (line_distance, 0),
215 z2 - (line_distance, 0),
217 draw_gridline (z3 + (line_distance, 0),
218 z4 + (line_distance, 0),
224 fet_beginchar ("Brevis notehead", "sM1");
227 draw_staff (-2, 2, 0);
232 fet_beginchar ("Brevis notehead", "sM1");
235 draw_staff (-2, 2, 0.5);
240 fet_beginchar ("Double-lined brevis notehead", "sM1double");
241 draw_brevis (2, 0.8);
243 draw_staff (-2, 2, 0);
248 fet_beginchar ("Double-lined brevis notehead", "sM1double");
249 draw_brevis (2, 0.8);
251 draw_staff (-2, 2, 0.5);
256 fet_beginchar ("Whole notehead", "s0");
257 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
258 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
259 0.68, 2 stafflinethickness#);
261 whole_notehead_width# := charwd;
263 draw_staff (-2, 2, 0);
268 fet_beginchar ("Whole notehead", "s0");
269 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
271 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
272 0.68, 2 stafflinethickness#);
274 draw_staff (-2, 2, 0.5);
279 fet_beginchar ("Half notehead", "s1");
280 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
281 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
283 half_notehead_width# := charwd;
285 draw_staff (-2, 2, 0);
290 fet_beginchar ("Half notehead", "s1");
291 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
293 undraw_inside_ellipse (3.25, 33, 0.81,
294 2.5 stafflinethickness#);
296 draw_staff (-2, 2, 0.5);
301 fet_beginchar ("Quarter notehead", "s2");
303 draw_staff (-2, 2, 0);
308 fet_beginchar ("Quarter notehead", "s2");
309 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
312 draw_staff (-2, 2, 0.5);
317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 fet_beginchar ("Whole diamondhead", "s0diamond");
321 draw_outside_ellipse (1.80, 0, 0.495, 0);
322 undraw_inside_ellipse (1.30, 125, 0.6,
323 .4 staff_space# + stafflinethickness#);
325 draw_staff (-2, 2, 0);
330 fet_beginchar ("Whole diamondhead", "s0diamond");
331 draw_outside_ellipse (1.80, 0, 0.495, 0);
332 undraw_inside_ellipse (1.30, 125, 0.6,
333 .4 staff_space# + stafflinethickness#);
335 draw_staff (-2, 2, 0.5);
340 fet_beginchar ("Half diamondhead", "s1diamond");
341 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
342 undraw_inside_ellipse (3.5, 33, 0.80,
343 .3 staff_space# + 1.5 stafflinethickness#);
345 draw_staff (-2, 2, 0);
350 fet_beginchar ("Half diamondhead", "s1diamond");
351 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
352 undraw_inside_ellipse (3.5, 33, 0.80,
354 + 1.5 stafflinethickness#);
356 draw_staff (-2, 2, 0.5);
361 fet_beginchar ("Quarter diamondhead", "s2diamond");
362 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
364 draw_staff (-2, 2, 0);
369 fet_beginchar ("Quarter diamondhead", "s2diamond");
370 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
372 draw_staff (-2, 2, 0.5);
377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380 vardef penposx@# (expr d) =
390 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
391 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
397 % UGH: xs not declared as argument.
399 def define_triangle_shape (expr stemdir) =
400 save triangle_a, triangle_b, triangle_c;
401 save triangle_out_a, triangle_out_b, triangle_out_c;
402 save triangle_in, triangle_out;
403 save width, depth, height;
404 save origin, left_up_dir;
405 save exact_left_point, exact_right_point, exact_down_point;
407 path triangle_a, triangle_b, triangle_c;
408 path triangle_out_a, triangle_out_b, triangle_out_c;
409 path triangle_in, triangle_out;
410 pair origin, left_up_dir;
411 pair exact_down_point, exact_left_point, exact_right_point;
414 pen_thick# = stafflinethickness# + .1 staff_space#;
415 define_pixels (llap);
416 define_blacker_pixels (pen_thick);
418 left_up_dir = llap# * dir (90 + tilt);
420 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
423 exact_left_point := origin + (left_up_dir xscaled xs);
424 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
425 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
427 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
428 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
429 width# = xpart (exact_right_point - exact_left_point)
432 set_char_box (0, width#, depth#, height#);
434 % Formerly, the shape has simply been drawn with an elliptical pen
435 % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
436 % is of 6th degree. For the sake of mf2pt1, we approximate it.
438 pickup pencircle scaled pen_thick xscaled xs;
440 z0 = (hround_pixels (xpart origin), 0);
442 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
443 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
444 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
446 z12 = caveness [.5[z1, z2], z3];
447 z23 = caveness [.5[z2, z3], z1];
448 z31 = caveness [.5[z3, z1], z2];
450 triangle_a = z1 .. z12 .. z2;
451 triangle_b = z2 .. z23 .. z3;
452 triangle_c = z3 .. z31 .. z1;
454 penposx1 (angle (direction 0 of triangle_a) - 90);
455 penposx2 (angle (direction 0 of triangle_b) - 90);
456 penposx3 (angle (direction 0 of triangle_c) - 90);
458 penposx1' (angle (direction infinity of triangle_c) + 90);
459 penposx2' (angle (direction infinity of triangle_a) + 90);
460 penposx3' (angle (direction infinity of triangle_b) + 90);
462 penposx12 (angle (z12 - z0));
463 penposx23 (angle (z23 - z0));
464 penposx31 (angle (z31 - z0));
466 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
467 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
468 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
481 triangle_out_a = z1r .. z12r .. z2'l;
482 triangle_out_b = z2r .. z23r .. z3'l;
483 triangle_out_c = z3r .. z31r .. z1'l;
485 triangle_out = top z1
487 .. z1r{direction 0 of triangle_out_a}
489 & {direction infinity of triangle_out_a}z2'l
492 .. z2r{direction 0 of triangle_out_b}
494 & {direction infinity of triangle_out_b}z3'l
497 .. z3r{direction 0 of triangle_out_c}
499 & {direction infinity of triangle_out_c}z1'l
502 labels (0, 10, 20, 30);
503 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
507 charwy := ypart exact_right_point;
508 charwx := xpart exact_right_point + .5 pen_thick# * xs;
510 charwy := -ypart exact_down_point;
511 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
516 def draw_whole_triangle_head =
522 llap# = 3/4 noteheight#;
526 define_triangle_shape (1);
532 fet_beginchar ("Whole trianglehead", "s0triangle");
533 draw_whole_triangle_head;
535 draw_staff (-2, 2, 0);
540 fet_beginchar ("Whole trianglehead", "s0triangle");
541 draw_whole_triangle_head;
543 draw_staff (-2, 2, 0.5);
548 def draw_small_triangle_head (expr dir) =
554 llap# = 2/3 noteheight#;
557 define_triangle_shape (dir);
561 filldraw triangle_out;
562 unfilldraw triangle_in;
566 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
567 draw_small_triangle_head (-1);
569 draw_staff (-2, 2, 0);
573 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
574 draw_small_triangle_head (1);
576 draw_staff (-2, 2, 0.5);
580 def draw_closed_triangle_head (expr dir) =
586 llap# = 2/3 noteheight#;
589 define_triangle_shape (dir);
594 fet_beginchar ("Quarter trianglehead (upstem)", "u2triangle");
595 draw_closed_triangle_head (1);
597 draw_staff (-2, 2, 0);
601 fet_beginchar ("Quarter trianglehead (downstem)", "d2triangle");
602 draw_closed_triangle_head (-1);
604 draw_staff (-2, 2, 0.5);
608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610 % Slash heads are for indicating improvisation. They are
611 % twice as high as normal heads.
613 def draw_slash (expr hwid_hash) =
617 exact_height = staff_space# + stafflinethickness# / 2;
619 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
620 exact_height, exact_height);
629 pickup pencircle scaled blot_diameter;
634 lft x2 = 2 h / slash_slope;
641 ne = unitvector (z3 - z4);
642 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
645 .. (z1 + nw_dist){ne}
646 -- (z2 + nw_dist){ne}
649 .. (z3 - nw_dist){-ne}
650 -- (z4 - nw_dist){-ne}
654 if hwid_hash > 2 slash_thick#:
657 th = slash_thick - blot_diameter;
662 z6 - z5 = whatever * ne;
663 z8 - z7 = whatever * ne;
665 z5 = z1 + whatever * ne + th * (ne rotated -90);
666 z8 = z4 + whatever * ne + th * (ne rotated 90);
674 labels (range 1 thru 10);
678 fet_beginchar ("Whole slashhead", "s0slash");
679 draw_slash (4 slash_thick# + 0.5 staff_space#);
681 draw_staff (-2, 2, 0);
685 fet_beginchar ("Half slashhead", "s1slash");
686 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
688 draw_staff (-2, 2, 0);
692 fet_beginchar ("Quarter slashhead", "s2slash");
693 draw_slash (1.5 slash_thick#);
695 draw_staff (-2, 2, 0);
699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701 % `thick' is the distance between the NE/SW parallel lines in the cross
702 % (distance between centres of lines) in multiples of stafflinethickness
704 def draw_cross (expr thick) =
706 save ne_dist, nw_dist, rt_dist, up_dist;
707 save crz_in, crz_out;
710 pair ne_dist, nw_dist, rt_dist, up_dist;
711 path crz_in, crz_out;
713 pen_thick# := 1.2 stafflinethickness#;
714 thickness# := thick * stafflinethickness#;
715 define_pixels (thickness);
716 define_blacker_pixels (pen_thick);
718 pickup pencircle scaled pen_thick;
723 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
726 z4 - z5 = whatever * ne;
728 z6 - z3 = whatever * ne;
729 z3 - z4 = whatever * (ne yscaled -1);
731 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
734 x1 = charwd / 2 - .5 pen_thick#;
736 + thick / 2 * stafflinethickness# * (ne rotated -90);
738 % labels (1, 2, 3, 4, 5, 6);
740 nw = unitvector (z3 - z4);
742 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
743 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
744 nw_dist = (ne rotated 90) * 0.5 pen_thick;
745 ne_dist = (nw rotated -90) * 0.5 pen_thick;
751 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
752 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
753 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
755 crz_out = (z6 + up_dist)
756 -- (z3 + nw_dist){ne}
758 .. (z3 + ne_dist){-nw}
759 -- (z4 + ne_dist){-nw}
761 .. (z4 - nw_dist){-ne}
763 crz_out := crz_out shifted (0, feta_shift)
764 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
766 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
770 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
771 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
772 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
774 crz_in = (bot z6){right}
775 .. (z6 - nw_dist){ne}
778 -- (z5 + nw_dist){-ne}
780 crz_in := crz_in shifted (0, feta_shift)
781 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
783 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
788 currentpicture := currentpicture shifted (hround (w / 2), 0);
791 charwy := y1 + feta_shift;
793 z12 = (charwx * hppp, y1 * vppp);
799 fet_beginchar ("Whole Crossed notehead", "s0cross");
802 wid# := black_notehead_width# + 4 stafflinethickness#;
803 hei# := noteheight# + stafflinethickness#;
805 set_char_box (0, wid#, hei# / 2, hei# / 2);
809 remember_pic := currentpicture;
811 draw_staff (-2, 2, 0);
816 fet_beginchar ("Whole Crossed notehead", "s0cross");
819 wid# := black_notehead_width# + 4 stafflinethickness#;
820 hei# := noteheight# + stafflinethickness#;
822 set_char_box (0, wid#, hei# / 2, hei# / 2);
824 currentpicture := remember_pic;
826 draw_staff (-2, 2, 0.5);
831 fet_beginchar ("Half Crossed notehead", "s1cross");
834 wid# := black_notehead_width# + 2 stafflinethickness#;
835 hei# := noteheight# + stafflinethickness# / 2;
837 set_char_box (0, wid#, hei# / 2, hei# / 2);
841 remember_pic := currentpicture;
843 draw_staff (-2, 2, 0);
848 fet_beginchar ("Half Crossed notehead", "s1cross");
851 wid# := black_notehead_width# + 2 stafflinethickness#;
852 hei# := noteheight# + stafflinethickness# / 2;
854 set_char_box (0, wid#, hei# / 2, hei# / 2);
856 currentpicture := remember_pic;
858 draw_staff (-2, 2, 0.5);
863 fet_beginchar ("Crossed notehead", "s2cross");
864 wid# := black_notehead_width#;
866 set_char_box (0, wid#, hei# / 2, hei# / 2);
870 remember_pic := currentpicture;
872 draw_staff (-2, 2, 0);
877 fet_beginchar ("Crossed notehead", "s2cross");
878 wid# := black_notehead_width#;
880 set_char_box (0, wid#, hei# / 2, hei# / 2);
882 currentpicture := remember_pic;
884 draw_staff (-2, 2, 0.5);
889 fet_beginchar ("X-Circled notehead", "s2xcircle");
891 save cthick, cxd, cyd, dy;
893 wid# := black_notehead_width# * sqrt (sqrt2);
894 hei# := noteheight# * sqrt (sqrt2);
896 set_char_box (0, wid#, hei# / 2, hei# / 2);
898 d := d - feta_space_shift;
900 cthick# := (1.2 + 1/4) * stafflinethickness#;
901 define_blacker_pixels (cthick);
904 cyd := h + d - cthick / 2;
908 pickup pencircle scaled cthick;
910 fill fullcircle xscaled (cxd + cthick)
911 yscaled (cyd + cthick)
913 unfill fullcircle xscaled (cxd - cthick)
914 yscaled (cyd - cthick)
917 xpos := .5 cxd / sqrt2;
918 ypos := .5 cyd / sqrt2;
920 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
921 draw (-xpos + w / 2, -ypos + dy)
922 -- (xpos + w / 2, ypos + dy);
924 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
925 draw (-xpos + w / 2, ypos + dy)
926 -- (xpos + w / 2, -ypos + dy);
931 z12 = (charwx * hppp, charwy * vppp);
934 remember_pic := currentpicture;
936 draw_staff (-2, 2, 0);
941 fet_beginchar ("X-Circled notehead", "s2xcircle");
943 save cthick, cxr, cyr;
945 wid# := black_notehead_width# * sqrt (sqrt2);
946 hei# := noteheight# * sqrt (sqrt2);
948 set_char_box (0, wid#, hei# / 2, hei# / 2);
950 currentpicture := remember_pic;
952 draw_staff (-2, 2, 0.5);
962 % Note: For whole and half notes, the `fill' curve (p_out) is offset from
963 % the points that specify the outer geometry, because we need to add
964 % the rounding. In contrast, the inner curve is not offset, because
965 % there is no rounding.
967 % This means that to get a line of thick_factor * pen_thickness,
968 % we need to offset the inner curve by
970 % (thick_factor - 0.5) * pen_thickness
974 % (2 * thick_factor - 1) * half_pen_thickness
976 save solfa_pen_thick;
977 solfa_pen_thick# = 1.3 stafflinethickness#;
978 define_blacker_pixels (solfa_pen_thick);
980 save solfa_pen_radius;
981 solfa_pen_radius = 0.5 solfa_pen_thick;
983 save solfa_base_notewidth;
984 solfa_base_notewidth# := black_notehead_width#;
986 solfa_whole_width := 1.0;
987 solfa_half_width := 1.0;
988 solfa_quarter_width := 1.0;
993 % Triangle with base parallel to staff lines.
996 def draw_do_head (expr width_factor, dir, thickness_factor) =
998 save left_dist, right_dist, bottom_dist;
1000 pair left_dist, right_dist, bottom_dist;
1002 set_char_box (0, width_factor * solfa_base_notewidth#,
1003 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1005 bottom_thick_factor := 2 * thickness_factor - 1;
1006 % no different thickness for left side if we want uniform thickness
1007 if thickness_factor = 1:
1008 left_thick_factor := 1;
1010 left_thick_factor := 0.7 * bottom_thick_factor;
1014 pen_radius := min (solfa_pen_radius,
1015 (h + d) / (3 * (1 + bottom_thick_factor)));
1017 pickup pencircle scaled (2 * pen_radius);
1026 left_dist = (unitvector (z3 - z1) rotated 90) * pen_radius;
1027 right_dist = (unitvector (z2 - z3) rotated 90) * pen_radius;
1028 bottom_dist = (0,1) * pen_radius;
1032 save point_a, point_b, point_c;
1033 pair point_a, point_b, point_c;
1035 pa := (z1 - left_thick_factor * left_dist)
1036 -- (z3 - left_thick_factor * left_dist);
1037 pb := (z1 + bottom_thick_factor * bottom_dist)
1038 -- (z2 + bottom_thick_factor * bottom_dist);
1039 pc := (z2 - right_dist)
1040 -- (z3 - right_dist);
1042 point_a := pa intersectionpoint pb;
1043 point_b := pb intersectionpoint pc;
1044 point_c := pc intersectionpoint pa;
1054 .. (z2 + right_dist){z3 - z2}
1055 -- (z3 + right_dist){z3 - z2}
1057 .. (z3 + left_dist){z1 - z3}
1058 -- (z1 + left_dist){z1 - z3}
1065 charwy := -chardp + 0.5 stafflinethickness#;
1075 fet_beginchar ("Whole dohead", "s0do");
1076 draw_do_head (solfa_whole_width, 1, do_weight);
1082 fet_beginchar ("Half dohead", "d1do");
1083 draw_do_head (solfa_half_width, -1, do_weight);
1089 fet_beginchar ("Half dohead", "u1do");
1090 draw_do_head (solfa_half_width, 1, do_weight);
1096 fet_beginchar ("Quarter dohead", "d2do");
1097 draw_do_head (solfa_quarter_width, -1, do_weight);
1102 fet_beginchar ("Quarter dohead", "u2do");
1103 draw_do_head (solfa_quarter_width, 1, do_weight);
1108 fet_beginchar ("Whole thin dohead", "s0doThin");
1109 draw_do_head (solfa_whole_width, 1, 1);
1115 fet_beginchar ("Half thin dohead", "d1doThin");
1116 draw_do_head (solfa_half_width, -1, 1);
1122 fet_beginchar ("Half thin dohead", "u1doThin");
1123 draw_do_head (solfa_half_width, 1, 1);
1129 fet_beginchar ("Quarter thin dohead", "d2doThin");
1130 draw_do_head (solfa_quarter_width, -1, 1);
1135 fet_beginchar ("Quarter thin dohead", "u2doThin");
1136 draw_do_head (solfa_quarter_width, 1, 1);
1142 % re - flat top, curved bottom:
1146 % .. {dir 90} (w,h/2)
1149 % (broader along the base and with more vertical sides for half and
1152 % Note: According to some shape-note singers, there should be no size
1153 % differences for half and whole notes, contrary to the comment above.
1154 % Consequently, we have made them all the same width.
1156 % stem attachment: h/2
1158 def draw_re_head (expr width_factor, dir, thickness_factor) =
1162 set_char_box (0, width_factor * solfa_base_notewidth#,
1163 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1166 offset = (2 * thickness_factor - 1);
1173 pen_radius := min (solfa_pen_radius,
1174 (h + d) * (1-curve_start) / (1+ offset));
1176 pickup pencircle scaled (2 * pen_radius);
1181 y2 = curve_start [y3, y1];
1189 labels (range 1 thru 5);
1191 p_in := (z1 + pen_radius * (1, -1 * offset))
1193 .. ((top z3) + (0, offset * pen_radius))
1195 -- (z5 + pen_radius * (-1, -1 * offset))
1208 charwy := curve_start [-chardp, charht];
1219 fet_beginchar ("Whole rehead", "s0re");
1220 draw_re_head (solfa_whole_width, 1, re_weight);
1226 fet_beginchar ("Half up rehead", "u1re");
1227 draw_re_head (solfa_half_width, 1, re_weight);
1233 fet_beginchar ("Half down rehead", "d1re");
1234 draw_re_head (solfa_half_width, -1, re_weight);
1240 fet_beginchar ("Quarter up rehead", "u2re");
1241 draw_re_head (solfa_quarter_width, 1, re_weight);
1246 fet_beginchar ("Quarter down rehead", "d2re");
1247 draw_re_head (solfa_quarter_width, -1, re_weight);
1252 fet_beginchar ("Whole thin rehead", "s0reThin");
1253 draw_re_head (solfa_whole_width, 1, 1);
1259 fet_beginchar ("Half up thin rehead", "u1reThin");
1260 draw_re_head (solfa_half_width, 1, 1);
1266 fet_beginchar ("Half down thin rehead", "d1reThin");
1267 draw_re_head (solfa_half_width, -1, 1);
1273 fet_beginchar ("Quarter thin rehead", "u2reThin");
1274 draw_re_head (solfa_quarter_width, 1, 1);
1279 fet_beginchar ("Quarter thin rehead", "d2reThin");
1280 draw_re_head (solfa_quarter_width, -1, 1);
1285 %%%% mi head -- diamond shape
1287 % two versions, depending on whether the `strong' lines are on the nw & se
1290 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1291 save path_out, path_in;
1292 save ne_dist, se_dist, ne, se;
1293 save path_a, path_b, path_c, path_d;
1294 path path_out, path_in;
1295 pair ne_dist, se_dist, ne, se;
1296 path path_a, path_b, path_c, path_d;
1300 set_char_box (0, width_factor * solfa_base_notewidth#,
1301 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1304 offset := 2 * thickness_factor - 1;
1308 note_diagonal := w / 2 ++ (h + d) / 2;
1312 pen_radius := min (solfa_pen_radius,
1313 .3 * note_diagonal / (1 + offset));
1315 pickup pencircle scaled (2 * pen_radius);
1326 % inner sides are parallel to outer sides
1327 z6 - z5 = whatever * (z2 - z1);
1328 z8 - z7 = whatever * (z4 - z3);
1329 z8 - z5 = whatever * (z4 - z1);
1330 z7 - z6 = whatever * (z3 - z2);
1332 ne = unitvector (z4 - z1);
1333 se = unitvector (z2 - z1);
1335 ne_dist = (ne rotated 90) * pen_radius;
1336 se_dist = (se rotated 90) * pen_radius;
1338 path_a := (z1 + se_dist)
1340 path_b := (z2 + (ne_dist * offset))
1341 -- (z3 + (ne_dist * offset));
1342 path_c := (z3 - se_dist)
1344 path_d := (z4 - (ne_dist * offset))
1345 -- (z1 - (ne_dist * offset));
1347 z5 = path_a intersectionpoint path_d;
1348 z7 = path_b intersectionpoint path_c;
1350 labels (range 1 thru 8);
1359 path_in := inner_path;
1361 path_in := inner_path reflectedabout (z2, z4);
1364 path_out := lft z1 {down}
1365 .. (z1 - se_dist){se}
1366 -- (z2 - se_dist){se}
1368 .. (z2 - ne_dist){ne}
1369 -- (z3 - ne_dist){ne}
1371 .. (z3 + se_dist){-se}
1372 -- (z4 + se_dist){-se}
1374 .. (z4 + ne_dist){-ne}
1375 -- (z1 + ne_dist){-ne}
1380 save mi_weight, mi_width;
1384 fet_beginchar ("Whole mihead", "s0mi");
1385 draw_mi_head (mi_width * solfa_whole_width, mi_weight, false);
1391 fet_beginchar ("Half mihead", "s1mi");
1392 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1398 fet_beginchar ("Quarter mihead", "s2mi");
1399 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1404 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1405 draw_mi_head (mi_width * solfa_whole_width, mi_weight, true);
1411 fet_beginchar ("Half mirror mihead", "s1miMirror");
1412 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1418 fet_beginchar ("Quarter mirror mihead", "s2miMirror");
1419 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1424 fet_beginchar ("Whole thin mihead", "s0miThin");
1425 draw_mi_head (mi_width * solfa_whole_width, 1, false);
1431 fet_beginchar ("Half thin mihead", "s1miThin");
1432 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1438 fet_beginchar ("Quarter thin mihead", "s2miThin");
1439 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1446 % Right triangle, hypotenuse from nw to se corner. Stem attaches on
1447 % vertical side in direction of horizontal side.
1449 def draw_fa_head (expr width_factor, thickness_factor) =
1450 set_char_box (0, width_factor * solfa_base_notewidth#,
1451 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1453 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1454 path p_down_in, p_down_out, p_up_in, p_up_out;
1455 save path_a, path_b, path_c;
1456 path path_a, path_b, path_c;
1460 offset := 2 * thickness_factor - 1;
1463 pen_radius := min (solfa_pen_radius,
1464 .33 * (h + d) / (1 + offset));
1466 pickup pencircle scaled (2 * pen_radius);
1479 labels (1, 2, 3, 4);
1481 nw = unitvector (z1 - z3);
1482 nw_dist = (nw rotated 90) * pen_radius;
1484 path_a := (z1 - (0,1) * offset * pen_radius)
1485 -- (z2 - (0,1) * offset * pen_radius);
1486 path_b := (z2 - (1,0) * pen_radius)
1487 -- (z3 - (1,0) * pen_radius);
1488 path_c := (z3 - nw_dist)
1491 p_up_in := (path_a intersectionpoint path_b)
1492 -- (path_b intersectionpoint path_c)
1493 -- (path_c intersectionpoint path_a)
1496 p_up_out := lft z1{down}
1497 .. (z1 + nw_dist){-nw}
1498 -- (z3 + nw_dist){-nw}
1506 p_down_in := p_up_in rotated 180 shifted (w, 0);
1507 p_down_out := p_up_out rotated 180 shifted (w, 0);
1516 fet_beginchar ("Whole fa up head", "u0fa");
1517 draw_fa_head (solfa_whole_width, fa_weight);
1523 fet_beginchar ("Whole fa down head", "d0fa");
1524 draw_fa_head (solfa_whole_width, fa_weight);
1530 fet_beginchar ("half fa up head", "u1fa");
1531 draw_fa_head (solfa_half_width, fa_weight);
1537 fet_beginchar ("Half fa down head", "d1fa");
1538 draw_fa_head (solfa_half_width, fa_weight);
1544 fet_beginchar ("Quarter fa up head", "u2fa");
1545 draw_fa_head (solfa_quarter_width, fa_weight);
1550 fet_beginchar ("Quarter fa down head", "d2fa");
1551 draw_fa_head (solfa_quarter_width, fa_weight);
1556 fet_beginchar ("Whole thin fa up head", "u0faThin");
1557 draw_fa_head (solfa_whole_width, 1);
1563 fet_beginchar ("Whole thin fa down head", "d0faThin");
1564 draw_fa_head (solfa_whole_width, 1);
1570 fet_beginchar ("half thin fa up head", "u1faThin");
1571 draw_fa_head (solfa_half_width, 1);
1577 fet_beginchar ("Half thin fa down head", "d1faThin");
1578 draw_fa_head (solfa_half_width, 1);
1584 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1585 draw_fa_head (solfa_quarter_width, 1);
1590 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1591 draw_fa_head (solfa_quarter_width, 1);
1599 % Note: sol head is the same shape as a standard music head, and doesn't
1600 % vary from style to style. However, width is constant with duration,
1601 % so we can't just use the standard note font.
1603 def draw_sol_head (expr filled) =
1604 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1606 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1608 draw_staff (-2, 2, 0);
1611 fet_beginchar ("Whole solhead", "s0sol");
1612 draw_sol_head ( false);
1616 fet_beginchar ("Half solhead", "s1sol");
1617 draw_sol_head ( false);
1621 fet_beginchar ("Quarter solhead", "s2sol");
1622 draw_sol_head ( true);
1630 def draw_la_head (expr width_factor, thickness_factor) =
1631 set_char_box (0, width_factor * solfa_base_notewidth#,
1632 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1637 offset := 2 * thickness_factor - 1;
1640 pen_radius := min (solfa_pen_radius,
1641 .35 * (h + d) / (1 + offset));
1643 pickup pencircle scaled (2 * pen_radius);
1656 labels (range 1 thru 4);
1658 p_in := (z1 + pen_radius * (1, -offset))
1659 -- (z2 + pen_radius * (-1, -offset))
1660 -- (z3 + pen_radius * (-1, offset))
1661 -- (z4 + pen_radius * (1, offset))
1679 fet_beginchar ("Whole lahead", "s0la");
1680 draw_la_head (solfa_whole_width, la_weight);
1686 fet_beginchar ("Half lahead", "s1la");
1687 draw_la_head (solfa_half_width, la_weight);
1693 fet_beginchar ("Quarter lahead", "s2la");
1694 draw_la_head (solfa_quarter_width, la_weight);
1699 fet_beginchar ("Whole thin lahead", "s0laThin");
1700 draw_la_head (solfa_whole_width, 1);
1706 fet_beginchar ("Half thin lahead", "s1laThin");
1707 draw_la_head (solfa_half_width, 1);
1713 fet_beginchar ("Quarter lahead", "s2laThin");
1714 draw_la_head (solfa_quarter_width, 1);
1721 % `Snow-cone', V with rounded top.
1723 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1724 set_char_box (0, width_factor * solfa_base_notewidth#,
1725 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1726 save p_in, p_out, p_top, p_top_in;
1727 path p_in, p_out, p_top, p_top_in;
1732 offset := 2 * thickness_factor - 1;
1735 pen_radius := min (solfa_pen_radius,
1736 .4 * (h + d) / (1 + offset));
1738 pickup pencircle scaled (2 * pen_radius);
1743 y2 = cone_height [y1, y3];
1749 y5 = y1 + offset * pen_radius;
1751 labels (range 1 thru 4);
1753 save nw_dist, sw_dist, nw, sw;
1754 pair nw_dist, sw_dist, nw, sw;
1756 nw = unitvector (z2 - z1);
1757 sw = unitvector (z1 - z4);
1759 nw_dist = (nw rotated 90) * pen_radius;
1760 sw_dist = (sw rotated 90) * pen_radius;
1762 p_top := (z2 + nw * pen_radius)
1764 .. (z4 - sw * pen_radius);
1766 p_top_in := (z2 - nw * offset * pen_radius)
1767 .. (z3 - (0,1) * pen_radius) {right}
1768 .. (z4 + sw * offset * pen_radius);
1770 save path_a, path_b;
1771 path path_a, path_b;
1777 z6 = path_a intersectionpoint p_top_in;
1778 z7 = path_b intersectionpoint p_top_in;
1790 .. (z2 + nw * pen_radius){direction 0 of p_top}
1792 & {direction infinity of p_top}(z4 - sw * pen_radius)
1799 charwy := cone_height [-chardp, charht];
1809 fet_beginchar ("Whole up tihead", "s0ti");
1810 draw_ti_head (solfa_whole_width, 1, ti_weight);
1816 fet_beginchar ("Half up tihead", "u1ti");
1817 draw_ti_head (solfa_half_width, 1, ti_weight);
1823 fet_beginchar ("Half down tihead", "d1ti");
1824 draw_ti_head (solfa_half_width, -1, ti_weight);
1830 fet_beginchar ("Quarter up tihead", "u2ti");
1831 draw_ti_head (solfa_quarter_width, 1, ti_weight);
1836 fet_beginchar ("Quarter down tihead", "d2ti");
1837 draw_ti_head (solfa_quarter_width, -1, ti_weight);
1842 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1843 draw_ti_head (solfa_whole_width, 1, 1);
1849 fet_beginchar ("Half thin up tihead", "u1tiThin");
1850 draw_ti_head (solfa_half_width, 1, 1);
1856 fet_beginchar ("Half thin down tihead", "d1tiThin");
1857 draw_ti_head (solfa_half_width, -1, 1);
1863 fet_beginchar ("Quarter thin up tihead", "u2tiThin");
1864 draw_ti_head (solfa_quarter_width, 1, 1);
1869 fet_beginchar ("Quarter thin down tihead", "d2tiThin");
1870 draw_ti_head (solfa_quarter_width, -1, 1);
1875 %%%%%% Funk shape note heads
1877 % Funk heads are narrower than Aiken and Sacred Harp, so we need a new
1880 funk_notehead_width := 0.75;
1884 % Parabolic on one side, vertical line on other
1885 % Has up and down shapes for *all* notes
1887 def draw_Funk_do_head (expr width_factor, thickness_factor) =
1888 set_char_box (0, width_factor * solfa_base_notewidth#,
1889 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1892 offset := 2 * thickness_factor - 1;
1895 pen_radius := min (solfa_pen_radius,
1896 .3 * (h + d) / (1 + offset));
1898 pickup pencircle scaled (2 * pen_radius);
1909 x4 = x1 - pen_radius;
1910 y4 = y1 + offset * pen_radius;
1913 x5 = x2 + pen_radius;
1916 y6 = y3 - offset * pen_radius;
1918 save p_up_in, p_up_out, p_down_in, p_down_out;
1919 path p_up_in, p_up_out, p_down_in, p_down_out;
1921 p_down_in := z4{left}
1926 p_down_out := bot z1{left}
1933 p_up_in := p_down_in rotated 180 shifted (w,0);
1934 p_up_out := p_down_out rotated 180 shifted (w,0);
1939 save funk_do_weight;
1940 funk_do_weight := 1.7;
1942 fet_beginchar ("Whole up Funk dohead", "u0doFunk");
1943 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1949 fet_beginchar ("Whole down Funk dohead", "d0doFunk");
1950 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1956 fet_beginchar ("Half up Funk dohead", "u1doFunk");
1957 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1963 fet_beginchar ("Half down Funk dohead", "d1doFunk");
1964 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1970 fet_beginchar ("Quarter up Funk dohead", "u2doFunk");
1971 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1976 fet_beginchar ("Quarter down Funk dohead", "d2doFunk");
1977 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1984 % Has up and down shapes for *all* notes
1986 def draw_Funk_re_head (expr width_factor, thickness_factor) =
1987 set_char_box (0, width_factor * solfa_base_notewidth#,
1988 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1991 offset := 2 * thickness_factor - 1;
1994 pen_radius := min (solfa_pen_radius,
1995 .3 * (h + d) / (1 + offset));
1997 pickup pencircle scaled (2 * pen_radius);
2008 x3 := curve_in [x1, x2];
2016 save ne, se, ne_perp, se_perp;
2017 pair ne, se, ne_perp, se_perp;
2019 ne := unitvector (z2 - z1);
2020 se := unitvector (z4 - z1);
2021 ne_perp := ne rotated 90;
2022 se_perp := se rotated 90;
2024 save path_a, path_b, path_c, path_d;
2025 path path_a, path_b, path_c, path_d;
2026 save arrow_a_perp, arrow_b_perp;
2027 pair arrow_a_perp, arrow_b_perp;
2030 path_d := z2 .. z3{down} .. z4;
2031 arrow_a_perp = unitvector (direction 0 of path_d rotated 90)
2033 arrow_b_perp = unitvector (direction 2 of path_d rotated 90)
2036 path_b := (z1 + se_perp * pen_radius)
2037 -- z4 + se_perp * offset * pen_radius;
2038 path_a := (z1 - ne_perp * pen_radius)
2039 -- z2 - ne_perp * offset * pen_radius;
2040 path_c := z2 - arrow_a_perp
2042 .. z4 - arrow_b_perp;
2044 z5 = path_a intersectionpoint path_b;
2045 z7 = path_a intersectionpoint path_c;
2046 z8 = path_b intersectionpoint path_c;
2048 save p_up_in, p_down_in, p_up_out, p_down_out;
2049 path p_up_in, p_down_in, p_up_out, p_down_out;
2057 p_down_out := lft z1{up}
2058 .. (z1 + ne_perp * pen_radius){ne}
2059 -- (z2 + ne_perp * pen_radius){ne}
2062 .. (z2 + arrow_a_perp)
2064 .. (z4 + arrow_b_perp)
2067 .. z4 - se_perp * pen_radius
2068 -- z1 - se_perp * pen_radius
2071 p_up_in := p_down_in rotated 180 shifted (w, 0);
2072 p_up_out := p_down_out rotated 180 shifted (w, 0);
2077 save funk_re_weight;
2078 funk_re_weight = 1.7;
2080 fet_beginchar ("Whole up Funk rehead", "u0reFunk");
2081 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2087 fet_beginchar ("Whole down Funk rehead", "d0reFunk");
2088 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2094 fet_beginchar ("Half up Funk rehead", "u1reFunk");
2095 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2101 fet_beginchar ("Half down Funk rehead", "d1reFunk");
2102 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2108 fet_beginchar ("Quarter up Funk rehead", "u2reFunk");
2109 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2114 fet_beginchar ("Quarter down Funk rehead", "d2reFunk");
2115 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2122 % Has up and down shapes for all hollow notes
2124 save funk_mi_width, funk_mi_weight;
2125 funk_mi_width := 1.2;
2126 funk_mi_weight := 1.9;
2128 fet_beginchar ("Whole up Funk mihead", "u0miFunk");
2129 draw_mi_head (funk_mi_width * funk_notehead_width,
2130 funk_mi_weight, false);
2136 fet_beginchar ("Whole down Funk mihead", "d0miFunk");
2137 draw_mi_head (funk_mi_width * funk_notehead_width,
2138 funk_mi_weight, true);
2144 fet_beginchar ("Half up Funk mihead", "u1miFunk");
2145 draw_mi_head (funk_mi_width * funk_notehead_width,
2146 funk_mi_weight, false);
2152 fet_beginchar ("Half down Funk mihead", "d1miFunk");
2153 draw_mi_head (funk_mi_width * funk_notehead_width,
2154 funk_mi_weight, true);
2160 fet_beginchar ("Quarter Funk mihead", "s2miFunk");
2161 draw_mi_head (funk_mi_width * funk_notehead_width,
2162 funk_mi_weight, false);
2169 % Does it rotate for whole notes?
2170 % Same as other shape note systems
2171 % Need special notes because of special width
2173 save funk_fa_weight;
2174 funk_fa_weight := 1.9;
2176 fet_beginchar ("Whole up Funk fahead", "u0faFunk");
2177 draw_fa_head (funk_notehead_width, funk_fa_weight);
2183 fet_beginchar ("Whole down Funk fahead", "d0faFunk");
2184 draw_fa_head (funk_notehead_width, funk_fa_weight);
2190 fet_beginchar ("Half up Funk fahead", "u1faFunk");
2191 draw_fa_head (funk_notehead_width, funk_fa_weight);
2197 fet_beginchar ("Half down Funk fahead", "d1faFunk");
2198 draw_fa_head (funk_notehead_width, funk_fa_weight);
2204 fet_beginchar ("Quarter up Funk fahead", "u2faFunk");
2205 draw_fa_head (funk_notehead_width, funk_fa_weight);
2210 fet_beginchar ("Quarter down Funk fahead", "d2faFunk");
2211 draw_fa_head (funk_notehead_width, funk_fa_weight);
2216 %%%%%% Funk sol head is the same as the others
2217 % Need special character because of skinnier head
2219 def draw_Funk_sol_head (expr filled) =
2222 noteheight# := solfa_noteheight#;
2223 draw_outside_ellipse (1.2, 34, 0.71, 0.);
2225 undraw_inside_ellipse (1.9, 33, 0.74, 5.5 stafflinethickness#);
2227 draw_staff (-2, 2, 0);
2232 fet_beginchar ("Whole Funk solhead", "s0solFunk");
2233 draw_Funk_sol_head ( false);
2237 fet_beginchar ("Half Funk solhead", "s1solFunk");
2238 draw_Funk_sol_head ( false);
2242 fet_beginchar ("Quarter Funk solhead", "s2solFunk");
2243 draw_Funk_sol_head ( true);
2249 % Same as for other shape notes
2250 % Smaller width requires special characters
2252 save funk_la_weight;
2253 funk_la_weight := 1.9;
2255 fet_beginchar ("Whole Funk lahead", "s0laFunk");
2256 draw_la_head (funk_notehead_width, funk_notehead_width);
2262 fet_beginchar ("Half Funk lahead", "s1laFunk");
2263 draw_la_head (funk_notehead_width, funk_notehead_width);
2269 fet_beginchar ("Quarter Funk lahead", "s2laFunk");
2270 draw_la_head (funk_notehead_width, funk_notehead_width);
2276 % `Sideways snow cone'.
2277 % Rotates for all notes.
2279 def draw_Funk_ti_head (expr width_factor, thickness_factor) =
2280 set_char_box (0, width_factor * solfa_base_notewidth#,
2281 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2286 offset := 2 * thickness_factor - 1;
2289 pen_radius := min (solfa_pen_radius,
2290 .33 * (h + d) / (1 + offset));
2292 pickup pencircle scaled (2 * pen_radius);
2297 x2 = cone_width [x1, x3];
2306 save nw_dist, sw_dist, ne, se;
2307 pair nw_dist, sw_dist, ne, se;
2309 ne = unitvector (z2 - z1);
2310 se = unitvector (z4 - z1);
2312 nw_dist = (ne rotated 90) * pen_radius ;
2313 sw_dist = (se rotated -90) * pen_radius;
2315 save path_a, path_b;
2316 path path_a, path_b;
2317 path_a := z1 - nw_dist
2318 -- z2 - offset * nw_dist;
2319 path_b := z1 - sw_dist
2320 -- z4 - offset * sw_dist;
2322 save path_right, path_right_in;
2323 path path_right, path_right_in;
2324 path_right := (z2 + ne * pen_radius)
2326 .. (z4 + se * pen_radius);
2328 path_right_in := (z2 - ne * pen_radius)
2330 .. (z4 - se * pen_radius);
2332 z5 = path_a intersectionpoint path_b;
2333 z6 = path_a intersectionpoint path_right_in;
2334 z7 = path_b intersectionpoint path_right_in;
2336 save p_up_in, p_down_in, p_up_out, p_down_out;
2337 path p_up_in, p_down_in, p_up_out, p_down_out;
2345 p_down_out := lft z1
2349 .. (z2 + ne * pen_radius){direction 0 of path_right}
2351 & {direction infinity of path_right}(z4 + se * pen_radius)
2357 p_up_in := p_down_in rotated 180 shifted (w, 0);
2358 p_up_out := p_down_out rotated 180 shifted (w, 0);
2362 save funk_ti_weight;
2363 funk_ti_weight := 1.6;
2365 fet_beginchar ("Whole up Funk tihead", "u0tiFunk");
2366 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2372 fet_beginchar ("Whole down Funk tihead", "d0tiFunk");
2373 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2379 fet_beginchar ("Half up Funk tihead", "u1tiFunk");
2380 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2386 fet_beginchar ("Half down Funk tihead", "d1tiFunk");
2387 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2393 fet_beginchar ("Quarter up Funk tihead", "u2tiFunk");
2394 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2399 fet_beginchar ("Quarter down Funk tihead", "d2tiFunk");
2400 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2405 %%%%%% Walker shape note heads
2407 % Walker heads are narrow like Funk heads, so use funk_notehead_width.
2410 %%%%%% Walker do head
2412 % Trapezoid, with largest side on stem side
2414 def draw_Walker_do_head (expr width_factor, dir, thickness_factor) =
2415 set_char_box (0, width_factor * solfa_base_notewidth#,
2416 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2418 pickup pencircle scaled solfa_pen_thick;
2421 offset := 2 * thickness_factor - 1;
2423 % adjust width so stem can be centered
2424 if .5w <> good.x .5w: change_width; fi
2428 scaling# = charwd / w;
2433 x1 = inset [x4, x3];
2436 x2 = inset [x3, x4];
2445 labels (range 1 thru 4);
2447 save left_dir, left_perp, right_dir, right_perp;
2448 pair left_dir, left_perp, right_dir, right_perp;
2450 left_dir = unitvector(z1 - z4);
2451 left_perp = (left_dir rotated 90) * solfa_pen_radius;
2452 right_dir = unitvector(z3 - z2);
2453 right_perp = (right_dir rotated 90) * solfa_pen_radius;
2455 save path_a, path_b, path_c, path_d;
2456 path path_a, path_b, path_c, path_d;
2458 path_a := (z4 - left_perp)
2459 -- (z1 - left_perp);
2460 path_b := (z1 - (0, offset*solfa_pen_radius))
2461 -- (z2 - (0, offset*solfa_pen_radius));
2462 path_c := (z2 - right_perp)
2463 -- (z3 - right_perp);
2464 path_d := (z3 + (0, offset*solfa_pen_radius))
2465 -- (z4 + (0, offset*solfa_pen_radius));
2470 p_in := (path_a intersectionpoint path_b)
2471 -- (path_b intersectionpoint path_c)
2472 -- (path_c intersectionpoint path_d)
2473 -- (path_d intersectionpoint path_a)
2476 p_out := top z1{right}
2478 .. z2 + right_perp {right_dir}
2479 -- z3 + right_perp {right_dir}
2482 .. z4 + left_perp {left_dir}
2483 .. z1 + left_perp {left_dir}
2486 charwx := scaling# * (w/2 + solfa_pen_radius);
2487 charwy := scaling# * y2 ;
2490 p_in := p_in rotated 180 shifted (w,0);
2491 p_out := p_out rotated 180 shifted (w,0);
2496 save walker_do_weight;
2497 walker_do_weight := 1.5;
2499 fet_beginchar ("Whole Walker dohead", "s0doWalker");
2500 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2506 fet_beginchar ("Half up Walker dohead", "u1doWalker");
2507 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2513 fet_beginchar ("Half down Walker dohead", "d1doWalker");
2514 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2520 fet_beginchar ("Quarter up Walker dohead", "u2doWalker");
2521 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2526 fet_beginchar ("Quarter down Walker dohead", "d2doWalker");
2527 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2532 %%%%%% Walker re head
2533 % Parabolic on one side, shallow parabola on other
2534 % Has up and down shapes for *all* notes
2536 def draw_Walker_re_head (expr width_factor, thickness_factor) =
2537 set_char_box (0, width_factor * solfa_base_notewidth#,
2538 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2541 offset := 2 * thickness_factor - 1;
2544 pen_radius := min (solfa_pen_radius,
2545 .3 * (h + d) / (1 + offset));
2547 pickup pencircle scaled (2 * pen_radius);
2550 dish_factor := 0.20;
2561 x4 = dish_factor [x1, x2];
2565 y5 = y1 + offset * pen_radius;
2568 x6 = x2 + pen_radius;
2571 y7 = y3 - offset * pen_radius;
2574 x8 = x4 - pen_radius;
2576 save path_a, path_d;
2577 path path_a, path_d;
2579 save p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2580 pair p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2582 path_a := z3 .. z4{down} .. z1;
2584 p_a_start_dir := unitvector(direction 0 of path_a);
2585 p_a_end_dir := unitvector(direction infinity of path_a);
2586 p_a_start_perp := (p_a_start_dir rotated 90) * pen_radius;
2587 p_a_end_perp := (p_a_end_dir rotated 90) * pen_radius;
2589 path_d := (z3 - p_a_start_perp){p_a_start_dir}
2591 ..(z1 - p_a_end_perp){p_a_end_dir};
2593 save path_b, path_c;
2594 path path_b, path_c;
2596 path_b := z5 {left} .. z6{up};
2597 path_c := z7 {left} .. z6{down};
2599 z9 = path_d intersectionpoint path_b;
2600 z10 = path_d intersectionpoint path_c;
2602 labels (range 1 thru 4);
2604 save p_up_in, p_up_out, p_down_in, p_down_out;
2605 path p_up_in, p_up_out, p_down_in, p_down_out;
2608 ... {right} z10 {p_a_start_dir}
2610 .. {p_a_end_dir} z9 {left}
2613 p_down_out := lft z2{up}
2616 .. (z3 + p_a_start_perp){p_a_start_dir}
2618 .. (z1 + p_a_end_perp) {p_a_end_dir}
2623 p_up_in := p_down_in rotated 180 shifted (w,0);
2624 p_up_out := p_down_out rotated 180 shifted (w,0);
2628 save walker_re_weight;
2629 walker_re_weight := 1.2;
2631 fet_beginchar ("Whole Walker rehead", "s0reWalker");
2632 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2638 fet_beginchar ("Half up Walker rehead", "u1reWalker");
2639 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2645 fet_beginchar ("Half down Walker rehead", "d1reWalker");
2646 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2652 fet_beginchar ("Quarter up Walker rehead", "u2reWalker");
2653 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2658 fet_beginchar ("Quarter down Walker rehead", "d2reWalker");
2659 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2664 %%%%%% Walker mi head
2666 % Symmetric for all hollow notes
2668 save walker_mi_width, walker_mi_weight;
2669 walker_mi_width := 1.2;
2670 walker_mi_weight := 1.5;
2672 fet_beginchar ("Whole Walker mihead", "s0miWalker");
2673 draw_mi_head (walker_mi_width * funk_notehead_width,
2674 walker_mi_weight, true);
2680 fet_beginchar ("Half Walker mihead", "s1miWalker");
2681 draw_mi_head (walker_mi_width * funk_notehead_width,
2682 walker_mi_weight, true);
2688 fet_beginchar ("Quarter Walker mihead", "s2miWalker");
2689 draw_mi_head (walker_mi_width * funk_notehead_width,
2690 walker_mi_weight, true);
2697 % Does not rotate for whole notes
2698 % Whole rotation is different from Funk, so special notes
2700 %%%%%% Funk sol head is the same as the others
2701 % Need special character because of skinnier head
2703 save walker_fa_weight;
2704 walker_fa_weight := 1.5;
2706 fet_beginchar ("Whole Walker fahead", "s0faWalker");
2707 draw_fa_head (funk_notehead_width, walker_fa_weight);
2713 fet_beginchar ("Half up Walker fahead", "u1faWalker");
2714 draw_fa_head (funk_notehead_width, walker_fa_weight);
2720 fet_beginchar ("Half down Walker fahead", "d1faWalker");
2721 draw_fa_head (funk_notehead_width, walker_fa_weight);
2727 fet_beginchar ("Quarter up Walker fahead", "u2faWalker");
2728 draw_fa_head (funk_notehead_width, walker_fa_weight);
2733 fet_beginchar ("Quarter down Walker fahead", "d2faWalker");
2734 draw_fa_head (funk_notehead_width, walker_fa_weight);
2740 % Same as Funk, no special notes
2743 %%%%%% Walker la head
2745 % Lighter weight requires separate notes
2747 save walker_la_weight;
2748 walker_la_weight := 1.5;
2750 fet_beginchar ("Whole Walker lahead", "s0laWalker");
2751 draw_la_head (funk_notehead_width, walker_la_weight);
2757 fet_beginchar ("Half Funk lahead", "s1laWalker");
2758 draw_la_head (funk_notehead_width, walker_la_weight);
2764 fet_beginchar ("Quarter Funk lahead", "s2laWalker");
2765 draw_la_head (funk_notehead_width, walker_la_weight);
2770 %%%%%% Walker ti head
2771 % Triangular arrowhead
2772 % Rotates for all but whole notes
2774 def draw_Walker_ti_head (expr width_factor, thickness_factor) =
2775 set_char_box (0, width_factor * solfa_base_notewidth#,
2776 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2779 offset := 2 * thickness_factor - 1;
2782 pen_radius := min (solfa_pen_radius,
2783 .3 * (h + d) / (1 + offset));
2785 pickup pencircle scaled (2 * pen_radius);
2797 labels (range 1 thru 4);
2799 save nw_dist, sw_dist, ne, se;
2800 pair nw_dist, sw_dist, ne, se;
2802 ne = unitvector (z2 - z1);
2803 se = unitvector (z3 - z1);
2805 nw_dist = (ne rotated 90) * pen_radius ;
2806 sw_dist = (se rotated -90) * pen_radius;
2809 save path_a, path_b, path_c;
2810 path path_a, path_b, path_c;
2811 path_a := z2 - nw_dist * offset
2812 -- z1 - nw_dist * offset;
2813 path_b := z3 - sw_dist * offset
2814 -- z1 - sw_dist * offset;
2815 path_c := z2 + left * pen_radius
2816 -- z3 + left * pen_radius;
2818 z4 = path_a intersectionpoint path_b;
2819 z5 = path_a intersectionpoint path_c;
2820 z6 = path_b intersectionpoint path_c;
2822 save p_up_in, p_down_in, p_up_out, p_down_out;
2823 path p_up_in, p_down_in, p_up_out, p_down_out;
2830 p_down_out := lft z1{up}
2831 .. (z1 + nw_dist){ne}
2832 -- (z2 + nw_dist){ne}
2837 .. (z3 + sw_dist){- se}
2838 .. (z1 + sw_dist){- se}
2841 p_up_in := p_down_in rotated 180 shifted (w, 0);
2842 p_up_out := p_down_out rotated 180 shifted (w, 0);
2846 save walker_ti_weight;
2847 walker_ti_weight := 1.4;
2849 fet_beginchar ("Whole Walker tihead", "s0tiWalker");
2850 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2856 fet_beginchar ("Half up Walker tihead", "u1tiWalker");
2857 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2863 fet_beginchar ("Half down Walker tihead", "d1tiWalker");
2864 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2870 fet_beginchar ("Quarter up Walker tihead", "u2tiWalker");
2871 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2876 fet_beginchar ("Quarter down Walker tihead", "d2tiWalker");
2877 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2881 fet_endgroup ("noteheads");
2885 % we derive black_notehead_width# from the quarter head,
2886 % so we have to define black_notehead_width (pixel qty)
2887 % after the black_notehead_width# itself.
2889 % Let's keep it outside the group as well.
2892 define_pixels (black_notehead_width);