]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-bolletjes.mf
(overdone_heads): add small style (ugly)
[lilypond.git] / mf / feta-bolletjes.mf
1 %  -*-Fundamental-*-
2 % feta-bolletjes.mf --  implement noteheads
3 %
4 % source file of LilyPond's pretty-but-neat music font
5 %
6 % (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@xs4all.nl>
8 % & Juergen Reuter <reuter@ipd.uka.de>
9 %
10
11 test_outlines := 0;
12
13
14 save remember_pic;
15 picture remember_pic;
16
17
18 % Most beautiful noteheads are pronounced, not circular,
19 % and not even symmetric.
20 % These examples are inspired by [Wanske]; see literature list.
21
22
23
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 % NOTE HEAD VARIABLES
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 save black_notehead_width, noteheight;
29 save slash_thick, slash_slope, overdone_heads, solfa_noteheight;
30 numeric black_notehead_width, noteheight, slash_thick;
31
32
33 fet_begingroup ("noteheads");
34
35
36 % Slope of slash.  From scm/grob-description.scm.  How to auto-copy?
37 slash_slope := 1.7;
38
39 % Thickness of slash lines.  Quarter notes get 1.5slt width.
40 slash_thick# := 2/3 * 0.48 staff_space#;
41
42
43 %
44 % Hand-engraved music often has balls extending above and below
45 % the lines.  If you like that, modify overdone heads (unit:
46 % stafflinethickness).
47 %
48 overdone_heads = 0.0;
49 noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;
50
51
52 %
53 % solfa heads should not overlap on chords.
54 %
55 solfa_noteheight# := staff_space# - stafflinethickness#;
56
57 define_pixels (slash_thick);
58 define_whole_vertical_pixels (noteheight);
59
60
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 %
63 % SLANT moves both extrema on the long axis (by SLANT * ELLIPTICITY,
64 % so SLANT = -1, puts the extreme on the long axis next to the short
65 % axis one).
66 %
67
68 def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
69         save attachment_y;
70         save pat;
71         path pat;
72
73         pat := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
74                              (-ellipticity, 0), (slant * ellipticity, -1.0),
75                              superness);
76         pat := pat rotated tilt;
77
78         save top_point, right_point;
79         pair top_point, right_point;
80
81         top_point := directionpoint left of pat;
82         right_point := directionpoint up of pat;
83
84         save scaling, width;
85
86         scaling# = noteheight# / (2 ypart (top_point));
87         width# := 2 xpart (right_point) * scaling#;
88         define_pixels (scaling, width);
89
90         set_char_box (0, width#, noteheight# / 2, noteheight# / 2);
91
92         d := d - feta_space_shift;
93
94         % attachment Y
95         charwy := ypart (right_point) * scaling#;
96         charwx := width#;
97
98         pat := pat scaled scaling shifted (w / 2, .5 (h - d));
99
100         width := hround width;
101
102         if test_outlines = 1:
103                 draw pat;
104         else:
105                 fill pat;
106         fi;
107 enddef;
108
109
110 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
111 begingroup
112         save pat;
113         path pat;
114
115         pat := superellipse ((ellipticity, 0), (0, 1.0),
116                              (-ellipticity, 0), (0, -1.0),
117                              superness);
118         pat := pat rotated tilt;
119
120         save top_point, right_point;
121         pair top_point, right_point;
122
123         top_point := directionpoint left of pat;
124         right_point := directionpoint up of pat;
125
126         save height, scaling;
127
128         height# = staff_space# + stafflinethickness# - clearance;
129         scaling# = height# / (2 ypart (top_point));
130         define_pixels (scaling);
131         pat := pat scaled scaling shifted (w / 2, .5 (h - d));
132
133         if test_outlines = 1:
134                 draw pat;
135         else:
136                 unfill pat;
137         fi
138 endgroup;
139 enddef;
140
141
142 %
143 % dimensions aren't entirely right.
144 %
145 def draw_brevis =
146         save stemthick, fudge;
147
148         stemthick# = 2 stafflinethickness#;
149         define_whole_blacker_pixels (stemthick);
150
151         fudge = hround (blot_diameter / 2);
152
153         draw_outside_ellipse (1.80, 0, 0.707, 0);
154         undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
155
156         pickup pencircle scaled stemthick;
157
158         bot y1 = -d;
159         top y2 = h;
160         rt x1 - fudge = 0;
161         x1 = x2;
162
163         fudge + lft x3 = w;
164         x4 = x3;
165         y4 = y2;
166         y3 = y1;
167
168         draw_gridline (z1, z2, stemthick);
169         draw_gridline (z3, z4, stemthick);
170 enddef;
171
172
173 fet_beginchar ("Brevis notehead", "s-1");
174         draw_brevis;
175
176         draw_staff (-2, 2, 0);
177 fet_endchar;
178
179
180 if test > 0:
181         fet_beginchar ("Brevis notehead", "s-1");
182                 draw_brevis;
183
184                 draw_staff (-2, 2, 0.5);
185         fet_endchar;
186 fi;
187
188
189 fet_beginchar ("Whole notehead", "s0");
190         draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
191         undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
192                                0.68, 2 stafflinethickness#);
193
194         draw_staff (-2, 2, 0);
195 fet_endchar;
196
197
198 if test > 0:
199         fet_beginchar ("Whole notehead", "s0");
200                 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
201                                       0.707, 0);
202                 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
203                                        0.68, 2 stafflinethickness#);
204
205                 draw_staff (-2, 2, 0.5);
206         fet_endchar;
207 fi;
208
209
210
211
212 fet_beginchar ("Half notehead", "s1");
213         draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
214         undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
215
216         draw_staff (-2, 2, 0);
217 fet_endchar;
218
219
220 if test > 0:
221         fet_beginchar ("Half notehead", "s1");
222                 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
223                                       0.66, 0.17);
224                 undraw_inside_ellipse (3.25, 33, 0.81,
225                                        2.5 stafflinethickness#);
226
227                 draw_staff (-2, 2, 0.5);
228         fet_endchar;
229 fi;
230
231
232 fet_beginchar ("Quart notehead", "s2");
233         % used to have 32. With 31, they are slightly bolder.
234         draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0);
235         black_notehead_width# := charwd;
236
237         draw_staff (-2, 2, 0);
238 fet_endchar;
239
240 if test > 0:
241         fet_beginchar ("Quart notehead", "s2");
242                 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
243                                       0.707, 0);
244
245                 draw_staff (-2, 2, 0.5);
246         fet_endchar;
247 fi;
248
249
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251
252
253 fet_beginchar ("Whole diamondhead", "s0diamond");
254         draw_outside_ellipse (1.80, 0, 0.495, 0);
255         undraw_inside_ellipse (1.30, 125, 0.6,
256                                .4 staff_space# + stafflinethickness#);
257
258         draw_staff (-2, 2, 0);
259 fet_endchar;
260
261
262 if test > 0:
263         fet_beginchar ("Whole diamondhead", "s0diamond");
264                 draw_outside_ellipse (1.80, 0, 0.495, 0);
265                 undraw_inside_ellipse (1.30, 125, 0.6,
266                                        .4 staff_space# + stafflinethickness#);
267
268                 draw_staff (-2, 2, 0.5);
269         fet_endchar;
270 fi;
271
272
273 fet_beginchar ("Half diamondhead", "s1diamond");
274         draw_outside_ellipse (1.50, 34, 0.49, 0.17);
275         undraw_inside_ellipse (3.5, 33, 0.80,
276                                .3 staff_space# + 1.5 stafflinethickness#);
277
278         draw_staff (-2, 2, 0);
279 fet_endchar;
280
281
282 if test > 0:
283         fet_beginchar ("Half diamondhead", "s1diamond");
284                 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
285                 undraw_inside_ellipse (3.5, 33, 0.80,
286                                        .3 staff_space#
287                                        + 1.5 stafflinethickness#);
288
289                 draw_staff (-2, 2, 0.5);
290         fet_endchar;
291 fi;
292
293
294 fet_beginchar ("Quart diamondhead", "s2diamond");
295         draw_outside_ellipse (1.80, 35, 0.495, -0.25);
296
297         draw_staff (-2, 2, 0);
298 fet_endchar;
299
300
301 if test > 0:
302         fet_beginchar ("Quart diamondhead", "s2diamond");
303                 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
304
305                 draw_staff (-2, 2, 0.5);
306         fet_endchar;
307 fi;
308
309
310 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311
312
313 vardef penposx@# (expr d) = 
314 begingroup;
315         save pat;
316         path pat;
317
318         pat = top z@#
319               .. lft z@#
320               .. bot z@#
321               .. rt z@#
322               .. cycle;
323         z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
324         z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
325 endgroup
326 enddef;
327
328
329 def define_triangle_shape (expr stemdir) =
330         save triangle_a, triangle_b, triangle_c;
331         save triangle_out_a, triangle_out_b, triangle_out_c;
332         save triangle_in, triangle_out;
333         save width, depth, height;
334         save origin, left_up_dir;
335         save exact_left_point, exact_right_point, exact_down_point;
336
337         path triangle_a, triangle_b, triangle_c;
338         path triangle_out_a, triangle_out_b, triangle_out_c;
339         path triangle_in, triangle_out;
340         pair origin, left_up_dir;
341         pair exact_down_point, exact_left_point, exact_right_point;
342
343         save pen_thick;
344         pen_thick# = stafflinethickness# + .1 staff_space#;
345         define_pixels (llap);
346         define_blacker_pixels (pen_thick);
347
348         left_up_dir = llap# * dir (90 + tilt);
349
350         xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
351         ypart origin = 0;
352
353         exact_left_point := origin + (left_up_dir xscaled xs);
354         exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
355         exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
356
357         height# = ypart (exact_left_point + origin) + pen_thick# / 2;
358         depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
359         width# = xpart (exact_right_point - exact_left_point)
360                  + pen_thick# * xs;
361
362         set_char_box (0, width#, depth#, height#);
363
364         % Formerly, the shape has simply been drawn with an elliptical pen
365         % (`scaled pen_thick xsaled xs'), but the envelope of such a curve
366         % is of 6th degree.  For the sake of mf2pt1, we approximate it.
367
368         pickup pencircle scaled pen_thick xscaled xs;
369
370         z0 = (hround_pixels (xpart origin), 0);
371
372         z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
373         z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
374         z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
375
376         z12 = caveness [.5[z1, z2], z3];
377         z23 = caveness [.5[z2, z3], z1];
378         z31 = caveness [.5[z3, z1], z2];
379
380         triangle_a = z1 .. z12 .. z2;
381         triangle_b = z2 .. z23 .. z3;
382         triangle_c = z3 .. z31 .. z1;
383
384         penposx1 (angle (direction 0 of triangle_a) - 90);
385         penposx2 (angle (direction 0 of triangle_b) - 90);
386         penposx3 (angle (direction 0 of triangle_c) - 90);
387
388         penposx1' (angle (direction infinity of triangle_c) + 90);
389         penposx2' (angle (direction infinity of triangle_a) + 90);
390         penposx3' (angle (direction infinity of triangle_b) + 90);
391
392         penposx12 (angle (z12 - z0));
393         penposx23 (angle (z23 - z0));
394         penposx31 (angle (z31 - z0));
395
396         z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
397         z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
398         z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
399
400         triangle_in = z10
401                       .. z12l
402                       .. z20
403                       & z20
404                       .. z23l
405                       .. z30
406                       & z30
407                       .. z31l
408                       .. z10
409                       & cycle;
410
411         triangle_out_a = z1r .. z12r .. z2'l;
412         triangle_out_b = z2r .. z23r .. z3'l;
413         triangle_out_c = z3r .. z31r .. z1'l;
414
415         triangle_out = top z1
416                        .. lft z1
417                        .. z1r{direction 0 of triangle_out_a}
418                        & triangle_out_a
419                        & {direction infinity of triangle_out_a}z2'l
420                        .. lft z2
421                        .. bot z2
422                        .. z2r{direction 0 of triangle_out_b}
423                        & triangle_out_b
424                        & {direction infinity of triangle_out_b}z3'l
425                        .. rt z3
426                        .. top z3
427                        .. z3r{direction 0 of triangle_out_c}
428                        & triangle_out_c
429                        & {direction infinity of triangle_out_c}z1'l
430                        .. cycle;
431
432         labels (0, 10, 20, 30);
433         penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
434
435         % attachment Y
436         if stemdir = 1:
437                 charwy := ypart exact_right_point;
438                 charwx := xpart exact_right_point;
439         else:
440                 charwy := -ypart exact_down_point;
441                 charwx := (width# - xpart exact_down_point);
442         fi
443 enddef;
444
445
446 def draw_whole_triangle_head =
447         save hei, xs;
448         save llap;
449         save tilt;
450
451         tilt = 40;
452         llap# = 3/4 noteheight#;
453
454         xs = 1.5;
455         caveness := 0.1;
456         define_triangle_shape (1);
457         fill triangle_out;
458         unfill triangle_in;
459 enddef;
460
461
462 fet_beginchar ("Whole trianglehead", "s0triangle");
463         draw_whole_triangle_head;
464
465         draw_staff (-2, 2, 0);
466 fet_endchar;
467
468
469 if test > 0:
470         fet_beginchar ("Whole trianglehead", "s0triangle");
471                 draw_whole_triangle_head;
472
473                 draw_staff (-2, 2, 0.5);
474         fet_endchar;
475 fi;
476
477
478 def draw_small_triangle_head (expr dir) =
479         save hei, xs;
480         save llap;
481         save tilt;
482
483         tilt = 40;
484         llap# = 2/3 noteheight#;
485         xs = 1.2;
486         caveness := 0.1;
487         define_triangle_shape (dir);
488
489         pickup feta_fillpen;
490
491         filldraw triangle_out;
492         unfilldraw triangle_in;
493 enddef;
494
495
496 fet_beginchar ("Half trianglehead", "d1triangle");
497         draw_small_triangle_head (-1);
498
499         draw_staff (-2, 2, 0);
500 fet_endchar;
501
502
503 fet_beginchar ("Half trianglehead", "u1triangle");
504         draw_small_triangle_head (1);
505
506         draw_staff (-2, 2, 0.5);
507 fet_endchar;
508
509
510 def draw_closed_triangle_head (expr dir) =
511         save hei, xs;
512         save llap;
513         save tilt;
514
515         tilt = 40;
516         llap# = 2/3 noteheight#;
517         xs = 1.0;
518         caveness := 0.1;
519         define_triangle_shape (dir);
520         fill triangle_out;
521 enddef;
522
523
524 fet_beginchar ("Quart trianglehead", "u2triangle");
525         draw_closed_triangle_head (1);
526
527         draw_staff (-2, 2, 0);
528 fet_endchar;
529
530
531 fet_beginchar ("Quart trianglehead", "d2triangle");
532         draw_closed_triangle_head (-1);
533
534         draw_staff (-2, 2, 0.5);
535 fet_endchar;
536
537
538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
539 %
540 % Slash heads are for indicating improvisation.  They are
541 % twice as high as normal heads.
542 %
543 def draw_slash (expr hwid_hash) =
544         save exact_height;
545         save ne, nw_dist;
546         pair ne, nw_dist;
547         exact_height = staff_space# + stafflinethickness# / 2;
548
549         set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
550                       exact_height, exact_height);
551
552         charwx := charwd;
553         charwy := charht;
554
555         clearxy;
556
557         d := d - feta_shift;
558
559         pickup pencircle scaled blot_diameter;
560
561         bot y1 = -d;
562         top y2 = h;
563         lft x1 = 0;
564         lft x2 = 2 h / slash_slope;
565
566         rt x3 = w;
567         y3 = y2;
568         y4 = y1;
569         x3 - x2 = x4 - x1;
570
571         ne = unitvector (z3 - z4);
572         nw_dist = (ne rotated 90) * 0.5 blot_diameter;
573
574         fill bot z1{left}
575              .. (z1 + nw_dist){ne}
576              -- (z2 + nw_dist){ne}
577              .. top z2{right}
578              -- top z3{right}
579              .. (z3 - nw_dist){-ne}
580              -- (z4 - nw_dist){-ne}
581              .. bot z4{left}
582              -- cycle;
583
584         if hwid_hash > 2 slash_thick#:
585                 save th;
586
587                 th = slash_thick - blot_diameter;
588                 y6 = y7;
589                 y5 = y8;
590                 y3 - y7 = th;
591                 y5 - y1 = th;
592                 z6 - z5 = whatever * ne;
593                 z8 - z7 = whatever * ne;
594
595                 z5 = z1 + whatever * ne + th * (ne rotated -90);
596                 z8 = z4 + whatever * ne + th * (ne rotated 90);
597
598                 unfill z5
599                        -- z6
600                        -- z7
601                        -- z8
602                        -- cycle;
603         fi
604         labels (range 1 thru 10);
605 enddef;
606
607
608 fet_beginchar ("Whole slashhead", "s0slash");
609         draw_slash (4 slash_thick# + 0.5 staff_space#);
610
611         draw_staff (-2, 2, 0);
612 fet_endchar;
613
614
615 fet_beginchar ("Half slashhead", "s1slash");
616         draw_slash (3.0 slash_thick# + 0.15 staff_space#);
617
618         draw_staff (-2, 2, 0);
619 fet_endchar;
620
621
622 fet_beginchar ("Quart slashhead", "s2slash");
623         draw_slash (1.5 slash_thick#);
624
625         draw_staff (-2, 2, 0);
626 fet_endchar;
627
628
629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 %
631 % `thick' is the distance between the NE/SW parallel lines in the cross
632 % (distance between centres of lines) in multiples of stafflinethickness
633 %
634 def draw_cross (expr thick) =
635         save ne, nw;
636         save ne_dist, nw_dist, rt_dist, up_dist;
637         save crz_in, crz_out;
638         save thickness;
639         pair ne, nw;
640         pair ne_dist, nw_dist, rt_dist, up_dist;
641         path crz_in, crz_out;
642
643         pen_thick# := 1.2 stafflinethickness#;
644         thickness# := thick * stafflinethickness#;
645         define_pixels (thickness);
646         define_blacker_pixels (pen_thick);
647
648         pickup pencircle scaled pen_thick;
649
650         h := h - feta_shift;
651
652         top y3 = h;
653         ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
654         rt x4 = w / 2;
655         y5 = 0;
656         z4 - z5 = whatever * ne;
657         x6 = 0;
658         z6 - z3 = whatever * ne;
659         z3 - z4 = whatever * (ne yscaled -1);
660
661         z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
662
663
664         x1 = charwd / 2 - .5 pen_thick#;
665         z1 = whatever * ne
666              + thick / 2 * stafflinethickness# * (ne rotated -90);
667
668         % labels (1, 2, 3, 4, 5, 6);
669
670         nw = unitvector (z3 - z4);
671
672         up_dist = up * 0.5 pen_thick / cosd (angle (ne));
673         rt_dist = right * 0.5 pen_thick / sind (angle (ne));
674         nw_dist = (ne rotated 90) * 0.5 pen_thick;
675         ne_dist = (nw rotated -90) * 0.5 pen_thick;
676
677         x4' := x4;
678         x5' := x5;
679         y6' := y6;
680
681         x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
682         x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
683         y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
684
685         crz_out = (z6 + up_dist)
686                   -- (z3 + nw_dist){ne}
687                   .. (top z3)
688                   .. (z3 + ne_dist){-nw}
689                   -- (z4 + ne_dist){-nw}
690                   .. (rt z4)
691                   .. (z4 - nw_dist){-ne}
692                   -- (z5 + rt_dist);
693         crz_out := crz_out shifted (0, feta_shift)
694                    -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
695         fill crz_out
696              -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
697              -- cycle;
698
699         if (thick > 1):
700                 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
701                 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
702                 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
703
704                 crz_in = (bot z6){right}
705                          .. (z6 - nw_dist){ne}
706                          -- (z3 - up_dist)
707                          -- (z4 - rt_dist)
708                          -- (z5 + nw_dist){-ne}
709                          .. {down}(lft z5);
710                 crz_in := crz_in shifted (0, feta_shift)
711                           -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
712                 unfill crz_in
713                        -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
714                        -- cycle;
715         fi
716
717         % ugh
718         currentpicture := currentpicture shifted (hround (w / 2), 0);
719
720         charwx := charwd;
721         charwy := y1 + feta_shift;
722
723         z12 = (charwx * hppp, y1 * vppp);
724
725         labels (12);
726 enddef;
727
728
729 fet_beginchar ("Whole Crossed notehead", "s0cross");
730         save wid, hei;
731
732         wid# := black_notehead_width# + 4 stafflinethickness#;
733         hei# := noteheight# + stafflinethickness#;
734
735         set_char_box (0, wid#, hei# / 2, hei# / 2);
736
737         draw_cross (3.75);
738
739         remember_pic := currentpicture;
740
741         draw_staff (-2, 2, 0);
742 fet_endchar;
743
744
745 if test > 0:
746         fet_beginchar ("Whole Crossed notehead", "s0cross");
747                 save wid, hei;
748
749                 wid# := black_notehead_width# + 4 stafflinethickness#;
750                 hei# := noteheight# + stafflinethickness#;
751
752                 set_char_box (0, wid#, hei# / 2, hei# / 2);
753
754                 currentpicture := remember_pic;
755
756                 draw_staff (-2, 2, 0.5);
757         fet_endchar;
758 fi;
759
760
761 fet_beginchar ("Half Crossed notehead", "s1cross");
762         save wid, hei;
763
764         wid# := black_notehead_width# + 2 stafflinethickness#;
765         hei# := noteheight# + stafflinethickness# / 2;
766
767         set_char_box (0, wid#, hei# / 2, hei# / 2);
768
769         draw_cross (3.0);
770
771         remember_pic := currentpicture;
772
773         draw_staff (-2, 2, 0);
774 fet_endchar;
775
776
777 if test > 0:
778         fet_beginchar ("Half Crossed notehead", "s1cross");
779                 save wid, hei;
780
781                 wid# := black_notehead_width# + 2 stafflinethickness#;
782                 hei# := noteheight# + stafflinethickness# / 2;
783
784                 set_char_box (0, wid#, hei# / 2, hei# / 2);
785
786                 currentpicture := remember_pic;
787
788                 draw_staff (-2, 2, 0.5);
789         fet_endchar;
790 fi;
791
792
793 fet_beginchar ("Crossed notehead", "s2cross");
794         wid# := black_notehead_width#;
795         hei# := noteheight#;
796         set_char_box (0, wid#, hei# / 2, hei# / 2);
797
798         draw_cross (1.0);
799
800         remember_pic := currentpicture;
801
802         draw_staff (-2, 2, 0);
803 fet_endchar;
804
805
806 if test > 0:
807         fet_beginchar ("Crossed notehead", "s2cross");
808                 wid# := black_notehead_width#;
809                 hei# := noteheight#;
810                 set_char_box (0, wid#, hei# / 2, hei# / 2);
811
812                 currentpicture := remember_pic;
813
814                 draw_staff (-2, 2, 0.5);
815         fet_endchar;
816 fi;
817
818
819 fet_beginchar ("X-Circled notehead", "s2xcircle");
820         save wid, hei;
821         save cthick, cxd, cyd, dy;
822
823         wid# := black_notehead_width# * sqrt (sqrt2);
824         hei# := noteheight# * sqrt (sqrt2);
825
826         set_char_box (0, wid#, hei# / 2, hei# / 2);
827
828         d := d - feta_space_shift;
829
830         cthick# := (1.2 + 1/4) * stafflinethickness#;
831         define_blacker_pixels (cthick);
832
833         cxd := w - cthick;
834         cyd := h + d - cthick / 2;
835
836         dy = .5 (h - d);
837
838         pickup pencircle scaled cthick;
839
840         fill fullcircle xscaled (cxd + cthick)
841                         yscaled (cyd + cthick)
842                         shifted (w / 2, dy);
843         unfill fullcircle xscaled (cxd - cthick)
844                           yscaled (cyd - cthick)
845                           shifted (w / 2, dy);
846
847         xpos := .5 cxd / sqrt2;
848         ypos := .5 cyd / sqrt2;
849
850         pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
851         draw (-xpos + w / 2, -ypos + dy) -- (xpos + w / 2, ypos + dy);
852
853         pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
854         draw (-xpos + w / 2, ypos + dy) -- (xpos + w / 2, -ypos + dy);
855
856         charwx := charwd;
857         charwy := 0;
858
859         z12 = (charwx * hppp, charwy * vppp);
860         labels (12);
861
862         remember_pic := currentpicture;
863
864         draw_staff (-2, 2, 0);
865 fet_endchar;
866
867
868 if test > 0:
869         fet_beginchar ("X-Circled notehead", "s2xcircle");
870                 save wid, hei;
871                 save cthick, cxr, cyr;
872
873                 wid# := black_notehead_width# * sqrt (sqrt2);
874                 hei# := noteheight# * sqrt (sqrt2);
875
876                 set_char_box (0, wid#, hei# / 2, hei# / 2);
877
878                 currentpicture := remember_pic;
879
880                 draw_staff (-2, 2, 0.5);
881         fet_endchar;
882 fi;
883
884
885 %%%%%%%%
886 %
887 % SOLFA SHAPED NOTES
888 %
889
890 save solfa_pen_thick;
891 solfa_pen_thick# = 2 stafflinethickness#;
892 define_blacker_pixels (solfa_pen_thick);
893
894
895 solfa_whole_width := 1.8;
896 solfa_half_width := 1.35;
897 solfa_quarter_width := 1.35;
898
899
900 def draw_do_head (expr width_factor, dir) =
901         save p_in, p_out;
902         save left_dist, right_dist;
903         path p_in, p_out;
904         pair left_dist, right_dist;
905
906         set_char_box (0, width_factor * solfa_noteheight#,
907                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
908
909         pickup pencircle scaled solfa_pen_thick;
910
911         bot y1 = -d;
912         y1 = y2;
913         lft x1 = 0;
914         rt x2 = w;
915         top y3 = h;
916         x3 =.5 [x1, x2];
917
918         left_dist = (unitvector (z3 - z1) rotated 90) * 0.5 solfa_pen_thick;
919         right_dist = (unitvector (z2 - z3) rotated 90) * 0.5 solfa_pen_thick;
920
921         p_in := (((z1 - left_dist) -- (z3 - left_dist)) intersectionpoint
922                   (top z1 -- top z2))
923                 -- ((top z1 -- top z2) intersectionpoint
924                     ((z2 - right_dist) -- (z3 - right_dist)))
925                 -- (((z2 - right_dist) -- (z3 - right_dist)) intersectionpoint
926                     ((z1 - left_dist) -- (z3 - left_dist)))
927                 -- cycle;
928
929         p_out := bot z1
930                  -- bot z2{right}
931                  .. rt z2{up}
932                  .. (z2 + right_dist){z3 - z2}
933                  -- (z3 + right_dist){z3 - z2}
934                  .. top z3{left}
935                  .. (z3 + left_dist){z1 - z3}
936                  -- (z1 + left_dist){z1 - z3}
937                  .. lft z1{down}
938                  .. {right}cycle;
939                  
940
941         labels (1, 2, 3);
942
943         charwx := charwd;
944         charwy := -chardp + 0.5 stafflinethickness#;
945         if dir = -1:
946                 charwy := -charwy;
947         fi;
948 enddef;
949
950
951 fet_beginchar ("Whole dohead", "s0do");
952         draw_do_head (solfa_whole_width, 1);
953         fill p_out;
954         unfill p_in;
955 fet_endchar;
956
957
958 fet_beginchar ("Half dohead", "d1do");
959         draw_do_head (solfa_half_width, -1);
960         fill p_out;
961         unfill p_in;
962 fet_endchar;
963
964
965 fet_beginchar ("Half dohead", "u1do");
966         draw_do_head (solfa_half_width, 1);
967         fill p_out;
968         unfill p_in;
969 fet_endchar;
970
971
972 fet_beginchar ("Quart dohead", "d2do");
973         draw_do_head (solfa_quarter_width, -1);
974         fill p_out;
975 fet_endchar;
976
977
978 fet_beginchar ("Quart dohead", "u2do");
979         draw_do_head (solfa_quarter_width, 1);
980         fill p_out;
981 fet_endchar;
982
983
984 %
985 % re - flat top, curved bottom:
986 %                (0,h/2) {dir -90} .. (w/2,-h/2) .. {dir 90} (w,h/2) -- cycle;
987 % (broader along the base and with more vertical sides for half and
988 % whole notes)
989 % stem attachment: h/2
990 %
991
992 def draw_re_head (expr width_factor, dir) =
993         save p_in, p_out;
994         path p_in, p_out;
995
996         set_char_box (0, width_factor * solfa_noteheight#,
997                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
998
999         pickup pencircle scaled solfa_pen_thick;
1000
1001         save curve_start;
1002         curve_start = 0.7;
1003         lft x1 = 0;
1004         y1 = y5;
1005         x1 = x2;
1006         y2 = curve_start [y3, y1];
1007         bot y3 = -d;
1008         x3 = .5 [x2, x4];
1009         rt x4 = w;
1010         y4 = y2;
1011         top y5 = h;
1012         x5 = x4;
1013
1014         labels (range 1 thru 5);
1015
1016         p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1017                 -- rt z2{down}
1018                 .. top z3
1019                 .. lft z4{up}
1020                 -- (z5 + 0.5 solfa_pen_thick * (-1, -1))
1021                 -- cycle;
1022
1023         p_out := lft z1
1024                  -- lft z2{down}
1025                  .. bot z3
1026                  .. rt z4{up}
1027                  -- rt z5{up}
1028                  .. top z5{left}
1029                  -- top z1{left}
1030                  .. {down}cycle;
1031
1032         charwx := charwd;
1033         charwy := curve_start [-chardp, charht];
1034
1035         if dir = -1:
1036                 charwy := -charwy;
1037         fi;
1038 enddef;
1039
1040
1041 fet_beginchar ("Whole rehead", "s0re");
1042         draw_re_head (solfa_whole_width, 1);
1043         fill p_out;
1044         unfill p_in;
1045 fet_endchar;
1046
1047
1048 fet_beginchar ("Half up rehead", "u1re");
1049         draw_re_head (solfa_half_width, 1);
1050         fill p_out;
1051         unfill p_in;
1052 fet_endchar;
1053
1054
1055 fet_beginchar ("Half down rehead", "d1re");
1056         draw_re_head (solfa_half_width, -1);
1057         fill p_out;
1058         unfill p_in;
1059 fet_endchar;
1060
1061
1062 fet_beginchar ("Quart rehead", "u2re");
1063         draw_re_head (solfa_quarter_width, 1);
1064         fill p_out;
1065 fet_endchar;
1066
1067
1068 fet_beginchar ("Quart rehead", "d2re");
1069         draw_re_head (solfa_quarter_width, -1);
1070         fill p_out;
1071 fet_endchar;
1072
1073
1074 def draw_mi_head (expr width_factor) =
1075         save path_out, path_in;
1076         save ne_dist, se_dist, ne, se;
1077         path path_out, path_in;
1078         pair ne_dist, se_dist, ne, se;
1079
1080         set_char_box (0, width_factor * solfa_noteheight#,
1081                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1082
1083         pickup pencircle scaled solfa_pen_thick;
1084
1085         lft x1 = 0;
1086         y1 = 0;
1087         bot y2 = -d;
1088         x2 = .5 [x1, x3];
1089         rt x3 = w;
1090         x4 = x2;
1091         y3 = y1;
1092         top y4 = h;
1093
1094         z6 - z5 = whatever * (z2 - z1);
1095         z8 - z7 = whatever * (z2 - z1);
1096         z8 - z5 = whatever * (z4 - z1);
1097         z6 - z7 = whatever * (z4 - z1);
1098
1099         ne = unitvector (z4 - z1);
1100         se = unitvector (z1 - z2);
1101
1102         ne_dist = (ne rotated 90) * 0.5 solfa_pen_thick;
1103         se_dist = (se rotated 90) * 0.5 solfa_pen_thick;
1104
1105         z5 = whatever [z1, z4] - ne_dist;
1106         z5 = whatever [z1, z2] - 1.5 se_dist;
1107
1108         z5 - z1 = -(z7 - z3);
1109
1110         labels (range 1 thru 8);
1111
1112         path_in := z5
1113                    -- z6
1114                    -- z7
1115                    -- z8
1116                    -- cycle;
1117
1118         path_out := lft z1
1119                     .. (z1 + se_dist){-se}
1120                     -- (z2 + se_dist){-se}
1121                     .. bot z2
1122                     .. (z2 - ne_dist){ne}
1123                     -- (z3 - ne_dist){ne}
1124                     .. rt z3
1125                     .. (z3 - se_dist){se}
1126                     -- (z4 - se_dist){se}
1127                     .. top z4
1128                     .. (z4 + ne_dist){-ne}
1129                     -- (z1 + ne_dist){-ne}
1130                     .. cycle;
1131 enddef;
1132
1133
1134 fet_beginchar ("Whole mihead", "s0mi");
1135         draw_mi_head (solfa_whole_width);
1136         fill path_out;
1137         unfill path_in;
1138 fet_endchar;
1139
1140
1141 fet_beginchar ("Half mihead", "s1mi");
1142         draw_mi_head (solfa_quarter_width);
1143         fill path_out;
1144         unfill path_in;
1145 fet_endchar;
1146
1147
1148 fet_beginchar ("Quart mihead", "s2mi");
1149         draw_mi_head (solfa_quarter_width);
1150         fill path_out;
1151 fet_endchar;
1152
1153
1154 def draw_fa_head (expr width_factor) =
1155         set_char_box (0, width_factor * solfa_noteheight#,
1156                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1157
1158         save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1159         path p_down_in, p_down_out, p_up_in, p_up_out;
1160         pair nw_dist, nw;
1161
1162         pickup pencircle scaled solfa_pen_thick;
1163
1164         lft x1 = 0;
1165         top y1 = h;
1166
1167         rt x2 = w;
1168         y2 = y1;
1169         bot y3 = -d;
1170         x3 = x2;
1171
1172         y4 = y3;
1173         x4 = x1;
1174
1175         labels (1, 2, 3, 4);
1176
1177         nw = unitvector (z1 - z3);
1178         nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1179
1180         p_up_in := (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1181                      (bot z1 -- bot z2))
1182                    -- (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1183                         (lft z3 -- lft z2))
1184                    -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1185                    -- cycle;
1186
1187         p_up_out := lft z1{down}
1188                     .. (z1 + nw_dist){-nw}
1189                     -- (z3 + nw_dist){-nw}
1190                     .. bot z3{right}
1191                     .. rt z3{up}
1192                     -- rt z2{up}
1193                     .. top z2{left}
1194                     -- top z1{left}
1195                     .. {down}cycle;
1196
1197         p_down_in := p_up_in rotated 180 shifted (w, 0);
1198         p_down_out := p_up_out rotated 180 shifted (w, 0);
1199
1200         charwy := 0.0;
1201         charwx := charwd;
1202 enddef;
1203
1204
1205 fet_beginchar ("Whole fa up head", "u0fa");
1206         draw_fa_head (solfa_whole_width);
1207         fill p_up_out;
1208         unfill p_up_in;
1209 fet_endchar;
1210
1211
1212 fet_beginchar ("Whole fa down head", "d0fa");
1213         draw_fa_head (solfa_whole_width);
1214         fill p_down_out;
1215         unfill p_down_in;
1216 fet_endchar;
1217
1218
1219 fet_beginchar ("half fa up head", "u1fa");
1220         draw_fa_head (solfa_half_width);
1221         fill p_up_out;
1222         unfill p_up_in;
1223 fet_endchar;
1224
1225
1226 fet_beginchar ("Half fa down head", "d1fa");
1227         draw_fa_head (solfa_half_width);
1228         fill p_down_out;
1229         unfill p_down_in;
1230 fet_endchar;
1231
1232
1233 fet_beginchar ("Quarter fa up head", "u2fa");
1234         draw_fa_head (solfa_quarter_width);
1235         fill p_up_out;
1236 fet_endchar;
1237
1238
1239 fet_beginchar ("Quarter fa down head", "d2fa");
1240         draw_fa_head (solfa_quarter_width);
1241         fill p_down_out;
1242 fet_endchar;
1243
1244
1245 def draw_la_head (expr width_factor) =
1246         set_char_box (0, width_factor * solfa_noteheight#,
1247                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1248         save p_in, p_out;
1249         path p_in, p_out;
1250
1251         pickup pencircle scaled solfa_pen_thick;
1252
1253         lft x1 = 0;
1254         top y1 = h;
1255
1256         rt x2 = w;
1257         y2 = y1;
1258         bot y3 = -d;
1259         x3 = x2;
1260
1261         y4 = y3;
1262         x4 = x1;
1263
1264         labels (range 1 thru 4);
1265
1266         p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1267                 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1268                 -- (z3 + 0.5 solfa_pen_thick * (-1, 1))
1269                 -- (z4 + 0.5 solfa_pen_thick * (1, 1))
1270                 -- cycle;
1271
1272         p_out := top z1
1273                  -- top z2{right}
1274                  .. rt z2{down}
1275                  -- rt z3{down}
1276                  .. bot z3{left}
1277                  -- bot z4{left}
1278                  .. lft z4{up}
1279                  -- lft z1{up}
1280                  .. cycle;
1281 enddef;
1282
1283
1284 fet_beginchar ("Whole lahead", "s0la");
1285         draw_la_head (solfa_whole_width);
1286         fill p_out;
1287         unfill p_in;
1288 fet_endchar;
1289
1290
1291 fet_beginchar ("Half lahead", "s1la");
1292         draw_la_head (solfa_half_width);
1293         fill p_out;
1294         unfill p_in;
1295 fet_endchar;
1296
1297
1298 fet_beginchar ("Quart lahead", "s2la");
1299         draw_la_head (solfa_quarter_width);
1300         fill p_out;
1301 fet_endchar;
1302
1303
1304 def draw_ti_head (expr width_factor, dir) =
1305         set_char_box (0, width_factor * solfa_noteheight#,
1306                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1307         save p_in, p_out, p_top;
1308         save nw_dist, sw_dist, nw, sw;
1309         path p_in, p_out, p_top;
1310         pair nw_dist, sw_dist, nw, sw;
1311         save cone_height;
1312         cone_height = 0.64;
1313
1314         pickup pencircle scaled solfa_pen_thick;
1315
1316         x1 = .5 [x2, x4];
1317         bot y1 = -d;
1318         lft x2 = 0;
1319         y2 = cone_height [y1, y3];
1320         rt x4 = w;
1321         y4 = y2;
1322         x3 = x1;
1323         top y3 = h;
1324
1325         labels (range 1 thru 4);
1326
1327         nw = unitvector (z2 - z1);
1328         sw = unitvector (z1 - z4);
1329
1330         nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1331         sw_dist = (sw rotated 90) * 0.5 solfa_pen_thick;
1332
1333         p_top := (z2 - sw_dist)
1334                  .. (top z3){right}
1335                  .. (z4 - nw_dist);
1336
1337         p_in := (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1338                   ((z1 - sw_dist) -- (z4 - sw_dist)))
1339                 -- (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1340                      ((z2 + sw_dist) .. {right}(bot z3)))
1341                 .. bot z3
1342                 .. (((bot z3){right} .. (z4 + nw_dist)) intersectionpoint
1343                      ((z1 - sw_dist) -- (z4 - sw_dist)))
1344                 -- cycle;
1345
1346         p_out := bot z1
1347                  .. (z1 + nw_dist)
1348                  -- (z2 + nw_dist)
1349                  .. lft z2
1350                  .. (z2 - sw_dist){direction 0 of p_top}
1351                  & p_top
1352                  & {direction infinity of p_top}(z4 - nw_dist)
1353                  .. rt z4
1354                  .. (z4 + sw_dist)
1355                  -- (z1 + sw_dist)
1356                  .. cycle;
1357
1358         charwx := charwd;
1359         charwy := cone_height [-chardp, charht];
1360         if dir = -1:
1361                 charwy := -charwy;
1362         fi;
1363 enddef;
1364
1365
1366 fet_beginchar ("Whole up tihead", "s0ti");
1367         draw_ti_head (solfa_whole_width, 1);
1368         fill p_out;
1369         unfill p_in;
1370 fet_endchar;
1371
1372
1373 fet_beginchar ("Half up tihead", "u1ti");
1374         draw_ti_head (solfa_half_width, 1);
1375         fill p_out;
1376         unfill p_in;
1377 fet_endchar;
1378
1379
1380 fet_beginchar ("Half down tihead", "d1ti");
1381         draw_ti_head (solfa_half_width, -1);
1382         fill p_out;
1383         unfill p_in;
1384 fet_endchar;
1385
1386
1387 fet_beginchar ("Quart up tihead", "u2ti");
1388         draw_ti_head (solfa_quarter_width, 1);
1389         fill p_out;
1390 fet_endchar;
1391
1392
1393 fet_beginchar ("Quart down tihead", "d2ti");
1394         draw_ti_head (solfa_quarter_width, -1);
1395         fill p_out;
1396 fet_endchar;
1397
1398
1399 fet_endgroup ("noteheads");
1400
1401
1402 %
1403 % we derive black_notehead_width# from the quarter head,
1404 % so we have to define black_notehead_width (pixel qty)
1405 % after the black_notehead_width# itself.
1406 %
1407 % Let's keep it outside the group as well.
1408 %
1409
1410 define_pixels (black_notehead_width);