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