2 % feta-bolletjes.mf -- implement noteheads
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 1997, 1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@stack.nl>
11 % most beautiful noteheads are pronounced, not circular,
12 % and not even symmetric.
13 % These examples are inspired by [Wanske], see literature list
16 save black_notehead_width;
17 numeric black_notehead_width;
19 fet_begingroup("noteheads");
21 noteheight#:=interline#+ (1 + overdone_heads) *stafflinethickness#;
22 define_pixels(noteheight);
23 brevis_wid# := 2 interline#;
25 def draw_brevis(expr brevwid) =
26 save beamheight, head_width;
27 save holeheight, stem_width;
28 save serif_size, serif_protrude;
30 head_width# = brevwid;
31 holeheight = 3 stafflinethickness;
32 stem_width = 1.4 stafflinethickness;
35 define_pixels(head_width);
36 set_char_box(0, head_width#, noteheight#/2, noteheight#/2);
38 2 beamheight + holeheight = noteheight;
39 serif_size = (holeheight - stafflinethickness)/2;
40 serif_protrude = 1.5 serif_size;
41 penpos1(stem_width, 0);
42 penpos2(stem_width, 0);
43 penpos3(beamheight, 90);
44 penpos4(beamheight, 90);
45 penpos5(stem_width, 180);
48 z2l = (0, -stafflinethickness/2);
49 z3r = z2r + serif_size *(1,-1);
52 z5l = z3l + (-serif_size, -serif_protrude);
54 penlabels(1,2,3,4, 5);
55 fill z1r -- z1l -- z5r{down} .. z5l{up} .. z3l{right}
56 -- z4l -- z4r -- z3r{left} .. z2r{up} -- cycle;
58 addto currentpicture also currentpicture yscaled -1;
60 addto currentpicture also currentpicture
61 shifted (-x4r,0) xscaled -1 shifted (x4l,0);
66 fet_beginchar("Ledger ending", "ledgerending", "ledgerending")
67 set_char_box (5/2 ledgerlinethickness#, 5/2 ledgerlinethickness#,
68 ledgerlinethickness#/2,ledgerlinethickness#/2);
69 pickup pencircle scaled 1.3 blot_diameter;
81 filldraw z1 --- z2 --- z3 --- z4 --- cycle ;
84 fet_beginchar("Brevis notehead", "-1", "brevishead")
85 draw_brevis(brevis_wid#);
89 % Some sources (eg Musix/OpusTeX think that the appendage should be on
90 % the right, my only other ref [Willemze], shows an appendage to the left
92 fet_beginchar("Longa notehead", "-2", "longahead");
93 draw_brevis(brevis_wid#);
96 z6 - z7 = (-stem_width/2, -interline);
97 theta = angle(z6-z7)+ 90;
98 penpos7(stem_width, theta);
99 penpos6(1.2 stem_width, theta);
101 fill z7r .. z6r{z6-z7} .. {z7-z6} z6l -- z7l -- cycle;
106 % TODO: Document these!
109 def setup_notehead_vars =
110 save a_b,err_y_a,tilt,superness;
111 save ai_a,ai_bi,err_y_ai,err_x_bi,inner_tilt,inner_superness;
115 % setup addititional vars and calc them
117 save a,beta,ai,bi, ht, wd;
124 define_pixels(a,beta);
125 define_pixels(ai,bi);
126 set_char_box(0, wd#, .5 ht#, .5 ht#);
130 % draw the outer and inner ellipse.
133 black=distorted_ellipse(a,beta,a*err_y_a,0,superness);
134 white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,inner_superness);
137 x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b;
141 black:=black rotated tilt;
142 black:=black shifted (w/2,0);
143 white:=white rotated inner_tilt;
144 white:=white shifted (w/2,0);
154 fet_beginchar("Whole notehead", "0", "wholehead")
158 err_y_a:=0; % no slant
169 inner_tilt:=125; % jcn
170 % inner_superness:=0.69;
171 inner_superness:=0.68; % jcn
172 b_h:=1; %no rotate-> no height correction
173 a_w:=1; % no rotate-> no width correction
176 whole_notehead_width# := wd#;
184 fet_beginchar("Half notehead", "1",
187 % a_b:=1.49; % after text
188 a_b:=1.50; % after drawing
192 superness:=0.67; % jcn
200 inner_superness:=0.80;
205 half_notehead_width# := wd#;
213 fet_beginchar("Quart notehead", "2", "quarthead")
215 % a_b:=1.57; % after text
216 a_b:=1.54; % after drawing
225 inner_superness:=0.707;
230 black_notehead_width# := wd#;
237 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
241 err_y_a:=0; % no slant
252 inner_tilt:=125; % jcn
253 % inner_superness:=0.69;
254 inner_superness:=0.6; % jcn
255 b_h:=1; %no rotate-> no height correction
256 a_w:=1; % no rotate-> no width correction
259 whole_notehead_width# := wd#;
266 fet_beginchar("Half diamondhead", "1diamond",
270 a_b := 1.50; % after drawing
274 superness:=0.49; % jcn
281 inner_superness:=0.80;
287 half_notehead_width# := wd#;
294 fet_beginchar("Quart diamondhead", "2diamond", "diamondhead")
295 set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
296 save a_b,err_y_a,tilt,superness;
298 save a,beta,ai,bi, ht, wd;
311 define_pixels(a,beta);
313 black := distorted_ellipse(.72 noteheight, .45 noteheight, -.2 noteheight , 0, superness)
315 % beta,a*err_y_a,0,superness);
317 black:=black rotated tilt;
318 black:=black shifted (w/2,0);
323 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
324 set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
325 pickup pencircle scaled 1.5 stafflinethickness;
332 draw (z1 .. z2) yscaled -1;
335 def draw_harmonic_notehead(expr harmwid) =
336 save beamheight, head_width, head_char_width;
341 head_width# = harmwid;
343 define_pixels(head_width);
345 head_char_width = 1.54 noteheight;
346 head_char_width# := 1.54 ht#;
349 set_char_box(0, head_width#, head_width#/2, head_width#/2);
351 thin = stafflinethickness - blot_diameter/2;
352 thick = 2.2 stafflinethickness - blot_diameter/2;
363 pickup pencircle scaled blot_diameter;
370 bot y3l = -noteheight/2;
377 top y7l = noteheight/2;
378 x7l = (head_width/2);
382 penlabels(1,2,3,4,5,6,7,8);
384 filldraw z1l -- z2r -- z7r -- z7l -- cycle;
385 filldraw z1l -- z1r -- z4r -- z4l -- cycle;
386 filldraw z3r -- z3l -- z6l -- z6r -- cycle;
387 filldraw z5r -- z5l -- z8l -- z8r -- cycle;
390 harmonic_wid# := interline#;
392 fet_beginchar("Harmonic notehead","2harmonic","harmonichead")
393 draw_harmonic_notehead(harmonic_wid#)
398 fet_endgroup("noteheads");
400 define_pixels(black_notehead_width);