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;
29 hip_thickness# = 1.0 stafflinethickness# + 0.069 staff_space#;
30 foot_thickness# = 1.2055 stafflinethickness# + 0.06 staff_space#;
33 % Inspired by Adobe Sonata and [Wanske]
34 % for example, see POSTSCRIPT Language -- program design,
35 % page 119, and [Wanske], p 41,42
37 def draw_flag(expr center, flare,
38 dims, hip_depth, foot_wid, hip_thickness, foot_thickness)=
44 x2r - x2l = hip_thickness;
45 penpos3 (foot_thickness, -20.0);
48 z2r = center + (xpart dims, -ypart(dims) * hip_depth);
49 z3r = center + (xpart(dims) * foot_wid, -ypart dims);
51 outer_path := z3r{curl c} .. z2r{up} .. {up}z1r;
55 ..tension 1.1 .. z2l{down} ..
56 {curl c} simple_serif(z3l, z3r, 80) &
57 outer_path & z1r -- cycle;
61 % TODO: calc intersectpoint (see TeX book, p. 137)
62 % TODO: calc incision_depth
65 def add_flag(expr yoff, flare, hip_wid_multiplier,
67 intersectpoint, hip_thickness, foot_thickness) =
69 save prev_center, prev_xextreme, prev_yextreme;
70 save rel_foot, ip, center, incision_depth;
71 save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
72 save hip_dep_ratio, foot_wid_ratio;
73 pair prev_center, center, foot, prev_xextreme, prev_yextreme;
76 incision_depth = 1.013;
77 prev_center = point 2 of outer_path;
78 prev_xextreme = point 1 of outer_path;
79 prev_yextreme = point 0 of outer_path;
80 prev_hipwid = xpart (prev_xextreme - prev_center);
81 prev_footdep = -ypart (prev_yextreme - prev_center);
82 prev_hipdep = -ypart(prev_xextreme - prev_center);
83 ip = point intersectpoint of outer_path;
85 wid = prev_hipwid * hip_wid_multiplier;
86 hip_dep = prev_hipdep * hip_dep_multiplier;
88 center = prev_center + (0,yoff);
89 rel_foot = incision_depth [(wid, hip_dep), ip - center];
90 dep = -ypart(rel_foot);
91 foot_wid_ratio = xpart(rel_foot ) / wid;
92 hip_dep_ratio = hip_dep / dep;
94 draw_flag(center, flare,
95 (wid, dep), hip_dep_ratio, foot_wid_ratio,
96 hip_thickness, foot_thickness);
100 fet_beginchar("8th Flag (up)", "u3", "eighthflag")
102 hip_depth_ratio, hip_width,
103 foot_depth, foot_width_ratio;
105 flare# = 1.0 staff_space#;
106 hip_depth_ratio = .72;
107 foot_width_ratio = .8;
108 hip_width# = upflag_width# - hip_thickness#/2;
110 foot_depth# = 3 staff_space# - blot_diameter#/2;
112 set_char_box(0, hip_width#
113 + stemthickness#/2 + right_upflag_space#,
114 foot_depth# + foot_thickness#/2, stemthickness#/2)
116 define_pixels(flare, hip_width, hip_thickness,
117 foot_depth, foot_thickness);
118 draw_flag((0,0), flare,
119 (hip_width, foot_depth),
120 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
122 draw_square_block ((-.5 stemthickness,-1 staff_space),
126 fet_beginchar("16th Flag (up)", "u4", "sixteenthflag")
128 hip_depth_ratio, hip_width,
129 foot_depth, foot_width_ratio;
130 save flagspace, total_depth, flag_count;
131 total_depth# = 3.5 staff_space# - blot_diameter# /2 ;
133 flare# = .85 staff_space#;
134 flagspace# = .85 staff_space#;
135 hip_depth_ratio = .72 ;
136 hip_width# = upflag_width# - hip_thickness#/2;
137 flagspace# + foot_depth# = total_depth#;
139 foot_width_ratio = .8;
141 set_char_box(0, hip_width#
142 + stemthickness#/2 + right_upflag_space#,
143 total_depth# + foot_thickness#/2, stemthickness#/2)
145 define_pixels(flare, hip_width, hip_thickness,
147 foot_depth, foot_thickness);
148 draw_flag((0, - flagspace ), flare,
149 (hip_width, foot_depth),
150 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
152 add_flag(flagspace, flare,
153 .97, 1.00, 1.25, hip_thickness, foot_thickness);
155 pickup pencircle scaled stemthickness;
157 draw_square_block ((-.5 stemthickness,0),
158 (0, -2 staff_space));
162 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
164 hip_depth_ratio, hip_width,
165 foot_depth, foot_width_ratio;
166 save flagspace, total_depth, flag_count;
168 total_depth#=4.25 staff_space#;
169 flare# = .85 staff_space#;
170 flagspace# = .87 staff_space#;
171 hip_depth_ratio = .72 ;
172 hip_width# = upflag_width# - hip_thickness#/2;
173 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
175 foot_width_ratio = .8;
177 set_char_box(0, hip_width#
178 + right_upflag_space#,
179 total_depth# + foot_thickness#/2, stemthickness#/2)
181 define_pixels(flare, hip_width, hip_thickness,
183 foot_depth, foot_thickness);
185 draw_flag((0,- 2 flagspace), flare,
186 (hip_width, foot_depth),
187 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
189 add_flag(flagspace, flare,
190 .97, 1.00, 1.25, hip_thickness, foot_thickness);
192 add_flag(flagspace, flare,
193 .95, 1.05, 1.25, hip_thickness, foot_thickness);
197 draw_square_block ((-.5 stemthickness,0),
198 (0, -3 staff_space));
201 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
203 hip_depth_ratio, hip_width,
204 foot_depth, foot_width_ratio;
205 save flagspace, total_depth, flag_count;
208 flare# = .85 staff_space#;
209 flagspace# = .9 staff_space#;
210 hip_depth_ratio = .72 ;
211 hip_width# = upflag_width# - hip_thickness#/2;
212 total_depth# = 5.25 staff_space#;
213 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
215 foot_width_ratio = .8;
217 set_char_box(0, hip_width#
218 + right_upflag_space#,
219 total_depth# + foot_thickness#/2, stemthickness#/2)
221 define_pixels(flare, hip_width, hip_thickness,
223 foot_depth, foot_thickness);
225 draw_flag((0,- (flag_count-1)* flagspace), flare,
226 (hip_width, foot_depth),
227 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
229 add_flag(flagspace, flare,
230 .97, 1.00, 1.3, hip_thickness, foot_thickness);
232 add_flag(flagspace, flare,
233 1.00, 1.00, 1.25, hip_thickness, foot_thickness);
234 add_flag(flagspace, flare,
235 .95, 1.05, 1.25, hip_thickness, foot_thickness);
237 draw_square_block ((-.5 stemthickness,0),
238 (0, -4 staff_space));
241 fet_beginchar("8th (down)", "d3", "deighthflag")
243 hip_depth_ratio, hip_width,
244 foot_depth, foot_width_ratio;
245 save flagspace, total_depth, flag_count;
248 flare# = .99 staff_space#;
249 flagspace# = .9 staff_space#;
250 hip_depth_ratio = .72 ;
251 hip_width# = downflag_width# - hip_thickness#/2;
252 total_depth# = 2.85 staff_space#;
253 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
255 foot_width_ratio = .8;
257 set_char_box(0, hip_width#
258 + right_downflag_space#,
259 total_depth# + foot_thickness#/2, stemthickness#/2)
261 define_pixels(flare, hip_width, hip_thickness,
263 foot_depth, foot_thickness);
265 draw_flag((0,- (flag_count-1) *flagspace), flare,
266 (hip_width, foot_depth),
267 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
268 draw_square_block ((-.5 stemthickness,0),
278 % Single Stroke for Short Appogiatura
283 fet_beginchar("grace dash (up)", "ugrace", "gracedash")
285 hip_depth_ratio, hip_width,
288 flare# = 1.0 staff_space#;
289 hip_depth_ratio = .72;
290 hip_width# = upflag_width# - hip_thickness#/2;
292 foot_depth# = 3 staff_space#;
294 define_pixels(flare, hip_width, hip_thickness,
295 foot_depth, foot_thickness);
297 set_char_box(hip_width# * hip_depth_ratio,
298 hip_width# + right_upflag_space#,
299 foot_depth# * hip_depth_ratio, -flare#)
301 pickup pencircle scaled 1.5 stemthickness;
307 fet_beginchar("grace dash (down)", "dgrace", "dgracedash")
308 save flare, hip_depth_ratio, hip_width, foot_depth;
309 save flagspace, total_depth, flag_count;
312 flare# = .99 staff_space#;
313 flagspace# = .9 staff_space#;
314 hip_depth_ratio = .72 ;
315 hip_width# = downflag_width# - hip_thickness#/2;
316 total_depth# = 2.85 staff_space#;
317 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
319 foot_width_ratio = .8;
321 define_pixels(flare, hip_width, hip_thickness,
322 flagspace, foot_depth);
324 set_char_box(hip_width# * hip_depth_ratio,
325 hip_width# + right_downflag_space#,
326 foot_depth# * hip_depth_ratio, -flare#)
328 pickup pencircle scaled 1.5 stemthickness;
334 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
336 hip_depth_ratio, hip_width,
337 foot_depth, foot_width_ratio;
338 save flagspace, total_depth, flag_count;
341 flare# = .8 staff_space#;
342 flagspace# = .9 staff_space#;
343 hip_depth_ratio = .85 ;
344 hip_width# = downflag_width# - hip_thickness#/2;
345 total_depth# = 3.0 staff_space# - blot_diameter# /2;
346 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
348 foot_width_ratio = .95;
350 set_char_box(0, hip_width#
351 + right_downflag_space#,
352 total_depth# + foot_thickness#/2, stemthickness#/2)
354 define_pixels(flare, hip_width, hip_thickness,
356 foot_depth, foot_thickness);
358 draw_flag((0,- (flag_count-1) *flagspace), flare,
359 (hip_width, foot_depth),
360 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
361 add_flag(flagspace, flare,
362 .95, 1.00, 1.25, hip_thickness, foot_thickness);
365 draw_square_block ((-.5 stemthickness,0),
366 (0, - 2 staff_space));
372 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
374 hip_depth_ratio, hip_width,
375 foot_depth, foot_width_ratio;
376 save flagspace, total_depth, flag_count;
379 flare# = .84 staff_space#;
380 flagspace# = .9 staff_space#;
381 hip_depth_ratio = .85 ;
382 hip_width# = downflag_width# - hip_thickness#/2;
383 total_depth# = 3.85 staff_space#;
384 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
386 foot_width_ratio = .95;
388 set_char_box(0, hip_width#
389 + right_downflag_space#,
390 total_depth# + foot_thickness#/2, stemthickness#/2)
392 define_pixels(flare, hip_width, hip_thickness,
394 foot_depth, foot_thickness);
396 draw_flag((0,- (flag_count-1) *flagspace), flare,
397 (hip_width, foot_depth),
398 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
399 add_flag(flagspace, flare,
400 .97, 1.00, 1.25, hip_thickness, foot_thickness);
402 add_flag(flagspace, flare,
403 .95, 1.05, 1.25, hip_thickness, foot_thickness);
404 draw_square_block ((-.5 stemthickness,0),
405 (0, - 3 staff_space));
410 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
412 hip_depth_ratio, hip_width,
413 foot_depth, foot_width_ratio;
414 save flagspace, total_depth, flag_count;
417 flare# = .8 staff_space#;
418 flagspace# = .9 staff_space#;
419 hip_depth_ratio = .85 ;
420 hip_width# = downflag_width# - hip_thickness#/2;
421 total_depth# = 4.35 staff_space#;
422 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
424 foot_width_ratio = .98;
426 set_char_box(0, hip_width#
427 + right_downflag_space#,
428 total_depth# + foot_thickness#/2, stemthickness#/2)
430 define_pixels(flare, hip_width, hip_thickness,
432 foot_depth, foot_thickness);
434 draw_flag((0,- (flag_count-1) *flagspace), flare,
435 (hip_width, foot_depth),
436 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
437 add_flag(flagspace, flare,
438 .97, 1.20, 1.175, hip_thickness, foot_thickness);
439 add_flag(flagspace, flare,
440 .97, 1.10, 1.175, hip_thickness, foot_thickness);
442 add_flag(.98 flagspace, flare,
443 .91, 1.05, 1.2, hip_thickness, foot_thickness);
445 draw_square_block ((-.5 stemthickness,0),
446 (0, - 4 staff_space));
453 fet_endgroup("flags");