]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-banier.mf
*** empty log message ***
[lilypond.git] / mf / feta-banier.mf
1 % flags
2 %
3
4
5 fet_begingroup ("flags");
6
7 save outer_path;
8 path outer_path;
9
10 %
11 % Flags pointing down overlap with the notehead (in x-direction), so
12 % the down-flag can be bigger.
13 %
14
15 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
16 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
17
18 right_upflag_space# = .0 upflag_width#;
19 right_downflag_space# = .0 downflag_width#;
20
21 %
22 % Flags pointing down cannot overlap with the notehead in y-direction,
23 % so they have less slant.
24 %
25 % Because of optical illusion, the utmost flag (bottom for
26 % down-pointing, top for up-pointing) should be smaller than the other
27 % flags.  Adobe Sonata doesn't do this correctly.  (Instead they have
28 % an extension flag, which looks less elegant.)
29 %
30
31 save hip_thickness, foot_thickness;
32
33 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
34 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
35
36 define_pixels (hip_thickness, foot_thickness);
37
38 %
39 % Inspired by Adobe Sonata and [Wanske].
40 % For example, see POSTSCRIPT Language -- program design,
41 % page 119, and [Wanske], p 41, 42.
42 %
43
44 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
45                hip_thickness, foot_thickness, show_labels) =
46         save c;
47
48         clearxy;
49
50         c = 0.7;
51
52         penpos1 (flare, 90);
53         penpos2 (whatever, 0);
54
55         x2r - x2l = hround (hip_thickness);
56
57         penpos3 (foot_thickness, -20.0);
58
59         z1r = center;
60         z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
61         z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
62
63         x2r := hround x2r;
64         y2r := vround y2r;
65
66         outer_path := z3r{curl c}
67                       .. z2r{up}
68                       .. {up}z1r;
69
70         if show_labels = 1:
71                 penlabels (1, 2, 3);
72         fi;
73
74         fill z1l{curl 0}
75              ..tension 1.1.. z2l{down}
76              .. {curl c}simple_serif (z3l, z3r, 80)
77              & outer_path
78              & z1r
79              -- cycle;
80 enddef;
81
82 %
83 % TODO: calculate intersectpoint (see TeX book, p. 137)
84 % TODO: calculate incision_depth
85 %
86
87 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
88               intersectpoint, hip_thickness, foot_thickness) =
89 begingroup
90         save prev_center, prev_xextreme, prev_yextreme;
91         save rel_foot, ip, center, incision_depth;
92         save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
93         save hip_dep_ratio, foot_wid_ratio;
94         pair prev_center, center, foot, prev_xextreme, prev_yextreme;
95         pair ip, rel_foot;
96
97         incision_depth = 1.013;
98         prev_center = point 2 of outer_path;
99         prev_xextreme = point 1 of outer_path;
100         prev_yextreme = point 0 of outer_path;
101         prev_hipwid = xpart (prev_xextreme - prev_center);
102         prev_footdep = -ypart (prev_yextreme - prev_center);
103         prev_hipdep = -ypart (prev_xextreme - prev_center);
104         ip = point intersectpoint of outer_path;
105
106         wid = prev_hipwid * hip_wid_multiplier;
107         hip_dep = prev_hipdep * hip_dep_multiplier;
108
109         center = prev_center + (0, yoff);
110         rel_foot = incision_depth [(wid, hip_dep), ip - center];
111         dep = -ypart (rel_foot);
112         foot_wid_ratio = xpart (rel_foot) / wid;
113         hip_dep_ratio = hip_dep / dep;
114
115         draw_flag (center, flare, (wid, dep),
116                    hip_dep_ratio, foot_wid_ratio,
117                    hip_thickness, foot_thickness, 0);
118 endgroup
119 enddef;
120
121
122 fet_beginchar ("8th Flag (up)", "u3");
123         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
124
125         flare = staff_space;
126         hip_depth_ratio = .72;
127         foot_width_ratio = .8;
128         hip_width# = upflag_width# - hip_thickness# / 2;
129         foot_depth# = 3 staff_space# - blot_diameter# / 2;
130         define_pixels (hip_width, foot_depth);
131
132         set_char_box (0,
133                       hip_width# + stemthickness# / 2 + right_upflag_space#,
134                       foot_depth# + foot_thickness# / 2, stemthickness# / 2);
135
136         draw_flag ((0,0), flare, (hip_width, foot_depth),
137                    hip_depth_ratio, foot_width_ratio,
138                    hip_thickness, foot_thickness, 1);
139
140         draw_square_block ((- 0.5 stemthickness_rounded, -staff_space_rounded),
141                            (0, 0));
142 fet_endchar;
143
144
145 fet_beginchar ("16th Flag (up)", "u4");
146         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
147         save flagspace, total_depth, flag_count;
148
149         total_depth# = 3.5 staff_space# - blot_diameter# / 2;
150         flag_count = 2;
151         flare = .85 staff_space;
152         flagspace# = .85 staff_space#;
153         hip_depth_ratio = .72;
154         hip_width# = upflag_width# - hip_thickness# / 2;
155         flagspace# + foot_depth# = total_depth#;
156         foot_width_ratio = .8;
157         define_pixels (hip_width, foot_depth);
158         define_whole_vertical_pixels (flagspace);
159
160         set_char_box (0,
161                       hip_width# + stemthickness# / 2 + right_upflag_space#,
162                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
163
164         draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
165                    hip_depth_ratio, foot_width_ratio,
166                    hip_thickness, foot_thickness, 1);
167
168         add_flag (flagspace, flare, .97, 1.00, 1.25,
169                   hip_thickness, foot_thickness);
170
171         draw_square_block ((- 0.5 stemthickness_rounded, 0),
172                            (0, -2 staff_space_rounded));
173 fet_endchar;
174
175
176 fet_beginchar ("32nd Flag (up)", "u5");
177         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
178         save flagspace, total_depth, flag_count;
179
180         flag_count = 3;
181         total_depth# = 4.25 staff_space#;
182         flare = .85 staff_space;
183         flagspace# = .87 staff_space#;
184         hip_depth_ratio = .72;
185         hip_width# = upflag_width# - hip_thickness# / 2;
186         foot_width_ratio = .8;
187
188         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
189
190         define_pixels (hip_width, foot_depth);
191         define_whole_vertical_pixels (flagspace);
192
193         set_char_box (0, hip_width# + right_upflag_space#,
194                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
195
196         draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
197                    hip_depth_ratio, foot_width_ratio,
198                    hip_thickness, foot_thickness, 1);
199
200         add_flag (flagspace, flare, .97, 1.00, 1.25,
201                   hip_thickness, foot_thickness);
202         add_flag (flagspace, flare, .95, 1.05, 1.25,
203                   hip_thickness, foot_thickness);
204
205         draw_square_block ((- 0.5 stemthickness_rounded, 0),
206                            (0, -3 staff_space_rounded));
207 fet_endchar;
208
209
210 fet_beginchar ("64th Flag (up)", "u6");
211         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
212         save flagspace, total_depth, flag_count;
213
214         flag_count = 4;
215         flare = .85 staff_space;
216         flagspace# = .9 staff_space#;
217         hip_depth_ratio = .72;
218         hip_width# = upflag_width# - hip_thickness# / 2;
219         total_depth# = 5.25 staff_space#;
220         foot_width_ratio = .8;
221
222         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
223
224         define_pixels (hip_width, foot_depth);
225         define_whole_vertical_pixels (flagspace);
226
227         set_char_box (0, hip_width# + right_upflag_space#,
228                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
229
230         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
231                    (hip_width, foot_depth),
232                    hip_depth_ratio, foot_width_ratio,
233                    hip_thickness, foot_thickness, 1);
234
235         add_flag (flagspace, flare, .97, 1.00, 1.3,
236                   hip_thickness, foot_thickness);
237         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
238                   hip_thickness, foot_thickness);
239         add_flag (flagspace, flare, .95, 1.05, 1.25,
240                   hip_thickness, foot_thickness);
241
242         draw_square_block ((- 0.5 stemthickness_rounded, 0),
243                            (0, -4 staff_space_rounded));
244 fet_endchar;
245
246
247 fet_beginchar ("8th (down)", "d3");
248         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
249         save flagspace, total_depth, flag_count;
250
251         flag_count = 1;
252         flare = .99 staff_space;
253         flagspace# = .9 staff_space#;
254         hip_depth_ratio = .72 ;
255         hip_width# = downflag_width# - hip_thickness# / 2;
256         total_depth# = 2.85 staff_space#;
257         foot_width_ratio = .8;
258
259         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
260
261         define_pixels (hip_width, flagspace, foot_depth);
262
263         set_char_box (0, hip_width# + right_downflag_space#,
264                       total_depth# + foot_thickness# / 2, stemthickness# / 2)
265
266         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
267                    (hip_width, foot_depth),
268                    hip_depth_ratio, foot_width_ratio,
269                    hip_thickness, foot_thickness, 0);
270
271         draw_square_block ((- 0.5 stemthickness_rounded, 0),
272                            (0, -staff_space_rounded));
273
274         y_mirror_char;
275 fet_endchar;
276
277
278 %%%%%%%%
279 %
280 % Single Stroke for Short Appogiatura
281 %
282
283 fet_beginchar ("grace dash (up)", "ugrace");
284         save flare, hip_depth_ratio, hip_width, foot_depth;
285
286         hip_depth_ratio = .72;
287         flare# = staff_space#;
288         hip_width# = upflag_width# - hip_thickness# / 2;
289         foot_depth# = 3 staff_space#;
290
291         define_pixels (hip_width, foot_depth);
292
293         set_char_box (hip_width# * hip_depth_ratio,
294                       hip_width# + right_upflag_space#,
295                       foot_depth# * hip_depth_ratio, -flare#)
296
297         pickup pencircle scaled 1.5 stemthickness;
298
299         z1 = (-b, -d);
300         z2 = (w, h);
301
302         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
303         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
304
305         fill z1l
306              -- z2l
307              .. top z2
308              .. rt z2
309              .. z2r
310              -- z1r
311              .. bot z1
312              .. lft z1
313              .. cycle;
314
315         penlabels (1, 2);
316 fet_endchar;
317
318
319 fet_beginchar ("grace dash (down)", "dgrace");
320         save flare, hip_depth_ratio, hip_width, foot_depth;
321         save total_depth;
322
323         hip_depth_ratio = .72 ;
324         flare# = .99 staff_space#;
325         hip_width# = downflag_width# - hip_thickness# / 2;
326         total_depth# = 2.85 staff_space#;
327         foot_depth# = total_depth#;
328         foot_width_ratio = .8;
329
330         define_pixels (hip_width, foot_depth);
331
332         set_char_box (hip_width# * hip_depth_ratio,
333                       hip_width# + right_downflag_space#,
334                       foot_depth# * hip_depth_ratio, -flare#)
335
336         pickup pencircle scaled 1.5 stemthickness;
337
338         z1 = (-b, -d);
339         z2 = (w, h);
340
341         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
342         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
343
344         fill z1l
345              -- z2l
346              .. top z2
347              .. rt z2
348              .. z2r
349              -- z1r
350              .. bot z1
351              .. lft z1
352              .. cycle;
353
354         y_mirror_char;
355 fet_endchar;
356
357
358 fet_beginchar ("16th (down)", "d4");
359         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
360         save flagspace, total_depth, flag_count;
361
362         flag_count = 2;
363         flare = .8 staff_space;
364         flagspace# = .9 staff_space#;
365         hip_depth_ratio = .85;
366         hip_width# = downflag_width# - hip_thickness# / 2;
367         total_depth# = 3.0 staff_space# - blot_diameter# / 2;
368         foot_width_ratio = .95;
369
370         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
371
372         set_char_box (0, hip_width# + right_downflag_space#,
373                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
374
375         define_pixels (hip_width, foot_depth);
376         define_whole_vertical_pixels (flagspace);
377
378         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
379                    (hip_width, foot_depth),
380                    hip_depth_ratio, foot_width_ratio,
381                    hip_thickness, foot_thickness, 0);
382
383         add_flag (flagspace, flare, .95, 1.00, 1.25,
384                   hip_thickness, foot_thickness);
385
386         draw_square_block ((-0.5 stemthickness_rounded, 0),
387                            (0, -2 staff_space_rounded));
388
389         y_mirror_char;
390 fet_endchar;
391
392
393 fet_beginchar ("32nd (down)", "d5");
394         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
395         save flagspace, total_depth, flag_count;
396
397         flag_count = 3;
398         flare = .84 staff_space;
399         flagspace# = .9 staff_space#;
400         hip_depth_ratio = .85;
401         hip_width# = downflag_width# - hip_thickness# / 2;
402         total_depth# = 3.85 staff_space#;
403         foot_width_ratio = .95;
404
405         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
406
407         define_pixels (hip_width, foot_depth);
408         define_whole_vertical_pixels (flagspace);
409
410         set_char_box (0, hip_width# + right_downflag_space#,
411                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
412
413         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
414                    (hip_width, foot_depth),
415                    hip_depth_ratio, foot_width_ratio,
416                    hip_thickness, foot_thickness, 0);
417
418         add_flag (flagspace, flare, .97, 1.00, 1.25,
419                   hip_thickness, foot_thickness);
420         add_flag (flagspace, flare, .95, 1.05, 1.25,
421                   hip_thickness, foot_thickness);
422
423         draw_square_block ((- 0.5 stemthickness_rounded, 0),
424                            (0, -3 staff_space_rounded));
425
426         y_mirror_char;
427 fet_endchar;
428
429
430 fet_beginchar ("64th (down)", "d6");
431         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
432         save flagspace, total_depth, flag_count;
433
434         flag_count = 4;
435         flare = .8 staff_space;
436         flagspace# = .9 staff_space#;
437         hip_depth_ratio = .85;
438         hip_width# = downflag_width# - hip_thickness# / 2;
439         total_depth# = 4.35 staff_space#;
440         foot_width_ratio = .98;
441
442         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
443
444         define_pixels (hip_width, foot_depth);
445         define_whole_vertical_pixels (flagspace);
446
447         set_char_box (0, hip_width# + right_downflag_space#,
448                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
449
450         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
451                    (hip_width, foot_depth),
452                    hip_depth_ratio, foot_width_ratio,
453                    hip_thickness, foot_thickness, 0);
454
455         add_flag (flagspace, flare, .97, 1.20, 1.175,
456                   hip_thickness, foot_thickness);
457         add_flag (flagspace, flare, .97, 1.10, 1.175,
458                   hip_thickness, foot_thickness);
459         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
460                   hip_thickness, foot_thickness);
461
462         draw_square_block ((- 0.5 stemthickness_rounded, 0),
463                            (0, -4 staff_space_rounded));
464
465         y_mirror_char;
466 fet_endchar;
467
468 fet_endgroup ("flags");