]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-banier.mf
release: 0.1.26
[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 %
14 % Flags pointing down cannot overlap with the notehead in y-direction,
15 % so they have less slant.
16
17 %
18 % Because of optical illusion, the utmost flag 
19 % (bottom for down-pointing, top  
20 % for up-pointing) should be smaller than the other flags 
21 %
22
23 save hip_thickness, foot_thickness;
24 hip_thickness# = 1.3 stemthickness#;
25 foot_thickness# =  hip_thickness#;
26
27 %
28 % Inspired by Adobe Sonata and [Wanske]
29 % for example, see POSTSCRIPT Language -- program design, 
30 % page 119, and [Wanske], p 41,42
31 %
32
33 def draw_flag(expr center, flare, 
34         dims, hip_depth, foot_wid, hip_thickness, foot_thickness)=
35         clearxy;
36
37         penpos1(flare, 90);
38         penpos2(whatever, 0);
39         x2r - x2l = hip_thickness;
40         penpos3(foot_thickness, 0) ;
41
42         z1r  = center;
43         z2r = center + (xpart dims, -ypart(dims) * hip_depth);
44         z3r = center + (xpart(dims) * foot_wid, -ypart dims);
45
46         outer_path := z3r{curl 0} .. z2r{up} .. {up}z1r;
47
48         penlabels(1, 2, 3);
49         fill z1l{curl 0}
50                 ..tension 1.1 .. z2l{down} .. 
51                 {curl 0} simple_serif(z3l, z3r, 80) &
52                 outer_path & z1r -- cycle;
53 enddef;
54
55 %
56 % TODO: calc intersectpoint
57 % TODO: calc incision_depth
58
59 def add_flag(expr yoff, flare, hip_wid_multiplier, 
60                 hip_dep_multiplier,
61                 intersectpoint, hip_thickness, foot_thickness) =
62         begingroup
63         save prev_center, prev_xextreme, prev_yextreme;
64         save rel_foot, ip, center, incision_depth;
65         save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
66         save hip_dep_ratio, foot_wid_ratio;
67         pair prev_center, center, foot, prev_xextreme, prev_yextreme;
68         pair ip, rel_foot;
69         
70         incision_depth = 1.013;
71         prev_center = point 2 of outer_path;
72         prev_xextreme = point 1 of outer_path;
73         prev_yextreme = point 0 of outer_path;
74         prev_hipwid = xpart (prev_xextreme - prev_center);
75         prev_footdep = -ypart (prev_yextreme - prev_center);
76         prev_hipdep = -ypart(prev_xextreme - prev_center);
77         ip = point intersectpoint of outer_path;
78
79         wid = prev_hipwid * hip_wid_multiplier;
80         hip_dep = prev_hipdep * hip_dep_multiplier;
81
82         center = prev_center + (0,yoff);
83         rel_foot = incision_depth [(wid, hip_dep), ip - center];
84         dep = -ypart(rel_foot);
85         foot_wid_ratio = xpart(rel_foot ) / wid;
86         hip_dep_ratio = hip_dep / dep;
87
88         draw_flag(center, flare, 
89                 (wid, dep), hip_dep_ratio, foot_wid_ratio, 
90                 hip_thickness, foot_thickness);
91         endgroup
92 enddef;
93
94 fet_beginchar("8th Flag (up)", "u3", "eighthflag")
95         save flare, 
96                 hip_depth_ratio, hip_width,
97                 foot_depth, foot_width_ratio;
98
99         flare# = 1.0 interline#;
100         hip_depth_ratio = .72; 
101         foot_width_ratio = .8;
102         hip_width# = upflag_width# - hip_thickness#/2;
103
104         foot_depth# =  3 interline#;
105
106         set_char_box(stemthickness# /2, hip_width# 
107                 + stemthickness#/2, 
108                  foot_depth# + foot_thickness#/2, stemthickness#/2)
109
110         define_pixels(flare, hip_width, hip_thickness,
111                 foot_depth, foot_thickness);
112         draw_flag((stemthickness/2,0), flare, 
113                 (hip_width, foot_depth), 
114                 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
115
116         pickup pencircle scaled stemthickness;
117         draw (0, 0) .. (0,-2 interline);
118 fet_endchar;
119
120 fet_beginchar("16th Flag (up)", "u4", "sixteenthflag")
121         save flare, 
122                 hip_depth_ratio, hip_width,
123                 foot_depth, foot_width_ratio;
124         save flagspace, total_depth, flag_count;
125         total_depth# = 3.5 interline#;
126         flag_count = 2;
127         flare# = .85 interline#;
128         flagspace# = .85 interline#;    
129         hip_depth_ratio = .72 ;
130         hip_width# = upflag_width# - hip_thickness#/2;
131         flagspace# + foot_depth# = total_depth#;
132
133         foot_width_ratio = .8;
134
135         set_char_box(stemthickness# /2, hip_width#
136                 + stemthickness#/2, 
137                 total_depth# + foot_thickness#/2, stemthickness#/2)
138
139         define_pixels(flare, hip_width, hip_thickness,
140                 flagspace,
141                 foot_depth,  foot_thickness);
142
143         draw_flag((stemthickness/2,- flagspace), flare, 
144                 (hip_width, foot_depth), 
145                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
146
147         add_flag(flagspace, flare,
148                 .97, 1.00, 1.25, hip_thickness, foot_thickness);  
149
150         pickup pencircle scaled stemthickness;
151         draw (0, 0) .. (0,-2 interline);
152 fet_endchar;
153
154
155 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
156         save flare, 
157                 hip_depth_ratio, hip_width,
158                 foot_depth, foot_width_ratio;
159         save flagspace, total_depth, flag_count;
160         flag_count = 3;
161         total_depth#=4.25 interline#;
162         flare# = .85 interline#;
163         flagspace# = .87 interline#;    
164         hip_depth_ratio = .72 ;
165         hip_width# = upflag_width# - hip_thickness#/2;
166         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
167
168         foot_width_ratio = .8;
169
170         set_char_box(stemthickness# /2, hip_width#
171                 + stemthickness#/2, 
172                 total_depth# + foot_thickness#/2, stemthickness#/2)
173
174         define_pixels(flare, hip_width, hip_thickness,
175                 flagspace,
176                 foot_depth,  foot_thickness);
177
178         draw_flag((stemthickness/2,- 2 flagspace), flare, 
179                 (hip_width, foot_depth), 
180                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
181
182         add_flag(flagspace, flare,
183                 .97, 1.00, 1.25, hip_thickness, foot_thickness);  
184
185         add_flag(flagspace, flare,
186                 .95, 1.05, 1.25, hip_thickness, foot_thickness);  
187
188         pickup pencircle scaled stemthickness;
189         draw (0, 0) .. (0,-2 interline);
190 fet_endchar;
191
192 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
193         save flare, 
194                 hip_depth_ratio, hip_width,
195                 foot_depth, foot_width_ratio;
196         save flagspace, total_depth, flag_count;
197         
198         flag_count = 4;
199         flare# = .85 interline#;
200         flagspace# = .9 interline#;     
201         hip_depth_ratio = .72 ;
202         hip_width# = upflag_width# - hip_thickness#/2;
203         total_depth# = 5.25 interline#;
204         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
205
206         foot_width_ratio = .8;
207
208         set_char_box(stemthickness# /2, hip_width#
209                 + stemthickness#/2, 
210                 total_depth# + foot_thickness#/2, stemthickness#/2)
211
212         define_pixels(flare, hip_width, hip_thickness,
213                 flagspace,
214                 foot_depth,  foot_thickness);
215
216         draw_flag((stemthickness/2,- (flag_count-1)* flagspace), flare, 
217                 (hip_width, foot_depth), 
218                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
219
220         add_flag(flagspace, flare,
221                 .97, 1.00, 1.3, hip_thickness, foot_thickness);  
222
223         add_flag(flagspace, flare,
224                 1.00, 1.00, 1.25, hip_thickness, foot_thickness);  
225         add_flag(flagspace, flare,
226                 .95, 1.05, 1.25, hip_thickness, foot_thickness);  
227         pickup pencircle scaled stemthickness;
228         draw (0, 0) .. (0,-2 interline);
229 fet_endchar;
230
231 fet_beginchar("8th (down)", "d3", "deighthflag")
232         save flare, 
233                 hip_depth_ratio, hip_width,
234                 foot_depth, foot_width_ratio;
235         save flagspace, total_depth, flag_count;
236         
237         flag_count = 1;
238         flare# = .99 interline#;
239         flagspace# = .9 interline#;     
240         hip_depth_ratio = .72 ;
241         hip_width# = downflag_width# - hip_thickness#/2;
242         total_depth# = 2.85 interline#;
243         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
244
245         foot_width_ratio = .8;
246
247         set_char_box(stemthickness# /2, hip_width#
248                 + stemthickness#/2, 
249                 total_depth# + foot_thickness#/2, stemthickness#/2)
250
251         define_pixels(flare, hip_width, hip_thickness,
252                 flagspace,
253                 foot_depth,  foot_thickness);
254
255         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
256                 (hip_width, foot_depth), 
257                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
258
259
260         pickup pencircle scaled stemthickness;
261         draw (0, 0) .. (0,-2 interline);
262         y_mirror_char;
263 fet_endchar;
264
265 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
266         save flare, 
267                 hip_depth_ratio, hip_width,
268                 foot_depth, foot_width_ratio;
269         save flagspace, total_depth, flag_count;
270         
271         flag_count = 2;
272         flare# = .8 interline#;
273         flagspace# = .9 interline#;     
274         hip_depth_ratio = .85 ;
275         hip_width# = downflag_width# - hip_thickness#/2;
276         total_depth# = 3.0 interline#;
277         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
278
279         foot_width_ratio = .95;
280
281         set_char_box(stemthickness# /2, hip_width#
282                 + stemthickness#/2, 
283                 total_depth# + foot_thickness#/2, stemthickness#/2)
284
285         define_pixels(flare, hip_width, hip_thickness,
286                 flagspace,
287                 foot_depth,  foot_thickness);
288
289         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
290                 (hip_width, foot_depth), 
291                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
292         add_flag(flagspace, flare,
293                 .95, 1.00, 1.25, hip_thickness, foot_thickness);  
294
295         
296
297         pickup pencircle scaled stemthickness;
298         draw (0, 0) .. (0,-2 interline);
299         y_mirror_char;
300 fet_endchar;
301
302 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
303         save flare, 
304                 hip_depth_ratio, hip_width,
305                 foot_depth, foot_width_ratio;
306         save flagspace, total_depth, flag_count;
307         
308         flag_count = 3;
309         flare# = .84 interline#;
310         flagspace# = .9 interline#;     
311         hip_depth_ratio = .85 ;
312         hip_width# = downflag_width# - hip_thickness#/2;
313         total_depth# = 3.85 interline#;
314         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
315
316         foot_width_ratio = .95;
317
318         set_char_box(stemthickness# /2, hip_width#
319                 + stemthickness#/2, 
320                 total_depth# + foot_thickness#/2, stemthickness#/2)
321
322         define_pixels(flare, hip_width, hip_thickness,
323                 flagspace,
324                 foot_depth,  foot_thickness);
325
326         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
327                 (hip_width, foot_depth), 
328                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
329         add_flag(flagspace, flare,
330                 .97, 1.00, 1.25, hip_thickness, foot_thickness);  
331
332         add_flag(flagspace, flare,
333                 .95, 1.05, 1.25, hip_thickness, foot_thickness);  
334
335         
336
337         pickup pencircle scaled stemthickness;
338         draw (0, 0) .. (0,-2 interline);
339         y_mirror_char;
340 fet_endchar;
341 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
342         save flare, 
343                 hip_depth_ratio, hip_width,
344                 foot_depth, foot_width_ratio;
345         save flagspace, total_depth, flag_count;
346         
347         flag_count = 4;
348         flare# = .8 interline#;
349         flagspace# = .9 interline#;     
350         hip_depth_ratio = .85 ;
351         hip_width# = downflag_width# - hip_thickness#/2;
352         total_depth# = 4.35 interline#;
353         (flag_count-1) * flagspace# + foot_depth# = total_depth#;
354
355         foot_width_ratio = .98;
356
357         set_char_box(stemthickness# /2, hip_width#
358                 + stemthickness#/2, 
359                 total_depth# + foot_thickness#/2, stemthickness#/2)
360
361         define_pixels(flare, hip_width, hip_thickness,
362                 flagspace,
363                 foot_depth,  foot_thickness);
364
365         draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare, 
366                 (hip_width, foot_depth), 
367                 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
368         add_flag(flagspace, flare,
369                 .97, 1.20, 1.175, hip_thickness, foot_thickness);  
370         add_flag(flagspace, flare,
371                 .97, 1.10, 1.175, hip_thickness, foot_thickness);  
372
373         add_flag(flagspace, flare,
374                 .95, 1.03, 1.175, hip_thickness, foot_thickness);  
375
376         
377
378         pickup pencircle scaled stemthickness;
379         draw (0, 0) .. (0,-2 interline);
380         y_mirror_char;
381 fet_endchar;
382 fet_endgroup("flags");