]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-banier.mf
release: 0.1.36
[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 %
21 % Because of optical illusion, the utmost flag (bottom for
22 % down-pointing, top for up-pointing) should be smaller than the other
23 % flags.  Adobe Sonata doesn't do this correctly.  (Instead they have an 
24 % extension flag. Yuck)
25 %
26
27 save hip_thickness, foot_thickness;
28 hip_thickness# = 1.3 stemthickness#;
29 foot_thickness# =  hip_thickness#;
30
31 %
32 % Inspired by Adobe Sonata and [Wanske]
33 % for example, see POSTSCRIPT Language -- program design, 
34 % page 119, and [Wanske], p 41,42
35 %
36 def draw_flag(expr center, flare, 
37         dims, hip_depth, foot_wid, hip_thickness, foot_thickness)=
38         clearxy;
39
40         penpos1(flare, 90);
41         penpos2(whatever, 0);
42         x2r - x2l = hip_thickness;
43         penpos3(foot_thickness, 0) ;
44
45         z1r  = center;
46         z2r = center + (xpart dims, -ypart(dims) * hip_depth);
47         z3r = center + (xpart(dims) * foot_wid, -ypart dims);
48
49         outer_path := z3r{curl 0} .. z2r{up} .. {up}z1r;
50
51         penlabels(1, 2, 3);
52         fill z1l{curl 0}
53                 ..tension 1.1 .. z2l{down} .. 
54                 {curl 0} simple_serif(z3l, z3r, 80) &
55                 outer_path & z1r -- cycle;
56 enddef;
57
58 %
59 % TODO: calc intersectpoint
60 % TODO: calc incision_depth
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 interline#;
103         hip_depth_ratio = .72; 
104         foot_width_ratio = .8;
105         hip_width# = upflag_width# - hip_thickness#/2;
106
107         foot_depth# =  3 interline#;
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,-2 interline);
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 interline#;
129         flag_count = 2;
130         flare# = .85 interline#;
131         flagspace# = .85 interline#;    
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
146         draw_flag((stemthickness/2,- flagspace), flare, 
147                 (hip_width, foot_depth), 
148                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
149
150         add_flag(flagspace, flare,
151                 .97, 1.00, 1.25, hip_thickness, foot_thickness);  
152
153         pickup pencircle scaled stemthickness;
154         draw (0, 0) .. (0,-2 interline);
155 fet_endchar;
156
157
158 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
159         save flare, 
160                 hip_depth_ratio, hip_width,
161                 foot_depth, foot_width_ratio;
162         save flagspace, total_depth, flag_count;
163         flag_count = 3;
164         total_depth#=4.25 interline#;
165         flare# = .85 interline#;
166         flagspace# = .87 interline#;    
167         hip_depth_ratio = .72 ;
168         hip_width# = upflag_width# - hip_thickness#/2;
169         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
170
171         foot_width_ratio = .8;
172
173         set_char_box(stemthickness# /2, hip_width#
174                 + stemthickness#/2 + right_upflag_space#, 
175                 total_depth# + foot_thickness#/2, stemthickness#/2)
176
177         define_pixels(flare, hip_width, hip_thickness,
178                 flagspace,
179                 foot_depth,  foot_thickness);
180
181         draw_flag((stemthickness/2,- 2 flagspace), flare, 
182                 (hip_width, foot_depth), 
183                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
184
185         add_flag(flagspace, flare,
186                 .97, 1.00, 1.25, hip_thickness, foot_thickness);  
187
188         add_flag(flagspace, flare,
189                 .95, 1.05, 1.25, hip_thickness, foot_thickness);  
190
191         pickup pencircle scaled stemthickness;
192         draw (0, 0) .. (0,-2 interline);
193 fet_endchar;
194
195 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
196         save flare, 
197                 hip_depth_ratio, hip_width,
198                 foot_depth, foot_width_ratio;
199         save flagspace, total_depth, flag_count;
200         
201         flag_count = 4;
202         flare# = .85 interline#;
203         flagspace# = .9 interline#;     
204         hip_depth_ratio = .72 ;
205         hip_width# = upflag_width# - hip_thickness#/2;
206         total_depth# = 5.25 interline#;
207         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
208
209         foot_width_ratio = .8;
210
211         set_char_box(stemthickness# /2, hip_width#
212                 + stemthickness#/2 + right_upflag_space#, 
213                 total_depth# + foot_thickness#/2, stemthickness#/2)
214
215         define_pixels(flare, hip_width, hip_thickness,
216                 flagspace,
217                 foot_depth,  foot_thickness);
218
219         draw_flag((stemthickness/2,- (flag_count-1)* flagspace), flare, 
220                 (hip_width, foot_depth), 
221                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
222
223         add_flag(flagspace, flare,
224                 .97, 1.00, 1.3, hip_thickness, foot_thickness);  
225
226         add_flag(flagspace, flare,
227                 1.00, 1.00, 1.25, hip_thickness, foot_thickness);  
228         add_flag(flagspace, flare,
229                 .95, 1.05, 1.25, hip_thickness, foot_thickness);  
230         pickup pencircle scaled stemthickness;
231         draw (0, 0) .. (0,-2 interline);
232 fet_endchar;
233
234 fet_beginchar("8th (down)", "d3", "deighthflag")
235         save flare, 
236                 hip_depth_ratio, hip_width,
237                 foot_depth, foot_width_ratio;
238         save flagspace, total_depth, flag_count;
239         
240         flag_count = 1;
241         flare# = .99 interline#;
242         flagspace# = .9 interline#;     
243         hip_depth_ratio = .72 ;
244         hip_width# = downflag_width# - hip_thickness#/2;
245         total_depth# = 2.85 interline#;
246         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
247
248         foot_width_ratio = .8;
249
250         set_char_box(stemthickness# /2, hip_width#
251                 + stemthickness#/2 + right_downflag_space#,
252                 total_depth# + foot_thickness#/2, stemthickness#/2)
253
254         define_pixels(flare, hip_width, hip_thickness,
255                 flagspace,
256                 foot_depth,  foot_thickness);
257
258         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
259                 (hip_width, foot_depth), 
260                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
261
262
263         pickup pencircle scaled stemthickness;
264         draw (0, 0) .. (0,-2 interline);
265         y_mirror_char;
266 fet_endchar;
267
268 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
269         save flare, 
270                 hip_depth_ratio, hip_width,
271                 foot_depth, foot_width_ratio;
272         save flagspace, total_depth, flag_count;
273         
274         flag_count = 2;
275         flare# = .8 interline#;
276         flagspace# = .9 interline#;     
277         hip_depth_ratio = .85 ;
278         hip_width# = downflag_width# - hip_thickness#/2;
279         total_depth# = 3.0 interline#;
280         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
281
282         foot_width_ratio = .95;
283
284         set_char_box(stemthickness# /2, hip_width#
285                 + stemthickness#/2 + right_downflag_space#, 
286                 total_depth# + foot_thickness#/2, stemthickness#/2)
287
288         define_pixels(flare, hip_width, hip_thickness,
289                 flagspace,
290                 foot_depth,  foot_thickness);
291
292         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
293                 (hip_width, foot_depth), 
294                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
295         add_flag(flagspace, flare,
296                 .95, 1.00, 1.25, hip_thickness, foot_thickness);  
297
298         
299
300         pickup pencircle scaled stemthickness;
301         draw (0, 0) .. (0,-2 interline);
302         y_mirror_char;
303 fet_endchar;
304
305 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
306         save flare, 
307                 hip_depth_ratio, hip_width,
308                 foot_depth, foot_width_ratio;
309         save flagspace, total_depth, flag_count;
310         
311         flag_count = 3;
312         flare# = .84 interline#;
313         flagspace# = .9 interline#;     
314         hip_depth_ratio = .85 ;
315         hip_width# = downflag_width# - hip_thickness#/2;
316         total_depth# = 3.85 interline#;
317         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
318
319         foot_width_ratio = .95;
320
321         set_char_box(stemthickness# /2, hip_width#
322                 + stemthickness#/2 + right_downflag_space#, 
323                 total_depth# + foot_thickness#/2, stemthickness#/2)
324
325         define_pixels(flare, hip_width, hip_thickness,
326                 flagspace,
327                 foot_depth,  foot_thickness);
328
329         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
330                 (hip_width, foot_depth), 
331                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
332         add_flag(flagspace, flare,
333                 .97, 1.00, 1.25, hip_thickness, foot_thickness);  
334
335         add_flag(flagspace, flare,
336                 .95, 1.05, 1.25, hip_thickness, foot_thickness);  
337
338         
339
340         pickup pencircle scaled stemthickness;
341         draw (0, 0) .. (0,-2 interline);
342         y_mirror_char;
343 fet_endchar;
344 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
345         save flare, 
346                 hip_depth_ratio, hip_width,
347                 foot_depth, foot_width_ratio;
348         save flagspace, total_depth, flag_count;
349         
350         flag_count = 4;
351         flare# = .8 interline#;
352         flagspace# = .9 interline#;     
353         hip_depth_ratio = .85 ;
354         hip_width# = downflag_width# - hip_thickness#/2;
355         total_depth# = 4.35 interline#;
356         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
357
358         foot_width_ratio = .98;
359
360         set_char_box(stemthickness# /2, hip_width#
361                 + stemthickness#/2 + right_downflag_space#, 
362                 total_depth# + foot_thickness#/2, stemthickness#/2)
363
364         define_pixels(flare, hip_width, hip_thickness,
365                 flagspace,
366                 foot_depth,  foot_thickness);
367
368         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
369                 (hip_width, foot_depth), 
370                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
371         add_flag(flagspace, flare,
372                 .97, 1.20, 1.175, hip_thickness, foot_thickness);  
373         add_flag(flagspace, flare,
374                 .97, 1.10, 1.175, hip_thickness, foot_thickness);  
375
376         add_flag(.98 flagspace, flare,
377                 .91, 1.05, 1.2, hip_thickness, foot_thickness);  
378
379         
380
381         pickup pencircle scaled stemthickness;
382         draw (0, 0) .. (0,-2 interline);
383         y_mirror_char;
384 fet_endchar;
385 fet_endgroup("flags");