5 fet_begingroup ("flags");
11 % Flags pointing down overlap with the notehead (in x-direction), so
12 % the down-flag can be bigger.
15 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
16 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
18 right_upflag_space# = .0 upflag_width#;
19 right_downflag_space# = .0 downflag_width#;
22 % Flags pointing down cannot overlap with the notehead in y-direction,
23 % so they have less slant.
25 % Because of optical illusion, the utmost flag (bottom for
26 % down-pointing, top for up-pointing) should be smaller than the other
27 % flags. Adobe Sonata doesn't do this correctly. (Instead they have
28 % an extension flag, which looks less elegant.)
31 save hip_thickness, foot_thickness;
33 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
34 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
36 define_pixels (hip_thickness, foot_thickness);
39 % Inspired by Adobe Sonata and [Wanske].
40 % For example, see POSTSCRIPT Language -- program design,
41 % page 119, and [Wanske], p 41, 42.
44 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
45 hip_thickness, foot_thickness, show_labels) =
53 penpos2 (whatever, 0);
55 x2r - x2l = hround (hip_thickness);
57 penpos3 (foot_thickness, -20.0);
60 z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
61 z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
66 outer_path := z3r{curl c}
75 ..tension 1.1.. z2l{down}
76 .. {curl c}simple_serif (z3l, z3r, 80)
83 % TODO: calculate intersectpoint (see TeX book, p. 137)
84 % TODO: calculate incision_depth
87 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
88 intersectpoint, hip_thickness, foot_thickness) =
90 save prev_center, prev_xextreme, prev_yextreme;
91 save rel_foot, ip, center, incision_depth;
92 save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
93 save hip_dep_ratio, foot_wid_ratio;
94 pair prev_center, center, foot, prev_xextreme, prev_yextreme;
97 incision_depth = 1.013;
98 prev_center = point 2 of outer_path;
99 prev_xextreme = point 1 of outer_path;
100 prev_yextreme = point 0 of outer_path;
101 prev_hipwid = xpart (prev_xextreme - prev_center);
102 prev_footdep = -ypart (prev_yextreme - prev_center);
103 prev_hipdep = -ypart (prev_xextreme - prev_center);
104 ip = point intersectpoint of outer_path;
106 wid = prev_hipwid * hip_wid_multiplier;
107 hip_dep = prev_hipdep * hip_dep_multiplier;
109 center = prev_center + (0, yoff);
110 rel_foot = incision_depth [(wid, hip_dep), ip - center];
111 dep = -ypart (rel_foot);
112 foot_wid_ratio = xpart (rel_foot) / wid;
113 hip_dep_ratio = hip_dep / dep;
115 draw_flag (center, flare, (wid, dep),
116 hip_dep_ratio, foot_wid_ratio,
117 hip_thickness, foot_thickness, 0);
122 fet_beginchar ("8th Flag (up)", "u3");
123 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
126 hip_depth_ratio = .72;
127 foot_width_ratio = .8;
128 hip_width# = upflag_width# - hip_thickness# / 2;
129 foot_depth# = 3 staff_space# - blot_diameter# / 2;
130 define_pixels (hip_width, foot_depth);
133 hip_width# + stemthickness# / 2 + right_upflag_space#,
134 foot_depth# + foot_thickness# / 2, stemthickness# / 2);
136 draw_flag ((0,0), flare, (hip_width, foot_depth),
137 hip_depth_ratio, foot_width_ratio,
138 hip_thickness, foot_thickness, 1);
140 draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
145 fet_beginchar ("16th Flag (up)", "u4");
146 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
147 save flagspace, total_depth, flag_count;
149 total_depth# = 3.5 staff_space# - blot_diameter# / 2;
151 flare = .85 staff_space;
152 flagspace# = .85 staff_space#;
153 hip_depth_ratio = .72;
154 hip_width# = upflag_width# - hip_thickness# / 2;
155 flagspace# + foot_depth# = total_depth#;
156 foot_width_ratio = .8;
157 define_pixels (hip_width, foot_depth);
158 define_whole_vertical_pixels (flagspace);
161 hip_width# + stemthickness# / 2 + right_upflag_space#,
162 total_depth# + foot_thickness# / 2, stemthickness# / 2);
164 draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
165 hip_depth_ratio, foot_width_ratio,
166 hip_thickness, foot_thickness, 1);
168 add_flag (flagspace, flare, .97, 1.00, 1.25,
169 hip_thickness, foot_thickness);
171 draw_square_block ((-0.5 stemthickness_rounded, 0),
172 (0, -2 staff_space_rounded));
176 fet_beginchar ("32nd Flag (up)", "u5");
177 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
178 save flagspace, total_depth, flag_count;
181 total_depth# = 4.25 staff_space#;
182 flare = .85 staff_space;
183 flagspace# = .87 staff_space#;
184 hip_depth_ratio = .72;
185 hip_width# = upflag_width# - hip_thickness# / 2;
186 foot_width_ratio = .8;
188 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
190 define_pixels (hip_width, foot_depth);
191 define_whole_vertical_pixels (flagspace);
193 set_char_box (0, hip_width# + right_upflag_space#,
194 total_depth# + foot_thickness# / 2, stemthickness# / 2);
196 draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
197 hip_depth_ratio, foot_width_ratio,
198 hip_thickness, foot_thickness, 1);
200 add_flag (flagspace, flare, .97, 1.00, 1.25,
201 hip_thickness, foot_thickness);
202 add_flag (flagspace, flare, .95, 1.05, 1.25,
203 hip_thickness, foot_thickness);
205 draw_square_block ((-0.5 stemthickness_rounded, 0),
206 (0, -3 staff_space_rounded));
210 fet_beginchar ("64th Flag (up)", "u6");
211 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
212 save flagspace, total_depth, flag_count;
215 flare = .85 staff_space;
216 flagspace# = .9 staff_space#;
217 hip_depth_ratio = .72;
218 hip_width# = upflag_width# - hip_thickness# / 2;
219 total_depth# = 5.25 staff_space#;
220 foot_width_ratio = .8;
222 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
224 define_pixels (hip_width, foot_depth);
225 define_whole_vertical_pixels (flagspace);
227 set_char_box (0, hip_width# + right_upflag_space#,
228 total_depth# + foot_thickness# / 2, stemthickness# / 2);
230 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
231 (hip_width, foot_depth),
232 hip_depth_ratio, foot_width_ratio,
233 hip_thickness, foot_thickness, 1);
235 add_flag (flagspace, flare, .97, 1.00, 1.3,
236 hip_thickness, foot_thickness);
237 add_flag (flagspace, flare, 1.00, 1.00, 1.25,
238 hip_thickness, foot_thickness);
239 add_flag (flagspace, flare, .95, 1.05, 1.25,
240 hip_thickness, foot_thickness);
242 draw_square_block ((-0.5 stemthickness_rounded, 0),
243 (0, -4 staff_space_rounded));
247 fet_beginchar ("8th (down)", "d3");
248 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
249 save flagspace, total_depth, flag_count;
253 flagspace# = .9 staff_space#;
254 hip_depth_ratio = .72;
255 hip_width# = downflag_width# - hip_thickness# / 2;
256 total_depth# = 2.85 staff_space#;
257 foot_width_ratio = .8;
259 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
261 define_pixels (hip_width, flagspace, foot_depth);
263 set_char_box (0, hip_width# + right_downflag_space#,
264 total_depth# + foot_thickness# / 2, stemthickness# / 2)
266 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
267 (hip_width, foot_depth),
268 hip_depth_ratio, foot_width_ratio,
269 hip_thickness, foot_thickness, 0);
271 draw_square_block ((-0.5 stemthickness_rounded, 0),
272 (0, -staff_space_rounded));
280 % Single Stroke for Short Appogiatura
283 fet_beginchar ("grace dash (up)", "ugrace");
284 save flare, hip_depth_ratio, hip_width, foot_depth;
286 hip_depth_ratio = .72;
287 flare# = staff_space#;
288 hip_width# = upflag_width# - hip_thickness# / 2;
289 foot_depth# = 3 staff_space#;
291 define_pixels (hip_width, foot_depth);
293 set_char_box (hip_width# * hip_depth_ratio,
294 hip_width# + right_upflag_space#,
295 foot_depth# * hip_depth_ratio, -flare#)
297 pickup pencircle scaled 1.5 stemthickness;
302 penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
303 penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
319 fet_beginchar ("grace dash (down)", "dgrace");
320 save flare, hip_depth_ratio, hip_width, foot_depth;
323 hip_depth_ratio = .72 ;
324 flare# = .99 staff_space#;
325 hip_width# = downflag_width# - hip_thickness# / 2;
326 total_depth# = 2.85 staff_space#;
327 foot_depth# = total_depth#;
328 foot_width_ratio = .8;
330 define_pixels (hip_width, foot_depth);
332 set_char_box (hip_width# * hip_depth_ratio,
333 hip_width# + right_downflag_space#,
334 foot_depth# * hip_depth_ratio, -flare#)
336 pickup pencircle scaled 1.5 stemthickness;
341 penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
342 penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
358 fet_beginchar ("16th (down)", "d4");
359 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
360 save flagspace, total_depth, flag_count;
363 flare = .8 staff_space;
364 flagspace# = .9 staff_space#;
365 hip_depth_ratio = .85;
366 hip_width# = downflag_width# - hip_thickness# / 2;
367 total_depth# = 3.0 staff_space# - blot_diameter# / 2;
368 foot_width_ratio = .95;
370 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
372 set_char_box (0, hip_width# + right_downflag_space#,
373 total_depth# + foot_thickness# / 2, stemthickness# / 2);
375 define_pixels (hip_width, foot_depth);
376 define_whole_vertical_pixels (flagspace);
378 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
379 (hip_width, foot_depth),
380 hip_depth_ratio, foot_width_ratio,
381 hip_thickness, foot_thickness, 0);
383 add_flag (flagspace, flare, .95, 1.00, 1.25,
384 hip_thickness, foot_thickness);
386 draw_square_block ((-0.5 stemthickness_rounded, 0),
387 (0, -2 staff_space_rounded));
393 fet_beginchar ("32nd (down)", "d5");
394 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
395 save flagspace, total_depth, flag_count;
398 flare = .84 staff_space;
399 flagspace# = .9 staff_space#;
400 hip_depth_ratio = .85;
401 hip_width# = downflag_width# - hip_thickness# / 2;
402 total_depth# = 3.85 staff_space#;
403 foot_width_ratio = .95;
405 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
407 define_pixels (hip_width, foot_depth);
408 define_whole_vertical_pixels (flagspace);
410 set_char_box (0, hip_width# + right_downflag_space#,
411 total_depth# + foot_thickness# / 2, stemthickness# / 2);
413 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
414 (hip_width, foot_depth),
415 hip_depth_ratio, foot_width_ratio,
416 hip_thickness, foot_thickness, 0);
418 add_flag (flagspace, flare, .97, 1.00, 1.25,
419 hip_thickness, foot_thickness);
420 add_flag (flagspace, flare, .95, 1.05, 1.25,
421 hip_thickness, foot_thickness);
423 draw_square_block ((-0.5 stemthickness_rounded, 0),
424 (0, -3 staff_space_rounded));
430 fet_beginchar ("64th (down)", "d6");
431 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
432 save flagspace, total_depth, flag_count;
435 flare = .8 staff_space;
436 flagspace# = .9 staff_space#;
437 hip_depth_ratio = .85;
438 hip_width# = downflag_width# - hip_thickness# / 2;
439 total_depth# = 4.35 staff_space#;
440 foot_width_ratio = .98;
442 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
444 define_pixels (hip_width, foot_depth);
445 define_whole_vertical_pixels (flagspace);
447 set_char_box (0, hip_width# + right_downflag_space#,
448 total_depth# + foot_thickness# / 2, stemthickness# / 2);
450 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
451 (hip_width, foot_depth),
452 hip_depth_ratio, foot_width_ratio,
453 hip_thickness, foot_thickness, 0);
455 add_flag (flagspace, flare, .97, 1.20, 1.175,
456 hip_thickness, foot_thickness);
457 add_flag (flagspace, flare, .97, 1.10, 1.175,
458 hip_thickness, foot_thickness);
459 add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
460 hip_thickness, foot_thickness);
462 draw_square_block ((-0.5 stemthickness_rounded, 0),
463 (0, -4 staff_space_rounded));
468 fet_endgroup ("flags");