]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-bolletjes.mf
(direction-polyphonic-grobs): new
[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--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 % & Juergen Reuter <reuter@ipd.uka.de>
9
10
11 test_outlines := 0;
12
13
14 % most beautiful noteheads are pronounced, not circular, 
15 % and not even symmetric.
16 % These examples are inspired by [Wanske], see literature list
17
18
19
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 % NOTE HEAD VARIABLES
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 save black_notehead_width, noteheight,
24         slash_thick, slash_slope, overdone_heads;
25 numeric black_notehead_width, noteheight, slash_thick;
26
27 fet_begingroup("noteheads");
28
29
30
31 % slope of slash. From scm/grob-description.scm. How to auto-copy?
32 slash_slope := 1.7; 
33
34 % thickness of slash lines. quarter notes get 1.5slt width.
35 slash_thick# := 2/3*0.48staff_space#;
36
37
38 %
39 % Hand-engraved music often has balls extending above and below
40 % the lines.  If you like that, modify overdone heads (unit:
41 % stafflinethickness)
42 %
43 overdone_heads = 0.0;
44 noteheight#:=staff_space#+ (1 + overdone_heads) *stafflinethickness#;
45
46 define_pixels(slash_thick, noteheight);
47
48
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 %
51 % SLANT moves both extremes on the long axis (by SLANT * ELLIPSIDITY,
52 % so SLANT = -1, puts the extreme on the long axis next to the short axis one.)
53 %
54
55 def draw_outside_ellipse (expr ellipsidity, tilt, superness,
56                         slant) =
57         save attachment_y;
58         save p;
59         path p;
60
61         p := superellipse ((ellipsidity, 0), (-slant * ellipsidity, 1.0),
62                         (- ellipsidity, 0), (slant * ellipsidity, -1.0), superness);
63
64         p := p rotated tilt;
65
66         save top_point, right_point;
67         pair top_point, right_point;
68
69         top_point := directionpoint left of p;
70         right_point := directionpoint up of p;
71
72         save scaling, width, height;
73
74         scaling# = noteheight# /(2 ypart (top_point));
75         width# := 2 xpart (right_point) * scaling#;
76
77         define_pixels (width, scaling);
78         
79         set_char_box (0, width#, noteheight#/2, noteheight#/2);
80
81         % attachment Y
82         charwy := ypart (right_point) * scaling#;
83         charwx := width# ;
84
85         p := p scaled scaling shifted (width/2, 0) ;
86         if test_outlines = 1:
87                 pickup pencircle scaled 1 ; draw p;
88         else:
89                 fill p;
90         fi;
91 enddef;
92
93
94 def undraw_inside_ellipse (expr ellipsidity, tilt, superness, clearance,
95                         center) =
96 begingroup
97         save p;
98         path p;
99
100         p := superellipse ((ellipsidity, 0), (0, 1.0),
101                         (- ellipsidity, 0), (0, -1.0), superness);
102
103         p := p rotated tilt;
104
105         save top_point, right_point;
106         pair top_point, right_point;
107
108         top_point := directionpoint left of p;
109         right_point := directionpoint up of p;
110
111         save height, scaling;
112
113         height# = staff_space# + stafflinethickness# - clearance;
114         scaling# = height# /(2 ypart (top_point));
115
116         define_pixels (scaling);
117         p := (p scaled scaling) shifted center;
118
119         if test_outlines = 1:
120                 pickup pencircle scaled 1; draw p;
121         else:
122                 unfill p;
123         fi
124 endgroup;
125 enddef;
126
127
128
129
130
131 %
132 % dimensions aren't entirely right.
133 %
134 fet_beginchar ("Brevis notehead", "-1", "brevishead");
135         save stemthick, fudge;
136         define_pixels (stemthick);
137         fudge = blot_diameter /2;
138         stemthick# = 2 stafflinethickness#;
139
140         draw_outside_ellipse (1.80, 0, 0.707, 0);
141         undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#,
142                                 (w /2, 0));
143
144         pickup pencircle scaled stemthick;
145
146         bot y1 = -d;
147         top y2 = h;
148         rt x1 - fudge = 0;
149         x1 = x2;
150
151         fudge + lft x3 = w;
152         x4 = x3;
153         y4 = y2;
154         y3 = y1;
155
156         draw_gridline(z1,z2,stemthick);
157         draw_gridline(z3,z4,stemthick);
158
159 fet_endchar;
160
161
162
163 fet_beginchar("Whole notehead", "0", "wholehead")
164         draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
165         undraw_inside_ellipse (1.30, 125 - puff_up_factor *10,
166                         0.68, 2 stafflinethickness#,
167                         (w /2, 0));
168
169 %       draw_staff_outline (-2, 2, 0.5);
170
171 fet_endchar;
172
173
174 fet_beginchar("Half notehead", "1", "halfhead")
175         draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
176         undraw_inside_ellipse (3.25, 33, 0.81,
177                 2.5 stafflinethickness#, (w/2, 0));
178
179 fet_endchar;
180         
181 fet_beginchar("Quart notehead", "2", "quarthead")
182         draw_outside_ellipse (1.54 - puff_up_factor / 2.0, 32, 0.707, 0);
183         black_notehead_width# := charwd;
184 fet_endchar;
185
186 fet_beginchar("Quart noteheadPQ", "2PQ", "quartheadPQ")
187         draw_outside_ellipse (1.0 - puff_up_factor / 2.0, 32, 0.707, 0);
188 fet_endchar;
189
190 fet_beginchar("Quart noteheadAA", "2AA", "quartheadAA")
191         draw_outside_ellipse (1.2 - puff_up_factor / 2.0, 32, 0.707, 0);
192 fet_endchar;
193
194 fet_beginchar("Quart noteheadAB", "2AB", "quartheadAB")
195         draw_outside_ellipse (1.3 - puff_up_factor / 2.0, 32, 0.707, 0);
196         
197 fet_endchar;
198 fet_beginchar("Quart noteheadAC", "2AC", "quartheadAC")
199         draw_outside_ellipse (1.4 - puff_up_factor / 2.0, 32, 0.707, 0);
200         
201 fet_endchar;
202 fet_beginchar("Quart noteheadAD", "2AD", "quartheadAD")
203         draw_outside_ellipse (1.5 - puff_up_factor / 2.0, 32, 0.707, 0);
204         
205 fet_endchar;
206 fet_beginchar("Quart noteheadBA", "2BA", "quartheadBA")
207         draw_outside_ellipse (1.2 - puff_up_factor / 2.0, 35, 0.707, 0);
208         
209 fet_endchar;
210 fet_beginchar("Quart noteheadBB", "2BB", "quartheadBB")
211         draw_outside_ellipse (1.3 - puff_up_factor / 2.0, 35, 0.707, 0);
212         
213 fet_endchar;
214 fet_beginchar("Quart noteheadBC", "2BC", "quartheadBC")
215         draw_outside_ellipse (1.4 - puff_up_factor / 2.0, 35, 0.707, 0);
216 fet_endchar;
217 fet_beginchar("Quart noteheadBD", "2BD", "quartheadBD")
218         draw_outside_ellipse (1.5 - puff_up_factor / 2.0, 35, 0.707, 0);
219         
220 fet_endchar;
221 fet_beginchar("Quart noteheadCA", "2CA", "quartheadCA")
222         draw_outside_ellipse (1.2 - puff_up_factor / 2.0, 38, 0.707, 0);
223         
224 fet_endchar;
225 fet_beginchar("Quart noteheadCB", "2CB", "quartheadCB")
226         draw_outside_ellipse (1.3 - puff_up_factor / 2.0, 38, 0.707, 0);
227         
228 fet_endchar;
229 fet_beginchar("Quart noteheadCC", "2CC", "quartheadCC")
230         draw_outside_ellipse (1.4 - puff_up_factor / 2.0, 38, 0.707, 0);
231         
232 fet_endchar;
233 fet_beginchar("Quart noteheadCD", "2CD", "quartheadCD")
234         draw_outside_ellipse (1.5 - puff_up_factor / 2.0, 38, 0.707, 0);
235 fet_endchar;
236
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238
239
240 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
241         draw_outside_ellipse (1.80, 0, 0.495, 0);
242         undraw_inside_ellipse (1.30, 125, 0.6,
243                         .4 staff_space# +  stafflinethickness#,
244                                 (w /2, 0));
245
246 fet_endchar;
247
248 fet_beginchar("Half diamondhead", "1diamond", 
249         "halfdiamondhead")
250
251         draw_outside_ellipse (1.50, 34, 0.49, 0.17);
252         undraw_inside_ellipse (3.5, 33, 0.80,
253                 .3 staff_space# + 1.5 stafflinethickness#, (w/2, 0));
254
255 fet_endchar;
256
257 fet_beginchar("Quart diamondheadh", "2diamondh", "diamondheadh")
258         draw_outside_ellipse (1.80, 35, 0.495, -0.25);
259 fet_endchar;
260
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262
263
264
265
266
267 def def_triangle =
268         save triangle,kern; path triangle;
269         save left_point, height, width;
270         pair exact_left_point;
271         save pen_thick;
272         pen_thick# = stafflinethickness#  + .1 staff_space#;
273         define_pixels(pen_thick);
274
275         exact_left_point := llap# * dir (90 + tilt);
276         height# = max (ypart exact_left_point,
277                         -ypart  (exact_left_point rotated 120)) + pen_thick#/2;
278
279         kern# = 1/3 xpart (exact_left_point - (exact_left_point rotated 120));
280         width# = xpart (-exact_left_point + (exact_left_point rotated 240));
281         define_pixels (kern);   
282         z1 = (hround_pixels (xpart exact_left_point), vround_pixels  (ypart exact_left_point));
283         z2 = z1 rotated 120;
284         z3 = z1 rotated 240;
285
286         z12 = caveness[.5[z1,z2],z3];
287         z23 = z12 rotated 120;
288         z31 = z12 rotated 240;
289         triangle = z1 .. z12 .. z2 ..
290                     z2 .. z23 .. z3 ..
291                     z3 .. z31 .. z1 ..
292                     cycle;
293         triangle := triangle shifted (-x1+pen_thick/2-kern,0) xscaled xs;
294         pickup pencircle scaled pen_thick xscaled xs;
295 %       labels(1,2,12,23,31,3);
296         set_char_box(0, width# - kern#+ pen_thick#, height#, height#);
297 enddef;
298
299 fet_beginchar("Whole trianglehead", "0triangle", "wholetrianglehead")
300         save hei,xs;
301         save llap;
302         save tilt;
303
304         tilt = 40;
305         llap# = 3/4noteheight#;
306
307         xs = 1.5;
308         caveness:=0.1;
309         def_triangle;
310         draw triangle;
311 fet_endchar;
312
313 fet_beginchar("Half trianglehead", "1triangle", "halftrianglehead")
314         save hei,xs;
315         save llap;
316         save tilt;
317
318         tilt = 40;
319         llap# = 2/3noteheight#;
320         xs = 1.2;
321         caveness:=0.1;
322         def_triangle;
323         draw triangle;
324 fet_endchar;
325
326 fet_beginchar("Quart trianglehead", "2triangle", "trianglehead")
327         save hei,xs;
328         save llap;
329         save tilt;
330         tilt = 40;
331         llap# = 2/3noteheight#;
332         xs = 1.0;
333         caveness:=0.1;
334         def_triangle;
335         filldraw triangle;
336 fet_endchar;
337
338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
339 %
340 % slash heads are for indicating improvisation. They are  
341 % twice as high as normal heads.
342 %
343 def draw_slash(expr hwid_hash) =
344         save exact_height;
345         save ne_dir;
346         pair ne_dir;
347         exact_height =  staff_space# + stafflinethickness#/2;
348
349         set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
350                         exact_height, exact_height);
351
352         charwx := charwd;
353         charwy := charht;
354
355         clearxy;
356         pickup pencircle scaled blot_diameter;
357
358         bot y1 = - d;
359         top y2 = h;
360         lft x1 = 0;
361         lft x2 = 2 h / slash_slope;
362         
363         rt x3 = w;
364         y3 = y2;
365         y4 = y1;
366         x3- x2 = x4 - x1;
367
368         ne_dir := unitvector( z3  - z4);
369         filldraw z1 --- z2 --- z3 --- z4 --- cycle;
370
371         if hwid_hash > 2 slash_thick#:
372                 save th;
373
374                 th = slash_thick - blot_diameter;
375                 y6 = y7;
376                 y5 = y8;
377                 y3 - y7 = th;
378                 y5 - y1 = th;
379                 z6 - z5 = whatever * ne_dir;
380                 z8 - z7 = whatever * ne_dir;
381
382                 z5  = z1 + whatever * ne_dir + th * (ne_dir rotated -90);
383                 z8  = z4 + whatever * ne_dir + th * (ne_dir rotated 90);
384
385                 unfill
386                         z5 -- z6 -- z7 -- z8 -- cycle;
387         fi
388         labels (range 1 thru 10);
389 enddef;
390
391 fet_beginchar("Whole slashhead","0slash","wholeslashhead")
392         draw_slash(4 slash_thick# + 0.5 staff_space#);
393 fet_endchar;
394
395 fet_beginchar("Half slashhead","1slash","halfslashhead")
396         draw_slash(3.0 slash_thick# + 0.15 staff_space#);
397 fet_endchar;
398
399 fet_beginchar("Quart slashhead","2slash","quartslashhead")
400         draw_slash(1.5 slash_thick#);
401 fet_endchar;
402
403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404 % thick is the distance between the NE/SW parallel lines in the cross
405 % (distance between centres of lines)
406 % in stafflinethickness def
407 %
408 def draw_cross(expr thick) =
409         save pent, slant, ne_dir;
410         pair ne_dir;
411         save crz; path crz;
412
413         pen_thick# := 1.2stafflinethickness#;
414         define_pixels (pen_thick);
415         pickup pencircle scaled pen_thick;
416
417         top y3 = h;
418         ne_dir := unitvector ((1, (2 h -pen_thick)/(w - pen_thick)));
419         rt x4 = w/2;
420         y5 = 0;
421         z4 - z5 = whatever * ne_dir;
422         x6 = 0;
423         z6 - z3 = whatever * ne_dir;
424         z3 - z4 = whatever * (ne_dir yscaled -1);
425
426         z4 - z3 = whatever * (ne_dir) + (ne_dir rotated -90) * thick * stafflinethickness;
427
428         x1 = charwd/2 - .5 pen_thick#;
429         z1 = whatever * ne_dir + thick/2 * stafflinethickness# * (ne_dir rotated -90);
430
431         
432         labels (1,2,3,4,5,6);
433
434         crz = (z6 -- z3 -- z4 -- z5) ;
435
436         draw crz shifted(w/2,0);
437         draw crz xscaled -1 shifted(w/2,0);
438         draw crz yscaled -1 shifted(w/2,0);
439         draw crz scaled -1 shifted(w/2,0);
440
441         charwx := charwd;
442         charwy := y1;
443                 message (decimal charwx);
444                 message (decimal charwy);
445         z12 = (charwx * hppp, y1 * vppp);
446         labels (12);
447 enddef;
448
449 fet_beginchar("Whole Crossed notehead", "0cross", "wholecrossedhead")
450         wid# := black_notehead_width#+4stafflinethickness#;
451         hei# := noteheight#+stafflinethickness#;
452         set_char_box(0, wid#,hei#/2,hei#/2);
453         
454         draw_cross (3.75);
455 fet_endchar;
456
457 fet_beginchar("Half Crossed notehead", "1cross", "halfcrossedhead")
458         wid# := black_notehead_width#+2stafflinethickness#;
459         hei# := noteheight#+stafflinethickness#/2;
460         set_char_box(0, wid#,hei#/2,hei#/2);
461         draw_cross(3.0);
462 fet_endchar;
463
464 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
465         wid# := black_notehead_width#;
466         hei# := noteheight#;
467         set_char_box(0, wid#,hei#/2,hei#/2);
468         draw_cross(1.0);
469 fet_endchar;
470
471 fet_beginchar("X-Circled notehead", "2xcircle", "xcircledhead")
472         wid# := black_notehead_width#*sqrt(sqrt2);
473         hei# := noteheight#*sqrt(sqrt2);
474         set_char_box(0, wid#,hei#/2,hei#/2);
475         cthick := (1.2+1/4)*stafflinethickness;
476         cxr := w/2-cthick/2;
477         cyr := h-cthick/2;
478         pickup pencircle scaled cthick;
479         draw fullcircle xscaled 2cxr yscaled 2cyr shifted (w/2,0);
480         xpos := cxr/sqrt2;
481         ypos := cyr/sqrt2;
482         draw (-xpos+w/2,-ypos) -- (xpos+w/2,ypos);
483         draw (-xpos+w/2,ypos) -- (xpos+w/2,-ypos);
484
485         charwx := charwd ; 
486         charwy := 0 ;
487
488         z12 = (charwx * hppp , charwy * vppp );
489         labels (12);
490 fet_endchar;
491
492
493
494 fet_endgroup("noteheads");
495
496 define_pixels(black_notehead_width);