]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-banier.mf
e3d56375c685c83f18f9627058e6f6f42b36d90f
[lilypond.git] / mf / feta-banier.mf
1 %
2 % feta-banier.mf -- draw flags
3 %
4 % source file of the GNU LilyPond music typesetter
5 %
6 % (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 fet_begingroup ("flags");
9
10 save outer_path;
11 path outer_path;
12
13 %
14 % Flags pointing down overlap with the notehead (in x-direction), so
15 % the down-flag can be bigger.
16 %
17
18 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
19 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
20
21 right_upflag_space# = .0 upflag_width#;
22 right_downflag_space# = .0 downflag_width#;
23
24 %
25 % Flags pointing down cannot overlap with the notehead in y-direction,
26 % so they have less slant.
27 %
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.)
32 %
33
34 save hip_thickness, foot_thickness;
35
36 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
37 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
38
39 define_pixels (hip_thickness, foot_thickness);
40
41 %
42 % Inspired by Adobe Sonata and [Wanske].
43 % For example, see POSTSCRIPT Language -- program design,
44 % page 119, and [Wanske], p 41, 42.
45 %
46
47 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
48                hip_thickness, foot_thickness, show_labels) =
49         save c;
50
51         clearxy;
52
53         c = 0.7;
54
55         penpos1 (flare, 90);
56         penpos2 (whatever, 0);
57
58         x2r - x2l = hround (hip_thickness);
59
60         penpos3 (foot_thickness, -20.0);
61
62         z1r = center;
63         z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
64         z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
65
66         x2r := hround x2r;
67         y2r := vround y2r;
68
69         outer_path := z3r{curl c}
70                       .. z2r{up}
71                       .. {up}z1r;
72
73         if show_labels = 1:
74                 penlabels (1, 2, 3);
75         fi;
76
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;
84
85 %
86 % TODO: calculate intersectpoint (see TeX book, p. 137)
87 % TODO: calculate incision_depth
88 %
89
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;
99
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;
108
109         wid = prev_hipwid * hip_wid_multiplier;
110         hip_dep = prev_hipdep * hip_dep_multiplier;
111
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;
117
118         draw_flag (center, flare, (wid, dep),
119                    hip_dep_ratio, foot_wid_ratio,
120                    hip_thickness, foot_thickness, 0);
121 endgroup
122 enddef;
123
124
125 fet_beginchar ("8th Flag (up)", "u3");
126         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
127
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);
134
135         set_char_box (0,
136                       hip_width# + stemthickness# / 2 + right_upflag_space#,
137                       foot_depth# + foot_thickness# / 2, stemthickness# / 2);
138
139         draw_flag ((0,0), flare, (hip_width, foot_depth),
140                    hip_depth_ratio, foot_width_ratio,
141                    hip_thickness, foot_thickness, 1);
142
143         draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
144                            (0, 0));
145 fet_endchar;
146
147
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;
151
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);
162
163         set_char_box (0,
164                       hip_width# + stemthickness# / 2 + right_upflag_space#,
165                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
166
167         draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
168                    hip_depth_ratio, foot_width_ratio,
169                    hip_thickness, foot_thickness, 1);
170
171         add_flag (flagspace, flare, .97, 1.00, 1.25,
172                   hip_thickness, foot_thickness);
173
174         draw_square_block ((-0.5 stemthickness_rounded, 0),
175                            (0, -2 staff_space_rounded));
176 fet_endchar;
177
178
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;
182
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;
190
191         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
192
193         define_pixels (hip_width, foot_depth);
194         define_whole_vertical_pixels (flagspace);
195
196         set_char_box (0, hip_width# + right_upflag_space#,
197                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
198
199         draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
200                    hip_depth_ratio, foot_width_ratio,
201                    hip_thickness, foot_thickness, 1);
202
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);
207
208         draw_square_block ((-0.5 stemthickness_rounded, 0),
209                            (0, -3 staff_space_rounded));
210 fet_endchar;
211
212
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;
216
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;
224
225         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
226
227         define_pixels (hip_width, foot_depth);
228         define_whole_vertical_pixels (flagspace);
229
230         set_char_box (0, hip_width# + right_upflag_space#,
231                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
232
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);
237
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);
244
245         draw_square_block ((-0.5 stemthickness_rounded, 0),
246                            (0, -4 staff_space_rounded));
247 fet_endchar;
248
249
250 fet_beginchar ("8th (down)", "d3");
251         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
252         save flagspace, total_depth, flag_count;
253
254         flag_count = 1;
255         flare = staff_space;
256         flagspace# = .9 staff_space#;
257         hip_depth_ratio = .72;
258         hip_width# = downflag_width# - hip_thickness# / 2;
259         total_depth# = 2.85 staff_space#;
260         foot_width_ratio = .8;
261
262         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
263
264         define_pixels (hip_width, flagspace, foot_depth);
265
266         set_char_box (0, hip_width# + right_downflag_space#,
267                       total_depth# + foot_thickness# / 2, stemthickness# / 2)
268
269         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
270                    (hip_width, foot_depth),
271                    hip_depth_ratio, foot_width_ratio,
272                    hip_thickness, foot_thickness, 0);
273
274         draw_square_block ((-0.5 stemthickness_rounded, 0),
275                            (0, -staff_space_rounded));
276
277         y_mirror_char;
278 fet_endchar;
279
280
281 %%%%%%%%
282 %
283 % Single Stroke for Short Appogiatura
284 %
285
286 fet_beginchar ("grace dash (up)", "ugrace");
287         save flare, hip_depth_ratio, hip_width, foot_depth;
288
289         hip_depth_ratio = .72;
290         flare# = staff_space#;
291         hip_width# = upflag_width# - hip_thickness# / 2;
292         foot_depth# = 3 staff_space#;
293
294         define_pixels (hip_width, foot_depth);
295
296         set_char_box (hip_width# * hip_depth_ratio,
297                       hip_width# + right_upflag_space#,
298                       foot_depth# * hip_depth_ratio, -flare#)
299
300         pickup pencircle scaled 1.5 stemthickness;
301
302         z1 = (-b, -d);
303         z2 = (w, h);
304
305         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
306         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
307
308         fill z1l
309              -- z2l
310              .. top z2
311              .. rt z2
312              .. z2r
313              -- z1r
314              .. bot z1
315              .. lft z1
316              .. cycle;
317
318         penlabels (1, 2);
319 fet_endchar;
320
321
322 fet_beginchar ("grace dash (down)", "dgrace");
323         save flare, hip_depth_ratio, hip_width, foot_depth;
324         save total_depth;
325
326         hip_depth_ratio = .72 ;
327         flare# = .99 staff_space#;
328         hip_width# = downflag_width# - hip_thickness# / 2;
329         total_depth# = 2.85 staff_space#;
330         foot_depth# = total_depth#;
331         foot_width_ratio = .8;
332
333         define_pixels (hip_width, foot_depth);
334
335         set_char_box (hip_width# * hip_depth_ratio,
336                       hip_width# + right_downflag_space#,
337                       foot_depth# * hip_depth_ratio, -flare#)
338
339         pickup pencircle scaled 1.5 stemthickness;
340
341         z1 = (-b, -d);
342         z2 = (w, h);
343
344         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
345         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
346
347         fill z1l
348              -- z2l
349              .. top z2
350              .. rt z2
351              .. z2r
352              -- z1r
353              .. bot z1
354              .. lft z1
355              .. cycle;
356
357         y_mirror_char;
358 fet_endchar;
359
360
361 fet_beginchar ("16th (down)", "d4");
362         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
363         save flagspace, total_depth, flag_count;
364
365         flag_count = 2;
366         flare = .8 staff_space;
367         flagspace# = .9 staff_space#;
368         hip_depth_ratio = .85;
369         hip_width# = downflag_width# - hip_thickness# / 2;
370         total_depth# = 3.0 staff_space# - blot_diameter# / 2;
371         foot_width_ratio = .95;
372
373         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
374
375         set_char_box (0, hip_width# + right_downflag_space#,
376                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
377
378         define_pixels (hip_width, foot_depth);
379         define_whole_vertical_pixels (flagspace);
380
381         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
382                    (hip_width, foot_depth),
383                    hip_depth_ratio, foot_width_ratio,
384                    hip_thickness, foot_thickness, 0);
385
386         add_flag (flagspace, flare, .95, 1.00, 1.25,
387                   hip_thickness, foot_thickness);
388
389         draw_square_block ((-0.5 stemthickness_rounded, 0),
390                            (0, -2 staff_space_rounded));
391
392         y_mirror_char;
393 fet_endchar;
394
395
396 fet_beginchar ("32nd (down)", "d5");
397         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
398         save flagspace, total_depth, flag_count;
399
400         flag_count = 3;
401         flare = .84 staff_space;
402         flagspace# = .9 staff_space#;
403         hip_depth_ratio = .85;
404         hip_width# = downflag_width# - hip_thickness# / 2;
405         total_depth# = 3.85 staff_space#;
406         foot_width_ratio = .95;
407
408         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
409
410         define_pixels (hip_width, foot_depth);
411         define_whole_vertical_pixels (flagspace);
412
413         set_char_box (0, hip_width# + right_downflag_space#,
414                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
415
416         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
417                    (hip_width, foot_depth),
418                    hip_depth_ratio, foot_width_ratio,
419                    hip_thickness, foot_thickness, 0);
420
421         add_flag (flagspace, flare, .97, 1.00, 1.25,
422                   hip_thickness, foot_thickness);
423         add_flag (flagspace, flare, .95, 1.05, 1.25,
424                   hip_thickness, foot_thickness);
425
426         draw_square_block ((-0.5 stemthickness_rounded, 0),
427                            (0, -3 staff_space_rounded));
428
429         y_mirror_char;
430 fet_endchar;
431
432
433 fet_beginchar ("64th (down)", "d6");
434         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
435         save flagspace, total_depth, flag_count;
436
437         flag_count = 4;
438         flare = .8 staff_space;
439         flagspace# = .9 staff_space#;
440         hip_depth_ratio = .85;
441         hip_width# = downflag_width# - hip_thickness# / 2;
442         total_depth# = 4.35 staff_space#;
443         foot_width_ratio = .98;
444
445         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
446
447         define_pixels (hip_width, foot_depth);
448         define_whole_vertical_pixels (flagspace);
449
450         set_char_box (0, hip_width# + right_downflag_space#,
451                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
452
453         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
454                    (hip_width, foot_depth),
455                    hip_depth_ratio, foot_width_ratio,
456                    hip_thickness, foot_thickness, 0);
457
458         add_flag (flagspace, flare, .97, 1.20, 1.175,
459                   hip_thickness, foot_thickness);
460         add_flag (flagspace, flare, .97, 1.10, 1.175,
461                   hip_thickness, foot_thickness);
462         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
463                   hip_thickness, foot_thickness);
464
465         draw_square_block ((-0.5 stemthickness_rounded, 0),
466                            (0, -4 staff_space_rounded));
467
468         y_mirror_char;
469 fet_endchar;
470
471 fet_endgroup ("flags");