2 % feta-banier.mf -- draw flags
4 % source file of the GNU LilyPond music typesetter
6 % (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 fet_begingroup ("flags");
14 % Flags pointing down overlap with the notehead (in x-direction), so
15 % the down-flag can be bigger.
18 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
19 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
21 right_upflag_space# = .0 upflag_width#;
22 right_downflag_space# = .0 downflag_width#;
25 % Flags pointing down cannot overlap with the notehead in y-direction,
26 % so they have less slant.
28 % Because of optical illusion, the utmost flag (bottom for
29 % down-pointing, top for up-pointing) should be smaller than the other
30 % flags. Adobe Sonata doesn't do this correctly. (Instead they have
31 % an extension flag, which looks less elegant.)
34 save hip_thickness, foot_thickness;
36 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
37 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
39 define_pixels (hip_thickness, foot_thickness);
42 % Inspired by Adobe Sonata and [Wanske].
43 % For example, see POSTSCRIPT Language -- program design,
44 % page 119, and [Wanske], p 41, 42.
47 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
48 hip_thickness, foot_thickness, show_labels) =
56 penpos2 (whatever, 0);
58 x2r - x2l = hround (hip_thickness);
60 penpos3 (foot_thickness, -20.0);
63 z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
64 z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
69 outer_path := z3r{curl c}
78 ..tension 1.1.. z2l{down}
79 .. {curl c}simple_serif (z3l, z3r, 80)
86 % TODO: calculate intersectpoint (see TeX book, p. 137)
87 % TODO: calculate incision_depth
90 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
91 intersectpoint, hip_thickness, foot_thickness) =
93 save prev_center, prev_xextreme, prev_yextreme;
94 save rel_foot, ip, center, incision_depth;
95 save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
96 save hip_dep_ratio, foot_wid_ratio;
97 pair prev_center, center, foot, prev_xextreme, prev_yextreme;
100 incision_depth = 1.013;
101 prev_center = point 2 of outer_path;
102 prev_xextreme = point 1 of outer_path;
103 prev_yextreme = point 0 of outer_path;
104 prev_hipwid = xpart (prev_xextreme - prev_center);
105 prev_footdep = -ypart (prev_yextreme - prev_center);
106 prev_hipdep = -ypart (prev_xextreme - prev_center);
107 ip = point intersectpoint of outer_path;
109 wid = prev_hipwid * hip_wid_multiplier;
110 hip_dep = prev_hipdep * hip_dep_multiplier;
112 center = prev_center + (0, yoff);
113 rel_foot = incision_depth [(wid, hip_dep), ip - center];
114 dep = -ypart (rel_foot);
115 foot_wid_ratio = xpart (rel_foot) / wid;
116 hip_dep_ratio = hip_dep / dep;
118 draw_flag (center, flare, (wid, dep),
119 hip_dep_ratio, foot_wid_ratio,
120 hip_thickness, foot_thickness, 0);
125 fet_beginchar ("8th Flag (up)", "u3");
126 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
129 hip_depth_ratio = .72;
130 foot_width_ratio = .8;
131 hip_width# = upflag_width# - hip_thickness# / 2;
132 foot_depth# = 3 staff_space# - blot_diameter# / 2;
133 define_pixels (hip_width, foot_depth);
136 hip_width# + stemthickness# / 2 + right_upflag_space#,
137 foot_depth# + foot_thickness# / 2, stemthickness# / 2);
139 draw_flag ((0,0), flare, (hip_width, foot_depth),
140 hip_depth_ratio, foot_width_ratio,
141 hip_thickness, foot_thickness, 1);
143 draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
148 fet_beginchar ("16th Flag (up)", "u4");
149 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
150 save flagspace, total_depth, flag_count;
152 total_depth# = 3.5 staff_space# - blot_diameter# / 2;
154 flare = .85 staff_space;
155 flagspace# = .85 staff_space#;
156 hip_depth_ratio = .72;
157 hip_width# = upflag_width# - hip_thickness# / 2;
158 flagspace# + foot_depth# = total_depth#;
159 foot_width_ratio = .8;
160 define_pixels (hip_width, foot_depth);
161 define_whole_vertical_pixels (flagspace);
164 hip_width# + stemthickness# / 2 + right_upflag_space#,
165 total_depth# + foot_thickness# / 2, stemthickness# / 2);
167 draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
168 hip_depth_ratio, foot_width_ratio,
169 hip_thickness, foot_thickness, 1);
171 add_flag (flagspace, flare, .97, 1.00, 1.25,
172 hip_thickness, foot_thickness);
174 draw_square_block ((-0.5 stemthickness_rounded, 0),
175 (0, -2 staff_space_rounded));
179 fet_beginchar ("32nd Flag (up)", "u5");
180 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
181 save flagspace, total_depth, flag_count;
184 total_depth# = 4.25 staff_space#;
185 flare = .85 staff_space;
186 flagspace# = .87 staff_space#;
187 hip_depth_ratio = .72;
188 hip_width# = upflag_width# - hip_thickness# / 2;
189 foot_width_ratio = .8;
191 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
193 define_pixels (hip_width, foot_depth);
194 define_whole_vertical_pixels (flagspace);
196 set_char_box (0, hip_width# + right_upflag_space#,
197 total_depth# + foot_thickness# / 2, stemthickness# / 2);
199 draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
200 hip_depth_ratio, foot_width_ratio,
201 hip_thickness, foot_thickness, 1);
203 add_flag (flagspace, flare, .97, 1.00, 1.25,
204 hip_thickness, foot_thickness);
205 add_flag (flagspace, flare, .95, 1.05, 1.25,
206 hip_thickness, foot_thickness);
208 draw_square_block ((-0.5 stemthickness_rounded, 0),
209 (0, -3 staff_space_rounded));
213 fet_beginchar ("64th Flag (up)", "u6");
214 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
215 save flagspace, total_depth, flag_count;
218 flare = .85 staff_space;
219 flagspace# = .9 staff_space#;
220 hip_depth_ratio = .72;
221 hip_width# = upflag_width# - hip_thickness# / 2;
222 total_depth# = 5.25 staff_space#;
223 foot_width_ratio = .8;
225 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
227 define_pixels (hip_width, foot_depth);
228 define_whole_vertical_pixels (flagspace);
230 set_char_box (0, hip_width# + right_upflag_space#,
231 total_depth# + foot_thickness# / 2, stemthickness# / 2);
233 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
234 (hip_width, foot_depth),
235 hip_depth_ratio, foot_width_ratio,
236 hip_thickness, foot_thickness, 1);
238 add_flag (flagspace, flare, .97, 1.00, 1.3,
239 hip_thickness, foot_thickness);
240 add_flag (flagspace, flare, 1.00, 1.00, 1.25,
241 hip_thickness, foot_thickness);
242 add_flag (flagspace, flare, .95, 1.05, 1.25,
243 hip_thickness, foot_thickness);
245 draw_square_block ((-0.5 stemthickness_rounded, 0),
246 (0, -4 staff_space_rounded));
250 fet_beginchar ("8th (down)", "d3");
251 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
252 save flagspace, total_depth, flag_count;
256 flagspace# = .9 staff_space#;
257 hip_depth_ratio = .72;
258 hip_width# = downflag_width# - hip_thickness# / 2;
259 total_depth# = 2.85 staff_space#;
260 foot_width_ratio = .8;
262 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
264 define_pixels (hip_width, flagspace, foot_depth);
266 set_char_box (0, hip_width# + right_downflag_space#,
267 total_depth# + foot_thickness# / 2, stemthickness# / 2)
269 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
270 (hip_width, foot_depth),
271 hip_depth_ratio, foot_width_ratio,
272 hip_thickness, foot_thickness, 0);
274 draw_square_block ((-0.5 stemthickness_rounded, 0),
275 (0, -staff_space_rounded));
283 % Single Stroke for Short Appogiatura
286 fet_beginchar ("grace dash (up)", "ugrace");
287 save flare, hip_depth_ratio, hip_width, foot_depth;
289 hip_depth_ratio = .72;
290 flare# = staff_space#;
291 hip_width# = upflag_width# - hip_thickness# / 2;
292 foot_depth# = 3 staff_space#;
294 define_pixels (hip_width, foot_depth);
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;
305 penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
306 penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
322 fet_beginchar ("grace dash (down)", "dgrace");
323 save flare, hip_depth_ratio, hip_width, foot_depth;
326 hip_depth_ratio = .72 ;
327 flare# = .99 staff_space#;
328 hip_width# = downflag_width# - hip_thickness# / 2;
329 total_depth# = 2.85 staff_space#;
330 foot_depth# = total_depth#;
331 foot_width_ratio = .8;
333 define_pixels (hip_width, foot_depth);
335 set_char_box (hip_width# * hip_depth_ratio,
336 hip_width# + right_downflag_space#,
337 foot_depth# * hip_depth_ratio, -flare#)
339 pickup pencircle scaled 1.5 stemthickness;
344 penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
345 penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
361 fet_beginchar ("16th (down)", "d4");
362 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
363 save flagspace, total_depth, flag_count;
366 flare = .8 staff_space;
367 flagspace# = .9 staff_space#;
368 hip_depth_ratio = .85;
369 hip_width# = downflag_width# - hip_thickness# / 2;
370 total_depth# = 3.0 staff_space# - blot_diameter# / 2;
371 foot_width_ratio = .95;
373 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
375 set_char_box (0, hip_width# + right_downflag_space#,
376 total_depth# + foot_thickness# / 2, stemthickness# / 2);
378 define_pixels (hip_width, foot_depth);
379 define_whole_vertical_pixels (flagspace);
381 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
382 (hip_width, foot_depth),
383 hip_depth_ratio, foot_width_ratio,
384 hip_thickness, foot_thickness, 0);
386 add_flag (flagspace, flare, .95, 1.00, 1.25,
387 hip_thickness, foot_thickness);
389 draw_square_block ((-0.5 stemthickness_rounded, 0),
390 (0, -2 staff_space_rounded));
396 fet_beginchar ("32nd (down)", "d5");
397 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
398 save flagspace, total_depth, flag_count;
401 flare = .84 staff_space;
402 flagspace# = .9 staff_space#;
403 hip_depth_ratio = .85;
404 hip_width# = downflag_width# - hip_thickness# / 2;
405 total_depth# = 3.85 staff_space#;
406 foot_width_ratio = .95;
408 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
410 define_pixels (hip_width, foot_depth);
411 define_whole_vertical_pixels (flagspace);
413 set_char_box (0, hip_width# + right_downflag_space#,
414 total_depth# + foot_thickness# / 2, stemthickness# / 2);
416 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
417 (hip_width, foot_depth),
418 hip_depth_ratio, foot_width_ratio,
419 hip_thickness, foot_thickness, 0);
421 add_flag (flagspace, flare, .97, 1.00, 1.25,
422 hip_thickness, foot_thickness);
423 add_flag (flagspace, flare, .95, 1.05, 1.25,
424 hip_thickness, foot_thickness);
426 draw_square_block ((-0.5 stemthickness_rounded, 0),
427 (0, -3 staff_space_rounded));
433 fet_beginchar ("64th (down)", "d6");
434 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
435 save flagspace, total_depth, flag_count;
438 flare = .8 staff_space;
439 flagspace# = .9 staff_space#;
440 hip_depth_ratio = .85;
441 hip_width# = downflag_width# - hip_thickness# / 2;
442 total_depth# = 4.35 staff_space#;
443 foot_width_ratio = .98;
445 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
447 define_pixels (hip_width, foot_depth);
448 define_whole_vertical_pixels (flagspace);
450 set_char_box (0, hip_width# + right_downflag_space#,
451 total_depth# + foot_thickness# / 2, stemthickness# / 2);
453 draw_flag ((0, -(flag_count - 1) * flagspace), flare,
454 (hip_width, foot_depth),
455 hip_depth_ratio, foot_width_ratio,
456 hip_thickness, foot_thickness, 0);
458 add_flag (flagspace, flare, .97, 1.20, 1.175,
459 hip_thickness, foot_thickness);
460 add_flag (flagspace, flare, .97, 1.10, 1.175,
461 hip_thickness, foot_thickness);
462 add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
463 hip_thickness, foot_thickness);
465 draw_square_block ((-0.5 stemthickness_rounded, 0),
466 (0, -4 staff_space_rounded));
471 fet_endgroup ("flags");