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# - blot_diameter#/2;
111 set_char_box(0, 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((0,0), flare,
118 (hip_width, foot_depth),
119 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
121 draw_square_block ((-.5 stemthickness,-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# - blot_diameter# /2 ;
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(0, 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((0, - 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;
156 draw_square_block ((-.5 stemthickness,0),
157 (0, -2 staff_space));
161 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
163 hip_depth_ratio, hip_width,
164 foot_depth, foot_width_ratio;
165 save flagspace, total_depth, flag_count;
167 total_depth#=4.25 staff_space#;
168 flare# = .85 staff_space#;
169 flagspace# = .87 staff_space#;
170 hip_depth_ratio = .72 ;
171 hip_width# = upflag_width# - hip_thickness#/2;
172 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
174 foot_width_ratio = .8;
176 set_char_box(0, hip_width#
177 + right_upflag_space#,
178 total_depth# + foot_thickness#/2, stemthickness#/2)
180 define_pixels(flare, hip_width, hip_thickness,
182 foot_depth, foot_thickness);
184 draw_flag((0,- 2 flagspace), flare,
185 (hip_width, foot_depth),
186 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
188 add_flag(flagspace, flare,
189 .97, 1.00, 1.25, hip_thickness, foot_thickness);
191 add_flag(flagspace, flare,
192 .95, 1.05, 1.25, hip_thickness, foot_thickness);
196 draw_square_block ((-.5 stemthickness,0),
197 (0, -3 staff_space));
200 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
202 hip_depth_ratio, hip_width,
203 foot_depth, foot_width_ratio;
204 save flagspace, total_depth, flag_count;
207 flare# = .85 staff_space#;
208 flagspace# = .9 staff_space#;
209 hip_depth_ratio = .72 ;
210 hip_width# = upflag_width# - hip_thickness#/2;
211 total_depth# = 5.25 staff_space#;
212 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
214 foot_width_ratio = .8;
216 set_char_box(0, hip_width#
217 + right_upflag_space#,
218 total_depth# + foot_thickness#/2, stemthickness#/2)
220 define_pixels(flare, hip_width, hip_thickness,
222 foot_depth, foot_thickness);
224 draw_flag((0,- (flag_count-1)* flagspace), flare,
225 (hip_width, foot_depth),
226 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
228 add_flag(flagspace, flare,
229 .97, 1.00, 1.3, hip_thickness, foot_thickness);
231 add_flag(flagspace, flare,
232 1.00, 1.00, 1.25, hip_thickness, foot_thickness);
233 add_flag(flagspace, flare,
234 .95, 1.05, 1.25, hip_thickness, foot_thickness);
236 draw_square_block ((-.5 stemthickness,0),
237 (0, -4 staff_space));
240 fet_beginchar("8th (down)", "d3", "deighthflag")
242 hip_depth_ratio, hip_width,
243 foot_depth, foot_width_ratio;
244 save flagspace, total_depth, flag_count;
247 flare# = .99 staff_space#;
248 flagspace# = .9 staff_space#;
249 hip_depth_ratio = .72 ;
250 hip_width# = downflag_width# - hip_thickness#/2;
251 total_depth# = 2.85 staff_space#;
252 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
254 foot_width_ratio = .8;
256 set_char_box(0, hip_width#
257 + right_downflag_space#,
258 total_depth# + foot_thickness#/2, stemthickness#/2)
260 define_pixels(flare, hip_width, hip_thickness,
262 foot_depth, foot_thickness);
264 draw_flag((0,- (flag_count-1) *flagspace), flare,
265 (hip_width, foot_depth),
266 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
267 draw_square_block ((-.5 stemthickness,0),
277 % Single Stroke for Short Appogiatura
282 fet_beginchar("grace dash (up)", "ugrace", "gracedash")
284 hip_depth_ratio, hip_width,
287 flare# = 1.0 staff_space#;
288 hip_depth_ratio = .72;
289 hip_width# = upflag_width# - hip_thickness#/2;
291 foot_depth# = 3 staff_space#;
293 define_pixels(flare, hip_width, hip_thickness,
294 foot_depth, foot_thickness);
296 set_char_box(hip_width# * hip_depth_ratio,
297 hip_width# + right_upflag_space#,
298 foot_depth# * hip_depth_ratio, -flare#)
300 pickup pencircle scaled 1.5 stemthickness;
306 fet_beginchar("grace dash (down)", "dgrace", "dgracedash")
307 save flare, hip_depth_ratio, hip_width, foot_depth;
308 save flagspace, total_depth, flag_count;
311 flare# = .99 staff_space#;
312 flagspace# = .9 staff_space#;
313 hip_depth_ratio = .72 ;
314 hip_width# = downflag_width# - hip_thickness#/2;
315 total_depth# = 2.85 staff_space#;
316 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
318 foot_width_ratio = .8;
320 define_pixels(flare, hip_width, hip_thickness,
321 flagspace, foot_depth);
323 set_char_box(hip_width# * hip_depth_ratio,
324 hip_width# + right_downflag_space#,
325 foot_depth# * hip_depth_ratio, -flare#)
327 pickup pencircle scaled 1.5 stemthickness;
333 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
335 hip_depth_ratio, hip_width,
336 foot_depth, foot_width_ratio;
337 save flagspace, total_depth, flag_count;
340 flare# = .8 staff_space#;
341 flagspace# = .9 staff_space#;
342 hip_depth_ratio = .85 ;
343 hip_width# = downflag_width# - hip_thickness#/2;
344 total_depth# = 3.0 staff_space# - blot_diameter# /2;
345 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
347 foot_width_ratio = .95;
349 set_char_box(0, hip_width#
350 + right_downflag_space#,
351 total_depth# + foot_thickness#/2, stemthickness#/2)
353 define_pixels(flare, hip_width, hip_thickness,
355 foot_depth, foot_thickness);
357 draw_flag((0,- (flag_count-1) *flagspace), flare,
358 (hip_width, foot_depth),
359 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
360 add_flag(flagspace, flare,
361 .95, 1.00, 1.25, hip_thickness, foot_thickness);
364 draw_square_block ((-.5 stemthickness,0),
365 (0, - 2 staff_space));
371 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
373 hip_depth_ratio, hip_width,
374 foot_depth, foot_width_ratio;
375 save flagspace, total_depth, flag_count;
378 flare# = .84 staff_space#;
379 flagspace# = .9 staff_space#;
380 hip_depth_ratio = .85 ;
381 hip_width# = downflag_width# - hip_thickness#/2;
382 total_depth# = 3.85 staff_space#;
383 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
385 foot_width_ratio = .95;
387 set_char_box(0, hip_width#
388 + right_downflag_space#,
389 total_depth# + foot_thickness#/2, stemthickness#/2)
391 define_pixels(flare, hip_width, hip_thickness,
393 foot_depth, foot_thickness);
395 draw_flag((0,- (flag_count-1) *flagspace), flare,
396 (hip_width, foot_depth),
397 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
398 add_flag(flagspace, flare,
399 .97, 1.00, 1.25, hip_thickness, foot_thickness);
401 add_flag(flagspace, flare,
402 .95, 1.05, 1.25, hip_thickness, foot_thickness);
403 draw_square_block ((-.5 stemthickness,0),
404 (0, - 3 staff_space));
409 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
411 hip_depth_ratio, hip_width,
412 foot_depth, foot_width_ratio;
413 save flagspace, total_depth, flag_count;
416 flare# = .8 staff_space#;
417 flagspace# = .9 staff_space#;
418 hip_depth_ratio = .85 ;
419 hip_width# = downflag_width# - hip_thickness#/2;
420 total_depth# = 4.35 staff_space#;
421 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
423 foot_width_ratio = .98;
425 set_char_box(0, hip_width#
426 + right_downflag_space#,
427 total_depth# + foot_thickness#/2, stemthickness#/2)
429 define_pixels(flare, hip_width, hip_thickness,
431 foot_depth, foot_thickness);
433 draw_flag((0,- (flag_count-1) *flagspace), flare,
434 (hip_width, foot_depth),
435 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
436 add_flag(flagspace, flare,
437 .97, 1.20, 1.175, hip_thickness, foot_thickness);
438 add_flag(flagspace, flare,
439 .97, 1.10, 1.175, hip_thickness, foot_thickness);
441 add_flag(.98 flagspace, flare,
442 .91, 1.05, 1.2, hip_thickness, foot_thickness);
444 draw_square_block ((-.5 stemthickness,0),
445 (0, - 4 staff_space));
452 fet_endgroup("flags");