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));
85 def draw_longa (expr up) =
86 save stemthick, fudge;
88 stemthick# = 2 stafflinethickness#;
89 define_whole_blacker_pixels (stemthick);
91 % Longas of smaller design sizes should have their lines farther
92 % apart (the overlap with notehead ellipsoid should be smaller).
93 fudge = hround (blot_diameter
96 - (20 / (design_size + 4)))),
99 draw_outside_ellipse (1.80, 0, 0.707, 0);
100 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
102 set_char_box (stemthick#,
107 pickup pencircle scaled stemthick;
109 % Longas of smaller design sizes should have their lines longer.
110 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
112 % Line lengths between 0.72 and 0.77 are not nice
113 % because they are neither separate nor connected
114 % when there is an interval of fourth.
115 if line_length < 0.75:
116 quanted_line_length := min (0.72, line_length);
118 quanted_line_length := max (0.77, line_length);
122 bot y1 = -quanted_line_length * staff_space;
123 top y2 = quanted_line_length * staff_space;
127 fudge + lft x3 = width;
129 top y4 = h + 3.0 staff_space;
132 bot y1 = -d - 3.0 staff_space;
133 top y2 = quanted_line_length * staff_space;
137 fudge + lft x3 = width;
140 bot y3 = -quanted_line_length * staff_space;
143 draw_gridline (z1, z2, stemthick);
144 draw_gridline (z3, z4, stemthick);
150 fet_beginchar ("Longa notehead", "uM2");
153 draw_staff (-2, 2, 0);
157 fet_beginchar ("Longa notehead", "dM2");
160 draw_staff (-2, 2, 0);
165 fet_beginchar ("Longa notehead", "uM2");
168 draw_staff (-2, 2, 0.5);
172 fet_beginchar ("Longa notehead", "dM2");
175 draw_staff (-2, 2, 0.5);
180 def draw_brevis (expr linecount, line_thickness_multiplier) =
181 save stemthick, fudge, gap;
183 stemthick# = line_thickness_multiplier * 2 * stafflinethickness#;
184 define_whole_blacker_pixels (stemthick);
186 % double-lined breves of smaller design sizes should have
187 % bigger gap between the lines.
188 gap# := (0.95 - 0.008 * design_size) * stemthick#;
190 % Breves of smaller design sizes should have their lines farther
191 % apart (the overlap with notehead ellipsoid should be smaller).
192 fudge = hround (blot_diameter
195 - (20 / (design_size + 4))
199 draw_outside_ellipse (1.80, 0, 0.707, 0);
200 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
202 set_char_box (stemthick# * linecount + gap# * (linecount - 1),
203 width# + stemthick# * linecount + gap# * (linecount - 1),
208 pickup pencircle scaled stemthick;
210 % Breves of smaller design sizes should have their lines longer.
211 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
213 % Line lengths between 0.72 and 0.77 are not nice
214 % because they are neither separate nor connected
215 % when there is an interval of fourth.
216 if line_length < 0.75:
217 quanted_line_length := min (0.72, line_length);
219 quanted_line_length := max (0.77, line_length);
222 bot y1 = -quanted_line_length * staff_space;
223 top y2 = quanted_line_length * staff_space;
227 fudge + lft x3 = width;
232 for i := 0 step 1 until linecount - 1:
233 line_distance := i * (gap + stemthick);
234 draw_gridline (z1 - (line_distance, 0),
235 z2 - (line_distance, 0),
237 draw_gridline (z3 + (line_distance, 0),
238 z4 + (line_distance, 0),
244 fet_beginchar ("Brevis notehead", "sM1");
247 draw_staff (-2, 2, 0);
252 fet_beginchar ("Brevis notehead", "sM1");
255 draw_staff (-2, 2, 0.5);
260 fet_beginchar ("Double-lined brevis notehead", "sM1double");
261 draw_brevis (2, 0.8);
263 draw_staff (-2, 2, 0);
268 fet_beginchar ("Double-lined brevis notehead", "sM1double");
269 draw_brevis (2, 0.8);
271 draw_staff (-2, 2, 0.5);
276 fet_beginchar ("Whole notehead", "s0");
277 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
278 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
279 0.68, 2 stafflinethickness#);
281 whole_notehead_width# := charwd;
283 draw_staff (-2, 2, 0);
288 fet_beginchar ("Whole notehead", "s0");
289 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
291 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
292 0.68, 2 stafflinethickness#);
294 draw_staff (-2, 2, 0.5);
299 fet_beginchar ("Half notehead", "s1");
300 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
301 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
303 half_notehead_width# := charwd;
305 draw_staff (-2, 2, 0);
310 fet_beginchar ("Half notehead", "s1");
311 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
313 undraw_inside_ellipse (3.25, 33, 0.81,
314 2.5 stafflinethickness#);
316 draw_staff (-2, 2, 0.5);
321 fet_beginchar ("Quarter notehead", "s2");
323 draw_staff (-2, 2, 0);
328 fet_beginchar ("Quarter notehead", "s2");
329 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
332 draw_staff (-2, 2, 0.5);
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
340 fet_beginchar ("Whole diamondhead", "s0diamond");
341 draw_outside_ellipse (1.80, 0, 0.495, 0);
342 undraw_inside_ellipse (1.30, 125, 0.6,
343 .4 staff_space# + stafflinethickness#);
345 draw_staff (-2, 2, 0);
350 fet_beginchar ("Whole diamondhead", "s0diamond");
351 draw_outside_ellipse (1.80, 0, 0.495, 0);
352 undraw_inside_ellipse (1.30, 125, 0.6,
353 .4 staff_space# + stafflinethickness#);
355 draw_staff (-2, 2, 0.5);
360 fet_beginchar ("Half diamondhead", "s1diamond");
361 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
362 undraw_inside_ellipse (3.5, 33, 0.80,
363 .3 staff_space# + 1.5 stafflinethickness#);
365 draw_staff (-2, 2, 0);
370 fet_beginchar ("Half diamondhead", "s1diamond");
371 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
372 undraw_inside_ellipse (3.5, 33, 0.80,
374 + 1.5 stafflinethickness#);
376 draw_staff (-2, 2, 0.5);
381 fet_beginchar ("Quarter diamondhead", "s2diamond");
382 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
384 draw_staff (-2, 2, 0);
389 fet_beginchar ("Quarter diamondhead", "s2diamond");
390 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
392 draw_staff (-2, 2, 0.5);
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400 vardef penposx@# (expr d) =
410 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
411 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
417 % UGH: xs not declared as argument.
419 def define_triangle_shape (expr stemdir) =
420 save triangle_a, triangle_b, triangle_c;
421 save triangle_out_a, triangle_out_b, triangle_out_c;
422 save triangle_in, triangle_out;
423 save width, depth, height;
424 save origin, left_up_dir;
425 save exact_left_point, exact_right_point, exact_down_point;
427 path triangle_a, triangle_b, triangle_c;
428 path triangle_out_a, triangle_out_b, triangle_out_c;
429 path triangle_in, triangle_out;
430 pair origin, left_up_dir;
431 pair exact_down_point, exact_left_point, exact_right_point;
434 pen_thick# = stafflinethickness# + .1 staff_space#;
435 define_pixels (llap);
436 define_blacker_pixels (pen_thick);
438 left_up_dir = llap# * dir (90 + tilt);
440 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
443 exact_left_point := origin + (left_up_dir xscaled xs);
444 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
445 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
447 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
448 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
449 width# = xpart (exact_right_point - exact_left_point)
452 set_char_box (0, width#, depth#, height#);
454 % Formerly, the shape has simply been drawn with an elliptical pen
455 % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
456 % is of 6th degree. For the sake of mf2pt1, we approximate it.
458 pickup pencircle scaled pen_thick xscaled xs;
460 z0 = (hround_pixels (xpart origin), 0);
462 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
463 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
464 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
466 z12 = caveness [.5[z1, z2], z3];
467 z23 = caveness [.5[z2, z3], z1];
468 z31 = caveness [.5[z3, z1], z2];
470 triangle_a = z1 .. z12 .. z2;
471 triangle_b = z2 .. z23 .. z3;
472 triangle_c = z3 .. z31 .. z1;
474 penposx1 (angle (direction 0 of triangle_a) - 90);
475 penposx2 (angle (direction 0 of triangle_b) - 90);
476 penposx3 (angle (direction 0 of triangle_c) - 90);
478 penposx1' (angle (direction infinity of triangle_c) + 90);
479 penposx2' (angle (direction infinity of triangle_a) + 90);
480 penposx3' (angle (direction infinity of triangle_b) + 90);
482 penposx12 (angle (z12 - z0));
483 penposx23 (angle (z23 - z0));
484 penposx31 (angle (z31 - z0));
486 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
487 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
488 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
501 triangle_out_a = z1r .. z12r .. z2'l;
502 triangle_out_b = z2r .. z23r .. z3'l;
503 triangle_out_c = z3r .. z31r .. z1'l;
505 triangle_out = top z1
507 .. z1r{direction 0 of triangle_out_a}
509 & {direction infinity of triangle_out_a}z2'l
512 .. z2r{direction 0 of triangle_out_b}
514 & {direction infinity of triangle_out_b}z3'l
517 .. z3r{direction 0 of triangle_out_c}
519 & {direction infinity of triangle_out_c}z1'l
522 labels (0, 10, 20, 30);
523 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
527 charwy := ypart exact_right_point;
528 charwx := xpart exact_right_point + .5 pen_thick# * xs;
530 charwy := -ypart exact_down_point;
531 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
536 def draw_whole_triangle_head =
542 llap# = 3/4 noteheight#;
546 define_triangle_shape (1);
552 fet_beginchar ("Whole trianglehead", "s0triangle");
553 draw_whole_triangle_head;
555 draw_staff (-2, 2, 0);
560 fet_beginchar ("Whole trianglehead", "s0triangle");
561 draw_whole_triangle_head;
563 draw_staff (-2, 2, 0.5);
568 def draw_small_triangle_head (expr dir) =
574 llap# = 2/3 noteheight#;
577 define_triangle_shape (dir);
581 filldraw triangle_out;
582 unfilldraw triangle_in;
586 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
587 draw_small_triangle_head (-1);
589 draw_staff (-2, 2, 0);
593 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
594 draw_small_triangle_head (1);
596 draw_staff (-2, 2, 0.5);
600 def draw_closed_triangle_head (expr dir) =
606 llap# = 2/3 noteheight#;
609 define_triangle_shape (dir);
614 fet_beginchar ("Quarter trianglehead (upstem)", "u2triangle");
615 draw_closed_triangle_head (1);
617 draw_staff (-2, 2, 0);
621 fet_beginchar ("Quarter trianglehead (downstem)", "d2triangle");
622 draw_closed_triangle_head (-1);
624 draw_staff (-2, 2, 0.5);
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 % Slash heads are for indicating improvisation. They are
631 % twice as high as normal heads.
633 def draw_slash (expr hwid_hash) =
637 exact_height = staff_space# + stafflinethickness# / 2;
639 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
640 exact_height, exact_height);
649 pickup pencircle scaled blot_diameter;
654 lft x2 = 2 h / slash_slope;
661 ne = unitvector (z3 - z4);
662 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
665 .. (z1 + nw_dist){ne}
666 -- (z2 + nw_dist){ne}
669 .. (z3 - nw_dist){-ne}
670 -- (z4 - nw_dist){-ne}
674 if hwid_hash > 2 slash_thick#:
677 th = slash_thick - blot_diameter;
682 z6 - z5 = whatever * ne;
683 z8 - z7 = whatever * ne;
685 z5 = z1 + whatever * ne + th * (ne rotated -90);
686 z8 = z4 + whatever * ne + th * (ne rotated 90);
694 labels (range 1 thru 10);
698 fet_beginchar ("Whole slashhead", "s0slash");
699 draw_slash (4 slash_thick# + 0.5 staff_space#);
701 draw_staff (-2, 2, 0);
705 fet_beginchar ("Half slashhead", "s1slash");
706 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
708 draw_staff (-2, 2, 0);
712 fet_beginchar ("Quarter slashhead", "s2slash");
713 draw_slash (1.5 slash_thick#);
715 draw_staff (-2, 2, 0);
719 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721 % `thick' is the distance between the NE/SW parallel lines in the cross
722 % (distance between centres of lines) in multiples of stafflinethickness
724 def draw_cross (expr thick) =
726 save ne_dist, nw_dist, rt_dist, up_dist;
727 save crz_in, crz_out;
730 pair ne_dist, nw_dist, rt_dist, up_dist;
731 path crz_in, crz_out;
733 pen_thick# := 1.2 stafflinethickness#;
734 thickness# := thick * stafflinethickness#;
735 define_pixels (thickness);
736 define_blacker_pixels (pen_thick);
738 pickup pencircle scaled pen_thick;
743 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
746 z4 - z5 = whatever * ne;
748 z6 - z3 = whatever * ne;
749 z3 - z4 = whatever * (ne yscaled -1);
751 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
754 x1 = charwd / 2 - .5 pen_thick#;
756 + thick / 2 * stafflinethickness# * (ne rotated -90);
758 % labels (1, 2, 3, 4, 5, 6);
760 nw = unitvector (z3 - z4);
762 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
763 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
764 nw_dist = (ne rotated 90) * 0.5 pen_thick;
765 ne_dist = (nw rotated -90) * 0.5 pen_thick;
771 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
772 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
773 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
775 crz_out = (z6 + up_dist)
776 -- (z3 + nw_dist){ne}
778 .. (z3 + ne_dist){-nw}
779 -- (z4 + ne_dist){-nw}
781 .. (z4 - nw_dist){-ne}
783 crz_out := crz_out shifted (0, feta_shift)
784 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
786 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
790 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
791 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
792 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
794 crz_in = (bot z6){right}
795 .. (z6 - nw_dist){ne}
798 -- (z5 + nw_dist){-ne}
800 crz_in := crz_in shifted (0, feta_shift)
801 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
803 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
808 currentpicture := currentpicture shifted (hround (w / 2), 0);
811 charwy := y1 + feta_shift;
813 z12 = (charwx * hppp, y1 * vppp);
819 fet_beginchar ("Whole Crossed notehead", "s0cross");
822 wid# := black_notehead_width# + 4 stafflinethickness#;
823 hei# := noteheight# + stafflinethickness#;
825 set_char_box (0, wid#, hei# / 2, hei# / 2);
829 remember_pic := currentpicture;
831 draw_staff (-2, 2, 0);
836 fet_beginchar ("Whole Crossed notehead", "s0cross");
839 wid# := black_notehead_width# + 4 stafflinethickness#;
840 hei# := noteheight# + stafflinethickness#;
842 set_char_box (0, wid#, hei# / 2, hei# / 2);
844 currentpicture := remember_pic;
846 draw_staff (-2, 2, 0.5);
851 fet_beginchar ("Half Crossed notehead", "s1cross");
854 wid# := black_notehead_width# + 2 stafflinethickness#;
855 hei# := noteheight# + stafflinethickness# / 2;
857 set_char_box (0, wid#, hei# / 2, hei# / 2);
861 remember_pic := currentpicture;
863 draw_staff (-2, 2, 0);
868 fet_beginchar ("Half Crossed notehead", "s1cross");
871 wid# := black_notehead_width# + 2 stafflinethickness#;
872 hei# := noteheight# + stafflinethickness# / 2;
874 set_char_box (0, wid#, hei# / 2, hei# / 2);
876 currentpicture := remember_pic;
878 draw_staff (-2, 2, 0.5);
883 fet_beginchar ("Crossed notehead", "s2cross");
884 wid# := black_notehead_width#;
886 set_char_box (0, wid#, hei# / 2, hei# / 2);
890 remember_pic := currentpicture;
892 draw_staff (-2, 2, 0);
897 fet_beginchar ("Crossed notehead", "s2cross");
898 wid# := black_notehead_width#;
900 set_char_box (0, wid#, hei# / 2, hei# / 2);
902 currentpicture := remember_pic;
904 draw_staff (-2, 2, 0.5);
909 fet_beginchar ("X-Circled notehead", "s2xcircle");
911 save cthick, cxd, cyd, dy;
913 wid# := black_notehead_width# * sqrt (sqrt2);
914 hei# := noteheight# * sqrt (sqrt2);
916 set_char_box (0, wid#, hei# / 2, hei# / 2);
918 d := d - feta_space_shift;
920 cthick# := (1.2 + 1/4) * stafflinethickness#;
921 define_blacker_pixels (cthick);
924 cyd := h + d - cthick / 2;
928 pickup pencircle scaled cthick;
930 fill fullcircle xscaled (cxd + cthick)
931 yscaled (cyd + cthick)
933 unfill fullcircle xscaled (cxd - cthick)
934 yscaled (cyd - cthick)
937 xpos := .5 cxd / sqrt2;
938 ypos := .5 cyd / sqrt2;
940 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
941 draw (-xpos + w / 2, -ypos + dy)
942 -- (xpos + w / 2, ypos + dy);
944 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
945 draw (-xpos + w / 2, ypos + dy)
946 -- (xpos + w / 2, -ypos + dy);
951 z12 = (charwx * hppp, charwy * vppp);
954 remember_pic := currentpicture;
956 draw_staff (-2, 2, 0);
961 fet_beginchar ("X-Circled notehead", "s2xcircle");
963 save cthick, cxr, cyr;
965 wid# := black_notehead_width# * sqrt (sqrt2);
966 hei# := noteheight# * sqrt (sqrt2);
968 set_char_box (0, wid#, hei# / 2, hei# / 2);
970 currentpicture := remember_pic;
972 draw_staff (-2, 2, 0.5);
982 % Note: For whole and half notes, the `fill' curve (p_out) is offset from
983 % the points that specify the outer geometry, because we need to add
984 % the rounding. In contrast, the inner curve is not offset, because
985 % there is no rounding.
987 % This means that to get a line of thick_factor * pen_thickness,
988 % we need to offset the inner curve by
990 % (thick_factor - 0.5) * pen_thickness
994 % (2 * thick_factor - 1) * half_pen_thickness
996 save solfa_pen_thick;
997 solfa_pen_thick# = 1.3 stafflinethickness#;
998 define_blacker_pixels (solfa_pen_thick);
1000 save solfa_pen_radius;
1001 solfa_pen_radius = 0.5 solfa_pen_thick;
1003 save solfa_base_notewidth;
1004 solfa_base_notewidth# := black_notehead_width#;
1006 solfa_whole_width := 1.0;
1007 solfa_half_width := 1.0;
1008 solfa_quarter_width := 1.0;
1013 % Triangle with base parallel to staff lines.
1016 def draw_do_head (expr width_factor, dir, thickness_factor) =
1018 save left_dist, right_dist, bottom_dist;
1020 pair left_dist, right_dist, bottom_dist;
1022 set_char_box (0, width_factor * solfa_base_notewidth#,
1023 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1025 bottom_thick_factor := 2 * thickness_factor - 1;
1026 % no different thickness for left side if we want uniform thickness
1027 if thickness_factor = 1:
1028 left_thick_factor := 1;
1030 left_thick_factor := 0.7 * bottom_thick_factor;
1034 pen_radius := min (solfa_pen_radius,
1035 (h + d) / (3 * (1 + bottom_thick_factor)));
1037 pickup pencircle scaled (2 * pen_radius);
1046 left_dist = (unitvector (z3 - z1) rotated 90) * pen_radius;
1047 right_dist = (unitvector (z2 - z3) rotated 90) * pen_radius;
1048 bottom_dist = (0,1) * pen_radius;
1052 save point_a, point_b, point_c;
1053 pair point_a, point_b, point_c;
1055 pa := (z1 - left_thick_factor * left_dist)
1056 -- (z3 - left_thick_factor * left_dist);
1057 pb := (z1 + bottom_thick_factor * bottom_dist)
1058 -- (z2 + bottom_thick_factor * bottom_dist);
1059 pc := (z2 - right_dist)
1060 -- (z3 - right_dist);
1062 point_a := pa intersectionpoint pb;
1063 point_b := pb intersectionpoint pc;
1064 point_c := pc intersectionpoint pa;
1074 .. (z2 + right_dist){z3 - z2}
1075 -- (z3 + right_dist){z3 - z2}
1077 .. (z3 + left_dist){z1 - z3}
1078 -- (z1 + left_dist){z1 - z3}
1085 charwy := -chardp + 0.5 stafflinethickness#;
1095 fet_beginchar ("Whole dohead", "s0do");
1096 draw_do_head (solfa_whole_width, 1, do_weight);
1102 fet_beginchar ("Half dohead", "d1do");
1103 draw_do_head (solfa_half_width, -1, do_weight);
1109 fet_beginchar ("Half dohead", "u1do");
1110 draw_do_head (solfa_half_width, 1, do_weight);
1116 fet_beginchar ("Quarter dohead", "d2do");
1117 draw_do_head (solfa_quarter_width, -1, do_weight);
1122 fet_beginchar ("Quarter dohead", "u2do");
1123 draw_do_head (solfa_quarter_width, 1, do_weight);
1128 fet_beginchar ("Whole thin dohead", "s0doThin");
1129 draw_do_head (solfa_whole_width, 1, 1);
1135 fet_beginchar ("Half thin dohead", "d1doThin");
1136 draw_do_head (solfa_half_width, -1, 1);
1142 fet_beginchar ("Half thin dohead", "u1doThin");
1143 draw_do_head (solfa_half_width, 1, 1);
1149 fet_beginchar ("Quarter thin dohead", "d2doThin");
1150 draw_do_head (solfa_quarter_width, -1, 1);
1155 fet_beginchar ("Quarter thin dohead", "u2doThin");
1156 draw_do_head (solfa_quarter_width, 1, 1);
1162 % re - flat top, curved bottom:
1166 % .. {dir 90} (w,h/2)
1169 % (broader along the base and with more vertical sides for half and
1172 % Note: According to some shape-note singers, there should be no size
1173 % differences for half and whole notes, contrary to the comment above.
1174 % Consequently, we have made them all the same width.
1176 % stem attachment: h/2
1178 def draw_re_head (expr width_factor, dir, thickness_factor) =
1182 set_char_box (0, width_factor * solfa_base_notewidth#,
1183 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1186 offset = (2 * thickness_factor - 1);
1193 pen_radius := min (solfa_pen_radius,
1194 (h + d) * (1-curve_start) / (1+ offset));
1196 pickup pencircle scaled (2 * pen_radius);
1201 y2 = curve_start [y3, y1];
1209 labels (range 1 thru 5);
1211 p_in := (z1 + pen_radius * (1, -1 * offset))
1213 .. ((top z3) + (0, offset * pen_radius))
1215 -- (z5 + pen_radius * (-1, -1 * offset))
1228 charwy := curve_start [-chardp, charht];
1239 fet_beginchar ("Whole rehead", "s0re");
1240 draw_re_head (solfa_whole_width, 1, re_weight);
1246 fet_beginchar ("Half up rehead", "u1re");
1247 draw_re_head (solfa_half_width, 1, re_weight);
1253 fet_beginchar ("Half down rehead", "d1re");
1254 draw_re_head (solfa_half_width, -1, re_weight);
1260 fet_beginchar ("Quarter up rehead", "u2re");
1261 draw_re_head (solfa_quarter_width, 1, re_weight);
1266 fet_beginchar ("Quarter down rehead", "d2re");
1267 draw_re_head (solfa_quarter_width, -1, re_weight);
1272 fet_beginchar ("Whole thin rehead", "s0reThin");
1273 draw_re_head (solfa_whole_width, 1, 1);
1279 fet_beginchar ("Half up thin rehead", "u1reThin");
1280 draw_re_head (solfa_half_width, 1, 1);
1286 fet_beginchar ("Half down thin rehead", "d1reThin");
1287 draw_re_head (solfa_half_width, -1, 1);
1293 fet_beginchar ("Quarter thin rehead", "u2reThin");
1294 draw_re_head (solfa_quarter_width, 1, 1);
1299 fet_beginchar ("Quarter thin rehead", "d2reThin");
1300 draw_re_head (solfa_quarter_width, -1, 1);
1305 %%%% mi head -- diamond shape
1307 % two versions, depending on whether the `strong' lines are on the nw & se
1310 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1311 save path_out, path_in;
1312 save ne_dist, se_dist, ne, se;
1313 save path_a, path_b, path_c, path_d;
1314 path path_out, path_in;
1315 pair ne_dist, se_dist, ne, se;
1316 path path_a, path_b, path_c, path_d;
1320 set_char_box (0, width_factor * solfa_base_notewidth#,
1321 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1324 offset := 2 * thickness_factor - 1;
1328 note_diagonal := w / 2 ++ (h + d) / 2;
1332 pen_radius := min (solfa_pen_radius,
1333 .3 * note_diagonal / (1 + offset));
1335 pickup pencircle scaled (2 * pen_radius);
1346 % inner sides are parallel to outer sides
1347 z6 - z5 = whatever * (z2 - z1);
1348 z8 - z7 = whatever * (z4 - z3);
1349 z8 - z5 = whatever * (z4 - z1);
1350 z7 - z6 = whatever * (z3 - z2);
1352 ne = unitvector (z4 - z1);
1353 se = unitvector (z2 - z1);
1355 ne_dist = (ne rotated 90) * pen_radius;
1356 se_dist = (se rotated 90) * pen_radius;
1358 path_a := (z1 + se_dist)
1360 path_b := (z2 + (ne_dist * offset))
1361 -- (z3 + (ne_dist * offset));
1362 path_c := (z3 - se_dist)
1364 path_d := (z4 - (ne_dist * offset))
1365 -- (z1 - (ne_dist * offset));
1367 z5 = path_a intersectionpoint path_d;
1368 z7 = path_b intersectionpoint path_c;
1370 labels (range 1 thru 8);
1379 path_in := inner_path;
1381 path_in := inner_path reflectedabout (z2, z4);
1384 path_out := lft z1 {down}
1385 .. (z1 - se_dist){se}
1386 -- (z2 - se_dist){se}
1388 .. (z2 - ne_dist){ne}
1389 -- (z3 - ne_dist){ne}
1391 .. (z3 + se_dist){-se}
1392 -- (z4 + se_dist){-se}
1394 .. (z4 + ne_dist){-ne}
1395 -- (z1 + ne_dist){-ne}
1400 save mi_weight, mi_width;
1404 fet_beginchar ("Whole mihead", "s0mi");
1405 draw_mi_head (mi_width * solfa_whole_width, mi_weight, false);
1411 fet_beginchar ("Half mihead", "s1mi");
1412 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1418 fet_beginchar ("Quarter mihead", "s2mi");
1419 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1424 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1425 draw_mi_head (mi_width * solfa_whole_width, mi_weight, true);
1431 fet_beginchar ("Half mirror mihead", "s1miMirror");
1432 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1438 fet_beginchar ("Quarter mirror mihead", "s2miMirror");
1439 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1444 fet_beginchar ("Whole thin mihead", "s0miThin");
1445 draw_mi_head (mi_width * solfa_whole_width, 1, false);
1451 fet_beginchar ("Half thin mihead", "s1miThin");
1452 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1458 fet_beginchar ("Quarter thin mihead", "s2miThin");
1459 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1466 % Right triangle, hypotenuse from nw to se corner. Stem attaches on
1467 % vertical side in direction of horizontal side.
1469 def draw_fa_head (expr width_factor, thickness_factor) =
1470 set_char_box (0, width_factor * solfa_base_notewidth#,
1471 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1473 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1474 path p_down_in, p_down_out, p_up_in, p_up_out;
1475 save path_a, path_b, path_c;
1476 path path_a, path_b, path_c;
1480 offset := 2 * thickness_factor - 1;
1483 pen_radius := min (solfa_pen_radius,
1484 .33 * (h + d) / (1 + offset));
1486 pickup pencircle scaled (2 * pen_radius);
1499 labels (1, 2, 3, 4);
1501 nw = unitvector (z1 - z3);
1502 nw_dist = (nw rotated 90) * pen_radius;
1504 path_a := (z1 - (0,1) * offset * pen_radius)
1505 -- (z2 - (0,1) * offset * pen_radius);
1506 path_b := (z2 - (1,0) * pen_radius)
1507 -- (z3 - (1,0) * pen_radius);
1508 path_c := (z3 - nw_dist)
1511 p_up_in := (path_a intersectionpoint path_b)
1512 -- (path_b intersectionpoint path_c)
1513 -- (path_c intersectionpoint path_a)
1516 p_up_out := lft z1{down}
1517 .. (z1 + nw_dist){-nw}
1518 -- (z3 + nw_dist){-nw}
1526 p_down_in := p_up_in rotated 180 shifted (w, 0);
1527 p_down_out := p_up_out rotated 180 shifted (w, 0);
1536 fet_beginchar ("Whole fa up head", "u0fa");
1537 draw_fa_head (solfa_whole_width, fa_weight);
1543 fet_beginchar ("Whole fa down head", "d0fa");
1544 draw_fa_head (solfa_whole_width, fa_weight);
1550 fet_beginchar ("half fa up head", "u1fa");
1551 draw_fa_head (solfa_half_width, fa_weight);
1557 fet_beginchar ("Half fa down head", "d1fa");
1558 draw_fa_head (solfa_half_width, fa_weight);
1564 fet_beginchar ("Quarter fa up head", "u2fa");
1565 draw_fa_head (solfa_quarter_width, fa_weight);
1570 fet_beginchar ("Quarter fa down head", "d2fa");
1571 draw_fa_head (solfa_quarter_width, fa_weight);
1576 fet_beginchar ("Whole thin fa up head", "u0faThin");
1577 draw_fa_head (solfa_whole_width, 1);
1583 fet_beginchar ("Whole thin fa down head", "d0faThin");
1584 draw_fa_head (solfa_whole_width, 1);
1590 fet_beginchar ("half thin fa up head", "u1faThin");
1591 draw_fa_head (solfa_half_width, 1);
1597 fet_beginchar ("Half thin fa down head", "d1faThin");
1598 draw_fa_head (solfa_half_width, 1);
1604 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1605 draw_fa_head (solfa_quarter_width, 1);
1610 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1611 draw_fa_head (solfa_quarter_width, 1);
1619 % Note: sol head is the same shape as a standard music head, and doesn't
1620 % vary from style to style. However, width is constant with duration,
1621 % so we can't just use the standard note font.
1623 def draw_sol_head (expr filled) =
1624 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1626 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1628 draw_staff (-2, 2, 0);
1631 fet_beginchar ("Whole solhead", "s0sol");
1632 draw_sol_head ( false);
1636 fet_beginchar ("Half solhead", "s1sol");
1637 draw_sol_head ( false);
1641 fet_beginchar ("Quarter solhead", "s2sol");
1642 draw_sol_head ( true);
1650 def draw_la_head (expr width_factor, thickness_factor) =
1651 set_char_box (0, width_factor * solfa_base_notewidth#,
1652 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1657 offset := 2 * thickness_factor - 1;
1660 pen_radius := min (solfa_pen_radius,
1661 .35 * (h + d) / (1 + offset));
1663 pickup pencircle scaled (2 * pen_radius);
1676 labels (range 1 thru 4);
1678 p_in := (z1 + pen_radius * (1, -offset))
1679 -- (z2 + pen_radius * (-1, -offset))
1680 -- (z3 + pen_radius * (-1, offset))
1681 -- (z4 + pen_radius * (1, offset))
1699 fet_beginchar ("Whole lahead", "s0la");
1700 draw_la_head (solfa_whole_width, la_weight);
1706 fet_beginchar ("Half lahead", "s1la");
1707 draw_la_head (solfa_half_width, la_weight);
1713 fet_beginchar ("Quarter lahead", "s2la");
1714 draw_la_head (solfa_quarter_width, la_weight);
1719 fet_beginchar ("Whole thin lahead", "s0laThin");
1720 draw_la_head (solfa_whole_width, 1);
1726 fet_beginchar ("Half thin lahead", "s1laThin");
1727 draw_la_head (solfa_half_width, 1);
1733 fet_beginchar ("Quarter lahead", "s2laThin");
1734 draw_la_head (solfa_quarter_width, 1);
1741 % `Snow-cone', V with rounded top.
1743 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1744 set_char_box (0, width_factor * solfa_base_notewidth#,
1745 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1746 save p_in, p_out, p_top, p_top_in;
1747 path p_in, p_out, p_top, p_top_in;
1752 offset := 2 * thickness_factor - 1;
1755 pen_radius := min (solfa_pen_radius,
1756 .4 * (h + d) / (1 + offset));
1758 pickup pencircle scaled (2 * pen_radius);
1763 y2 = cone_height [y1, y3];
1769 y5 = y1 + offset * pen_radius;
1771 labels (range 1 thru 4);
1773 save nw_dist, sw_dist, nw, sw;
1774 pair nw_dist, sw_dist, nw, sw;
1776 nw = unitvector (z2 - z1);
1777 sw = unitvector (z1 - z4);
1779 nw_dist = (nw rotated 90) * pen_radius;
1780 sw_dist = (sw rotated 90) * pen_radius;
1782 p_top := (z2 + nw * pen_radius)
1784 .. (z4 - sw * pen_radius);
1786 p_top_in := (z2 - nw * offset * pen_radius)
1787 .. (z3 - (0,1) * pen_radius) {right}
1788 .. (z4 + sw * offset * pen_radius);
1790 save path_a, path_b;
1791 path path_a, path_b;
1797 z6 = path_a intersectionpoint p_top_in;
1798 z7 = path_b intersectionpoint p_top_in;
1810 .. (z2 + nw * pen_radius){direction 0 of p_top}
1812 & {direction infinity of p_top}(z4 - sw * pen_radius)
1819 charwy := cone_height [-chardp, charht];
1829 fet_beginchar ("Whole up tihead", "s0ti");
1830 draw_ti_head (solfa_whole_width, 1, ti_weight);
1836 fet_beginchar ("Half up tihead", "u1ti");
1837 draw_ti_head (solfa_half_width, 1, ti_weight);
1843 fet_beginchar ("Half down tihead", "d1ti");
1844 draw_ti_head (solfa_half_width, -1, ti_weight);
1850 fet_beginchar ("Quarter up tihead", "u2ti");
1851 draw_ti_head (solfa_quarter_width, 1, ti_weight);
1856 fet_beginchar ("Quarter down tihead", "d2ti");
1857 draw_ti_head (solfa_quarter_width, -1, ti_weight);
1862 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1863 draw_ti_head (solfa_whole_width, 1, 1);
1869 fet_beginchar ("Half thin up tihead", "u1tiThin");
1870 draw_ti_head (solfa_half_width, 1, 1);
1876 fet_beginchar ("Half thin down tihead", "d1tiThin");
1877 draw_ti_head (solfa_half_width, -1, 1);
1883 fet_beginchar ("Quarter thin up tihead", "u2tiThin");
1884 draw_ti_head (solfa_quarter_width, 1, 1);
1889 fet_beginchar ("Quarter thin down tihead", "d2tiThin");
1890 draw_ti_head (solfa_quarter_width, -1, 1);
1895 %%%%%% Funk shape note heads
1897 % Funk heads are narrower than Aiken and Sacred Harp, so we need a new
1900 funk_notehead_width := 0.75;
1904 % Parabolic on one side, vertical line on other
1905 % Has up and down shapes for *all* notes
1907 def draw_Funk_do_head (expr width_factor, thickness_factor) =
1908 set_char_box (0, width_factor * solfa_base_notewidth#,
1909 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1912 offset := 2 * thickness_factor - 1;
1915 pen_radius := min (solfa_pen_radius,
1916 .3 * (h + d) / (1 + offset));
1918 pickup pencircle scaled (2 * pen_radius);
1929 x4 = x1 - pen_radius;
1930 y4 = y1 + offset * pen_radius;
1933 x5 = x2 + pen_radius;
1936 y6 = y3 - offset * pen_radius;
1938 save p_up_in, p_up_out, p_down_in, p_down_out;
1939 path p_up_in, p_up_out, p_down_in, p_down_out;
1941 p_down_in := z4{left}
1946 p_down_out := bot z1{left}
1953 p_up_in := p_down_in rotated 180 shifted (w,0);
1954 p_up_out := p_down_out rotated 180 shifted (w,0);
1959 save funk_do_weight;
1960 funk_do_weight := 1.7;
1962 fet_beginchar ("Whole up Funk dohead", "u0doFunk");
1963 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1969 fet_beginchar ("Whole down Funk dohead", "d0doFunk");
1970 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1976 fet_beginchar ("Half up Funk dohead", "u1doFunk");
1977 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1983 fet_beginchar ("Half down Funk dohead", "d1doFunk");
1984 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1990 fet_beginchar ("Quarter up Funk dohead", "u2doFunk");
1991 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1996 fet_beginchar ("Quarter down Funk dohead", "d2doFunk");
1997 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
2004 % Has up and down shapes for *all* notes
2006 def draw_Funk_re_head (expr width_factor, thickness_factor) =
2007 set_char_box (0, width_factor * solfa_base_notewidth#,
2008 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2011 offset := 2 * thickness_factor - 1;
2014 pen_radius := min (solfa_pen_radius,
2015 .3 * (h + d) / (1 + offset));
2017 pickup pencircle scaled (2 * pen_radius);
2028 x3 := curve_in [x1, x2];
2036 save ne, se, ne_perp, se_perp;
2037 pair ne, se, ne_perp, se_perp;
2039 ne := unitvector (z2 - z1);
2040 se := unitvector (z4 - z1);
2041 ne_perp := ne rotated 90;
2042 se_perp := se rotated 90;
2044 save path_a, path_b, path_c, path_d;
2045 path path_a, path_b, path_c, path_d;
2046 save arrow_a_perp, arrow_b_perp;
2047 pair arrow_a_perp, arrow_b_perp;
2050 path_d := z2 .. z3{down} .. z4;
2051 arrow_a_perp = unitvector (direction 0 of path_d rotated 90)
2053 arrow_b_perp = unitvector (direction 2 of path_d rotated 90)
2056 path_b := (z1 + se_perp * pen_radius)
2057 -- z4 + se_perp * offset * pen_radius;
2058 path_a := (z1 - ne_perp * pen_radius)
2059 -- z2 - ne_perp * offset * pen_radius;
2060 path_c := z2 - arrow_a_perp
2062 .. z4 - arrow_b_perp;
2064 z5 = path_a intersectionpoint path_b;
2065 z7 = path_a intersectionpoint path_c;
2066 z8 = path_b intersectionpoint path_c;
2068 save p_up_in, p_down_in, p_up_out, p_down_out;
2069 path p_up_in, p_down_in, p_up_out, p_down_out;
2077 p_down_out := lft z1{up}
2078 .. (z1 + ne_perp * pen_radius){ne}
2079 -- (z2 + ne_perp * pen_radius){ne}
2082 .. (z2 + arrow_a_perp)
2084 .. (z4 + arrow_b_perp)
2087 .. z4 - se_perp * pen_radius
2088 -- z1 - se_perp * pen_radius
2091 p_up_in := p_down_in rotated 180 shifted (w, 0);
2092 p_up_out := p_down_out rotated 180 shifted (w, 0);
2097 save funk_re_weight;
2098 funk_re_weight = 1.7;
2100 fet_beginchar ("Whole up Funk rehead", "u0reFunk");
2101 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2107 fet_beginchar ("Whole down Funk rehead", "d0reFunk");
2108 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2114 fet_beginchar ("Half up Funk rehead", "u1reFunk");
2115 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2121 fet_beginchar ("Half down Funk rehead", "d1reFunk");
2122 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2128 fet_beginchar ("Quarter up Funk rehead", "u2reFunk");
2129 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2134 fet_beginchar ("Quarter down Funk rehead", "d2reFunk");
2135 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2142 % Has up and down shapes for all hollow notes
2144 save funk_mi_width, funk_mi_weight;
2145 funk_mi_width := 1.2;
2146 funk_mi_weight := 1.9;
2148 fet_beginchar ("Whole up Funk mihead", "u0miFunk");
2149 draw_mi_head (funk_mi_width * funk_notehead_width,
2150 funk_mi_weight, false);
2156 fet_beginchar ("Whole down Funk mihead", "d0miFunk");
2157 draw_mi_head (funk_mi_width * funk_notehead_width,
2158 funk_mi_weight, true);
2164 fet_beginchar ("Half up Funk mihead", "u1miFunk");
2165 draw_mi_head (funk_mi_width * funk_notehead_width,
2166 funk_mi_weight, false);
2172 fet_beginchar ("Half down Funk mihead", "d1miFunk");
2173 draw_mi_head (funk_mi_width * funk_notehead_width,
2174 funk_mi_weight, true);
2180 fet_beginchar ("Quarter Funk mihead", "s2miFunk");
2181 draw_mi_head (funk_mi_width * funk_notehead_width,
2182 funk_mi_weight, false);
2189 % Does it rotate for whole notes?
2190 % Same as other shape note systems
2191 % Need special notes because of special width
2193 save funk_fa_weight;
2194 funk_fa_weight := 1.9;
2196 fet_beginchar ("Whole up Funk fahead", "u0faFunk");
2197 draw_fa_head (funk_notehead_width, funk_fa_weight);
2203 fet_beginchar ("Whole down Funk fahead", "d0faFunk");
2204 draw_fa_head (funk_notehead_width, funk_fa_weight);
2210 fet_beginchar ("Half up Funk fahead", "u1faFunk");
2211 draw_fa_head (funk_notehead_width, funk_fa_weight);
2217 fet_beginchar ("Half down Funk fahead", "d1faFunk");
2218 draw_fa_head (funk_notehead_width, funk_fa_weight);
2224 fet_beginchar ("Quarter up Funk fahead", "u2faFunk");
2225 draw_fa_head (funk_notehead_width, funk_fa_weight);
2230 fet_beginchar ("Quarter down Funk fahead", "d2faFunk");
2231 draw_fa_head (funk_notehead_width, funk_fa_weight);
2236 %%%%%% Funk sol head is the same as the others
2237 % Need special character because of skinnier head
2239 def draw_Funk_sol_head (expr filled) =
2242 noteheight# := solfa_noteheight#;
2243 draw_outside_ellipse (1.2, 34, 0.71, 0.);
2245 undraw_inside_ellipse (1.9, 33, 0.74, 5.5 stafflinethickness#);
2247 draw_staff (-2, 2, 0);
2252 fet_beginchar ("Whole Funk solhead", "s0solFunk");
2253 draw_Funk_sol_head ( false);
2257 fet_beginchar ("Half Funk solhead", "s1solFunk");
2258 draw_Funk_sol_head ( false);
2262 fet_beginchar ("Quarter Funk solhead", "s2solFunk");
2263 draw_Funk_sol_head ( true);
2269 % Same as for other shape notes
2270 % Smaller width requires special characters
2272 save funk_la_weight;
2273 funk_la_weight := 1.9;
2275 fet_beginchar ("Whole Funk lahead", "s0laFunk");
2276 draw_la_head (funk_notehead_width, funk_notehead_width);
2282 fet_beginchar ("Half Funk lahead", "s1laFunk");
2283 draw_la_head (funk_notehead_width, funk_notehead_width);
2289 fet_beginchar ("Quarter Funk lahead", "s2laFunk");
2290 draw_la_head (funk_notehead_width, funk_notehead_width);
2296 % `Sideways snow cone'.
2297 % Rotates for all notes.
2299 def draw_Funk_ti_head (expr width_factor, thickness_factor) =
2300 set_char_box (0, width_factor * solfa_base_notewidth#,
2301 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2306 offset := 2 * thickness_factor - 1;
2309 pen_radius := min (solfa_pen_radius,
2310 .33 * (h + d) / (1 + offset));
2312 pickup pencircle scaled (2 * pen_radius);
2317 x2 = cone_width [x1, x3];
2326 save nw_dist, sw_dist, ne, se;
2327 pair nw_dist, sw_dist, ne, se;
2329 ne = unitvector (z2 - z1);
2330 se = unitvector (z4 - z1);
2332 nw_dist = (ne rotated 90) * pen_radius ;
2333 sw_dist = (se rotated -90) * pen_radius;
2335 save path_a, path_b;
2336 path path_a, path_b;
2337 path_a := z1 - nw_dist
2338 -- z2 - offset * nw_dist;
2339 path_b := z1 - sw_dist
2340 -- z4 - offset * sw_dist;
2342 save path_right, path_right_in;
2343 path path_right, path_right_in;
2344 path_right := (z2 + ne * pen_radius)
2346 .. (z4 + se * pen_radius);
2348 path_right_in := (z2 - ne * pen_radius)
2350 .. (z4 - se * pen_radius);
2352 z5 = path_a intersectionpoint path_b;
2353 z6 = path_a intersectionpoint path_right_in;
2354 z7 = path_b intersectionpoint path_right_in;
2356 save p_up_in, p_down_in, p_up_out, p_down_out;
2357 path p_up_in, p_down_in, p_up_out, p_down_out;
2365 p_down_out := lft z1
2369 .. (z2 + ne * pen_radius){direction 0 of path_right}
2371 & {direction infinity of path_right}(z4 + se * pen_radius)
2377 p_up_in := p_down_in rotated 180 shifted (w, 0);
2378 p_up_out := p_down_out rotated 180 shifted (w, 0);
2382 save funk_ti_weight;
2383 funk_ti_weight := 1.6;
2385 fet_beginchar ("Whole up Funk tihead", "u0tiFunk");
2386 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2392 fet_beginchar ("Whole down Funk tihead", "d0tiFunk");
2393 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2399 fet_beginchar ("Half up Funk tihead", "u1tiFunk");
2400 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2406 fet_beginchar ("Half down Funk tihead", "d1tiFunk");
2407 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2413 fet_beginchar ("Quarter up Funk tihead", "u2tiFunk");
2414 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2419 fet_beginchar ("Quarter down Funk tihead", "d2tiFunk");
2420 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2425 %%%%%% Walker shape note heads
2427 % Walker heads are narrow like Funk heads, so use funk_notehead_width.
2430 %%%%%% Walker do head
2432 % Trapezoid, with largest side on stem side
2434 def draw_Walker_do_head (expr width_factor, dir, thickness_factor) =
2435 set_char_box (0, width_factor * solfa_base_notewidth#,
2436 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2438 pickup pencircle scaled solfa_pen_thick;
2441 offset := 2 * thickness_factor - 1;
2443 % adjust width so stem can be centered
2444 if .5w <> good.x .5w: change_width; fi
2448 scaling# = charwd / w;
2453 x1 = inset [x4, x3];
2456 x2 = inset [x3, x4];
2465 labels (range 1 thru 4);
2467 save left_dir, left_perp, right_dir, right_perp;
2468 pair left_dir, left_perp, right_dir, right_perp;
2470 left_dir = unitvector(z1 - z4);
2471 left_perp = (left_dir rotated 90) * solfa_pen_radius;
2472 right_dir = unitvector(z3 - z2);
2473 right_perp = (right_dir rotated 90) * solfa_pen_radius;
2475 save path_a, path_b, path_c, path_d;
2476 path path_a, path_b, path_c, path_d;
2478 path_a := (z4 - left_perp)
2479 -- (z1 - left_perp);
2480 path_b := (z1 - (0, offset*solfa_pen_radius))
2481 -- (z2 - (0, offset*solfa_pen_radius));
2482 path_c := (z2 - right_perp)
2483 -- (z3 - right_perp);
2484 path_d := (z3 + (0, offset*solfa_pen_radius))
2485 -- (z4 + (0, offset*solfa_pen_radius));
2490 p_in := (path_a intersectionpoint path_b)
2491 -- (path_b intersectionpoint path_c)
2492 -- (path_c intersectionpoint path_d)
2493 -- (path_d intersectionpoint path_a)
2496 p_out := top z1{right}
2498 .. z2 + right_perp {right_dir}
2499 -- z3 + right_perp {right_dir}
2502 .. z4 + left_perp {left_dir}
2503 .. z1 + left_perp {left_dir}
2506 charwx := scaling# * (w/2 + solfa_pen_radius);
2507 charwy := scaling# * y2 ;
2510 p_in := p_in rotated 180 shifted (w,0);
2511 p_out := p_out rotated 180 shifted (w,0);
2516 save walker_do_weight;
2517 walker_do_weight := 1.5;
2519 fet_beginchar ("Whole Walker dohead", "s0doWalker");
2520 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2526 fet_beginchar ("Half up Walker dohead", "u1doWalker");
2527 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2533 fet_beginchar ("Half down Walker dohead", "d1doWalker");
2534 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2540 fet_beginchar ("Quarter up Walker dohead", "u2doWalker");
2541 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2546 fet_beginchar ("Quarter down Walker dohead", "d2doWalker");
2547 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2552 %%%%%% Walker re head
2553 % Parabolic on one side, shallow parabola on other
2554 % Has up and down shapes for *all* notes
2556 def draw_Walker_re_head (expr width_factor, thickness_factor) =
2557 set_char_box (0, width_factor * solfa_base_notewidth#,
2558 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2561 offset := 2 * thickness_factor - 1;
2564 pen_radius := min (solfa_pen_radius,
2565 .3 * (h + d) / (1 + offset));
2567 pickup pencircle scaled (2 * pen_radius);
2570 dish_factor := 0.20;
2581 x4 = dish_factor [x1, x2];
2585 y5 = y1 + offset * pen_radius;
2588 x6 = x2 + pen_radius;
2591 y7 = y3 - offset * pen_radius;
2594 x8 = x4 - pen_radius;
2596 save path_a, path_d;
2597 path path_a, path_d;
2599 save p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2600 pair p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2602 path_a := z3 .. z4{down} .. z1;
2604 p_a_start_dir := unitvector(direction 0 of path_a);
2605 p_a_end_dir := unitvector(direction infinity of path_a);
2606 p_a_start_perp := (p_a_start_dir rotated 90) * pen_radius;
2607 p_a_end_perp := (p_a_end_dir rotated 90) * pen_radius;
2609 path_d := (z3 - p_a_start_perp){p_a_start_dir}
2611 ..(z1 - p_a_end_perp){p_a_end_dir};
2613 save path_b, path_c;
2614 path path_b, path_c;
2616 path_b := z5 {left} .. z6{up};
2617 path_c := z7 {left} .. z6{down};
2619 z9 = path_d intersectionpoint path_b;
2620 z10 = path_d intersectionpoint path_c;
2622 labels (range 1 thru 4);
2624 save p_up_in, p_up_out, p_down_in, p_down_out;
2625 path p_up_in, p_up_out, p_down_in, p_down_out;
2628 ... {right} z10 {p_a_start_dir}
2630 .. {p_a_end_dir} z9 {left}
2633 p_down_out := lft z2{up}
2636 .. (z3 + p_a_start_perp){p_a_start_dir}
2638 .. (z1 + p_a_end_perp) {p_a_end_dir}
2643 p_up_in := p_down_in rotated 180 shifted (w,0);
2644 p_up_out := p_down_out rotated 180 shifted (w,0);
2648 save walker_re_weight;
2649 walker_re_weight := 1.2;
2651 fet_beginchar ("Whole Walker rehead", "s0reWalker");
2652 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2658 fet_beginchar ("Half up Walker rehead", "u1reWalker");
2659 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2665 fet_beginchar ("Half down Walker rehead", "d1reWalker");
2666 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2672 fet_beginchar ("Quarter up Walker rehead", "u2reWalker");
2673 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2678 fet_beginchar ("Quarter down Walker rehead", "d2reWalker");
2679 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2684 %%%%%% Walker mi head
2686 % Symmetric for all hollow notes
2688 save walker_mi_width, walker_mi_weight;
2689 walker_mi_width := 1.2;
2690 walker_mi_weight := 1.5;
2692 fet_beginchar ("Whole Walker mihead", "s0miWalker");
2693 draw_mi_head (walker_mi_width * funk_notehead_width,
2694 walker_mi_weight, true);
2700 fet_beginchar ("Half Walker mihead", "s1miWalker");
2701 draw_mi_head (walker_mi_width * funk_notehead_width,
2702 walker_mi_weight, true);
2708 fet_beginchar ("Quarter Walker mihead", "s2miWalker");
2709 draw_mi_head (walker_mi_width * funk_notehead_width,
2710 walker_mi_weight, true);
2717 % Does not rotate for whole notes
2718 % Whole rotation is different from Funk, so special notes
2720 %%%%%% Funk sol head is the same as the others
2721 % Need special character because of skinnier head
2723 save walker_fa_weight;
2724 walker_fa_weight := 1.5;
2726 fet_beginchar ("Whole Walker fahead", "s0faWalker");
2727 draw_fa_head (funk_notehead_width, walker_fa_weight);
2733 fet_beginchar ("Half up Walker fahead", "u1faWalker");
2734 draw_fa_head (funk_notehead_width, walker_fa_weight);
2740 fet_beginchar ("Half down Walker fahead", "d1faWalker");
2741 draw_fa_head (funk_notehead_width, walker_fa_weight);
2747 fet_beginchar ("Quarter up Walker fahead", "u2faWalker");
2748 draw_fa_head (funk_notehead_width, walker_fa_weight);
2753 fet_beginchar ("Quarter down Walker fahead", "d2faWalker");
2754 draw_fa_head (funk_notehead_width, walker_fa_weight);
2760 % Same as Funk, no special notes
2763 %%%%%% Walker la head
2765 % Lighter weight requires separate notes
2767 save walker_la_weight;
2768 walker_la_weight := 1.5;
2770 fet_beginchar ("Whole Walker lahead", "s0laWalker");
2771 draw_la_head (funk_notehead_width, walker_la_weight);
2777 fet_beginchar ("Half Funk lahead", "s1laWalker");
2778 draw_la_head (funk_notehead_width, walker_la_weight);
2784 fet_beginchar ("Quarter Funk lahead", "s2laWalker");
2785 draw_la_head (funk_notehead_width, walker_la_weight);
2790 %%%%%% Walker ti head
2791 % Triangular arrowhead
2792 % Rotates for all but whole notes
2794 def draw_Walker_ti_head (expr width_factor, thickness_factor) =
2795 set_char_box (0, width_factor * solfa_base_notewidth#,
2796 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2799 offset := 2 * thickness_factor - 1;
2802 pen_radius := min (solfa_pen_radius,
2803 .3 * (h + d) / (1 + offset));
2805 pickup pencircle scaled (2 * pen_radius);
2817 labels (range 1 thru 4);
2819 save nw_dist, sw_dist, ne, se;
2820 pair nw_dist, sw_dist, ne, se;
2822 ne = unitvector (z2 - z1);
2823 se = unitvector (z3 - z1);
2825 nw_dist = (ne rotated 90) * pen_radius ;
2826 sw_dist = (se rotated -90) * pen_radius;
2829 save path_a, path_b, path_c;
2830 path path_a, path_b, path_c;
2831 path_a := z2 - nw_dist * offset
2832 -- z1 - nw_dist * offset;
2833 path_b := z3 - sw_dist * offset
2834 -- z1 - sw_dist * offset;
2835 path_c := z2 + left * pen_radius
2836 -- z3 + left * pen_radius;
2838 z4 = path_a intersectionpoint path_b;
2839 z5 = path_a intersectionpoint path_c;
2840 z6 = path_b intersectionpoint path_c;
2842 save p_up_in, p_down_in, p_up_out, p_down_out;
2843 path p_up_in, p_down_in, p_up_out, p_down_out;
2850 p_down_out := lft z1{up}
2851 .. (z1 + nw_dist){ne}
2852 -- (z2 + nw_dist){ne}
2857 .. (z3 + sw_dist){- se}
2858 .. (z1 + sw_dist){- se}
2861 p_up_in := p_down_in rotated 180 shifted (w, 0);
2862 p_up_out := p_down_out rotated 180 shifted (w, 0);
2866 save walker_ti_weight;
2867 walker_ti_weight := 1.4;
2869 fet_beginchar ("Whole Walker tihead", "s0tiWalker");
2870 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2876 fet_beginchar ("Half up Walker tihead", "u1tiWalker");
2877 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2883 fet_beginchar ("Half down Walker tihead", "d1tiWalker");
2884 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2890 fet_beginchar ("Quarter up Walker tihead", "u2tiWalker");
2891 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2896 fet_beginchar ("Quarter down Walker tihead", "d2tiWalker");
2897 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2901 fet_endgroup ("noteheads");
2905 % we derive black_notehead_width# from the quarter head,
2906 % so we have to define black_notehead_width (pixel qty)
2907 % after the black_notehead_width# itself.
2909 % Let's keep it outside the group as well.
2912 define_pixels (black_notehead_width);