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