5 fet_begingroup("flags")
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;
13 right_upflag_space# = .2 upflag_width#;
14 right_downflag_space# = .2 downflag_width#;
17 % Flags pointing down cannot overlap with the notehead in y-direction,
18 % 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 an
24 % extension flag. Yuck)
27 save hip_thickness, foot_thickness;
28 hip_thickness# = 1.3 stemthickness#;
29 foot_thickness# = 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)=
42 x2r - x2l = hip_thickness;
43 penpos3(foot_thickness, 0) ;
46 z2r = center + (xpart dims, -ypart(dims) * hip_depth);
47 z3r = center + (xpart(dims) * foot_wid, -ypart dims);
49 outer_path := z3r{curl 0} .. z2r{up} .. {up}z1r;
53 ..tension 1.1 .. z2l{down} ..
54 {curl 0} simple_serif(z3l, z3r, 80) &
55 outer_path & z1r -- cycle;
59 % TODO: calc intersectpoint
60 % TODO: calc incision_depth
62 def add_flag(expr yoff, flare, hip_wid_multiplier,
64 intersectpoint, hip_thickness, foot_thickness) =
66 save prev_center, prev_xextreme, prev_yextreme;
67 save rel_foot, ip, center, incision_depth;
68 save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
69 save hip_dep_ratio, foot_wid_ratio;
70 pair prev_center, center, foot, prev_xextreme, prev_yextreme;
73 incision_depth = 1.013;
74 prev_center = point 2 of outer_path;
75 prev_xextreme = point 1 of outer_path;
76 prev_yextreme = point 0 of outer_path;
77 prev_hipwid = xpart (prev_xextreme - prev_center);
78 prev_footdep = -ypart (prev_yextreme - prev_center);
79 prev_hipdep = -ypart(prev_xextreme - prev_center);
80 ip = point intersectpoint of outer_path;
82 wid = prev_hipwid * hip_wid_multiplier;
83 hip_dep = prev_hipdep * hip_dep_multiplier;
85 center = prev_center + (0,yoff);
86 rel_foot = incision_depth [(wid, hip_dep), ip - center];
87 dep = -ypart(rel_foot);
88 foot_wid_ratio = xpart(rel_foot ) / wid;
89 hip_dep_ratio = hip_dep / dep;
91 draw_flag(center, flare,
92 (wid, dep), hip_dep_ratio, foot_wid_ratio,
93 hip_thickness, foot_thickness);
97 fet_beginchar("8th Flag (up)", "u3", "eighthflag")
99 hip_depth_ratio, hip_width,
100 foot_depth, foot_width_ratio;
102 flare# = 1.0 interline#;
103 hip_depth_ratio = .72;
104 foot_width_ratio = .8;
105 hip_width# = upflag_width# - hip_thickness#/2;
107 foot_depth# = 3 interline#;
109 set_char_box(stemthickness# /2, hip_width#
110 + stemthickness#/2 + right_upflag_space#,
111 foot_depth# + foot_thickness#/2, stemthickness#/2)
113 define_pixels(flare, hip_width, hip_thickness,
114 foot_depth, foot_thickness);
115 draw_flag((stemthickness/2,0), flare,
116 (hip_width, foot_depth),
117 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
119 pickup pencircle scaled stemthickness;
120 draw (0, 0) .. (0,-2 interline);
123 fet_beginchar("16th Flag (up)", "u4", "sixteenthflag")
125 hip_depth_ratio, hip_width,
126 foot_depth, foot_width_ratio;
127 save flagspace, total_depth, flag_count;
128 total_depth# = 3.5 interline#;
130 flare# = .85 interline#;
131 flagspace# = .85 interline#;
132 hip_depth_ratio = .72 ;
133 hip_width# = upflag_width# - hip_thickness#/2;
134 flagspace# + foot_depth# = total_depth#;
136 foot_width_ratio = .8;
138 set_char_box(stemthickness# /2, hip_width#
139 + stemthickness#/2 + right_upflag_space#,
140 total_depth# + foot_thickness#/2, stemthickness#/2)
142 define_pixels(flare, hip_width, hip_thickness,
144 foot_depth, foot_thickness);
145 draw_flag((stemthickness/2,- flagspace), flare,
146 (hip_width, foot_depth),
147 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
149 add_flag(flagspace, flare,
150 .97, 1.00, 1.25, hip_thickness, foot_thickness);
152 pickup pencircle scaled stemthickness;
153 draw (0, 0) .. (0,-2 interline);
157 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
159 hip_depth_ratio, hip_width,
160 foot_depth, foot_width_ratio;
161 save flagspace, total_depth, flag_count;
163 total_depth#=4.25 interline#;
164 flare# = .85 interline#;
165 flagspace# = .87 interline#;
166 hip_depth_ratio = .72 ;
167 hip_width# = upflag_width# - hip_thickness#/2;
168 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
170 foot_width_ratio = .8;
172 set_char_box(stemthickness# /2, hip_width#
173 + stemthickness#/2 + right_upflag_space#,
174 total_depth# + foot_thickness#/2, stemthickness#/2)
176 define_pixels(flare, hip_width, hip_thickness,
178 foot_depth, foot_thickness);
180 draw_flag((stemthickness/2,- 2 flagspace), flare,
181 (hip_width, foot_depth),
182 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
184 add_flag(flagspace, flare,
185 .97, 1.00, 1.25, hip_thickness, foot_thickness);
187 add_flag(flagspace, flare,
188 .95, 1.05, 1.25, hip_thickness, foot_thickness);
190 pickup pencircle scaled stemthickness;
191 draw (0, 0) .. (0,-2 interline);
194 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
196 hip_depth_ratio, hip_width,
197 foot_depth, foot_width_ratio;
198 save flagspace, total_depth, flag_count;
201 flare# = .85 interline#;
202 flagspace# = .9 interline#;
203 hip_depth_ratio = .72 ;
204 hip_width# = upflag_width# - hip_thickness#/2;
205 total_depth# = 5.25 interline#;
206 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
208 foot_width_ratio = .8;
210 set_char_box(stemthickness# /2, hip_width#
211 + stemthickness#/2 + right_upflag_space#,
212 total_depth# + foot_thickness#/2, stemthickness#/2)
214 define_pixels(flare, hip_width, hip_thickness,
216 foot_depth, foot_thickness);
218 draw_flag((stemthickness/2,- (flag_count-1)* flagspace), flare,
219 (hip_width, foot_depth),
220 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
222 add_flag(flagspace, flare,
223 .97, 1.00, 1.3, hip_thickness, foot_thickness);
225 add_flag(flagspace, flare,
226 1.00, 1.00, 1.25, hip_thickness, foot_thickness);
227 add_flag(flagspace, flare,
228 .95, 1.05, 1.25, hip_thickness, foot_thickness);
229 pickup pencircle scaled stemthickness;
230 draw (0, 0) .. (0,-2 interline);
233 fet_beginchar("grace 8th Flag (up)", "u3grace", "graceeighthflag")
235 hip_depth_ratio, hip_width,
236 foot_depth, foot_width_ratio;
238 flare# = 1.0 interline#;
239 hip_depth_ratio = .72;
240 foot_width_ratio = .8;
241 hip_width# = upflag_width# - hip_thickness#/2;
243 foot_depth# = 3 interline#;
245 set_char_box(hip_width# * hip_depth_ratio,
246 hip_width# + stemthickness#/2 + right_upflag_space#,
247 foot_depth# + foot_thickness#/2, stemthickness#/2)
249 define_pixels(flare, hip_width, hip_thickness,
250 foot_depth, foot_thickness);
251 draw_flag((stemthickness/2,0), flare,
252 (hip_width, foot_depth),
253 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
255 pickup pencircle scaled stemthickness;
256 draw (0, 0) .. (0,-2 interline);
257 draw (-b ,-foot_depth * hip_depth_ratio) ..
261 fet_beginchar("8th (down)", "d3", "deighthflag")
263 hip_depth_ratio, hip_width,
264 foot_depth, foot_width_ratio;
265 save flagspace, total_depth, flag_count;
268 flare# = .99 interline#;
269 flagspace# = .9 interline#;
270 hip_depth_ratio = .72 ;
271 hip_width# = downflag_width# - hip_thickness#/2;
272 total_depth# = 2.85 interline#;
273 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
275 foot_width_ratio = .8;
277 set_char_box(stemthickness# /2, hip_width#
278 + stemthickness#/2 + right_downflag_space#,
279 total_depth# + foot_thickness#/2, stemthickness#/2)
281 define_pixels(flare, hip_width, hip_thickness,
283 foot_depth, foot_thickness);
285 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
286 (hip_width, foot_depth),
287 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
290 pickup pencircle scaled stemthickness;
291 draw (0, 0) .. (0,-2 interline);
295 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
297 hip_depth_ratio, hip_width,
298 foot_depth, foot_width_ratio;
299 save flagspace, total_depth, flag_count;
302 flare# = .8 interline#;
303 flagspace# = .9 interline#;
304 hip_depth_ratio = .85 ;
305 hip_width# = downflag_width# - hip_thickness#/2;
306 total_depth# = 3.0 interline#;
307 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
309 foot_width_ratio = .95;
311 set_char_box(stemthickness# /2, hip_width#
312 + stemthickness#/2 + right_downflag_space#,
313 total_depth# + foot_thickness#/2, stemthickness#/2)
315 define_pixels(flare, hip_width, hip_thickness,
317 foot_depth, foot_thickness);
319 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
320 (hip_width, foot_depth),
321 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
322 add_flag(flagspace, flare,
323 .95, 1.00, 1.25, hip_thickness, foot_thickness);
327 pickup pencircle scaled stemthickness;
328 draw (0, 0) .. (0,-2 interline);
332 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
334 hip_depth_ratio, hip_width,
335 foot_depth, foot_width_ratio;
336 save flagspace, total_depth, flag_count;
339 flare# = .84 interline#;
340 flagspace# = .9 interline#;
341 hip_depth_ratio = .85 ;
342 hip_width# = downflag_width# - hip_thickness#/2;
343 total_depth# = 3.85 interline#;
344 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
346 foot_width_ratio = .95;
348 set_char_box(stemthickness# /2, hip_width#
349 + stemthickness#/2 + right_downflag_space#,
350 total_depth# + foot_thickness#/2, stemthickness#/2)
352 define_pixels(flare, hip_width, hip_thickness,
354 foot_depth, foot_thickness);
356 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
357 (hip_width, foot_depth),
358 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
359 add_flag(flagspace, flare,
360 .97, 1.00, 1.25, hip_thickness, foot_thickness);
362 add_flag(flagspace, flare,
363 .95, 1.05, 1.25, hip_thickness, foot_thickness);
367 pickup pencircle scaled stemthickness;
368 draw (0, 0) .. (0,-2 interline);
371 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
373 hip_depth_ratio, hip_width,
374 foot_depth, foot_width_ratio;
375 save flagspace, total_depth, flag_count;
378 flare# = .8 interline#;
379 flagspace# = .9 interline#;
380 hip_depth_ratio = .85 ;
381 hip_width# = downflag_width# - hip_thickness#/2;
382 total_depth# = 4.35 interline#;
383 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
385 foot_width_ratio = .98;
387 set_char_box(stemthickness# /2, hip_width#
388 + stemthickness#/2 + 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((stemthickness/2,- (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.20, 1.175, hip_thickness, foot_thickness);
400 add_flag(flagspace, flare,
401 .97, 1.10, 1.175, hip_thickness, foot_thickness);
403 add_flag(.98 flagspace, flare,
404 .91, 1.05, 1.2, hip_thickness, foot_thickness);
408 pickup pencircle scaled stemthickness;
409 draw (0, 0) .. (0,-2 interline);
414 fet_beginchar("grace 8th (down)", "d3grace", "dgraceeighthflag")
416 hip_depth_ratio, hip_width,
417 foot_depth, foot_width_ratio;
418 save flagspace, total_depth, flag_count;
421 flare# = .99 interline#;
422 flagspace# = .9 interline#;
423 hip_depth_ratio = .72 ;
424 hip_width# = downflag_width# - hip_thickness#/2;
425 total_depth# = 2.85 interline#;
426 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
428 foot_width_ratio = .8;
430 set_char_box(hip_width# * hip_depth_ratio,
431 hip_width# + stemthickness#/2 + right_downflag_space#,
432 total_depth# + foot_thickness#/2, stemthickness#/2)
434 define_pixels(flare, hip_width, hip_thickness,
436 foot_depth, foot_thickness);
438 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
439 (hip_width, foot_depth),
440 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
443 pickup pencircle scaled stemthickness;
444 draw (0, 0) .. (0,-2 interline);
445 draw (-b, -foot_depth * hip_depth_ratio) .. (w,-flare);
449 fet_endgroup("flags");