5 fet_begingroup("flags")
9 % Flags pointing down overlap with the notehead (in x-direction), so
10 % the down-flag can be bigger
11 upflag_width# = .650 black_notehead_width# + stemthickness#/2;
12 downflag_width# = .833 black_notehead_width# + stemthickness#/2;
14 right_upflag_space# = .0 upflag_width#;
15 right_downflag_space# = .0 downflag_width#;
18 % Flags pointing down cannot overlap with the notehead in y-direction,
19 % so they have less slant.
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
24 % an extension flag, which looks less elegant)
27 save hip_thickness, foot_thickness;
28 hip_thickness# = 1.3 stemthickness#;
29 foot_thickness# = 0.95 hip_thickness#;
32 % Inspired by Adobe Sonata and [Wanske]
33 % for example, see POSTSCRIPT Language -- program design,
34 % page 119, and [Wanske], p 41,42
36 def draw_flag(expr center, flare,
37 dims, hip_depth, foot_wid, hip_thickness, foot_thickness)=
43 x2r - x2l = hip_thickness;
44 penpos3 (foot_thickness, -20.0);
47 z2r = center + (xpart dims, -ypart(dims) * hip_depth);
48 z3r = center + (xpart(dims) * foot_wid, -ypart dims);
50 outer_path := z3r{curl c} .. z2r{up} .. {up}z1r;
54 ..tension 1.1 .. z2l{down} ..
55 {curl c} simple_serif(z3l, z3r, 80) &
56 outer_path & z1r -- cycle;
60 % TODO: calc intersectpoint (see TeX book, p. 137)
61 % TODO: calc incision_depth
64 def add_flag(expr yoff, flare, hip_wid_multiplier,
66 intersectpoint, hip_thickness, foot_thickness) =
68 save prev_center, prev_xextreme, prev_yextreme;
69 save rel_foot, ip, center, incision_depth;
70 save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
71 save hip_dep_ratio, foot_wid_ratio;
72 pair prev_center, center, foot, prev_xextreme, prev_yextreme;
75 incision_depth = 1.013;
76 prev_center = point 2 of outer_path;
77 prev_xextreme = point 1 of outer_path;
78 prev_yextreme = point 0 of outer_path;
79 prev_hipwid = xpart (prev_xextreme - prev_center);
80 prev_footdep = -ypart (prev_yextreme - prev_center);
81 prev_hipdep = -ypart(prev_xextreme - prev_center);
82 ip = point intersectpoint of outer_path;
84 wid = prev_hipwid * hip_wid_multiplier;
85 hip_dep = prev_hipdep * hip_dep_multiplier;
87 center = prev_center + (0,yoff);
88 rel_foot = incision_depth [(wid, hip_dep), ip - center];
89 dep = -ypart(rel_foot);
90 foot_wid_ratio = xpart(rel_foot ) / wid;
91 hip_dep_ratio = hip_dep / dep;
93 draw_flag(center, flare,
94 (wid, dep), hip_dep_ratio, foot_wid_ratio,
95 hip_thickness, foot_thickness);
99 fet_beginchar("8th Flag (up)", "u3", "eighthflag")
101 hip_depth_ratio, hip_width,
102 foot_depth, foot_width_ratio;
104 flare# = 1.0 staff_space#;
105 hip_depth_ratio = .72;
106 foot_width_ratio = .8;
107 hip_width# = upflag_width# - hip_thickness#/2;
109 foot_depth# = 3 staff_space#;
111 set_char_box(stemthickness# /2, hip_width#
112 + stemthickness#/2 + right_upflag_space#,
113 foot_depth# + foot_thickness#/2, stemthickness#/2)
115 define_pixels(flare, hip_width, hip_thickness,
116 foot_depth, foot_thickness);
117 draw_flag((stemthickness/2,0), flare,
118 (hip_width, foot_depth),
119 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
121 pickup pencircle scaled stemthickness;
122 draw (0, 0) .. (0,-1 staff_space);
125 fet_beginchar("16th Flag (up)", "u4", "sixteenthflag")
127 hip_depth_ratio, hip_width,
128 foot_depth, foot_width_ratio;
129 save flagspace, total_depth, flag_count;
130 total_depth# = 3.5 staff_space#;
132 flare# = .85 staff_space#;
133 flagspace# = .85 staff_space#;
134 hip_depth_ratio = .72 ;
135 hip_width# = upflag_width# - hip_thickness#/2;
136 flagspace# + foot_depth# = total_depth#;
138 foot_width_ratio = .8;
140 set_char_box(stemthickness# /2, hip_width#
141 + stemthickness#/2 + right_upflag_space#,
142 total_depth# + foot_thickness#/2, stemthickness#/2)
144 define_pixels(flare, hip_width, hip_thickness,
146 foot_depth, foot_thickness);
147 draw_flag((stemthickness/2,- flagspace), flare,
148 (hip_width, foot_depth),
149 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
151 add_flag(flagspace, flare,
152 .97, 1.00, 1.25, hip_thickness, foot_thickness);
154 pickup pencircle scaled stemthickness;
155 draw (0, 0) .. (0,-2 staff_space);
159 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
161 hip_depth_ratio, hip_width,
162 foot_depth, foot_width_ratio;
163 save flagspace, total_depth, flag_count;
165 total_depth#=4.25 staff_space#;
166 flare# = .85 staff_space#;
167 flagspace# = .87 staff_space#;
168 hip_depth_ratio = .72 ;
169 hip_width# = upflag_width# - hip_thickness#/2;
170 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
172 foot_width_ratio = .8;
174 set_char_box(stemthickness# /2, hip_width#
175 + stemthickness#/2 + right_upflag_space#,
176 total_depth# + foot_thickness#/2, stemthickness#/2)
178 define_pixels(flare, hip_width, hip_thickness,
180 foot_depth, foot_thickness);
182 draw_flag((stemthickness/2,- 2 flagspace), flare,
183 (hip_width, foot_depth),
184 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
186 add_flag(flagspace, flare,
187 .97, 1.00, 1.25, hip_thickness, foot_thickness);
189 add_flag(flagspace, flare,
190 .95, 1.05, 1.25, hip_thickness, foot_thickness);
192 pickup pencircle scaled stemthickness;
193 draw (0, 0) .. (0,-2 staff_space);
196 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
198 hip_depth_ratio, hip_width,
199 foot_depth, foot_width_ratio;
200 save flagspace, total_depth, flag_count;
203 flare# = .85 staff_space#;
204 flagspace# = .9 staff_space#;
205 hip_depth_ratio = .72 ;
206 hip_width# = upflag_width# - hip_thickness#/2;
207 total_depth# = 5.25 staff_space#;
208 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
210 foot_width_ratio = .8;
212 set_char_box(stemthickness# /2, hip_width#
213 + stemthickness#/2 + right_upflag_space#,
214 total_depth# + foot_thickness#/2, stemthickness#/2)
216 define_pixels(flare, hip_width, hip_thickness,
218 foot_depth, foot_thickness);
220 draw_flag((stemthickness/2,- (flag_count-1)* flagspace), flare,
221 (hip_width, foot_depth),
222 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
224 add_flag(flagspace, flare,
225 .97, 1.00, 1.3, hip_thickness, foot_thickness);
227 add_flag(flagspace, flare,
228 1.00, 1.00, 1.25, hip_thickness, foot_thickness);
229 add_flag(flagspace, flare,
230 .95, 1.05, 1.25, hip_thickness, foot_thickness);
231 pickup pencircle scaled stemthickness;
232 draw (0, 0) .. (0,-2 staff_space);
235 fet_beginchar("8th (down)", "d3", "deighthflag")
237 hip_depth_ratio, hip_width,
238 foot_depth, foot_width_ratio;
239 save flagspace, total_depth, flag_count;
242 flare# = .99 staff_space#;
243 flagspace# = .9 staff_space#;
244 hip_depth_ratio = .72 ;
245 hip_width# = downflag_width# - hip_thickness#/2;
246 total_depth# = 2.85 staff_space#;
247 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
249 foot_width_ratio = .8;
251 set_char_box(stemthickness# /2, hip_width#
252 + stemthickness#/2 + right_downflag_space#,
253 total_depth# + foot_thickness#/2, stemthickness#/2)
255 define_pixels(flare, hip_width, hip_thickness,
257 foot_depth, foot_thickness);
259 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
260 (hip_width, foot_depth),
261 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
263 pickup pencircle scaled stemthickness;
264 draw (0, 0) .. (0,-2 staff_space);
272 % Single Stroke for Short Appogiatura
277 fet_beginchar("grace dash (up)", "ugrace", "gracedash")
279 hip_depth_ratio, hip_width,
282 flare# = 1.0 staff_space#;
283 hip_depth_ratio = .72;
284 hip_width# = upflag_width# - hip_thickness#/2;
286 foot_depth# = 3 staff_space#;
288 define_pixels(flare, hip_width, hip_thickness,
289 foot_depth, foot_thickness);
291 set_char_box(hip_width# * hip_depth_ratio,
292 hip_width# + stemthickness#/2 + right_upflag_space#,
293 foot_depth# * hip_depth_ratio, -flare#)
295 pickup pencircle scaled 1.5 stemthickness;
300 fet_beginchar("grace dash (down)", "dgrace", "dgracedash")
301 save flare, hip_depth_ratio, hip_width, foot_depth;
302 save flagspace, total_depth, flag_count;
305 flare# = .99 staff_space#;
306 flagspace# = .9 staff_space#;
307 hip_depth_ratio = .72 ;
308 hip_width# = downflag_width# - hip_thickness#/2;
309 total_depth# = 2.85 staff_space#;
310 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
312 foot_width_ratio = .8;
314 define_pixels(flare, hip_width, hip_thickness,
315 flagspace, foot_depth);
317 set_char_box(hip_width# * hip_depth_ratio,
318 hip_width# + stemthickness#/2 + right_downflag_space#,
319 foot_depth# * hip_depth_ratio, -flare#)
321 pickup pencircle scaled 1.5 stemthickness;
322 draw (-b, -d) .. (w,h);
326 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
328 hip_depth_ratio, hip_width,
329 foot_depth, foot_width_ratio;
330 save flagspace, total_depth, flag_count;
333 flare# = .8 staff_space#;
334 flagspace# = .9 staff_space#;
335 hip_depth_ratio = .85 ;
336 hip_width# = downflag_width# - hip_thickness#/2;
337 total_depth# = 3.0 staff_space#;
338 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
340 foot_width_ratio = .95;
342 set_char_box(stemthickness# /2, hip_width#
343 + stemthickness#/2 + right_downflag_space#,
344 total_depth# + foot_thickness#/2, stemthickness#/2)
346 define_pixels(flare, hip_width, hip_thickness,
348 foot_depth, foot_thickness);
350 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
351 (hip_width, foot_depth),
352 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
353 add_flag(flagspace, flare,
354 .95, 1.00, 1.25, hip_thickness, foot_thickness);
358 pickup pencircle scaled stemthickness;
359 draw (0, 0) .. (0,-2 staff_space);
363 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
365 hip_depth_ratio, hip_width,
366 foot_depth, foot_width_ratio;
367 save flagspace, total_depth, flag_count;
370 flare# = .84 staff_space#;
371 flagspace# = .9 staff_space#;
372 hip_depth_ratio = .85 ;
373 hip_width# = downflag_width# - hip_thickness#/2;
374 total_depth# = 3.85 staff_space#;
375 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
377 foot_width_ratio = .95;
379 set_char_box(stemthickness# /2, hip_width#
380 + stemthickness#/2 + right_downflag_space#,
381 total_depth# + foot_thickness#/2, stemthickness#/2)
383 define_pixels(flare, hip_width, hip_thickness,
385 foot_depth, foot_thickness);
387 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
388 (hip_width, foot_depth),
389 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
390 add_flag(flagspace, flare,
391 .97, 1.00, 1.25, hip_thickness, foot_thickness);
393 add_flag(flagspace, flare,
394 .95, 1.05, 1.25, hip_thickness, foot_thickness);
398 pickup pencircle scaled stemthickness;
399 draw (0, 0) .. (0,-2 staff_space);
402 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
404 hip_depth_ratio, hip_width,
405 foot_depth, foot_width_ratio;
406 save flagspace, total_depth, flag_count;
409 flare# = .8 staff_space#;
410 flagspace# = .9 staff_space#;
411 hip_depth_ratio = .85 ;
412 hip_width# = downflag_width# - hip_thickness#/2;
413 total_depth# = 4.35 staff_space#;
414 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
416 foot_width_ratio = .98;
418 set_char_box(stemthickness# /2, hip_width#
419 + stemthickness#/2 + right_downflag_space#,
420 total_depth# + foot_thickness#/2, stemthickness#/2)
422 define_pixels(flare, hip_width, hip_thickness,
424 foot_depth, foot_thickness);
426 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
427 (hip_width, foot_depth),
428 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
429 add_flag(flagspace, flare,
430 .97, 1.20, 1.175, hip_thickness, foot_thickness);
431 add_flag(flagspace, flare,
432 .97, 1.10, 1.175, hip_thickness, foot_thickness);
434 add_flag(.98 flagspace, flare,
435 .91, 1.05, 1.2, hip_thickness, foot_thickness);
439 pickup pencircle scaled stemthickness;
440 draw (0, 0) .. (0,-2 staff_space);
447 % Stem characters so we can compose metronome markings with Feta
451 fet_beginchar("stem (up)", "stem", "stem")
452 set_char_box(stemthickness#/2, stemthickness#/2, 0, 3.5staff_space#);
453 pickup pencircle scaled stemthickness;
454 draw (0, 0.2staff_space) .. (0, 3.5staff_space);
458 fet_beginchar("stem (down)", "dstem", "dstem")
459 set_char_box(stemthickness#/2, stemthickness#/2, 3.5staff_space#, 0);
460 pickup pencircle scaled stemthickness;
461 draw (0, -0.2staff_space) .. (0, -3.5staff_space);
465 fet_endgroup("flags");