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);
146 draw_flag((stemthickness/2,- flagspace), flare,
147 (hip_width, foot_depth),
148 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
150 add_flag(flagspace, flare,
151 .97, 1.00, 1.25, hip_thickness, foot_thickness);
153 pickup pencircle scaled stemthickness;
154 draw (0, 0) .. (0,-2 interline);
158 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
160 hip_depth_ratio, hip_width,
161 foot_depth, foot_width_ratio;
162 save flagspace, total_depth, flag_count;
164 total_depth#=4.25 interline#;
165 flare# = .85 interline#;
166 flagspace# = .87 interline#;
167 hip_depth_ratio = .72 ;
168 hip_width# = upflag_width# - hip_thickness#/2;
169 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
171 foot_width_ratio = .8;
173 set_char_box(stemthickness# /2, hip_width#
174 + stemthickness#/2 + right_upflag_space#,
175 total_depth# + foot_thickness#/2, stemthickness#/2)
177 define_pixels(flare, hip_width, hip_thickness,
179 foot_depth, foot_thickness);
181 draw_flag((stemthickness/2,- 2 flagspace), flare,
182 (hip_width, foot_depth),
183 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
185 add_flag(flagspace, flare,
186 .97, 1.00, 1.25, hip_thickness, foot_thickness);
188 add_flag(flagspace, flare,
189 .95, 1.05, 1.25, hip_thickness, foot_thickness);
191 pickup pencircle scaled stemthickness;
192 draw (0, 0) .. (0,-2 interline);
195 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
197 hip_depth_ratio, hip_width,
198 foot_depth, foot_width_ratio;
199 save flagspace, total_depth, flag_count;
202 flare# = .85 interline#;
203 flagspace# = .9 interline#;
204 hip_depth_ratio = .72 ;
205 hip_width# = upflag_width# - hip_thickness#/2;
206 total_depth# = 5.25 interline#;
207 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
209 foot_width_ratio = .8;
211 set_char_box(stemthickness# /2, hip_width#
212 + stemthickness#/2 + right_upflag_space#,
213 total_depth# + foot_thickness#/2, stemthickness#/2)
215 define_pixels(flare, hip_width, hip_thickness,
217 foot_depth, foot_thickness);
219 draw_flag((stemthickness/2,- (flag_count-1)* flagspace), flare,
220 (hip_width, foot_depth),
221 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
223 add_flag(flagspace, flare,
224 .97, 1.00, 1.3, hip_thickness, foot_thickness);
226 add_flag(flagspace, flare,
227 1.00, 1.00, 1.25, hip_thickness, foot_thickness);
228 add_flag(flagspace, flare,
229 .95, 1.05, 1.25, hip_thickness, foot_thickness);
230 pickup pencircle scaled stemthickness;
231 draw (0, 0) .. (0,-2 interline);
234 fet_beginchar("8th (down)", "d3", "deighthflag")
236 hip_depth_ratio, hip_width,
237 foot_depth, foot_width_ratio;
238 save flagspace, total_depth, flag_count;
241 flare# = .99 interline#;
242 flagspace# = .9 interline#;
243 hip_depth_ratio = .72 ;
244 hip_width# = downflag_width# - hip_thickness#/2;
245 total_depth# = 2.85 interline#;
246 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
248 foot_width_ratio = .8;
250 set_char_box(stemthickness# /2, hip_width#
251 + stemthickness#/2 + right_downflag_space#,
252 total_depth# + foot_thickness#/2, stemthickness#/2)
254 define_pixels(flare, hip_width, hip_thickness,
256 foot_depth, foot_thickness);
258 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
259 (hip_width, foot_depth),
260 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
263 pickup pencircle scaled stemthickness;
264 draw (0, 0) .. (0,-2 interline);
268 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
270 hip_depth_ratio, hip_width,
271 foot_depth, foot_width_ratio;
272 save flagspace, total_depth, flag_count;
275 flare# = .8 interline#;
276 flagspace# = .9 interline#;
277 hip_depth_ratio = .85 ;
278 hip_width# = downflag_width# - hip_thickness#/2;
279 total_depth# = 3.0 interline#;
280 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
282 foot_width_ratio = .95;
284 set_char_box(stemthickness# /2, hip_width#
285 + stemthickness#/2 + right_downflag_space#,
286 total_depth# + foot_thickness#/2, stemthickness#/2)
288 define_pixels(flare, hip_width, hip_thickness,
290 foot_depth, foot_thickness);
292 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
293 (hip_width, foot_depth),
294 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
295 add_flag(flagspace, flare,
296 .95, 1.00, 1.25, hip_thickness, foot_thickness);
300 pickup pencircle scaled stemthickness;
301 draw (0, 0) .. (0,-2 interline);
305 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
307 hip_depth_ratio, hip_width,
308 foot_depth, foot_width_ratio;
309 save flagspace, total_depth, flag_count;
312 flare# = .84 interline#;
313 flagspace# = .9 interline#;
314 hip_depth_ratio = .85 ;
315 hip_width# = downflag_width# - hip_thickness#/2;
316 total_depth# = 3.85 interline#;
317 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
319 foot_width_ratio = .95;
321 set_char_box(stemthickness# /2, hip_width#
322 + stemthickness#/2 + right_downflag_space#,
323 total_depth# + foot_thickness#/2, stemthickness#/2)
325 define_pixels(flare, hip_width, hip_thickness,
327 foot_depth, foot_thickness);
329 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
330 (hip_width, foot_depth),
331 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
332 add_flag(flagspace, flare,
333 .97, 1.00, 1.25, hip_thickness, foot_thickness);
335 add_flag(flagspace, flare,
336 .95, 1.05, 1.25, hip_thickness, foot_thickness);
340 pickup pencircle scaled stemthickness;
341 draw (0, 0) .. (0,-2 interline);
344 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
346 hip_depth_ratio, hip_width,
347 foot_depth, foot_width_ratio;
348 save flagspace, total_depth, flag_count;
351 flare# = .8 interline#;
352 flagspace# = .9 interline#;
353 hip_depth_ratio = .85 ;
354 hip_width# = downflag_width# - hip_thickness#/2;
355 total_depth# = 4.35 interline#;
356 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
358 foot_width_ratio = .98;
360 set_char_box(stemthickness# /2, hip_width#
361 + stemthickness#/2 + right_downflag_space#,
362 total_depth# + foot_thickness#/2, stemthickness#/2)
364 define_pixels(flare, hip_width, hip_thickness,
366 foot_depth, foot_thickness);
368 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
369 (hip_width, foot_depth),
370 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
371 add_flag(flagspace, flare,
372 .97, 1.20, 1.175, hip_thickness, foot_thickness);
373 add_flag(flagspace, flare,
374 .97, 1.10, 1.175, hip_thickness, foot_thickness);
376 add_flag(.98 flagspace, flare,
377 .91, 1.05, 1.2, hip_thickness, foot_thickness);
381 pickup pencircle scaled stemthickness;
382 draw (0, 0) .. (0,-2 interline);
385 fet_endgroup("flags");