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;
14 % Flags pointing down cannot overlap with the notehead in y-direction,
15 % so they have less slant.
18 % Because of optical illusion, the utmost flag (bottom for
19 % down-pointing, top for up-pointing) should be smaller than the other
20 % flags. Adobe Sonata doesn't do this correctly. (Instead they have an
21 % extension flag. Yuck)
24 save hip_thickness, foot_thickness;
25 hip_thickness# = 1.3 stemthickness#;
26 foot_thickness# = hip_thickness#;
29 % Inspired by Adobe Sonata and [Wanske]
30 % for example, see POSTSCRIPT Language -- program design,
31 % page 119, and [Wanske], p 41,42
33 def draw_flag(expr center, flare,
34 dims, hip_depth, foot_wid, hip_thickness, foot_thickness)=
39 x2r - x2l = hip_thickness;
40 penpos3(foot_thickness, 0) ;
43 z2r = center + (xpart dims, -ypart(dims) * hip_depth);
44 z3r = center + (xpart(dims) * foot_wid, -ypart dims);
46 outer_path := z3r{curl 0} .. z2r{up} .. {up}z1r;
50 ..tension 1.1 .. z2l{down} ..
51 {curl 0} simple_serif(z3l, z3r, 80) &
52 outer_path & z1r -- cycle;
56 % TODO: calc intersectpoint
57 % TODO: calc incision_depth
59 def add_flag(expr yoff, flare, hip_wid_multiplier,
61 intersectpoint, hip_thickness, foot_thickness) =
63 save prev_center, prev_xextreme, prev_yextreme;
64 save rel_foot, ip, center, incision_depth;
65 save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
66 save hip_dep_ratio, foot_wid_ratio;
67 pair prev_center, center, foot, prev_xextreme, prev_yextreme;
70 incision_depth = 1.013;
71 prev_center = point 2 of outer_path;
72 prev_xextreme = point 1 of outer_path;
73 prev_yextreme = point 0 of outer_path;
74 prev_hipwid = xpart (prev_xextreme - prev_center);
75 prev_footdep = -ypart (prev_yextreme - prev_center);
76 prev_hipdep = -ypart(prev_xextreme - prev_center);
77 ip = point intersectpoint of outer_path;
79 wid = prev_hipwid * hip_wid_multiplier;
80 hip_dep = prev_hipdep * hip_dep_multiplier;
82 center = prev_center + (0,yoff);
83 rel_foot = incision_depth [(wid, hip_dep), ip - center];
84 dep = -ypart(rel_foot);
85 foot_wid_ratio = xpart(rel_foot ) / wid;
86 hip_dep_ratio = hip_dep / dep;
88 draw_flag(center, flare,
89 (wid, dep), hip_dep_ratio, foot_wid_ratio,
90 hip_thickness, foot_thickness);
94 fet_beginchar("8th Flag (up)", "u3", "eighthflag")
96 hip_depth_ratio, hip_width,
97 foot_depth, foot_width_ratio;
99 flare# = 1.0 interline#;
100 hip_depth_ratio = .72;
101 foot_width_ratio = .8;
102 hip_width# = upflag_width# - hip_thickness#/2;
104 foot_depth# = 3 interline#;
106 set_char_box(stemthickness# /2, hip_width#
108 foot_depth# + foot_thickness#/2, stemthickness#/2)
110 define_pixels(flare, hip_width, hip_thickness,
111 foot_depth, foot_thickness);
112 draw_flag((stemthickness/2,0), flare,
113 (hip_width, foot_depth),
114 hip_depth_ratio, foot_width_ratio, hip_thickness, foot_thickness);
116 pickup pencircle scaled stemthickness;
117 draw (0, 0) .. (0,-2 interline);
120 fet_beginchar("16th Flag (up)", "u4", "sixteenthflag")
122 hip_depth_ratio, hip_width,
123 foot_depth, foot_width_ratio;
124 save flagspace, total_depth, flag_count;
125 total_depth# = 3.5 interline#;
127 flare# = .85 interline#;
128 flagspace# = .85 interline#;
129 hip_depth_ratio = .72 ;
130 hip_width# = upflag_width# - hip_thickness#/2;
131 flagspace# + foot_depth# = total_depth#;
133 foot_width_ratio = .8;
135 set_char_box(stemthickness# /2, hip_width#
137 total_depth# + foot_thickness#/2, stemthickness#/2)
139 define_pixels(flare, hip_width, hip_thickness,
141 foot_depth, foot_thickness);
143 draw_flag((stemthickness/2,- flagspace), flare,
144 (hip_width, foot_depth),
145 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
147 add_flag(flagspace, flare,
148 .97, 1.00, 1.25, hip_thickness, foot_thickness);
150 pickup pencircle scaled stemthickness;
151 draw (0, 0) .. (0,-2 interline);
155 fet_beginchar("32nd Flag (up)", "u5", "thirtysecondflag")
157 hip_depth_ratio, hip_width,
158 foot_depth, foot_width_ratio;
159 save flagspace, total_depth, flag_count;
161 total_depth#=4.25 interline#;
162 flare# = .85 interline#;
163 flagspace# = .87 interline#;
164 hip_depth_ratio = .72 ;
165 hip_width# = upflag_width# - hip_thickness#/2;
166 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
168 foot_width_ratio = .8;
170 set_char_box(stemthickness# /2, hip_width#
172 total_depth# + foot_thickness#/2, stemthickness#/2)
174 define_pixels(flare, hip_width, hip_thickness,
176 foot_depth, foot_thickness);
178 draw_flag((stemthickness/2,- 2 flagspace), flare,
179 (hip_width, foot_depth),
180 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
182 add_flag(flagspace, flare,
183 .97, 1.00, 1.25, hip_thickness, foot_thickness);
185 add_flag(flagspace, flare,
186 .95, 1.05, 1.25, hip_thickness, foot_thickness);
188 pickup pencircle scaled stemthickness;
189 draw (0, 0) .. (0,-2 interline);
192 fet_beginchar("64th Flag (up)", "u6", "sixtyfourthflag")
194 hip_depth_ratio, hip_width,
195 foot_depth, foot_width_ratio;
196 save flagspace, total_depth, flag_count;
199 flare# = .85 interline#;
200 flagspace# = .9 interline#;
201 hip_depth_ratio = .72 ;
202 hip_width# = upflag_width# - hip_thickness#/2;
203 total_depth# = 5.25 interline#;
204 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
206 foot_width_ratio = .8;
208 set_char_box(stemthickness# /2, hip_width#
210 total_depth# + foot_thickness#/2, stemthickness#/2)
212 define_pixels(flare, hip_width, hip_thickness,
214 foot_depth, foot_thickness);
216 draw_flag((stemthickness/2,- (flag_count-1)* flagspace), flare,
217 (hip_width, foot_depth),
218 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
220 add_flag(flagspace, flare,
221 .97, 1.00, 1.3, hip_thickness, foot_thickness);
223 add_flag(flagspace, flare,
224 1.00, 1.00, 1.25, hip_thickness, foot_thickness);
225 add_flag(flagspace, flare,
226 .95, 1.05, 1.25, hip_thickness, foot_thickness);
227 pickup pencircle scaled stemthickness;
228 draw (0, 0) .. (0,-2 interline);
231 fet_beginchar("8th (down)", "d3", "deighthflag")
233 hip_depth_ratio, hip_width,
234 foot_depth, foot_width_ratio;
235 save flagspace, total_depth, flag_count;
238 flare# = .99 interline#;
239 flagspace# = .9 interline#;
240 hip_depth_ratio = .72 ;
241 hip_width# = downflag_width# - hip_thickness#/2;
242 total_depth# = 2.85 interline#;
243 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
245 foot_width_ratio = .8;
247 set_char_box(stemthickness# /2, hip_width#
249 total_depth# + foot_thickness#/2, stemthickness#/2)
251 define_pixels(flare, hip_width, hip_thickness,
253 foot_depth, foot_thickness);
255 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
256 (hip_width, foot_depth),
257 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
260 pickup pencircle scaled stemthickness;
261 draw (0, 0) .. (0,-2 interline);
265 fet_beginchar("16th (down)", "d4", "dsixteenthflag")
267 hip_depth_ratio, hip_width,
268 foot_depth, foot_width_ratio;
269 save flagspace, total_depth, flag_count;
272 flare# = .8 interline#;
273 flagspace# = .9 interline#;
274 hip_depth_ratio = .85 ;
275 hip_width# = downflag_width# - hip_thickness#/2;
276 total_depth# = 3.0 interline#;
277 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
279 foot_width_ratio = .95;
281 set_char_box(stemthickness# /2, hip_width#
283 total_depth# + foot_thickness#/2, stemthickness#/2)
285 define_pixels(flare, hip_width, hip_thickness,
287 foot_depth, foot_thickness);
289 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
290 (hip_width, foot_depth),
291 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
292 add_flag(flagspace, flare,
293 .95, 1.00, 1.25, hip_thickness, foot_thickness);
297 pickup pencircle scaled stemthickness;
298 draw (0, 0) .. (0,-2 interline);
302 fet_beginchar("32nd (down)", "d5", "dthirtysecondflag")
304 hip_depth_ratio, hip_width,
305 foot_depth, foot_width_ratio;
306 save flagspace, total_depth, flag_count;
309 flare# = .84 interline#;
310 flagspace# = .9 interline#;
311 hip_depth_ratio = .85 ;
312 hip_width# = downflag_width# - hip_thickness#/2;
313 total_depth# = 3.85 interline#;
314 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
316 foot_width_ratio = .95;
318 set_char_box(stemthickness# /2, hip_width#
320 total_depth# + foot_thickness#/2, stemthickness#/2)
322 define_pixels(flare, hip_width, hip_thickness,
324 foot_depth, foot_thickness);
326 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
327 (hip_width, foot_depth),
328 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
329 add_flag(flagspace, flare,
330 .97, 1.00, 1.25, hip_thickness, foot_thickness);
332 add_flag(flagspace, flare,
333 .95, 1.05, 1.25, hip_thickness, foot_thickness);
337 pickup pencircle scaled stemthickness;
338 draw (0, 0) .. (0,-2 interline);
341 fet_beginchar("64th (down)", "d6", "dsixtyfourthflag")
343 hip_depth_ratio, hip_width,
344 foot_depth, foot_width_ratio;
345 save flagspace, total_depth, flag_count;
348 flare# = .8 interline#;
349 flagspace# = .9 interline#;
350 hip_depth_ratio = .85 ;
351 hip_width# = downflag_width# - hip_thickness#/2;
352 total_depth# = 4.35 interline#;
353 (flag_count-1) * flagspace# + foot_depth# = total_depth#;
355 foot_width_ratio = .98;
357 set_char_box(stemthickness# /2, hip_width#
359 total_depth# + foot_thickness#/2, stemthickness#/2)
361 define_pixels(flare, hip_width, hip_thickness,
363 foot_depth, foot_thickness);
365 draw_flag((stemthickness/2,- (flag_count-1) *flagspace), flare,
366 (hip_width, foot_depth),
367 hip_depth_ratio,foot_width_ratio, hip_thickness, foot_thickness);
368 add_flag(flagspace, flare,
369 .97, 1.20, 1.175, hip_thickness, foot_thickness);
370 add_flag(flagspace, flare,
371 .97, 1.10, 1.175, hip_thickness, foot_thickness);
373 add_flag(.98 flagspace, flare,
374 .91, 1.05, 1.2, hip_thickness, foot_thickness);
378 pickup pencircle scaled stemthickness;
379 draw (0, 0) .. (0,-2 interline);
382 fet_endgroup("flags");