Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / mf / feta-banier.mf
blob46b3b0617b9c6102460b6d75328f687317ab1101
2 % feta-banier.mf -- draw flags
4 % source file of the GNU LilyPond music typesetter
6 % (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 fet_begingroup ("flags");
10 save outer_path;
11 path outer_path;
14 % Flags pointing down overlap with the notehead (in x-direction), so
15 % the down-flag can be bigger.
18 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
19 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
21 right_upflag_space# = .0 upflag_width#;
22 right_downflag_space# = .0 downflag_width#;
25 % Flags pointing down cannot overlap with the notehead in y-direction,
26 % so they have less slant.
28 % Because of optical illusion, the utmost flag (bottom for
29 % down-pointing, top for up-pointing) should be smaller than the other
30 % flags.  Adobe Sonata doesn't do this correctly.  (Instead they have
31 % an extension flag, which looks less elegant.)
34 save hip_thickness, foot_thickness;
36 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
37 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
39 define_pixels (hip_thickness, foot_thickness);
42 % Inspired by Adobe Sonata and [Wanske].
43 % For example, see POSTSCRIPT Language -- program design,
44 % page 119, and [Wanske], p 41, 42.
47 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
48                hip_thickness, foot_thickness, show_labels) =
49         save c;
51         clearxy;
53         c = 0.7;
55         penpos1 (flare, 90);
56         penpos2 (whatever, 0);
58         x2r - x2l = hround (hip_thickness);
60         penpos3 (foot_thickness, -20.0);
62         z1r = center;
63         z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
64         z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
66         x2r := hround x2r;
67         y2r := vround y2r;
69         outer_path := z3r{curl c}
70                       .. z2r{up}
71                       .. {up}z1r;
73         if show_labels = 1:
74                 penlabels (1, 2, 3);
75         fi;
77         fill z1l{curl 0}
78              ..tension 1.1.. z2l{down}
79              .. {curl c}simple_serif (z3l, z3r, 80)
80              & outer_path
81              & z1r
82              -- cycle;
83 enddef;
86 % TODO: calculate intersectpoint (see TeX book, p. 137)
87 % TODO: calculate incision_depth
90 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
91               intersectpoint, hip_thickness, foot_thickness) =
92 begingroup
93         save prev_center, prev_xextreme, prev_yextreme;
94         save rel_foot, ip, center, incision_depth;
95         save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
96         save hip_dep_ratio, foot_wid_ratio;
97         pair prev_center, center, foot, prev_xextreme, prev_yextreme;
98         pair ip, rel_foot;
100         incision_depth = 1.013;
101         prev_center = point 2 of outer_path;
102         prev_xextreme = point 1 of outer_path;
103         prev_yextreme = point 0 of outer_path;
104         prev_hipwid = xpart (prev_xextreme - prev_center);
105         prev_footdep = -ypart (prev_yextreme - prev_center);
106         prev_hipdep = -ypart (prev_xextreme - prev_center);
107         ip = point intersectpoint of outer_path;
109         wid = prev_hipwid * hip_wid_multiplier;
110         hip_dep = prev_hipdep * hip_dep_multiplier;
112         center = prev_center + (0, yoff);
113         rel_foot = incision_depth [(wid, hip_dep), ip - center];
114         dep = -ypart (rel_foot);
115         foot_wid_ratio = xpart (rel_foot) / wid;
116         hip_dep_ratio = hip_dep / dep;
118         draw_flag (center, flare, (wid, dep),
119                    hip_dep_ratio, foot_wid_ratio,
120                    hip_thickness, foot_thickness, 0);
121 endgroup
122 enddef;
125 fet_beginchar ("8th Flag (up)", "u3");
126         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
128         flare = staff_space;
129         hip_depth_ratio = .72;
130         foot_width_ratio = .8;
131         hip_width# = upflag_width# - hip_thickness# / 2;
132         foot_depth# = 3 staff_space# - blot_diameter# / 2;
133         define_pixels (hip_width, foot_depth);
135         set_char_box (0,
136                       hip_width# + stemthickness# / 2 + right_upflag_space#,
137                       foot_depth# + foot_thickness# / 2, stemthickness# / 2);
139         draw_flag ((0,0), flare, (hip_width, foot_depth),
140                    hip_depth_ratio, foot_width_ratio,
141                    hip_thickness, foot_thickness, 1);
143         draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
144                            (0, 0));
145 fet_endchar;
148 fet_beginchar ("16th Flag (up)", "u4");
149         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
150         save flagspace, total_depth, flag_count;
152         total_depth# = 3.5 staff_space# - blot_diameter# / 2;
153         flag_count = 2;
154         flare = .85 staff_space;
155         flagspace# = .85 staff_space#;
156         hip_depth_ratio = .72;
157         hip_width# = upflag_width# - hip_thickness# / 2;
158         flagspace# + foot_depth# = total_depth#;
159         foot_width_ratio = .8;
160         define_pixels (hip_width, foot_depth);
161         define_whole_vertical_pixels (flagspace);
163         set_char_box (0,
164                       hip_width# + stemthickness# / 2 + right_upflag_space#,
165                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
167         draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
168                    hip_depth_ratio, foot_width_ratio,
169                    hip_thickness, foot_thickness, 1);
171         add_flag (flagspace, flare, .97, 1.00, 1.25,
172                   hip_thickness, foot_thickness);
174         draw_square_block ((-0.5 stemthickness_rounded, 0),
175                            (0, -2 staff_space_rounded));
176 fet_endchar;
179 fet_beginchar ("32nd Flag (up)", "u5");
180         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
181         save flagspace, total_depth, flag_count;
183         flag_count = 3;
184         total_depth# = 4.25 staff_space#;
185         flare = .85 staff_space;
186         flagspace# = .87 staff_space#;
187         hip_depth_ratio = .72;
188         hip_width# = upflag_width# - hip_thickness# / 2;
189         foot_width_ratio = .8;
191         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
193         define_pixels (hip_width, foot_depth);
194         define_whole_vertical_pixels (flagspace);
196         set_char_box (0, hip_width# + right_upflag_space#,
197                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
199         draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
200                    hip_depth_ratio, foot_width_ratio,
201                    hip_thickness, foot_thickness, 1);
203         add_flag (flagspace, flare, .97, 1.00, 1.25,
204                   hip_thickness, foot_thickness);
205         add_flag (flagspace, flare, .95, 1.05, 1.25,
206                   hip_thickness, foot_thickness);
208         draw_square_block ((-0.5 stemthickness_rounded, 0),
209                            (0, -3 staff_space_rounded));
210 fet_endchar;
213 fet_beginchar ("64th Flag (up)", "u6");
214         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
215         save flagspace, total_depth, flag_count;
217         flag_count = 4;
218         flare = .85 staff_space;
219         flagspace# = .9 staff_space#;
220         hip_depth_ratio = .72;
221         hip_width# = upflag_width# - hip_thickness# / 2;
222         total_depth# = 5.25 staff_space#;
223         foot_width_ratio = .8;
225         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
227         define_pixels (hip_width, foot_depth);
228         define_whole_vertical_pixels (flagspace);
230         set_char_box (0, hip_width# + right_upflag_space#,
231                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
233         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
234                    (hip_width, foot_depth),
235                    hip_depth_ratio, foot_width_ratio,
236                    hip_thickness, foot_thickness, 1);
238         add_flag (flagspace, flare, .97, 1.00, 1.3,
239                   hip_thickness, foot_thickness);
240         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
241                   hip_thickness, foot_thickness);
242         add_flag (flagspace, flare, .95, 1.05, 1.25,
243                   hip_thickness, foot_thickness);
245         draw_square_block ((-0.5 stemthickness_rounded, 0),
246                            (0, -4 staff_space_rounded));
247 fet_endchar;
250 fet_beginchar ("128th Flag (up)", "u7");
251         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
252         save flagspace, total_depth, flag_count;
254         flag_count = 5;
255         flare = .85 staff_space;
256         flagspace# = .93 staff_space#;
257         hip_depth_ratio = .72;
258         hip_width# = upflag_width# - hip_thickness# / 2;
259         total_depth# = 6.25 staff_space#;
260         foot_width_ratio = .8;
262         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
264         define_pixels (hip_width, foot_depth);
265         define_whole_vertical_pixels (flagspace);
267         set_char_box (0, hip_width# + right_upflag_space#,
268                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
270         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
271                    (hip_width, foot_depth),
272                    hip_depth_ratio, foot_width_ratio,
273                    hip_thickness, foot_thickness, 1);
275         add_flag (flagspace, flare, .97, 1.00, 1.3,
276                   hip_thickness, foot_thickness);
277         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
278                   hip_thickness, foot_thickness);
279         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
280                   hip_thickness, foot_thickness);
281         add_flag (flagspace, flare, 0.95, 1.05, 1.25,
282                   hip_thickness, foot_thickness);
284         draw_square_block ((-0.5 stemthickness_rounded, 0),
285                            (0, -5 staff_space_rounded));
286 fet_endchar;
289 fet_beginchar ("8th (down)", "d3");
290         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
291         save flagspace, total_depth, flag_count;
293         flag_count = 1;
294         flare = staff_space;
295         flagspace# = .9 staff_space#;
296         hip_depth_ratio = .72;
297         hip_width# = downflag_width# - hip_thickness# / 2;
298         total_depth# = 2.85 staff_space#;
299         foot_width_ratio = .8;
301         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
303         define_pixels (hip_width, flagspace, foot_depth);
305         set_char_box (0, hip_width# + right_downflag_space#,
306                       total_depth# + foot_thickness# / 2, stemthickness# / 2)
308         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
309                    (hip_width, foot_depth),
310                    hip_depth_ratio, foot_width_ratio,
311                    hip_thickness, foot_thickness, 0);
313         draw_square_block ((-0.5 stemthickness_rounded, 0),
314                            (0, -staff_space_rounded));
316         y_mirror_char;
317 fet_endchar;
320 %%%%%%%%
322 % Single Stroke for Short Appogiatura
325 fet_beginchar ("grace dash (up)", "ugrace");
326         save flare, hip_depth_ratio, hip_width, foot_depth;
328         hip_depth_ratio = .72;
329         flare# = staff_space#;
330         hip_width# = upflag_width# - hip_thickness# / 2;
331         foot_depth# = 3 staff_space#;
333         define_pixels (hip_width, foot_depth);
335         set_char_box (hip_width# * hip_depth_ratio,
336                       hip_width# + right_upflag_space#,
337                       foot_depth# * hip_depth_ratio, -flare#)
339         pickup pencircle scaled 1.5 stemthickness;
341         z1 = (-b, -d);
342         z2 = (w, h);
344         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
345         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
347         fill z1l
348              -- z2l
349              .. top z2
350              .. rt z2
351              .. z2r
352              -- z1r
353              .. bot z1
354              .. lft z1
355              .. cycle;
357         penlabels (1, 2);
358 fet_endchar;
361 fet_beginchar ("grace dash (down)", "dgrace");
362         save flare, hip_depth_ratio, hip_width, foot_depth;
363         save total_depth;
365         hip_depth_ratio = .72 ;
366         flare# = .99 staff_space#;
367         hip_width# = downflag_width# - hip_thickness# / 2;
368         total_depth# = 2.85 staff_space#;
369         foot_depth# = total_depth#;
370         foot_width_ratio = .8;
372         define_pixels (hip_width, foot_depth);
374         set_char_box (hip_width# * hip_depth_ratio,
375                       hip_width# + right_downflag_space#,
376                       foot_depth# * hip_depth_ratio, -flare#)
378         pickup pencircle scaled 1.5 stemthickness;
380         z1 = (-b, -d);
381         z2 = (w, h);
383         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
384         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
386         fill z1l
387              -- z2l
388              .. top z2
389              .. rt z2
390              .. z2r
391              -- z1r
392              .. bot z1
393              .. lft z1
394              .. cycle;
396         y_mirror_char;
397 fet_endchar;
400 fet_beginchar ("16th (down)", "d4");
401         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
402         save flagspace, total_depth, flag_count;
404         flag_count = 2;
405         flare = .8 staff_space;
406         flagspace# = .9 staff_space#;
407         hip_depth_ratio = .85;
408         hip_width# = downflag_width# - hip_thickness# / 2;
409         total_depth# = 3.0 staff_space# - blot_diameter# / 2;
410         foot_width_ratio = .95;
412         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
414         set_char_box (0, hip_width# + right_downflag_space#,
415                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
417         define_pixels (hip_width, foot_depth);
418         define_whole_vertical_pixels (flagspace);
420         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
421                    (hip_width, foot_depth),
422                    hip_depth_ratio, foot_width_ratio,
423                    hip_thickness, foot_thickness, 0);
425         add_flag (flagspace, flare, .95, 1.00, 1.25,
426                   hip_thickness, foot_thickness);
428         draw_square_block ((-0.5 stemthickness_rounded, 0),
429                            (0, -2 staff_space_rounded));
431         y_mirror_char;
432 fet_endchar;
435 fet_beginchar ("32nd (down)", "d5");
436         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
437         save flagspace, total_depth, flag_count;
439         flag_count = 3;
440         flare = .84 staff_space;
441         flagspace# = .9 staff_space#;
442         hip_depth_ratio = .85;
443         hip_width# = downflag_width# - hip_thickness# / 2;
444         total_depth# = 3.85 staff_space#;
445         foot_width_ratio = .95;
447         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
449         define_pixels (hip_width, foot_depth);
450         define_whole_vertical_pixels (flagspace);
452         set_char_box (0, hip_width# + right_downflag_space#,
453                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
455         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
456                    (hip_width, foot_depth),
457                    hip_depth_ratio, foot_width_ratio,
458                    hip_thickness, foot_thickness, 0);
460         add_flag (flagspace, flare, .97, 1.00, 1.25,
461                   hip_thickness, foot_thickness);
462         add_flag (flagspace, flare, .95, 1.05, 1.25,
463                   hip_thickness, foot_thickness);
465         draw_square_block ((-0.5 stemthickness_rounded, 0),
466                            (0, -3 staff_space_rounded));
468         y_mirror_char;
469 fet_endchar;
472 fet_beginchar ("64th (down)", "d6");
473         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
474         save flagspace, total_depth, flag_count;
476         flag_count = 4;
477         flare = .8 staff_space;
478         flagspace# = .9 staff_space#;
479         hip_depth_ratio = .85;
480         hip_width# = downflag_width# - hip_thickness# / 2;
481         total_depth# = 4.35 staff_space#;
482         foot_width_ratio = .98;
484         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
486         define_pixels (hip_width, foot_depth);
487         define_whole_vertical_pixels (flagspace);
489         set_char_box (0, hip_width# + right_downflag_space#,
490                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
492         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
493                    (hip_width, foot_depth),
494                    hip_depth_ratio, foot_width_ratio,
495                    hip_thickness, foot_thickness, 0);
497         add_flag (flagspace, flare, .97, 1.20, 1.175,
498                   hip_thickness, foot_thickness);
499         add_flag (flagspace, flare, .97, 1.10, 1.175,
500                   hip_thickness, foot_thickness);
501         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
502                   hip_thickness, foot_thickness);
504         draw_square_block ((-0.5 stemthickness_rounded, 0),
505                            (0, -4 staff_space_rounded));
507         y_mirror_char;
508 fet_endchar;
511 fet_beginchar ("128th (down)", "d7");
512         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
513         save flagspace, total_depth, flag_count;
515         flag_count = 5;
516         flare = .8 staff_space;
517         flagspace# = .9 staff_space#;
518         hip_depth_ratio = .85;
519         hip_width# = downflag_width# - hip_thickness# / 2;
520         total_depth# = 5.25 staff_space#;
521         foot_width_ratio = .98;
523         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
524         define_pixels (hip_width, foot_depth);
525         define_whole_vertical_pixels (flagspace);
527         set_char_box (0, hip_width# + right_downflag_space#,
528                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
530         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
531                    (hip_width, foot_depth),
532                    hip_depth_ratio, foot_width_ratio,
533                    hip_thickness, foot_thickness, 0);
535         add_flag (flagspace, flare, .97, 1.20, 1.175,
536                   hip_thickness, foot_thickness);
537         add_flag (flagspace, flare, .97, 1.10, 1.175,
538                   hip_thickness, foot_thickness);
539         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
540                   hip_thickness, foot_thickness);
541         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
542                   hip_thickness, foot_thickness);
544         draw_square_block ((-0.5 stemthickness_rounded, 0),
545                            (0, -5 staff_space_rounded));
547         y_mirror_char;
548 fet_endchar;
550 fet_endgroup ("flags");