]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-flats.mf
Add '-dcrop' option to ps and svg backends
[lilypond.git] / mf / feta-flats.mf
1
2 %
3 % Dedicated to my mom.    (3/10/97)
4 %
5 % Mamma, ik hou van je; kom je alsjeblieft terug?
6 %    -- HW
7 %
8 %
9 % TODO: remove crook_fatness
10 % TODO: document, simplify!
11 %
12
13 def draw_meta_flat (expr xcenter, w, crook_fatness, arrowup, arrowdown) =
14         save crook_thinness;
15         save bottom_overshoot, bot_crook_dir;
16         save top_stem_thick, top_stem_thick_orig;
17         save bottom_stem_thick, hair, smaller_hole;
18         save top_crook_thinness;
19         save zwiep;
20         save center;
21         pair center, bot_crook_dir;
22         save clearing, clearing_orig;
23
24         clearxy;
25
26         % the stem shouldn't reach the top staff line.
27         %% TODO: should take from height.
28         %
29         % TODO: parameterize this
30         %
31         if w >= 0.75 staff_space:
32                 smaller_hole = 0.35 stafflinethickness;
33         else:
34                 smaller_hole = 0;
35         fi;
36         crook_thinness = .7 stafflinethickness + .06 staff_space;
37         top_crook_thinness = 1 stafflinethickness + .065 staff_space;
38         clearing = 1.7 stafflinethickness;
39         clearing_orig = clearing;
40         if arrowup:
41                 clearing := 0.5 staff_space;
42         fi;
43         bottom_overshoot = stafflinethickness;
44
45         bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
46         top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
47         top_stem_thick_orig# = top_stem_thick#;
48         if arrowup:
49                 % to look nice, arrowed stems should be less brushed
50                 top_stem_thick# := top_stem_thick# * 0.8;
51         fi;
52         define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick,
53                                      top_stem_thick_orig);
54
55         if odd (top_stem_thick - bottom_stem_thick):
56                 top_stem_thick := top_stem_thick - 1;
57         fi;
58         if odd (top_stem_thick_orig - bottom_stem_thick):
59                 top_stem_thick_orig := top_stem_thick_orig - 1;
60         fi;
61
62         center = (xcenter, 0);
63
64         x1l = hround (xcenter - .5 top_stem_thick);
65         y1 = vround (2 staff_space - clearing);
66         x2l = hround (xcenter - .5 bottom_stem_thick);
67         y2 = -.5 staff_space - .5 stafflinethickness;
68         % z16 and the `*_orig' variables are needed for arrowed accidentals
69         % because their inner part should be unchanged from plain ones but
70         % the points z3l, z3r, and z10 depend on values that are different
71         % for arrowed accidentals
72         x16l = hround (xcenter -.5 top_stem_thick_orig);
73         y16 = vround (2 staff_space - clearing_orig);
74
75         penpos1 (top_stem_thick, 0);
76         penpos16 (top_stem_thick_orig, 0);
77         penpos2 (bottom_stem_thick, 0);
78
79         y3l = vfloor ((staff_space - stafflinethickness) / 2);
80         z3l = whatever [z2r, z1r];
81         z3r = .3 [z2r,
82                   (z16r shifted (0, clearing_orig - 1.7 stafflinethickness))]
83               + (smaller_hole, 0);
84         x3r := hceiling x3r;
85
86         % we insert z3l to get better conversion with mf2pt1
87         fill simple_serif (z1r, z1l, 30)
88              -- z2l
89              -- z2r
90              -- z3l
91              -- cycle;
92
93         z10 = whatever [z2r, z16r] + (smaller_hole, 0);
94         y10 = -1/10 staff_space;
95         x10 := hceiling x10;
96
97         x11 = xcenter + bottom_overshoot / 3;
98         y11 = -vround (.5 (staff_space + stafflinethickness)
99                        + bottom_overshoot);
100
101         x2a = 0.2[x2r, x7];
102         y2a = 1.5[y2, y11];
103
104         penpos4 (whatever, 53);
105
106         y4l - y4r = top_crook_thinness;
107         y5r = .15 staff_space;
108         x5l = hround (w + xcenter);
109         y4 = staff_space / 2;
110         x4r = .45 [x5r, x3r];
111         y4l := vround y4l;
112
113         penpos5 (crook_fatness, -175);
114
115         bot_crook_dir = unitvector ((x5l, 0) - z11);
116         z8 = z11 + whatever * bot_crook_dir;
117         y8 = -staff_space / 2;
118
119         z7 = z8
120              + whatever * bot_crook_dir
121              + crook_thinness * (bot_crook_dir rotated 90);
122         x7 = .1 [x3r, x8];
123
124         unfill z3r{z3r - z10}
125                .. z4r{right}
126                .. z5r{down}
127                .. z7{-bot_crook_dir}
128                & z7
129                .. z10{z3r - z10}
130                -- cycle;
131
132         if arrowdown:
133                 fill z2l{down}
134                      .. z2a{up}
135                      .. z8{bot_crook_dir}
136                      .. z5l{up}
137                      .. z4l{left}
138                      .. z3l
139                      -- cycle;
140         else:
141                 fill z2l{down}
142                      .. z11{right}
143                      .. z8{bot_crook_dir}
144                      .. z5l{up}
145                      .. z4l{left}
146                      .. z3l
147                      -- cycle;
148         fi;
149
150         if arrowup:
151                 draw_arrow (z1, top_stem_thick, z1l - z2l,
152                             0.5 stafflinethickness, false);
153         fi;
154         if arrowdown:
155                 draw_arrow ((0.5 [x2l, x2a], y2), x2a - x2l, up,
156                             staff_space / 2, true);
157         fi;
158 enddef;
159
160
161 def draw_arrowed_meta_flat (expr xcenter, width, crook_fatness,
162                                  arrowup, arrowdown) =
163         save depth, height, extendleft;
164
165         depth# = 0.6 staff_space#;
166         height# = 1.9 staff_space#;
167         extendleft# := 1.2 stafflinethickness#;
168         if arrowup:
169                 extendleft# := 3.45 stafflinethickness#;
170                 height# := height# + 0.8 staff_space#;
171         fi;
172         if arrowdown:
173                 extendleft# := 3.45 stafflinethickness#;
174                 depth# := depth# + 1.6 staff_space#;
175         fi;
176
177         set_char_box (extendleft#, width, depth#, height#);
178         draw_meta_flat(xcenter, w, crook_fatness, arrowup, arrowdown);
179 enddef;
180
181 %
182 % unfortunately, 600dpi is not enough to show the brush of the stem.
183 %
184
185 fet_beginchar ("Flat", "flat");
186         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
187                                 false, false);
188         penlabels (range 0 thru 11);
189
190         draw_staff_if_debugging (-2, 2);
191 fet_endchar;
192
193
194 fet_beginchar ("Arrowed Flat (arrow up)", "flat.arrowup");
195         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
196                                 true, false);
197         penlabels (range 0 thru 23);
198
199         draw_staff_if_debugging (-2, 2);
200 fet_endchar;
201
202
203 fet_beginchar ("Arrowed Flat (arrow down)", "flat.arrowdown");
204         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
205                                 false, true);
206         penlabels (range 0 thru 23);
207
208         draw_staff_if_debugging (-2, 2);
209 fet_endchar;
210
211
212 fet_beginchar ("Arrowed Flat (arrow up and down)", "flat.arrowboth");
213         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
214                                 true, true);
215         penlabels (range 0 thru 23);
216
217         draw_staff_if_debugging (-2, 2);
218 fet_endchar;
219
220
221 fet_beginchar ("Flat (slashed)", "flat.slash");
222         set_char_box (.4 staff_space#, .8 staff_space#,
223                       0.6 staff_space#, 1.9 staff_space#);
224
225         draw_meta_flat (0, w, 0.31 staff_space, false, false);
226
227         clearxy;
228
229         save slope, slash_width;
230         slope = 0.5;
231         slash_width = w;
232
233         z11 = (0, h / 2);
234         z12 = z11 - (slash_width, slash_width * slope) / 2;
235         z13 = z11 + (slash_width, slash_width * slope) / 2;
236         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
237         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
238
239         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
240         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
241
242         fill z13r
243              .. z15
244              .. z13l
245              -- z12l
246              .. z14
247              .. z12r
248              -- z13r
249              .. cycle;
250
251         penlabels (12, 13);
252         labels (14, 15);
253
254         draw_staff_if_debugging (-2, 2);
255 fet_endchar;
256
257
258 fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
259         set_char_box (.4 staff_space#, .8 staff_space#,
260                       0.6 staff_space#, 1.9 staff_space#);
261
262         draw_meta_flat (0, w, 0.31 staff_space, false, false);
263
264         clearxy;
265
266         save slope, slash_width;
267         slope = 0.5;
268         slash_width = w;
269
270         z11 = (0, 5/12 h);
271         z12 = z11 - (slash_width, slash_width * slope) / 2;
272         z13 = z11 + (slash_width, slash_width * slope) / 2;
273         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
274         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
275
276         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
277         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
278
279         fill z13r
280              .. z15
281              .. z13l
282              -- z12l
283              .. z14
284              .. z12r
285              -- z13r
286              .. cycle;
287
288         penlabels (12, 13);
289         labels (14, 15);
290
291         z21 = (0, 2/3 h);
292         z22 = z21 - (slash_width, slash_width * slope) / 2;
293         z23 = z21 + (slash_width, slash_width * slope) / 2;
294         penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
295         penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
296
297         z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
298         z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
299
300         fill z23r
301              .. z25
302              .. z23l
303              -- z22l
304              .. z24
305              .. z22r
306              -- z23r
307              .. cycle;
308
309         penlabels (22, 23);
310         labels (24, 25);
311
312         draw_staff_if_debugging (-2, 2);
313 fet_endchar;
314
315
316 fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
317         set_char_box (0, 1.6 staff_space#,
318                       0.6 staff_space#, 1.9 staff_space#);
319
320         % This is a modified version of `draw_meta_flat'.
321
322         save crook_thinness, crook_fatness;
323         save bottom_overshoot, bot_crook_dir;
324         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
325         save top_crook_thinness;
326         save zwiep;
327         save center;
328         pair center, bot_crook_dir;
329         save clearing, wid;
330         save pat;
331         path pat;
332
333         clearxy;
334
335         wid = w / 2;
336
337         % the stem shouldn't reach the top staff line.
338         %% TODO: should take from height.
339         %
340         % TODO: parameterize this
341         %
342         if wid >= 0.75 staff_space:
343                 smaller_hole = 0.35 stafflinethickness;
344         else:
345                 smaller_hole = 0;
346         fi;
347         clearing = 1.7 stafflinethickness;
348         crook_thinness = .7 stafflinethickness + .06 staff_space;
349         crook_fatness = 0.31 staff_space;
350         top_crook_thinness = 1 stafflinethickness + .065 staff_space;
351         bottom_overshoot = stafflinethickness;
352
353         bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
354         top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
355         define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
356
357         if odd (top_stem_thick - bottom_stem_thick):
358                 top_stem_thick := top_stem_thick - 1;
359         fi;
360
361         center = (0, 0);
362
363         x1l = hround (-.5 top_stem_thick);
364         y1 = vround (2 staff_space - clearing);
365         x2l = hround (-.5 bottom_stem_thick);
366         y2 = -.5 staff_space - .5 stafflinethickness;
367
368         penpos1 (top_stem_thick, 0);
369         penpos2 (bottom_stem_thick, 0);
370
371         y3l = vfloor ((staff_space - stafflinethickness) / 2);
372         z3l = whatever [z2r, z1r];
373         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
374         x3r := hceiling x3r;
375
376         z10 = whatever [z2r, z1r] + (smaller_hole, 0);
377         y10 = -1/10 staff_space;
378         x10 := hceiling x10;
379
380         x11 = bottom_overshoot / 3;
381         y11 = -vround (.5 (staff_space + stafflinethickness)
382                        + bottom_overshoot);
383
384         penpos4 (whatever, 53);
385
386         y4l - y4r = top_crook_thinness;
387         y5r = .15 staff_space;
388         x5l = hround (wid);
389         y4 = staff_space / 2;
390         x4r = .45 [x5r, x3r];
391         y4l := vround y4l;
392
393         penpos5 (crook_fatness, -175);
394
395         bot_crook_dir = unitvector ((x5l, 0) - z11);
396         z8 = z11 + whatever * bot_crook_dir;
397         y8 = -staff_space / 2;
398
399         z7 = z8
400              + whatever * bot_crook_dir
401              + crook_thinness * (bot_crook_dir rotated 90);
402         x7 = .1 [x3r, x8];
403
404         pat := z3r{z3r - z10}
405                .. z4r{right}
406                .. z5r{down}
407                .. z7{-bot_crook_dir}
408                & z7
409                .. z10{z3r - z10}
410                -- cycle;
411         unfill pat;
412         unfill pat xscaled -1;
413
414         pat := z11{right}
415                .. z8{bot_crook_dir}
416                .. z5l{up}
417                .. z4l{left}
418                .. z3l;
419         fill pat
420              -- simple_serif (z1r, z1l, 30)
421              -- reverse pat xscaled -1 shifted (-feta_eps, 0)
422              -- cycle;
423
424         currentpicture := currentpicture shifted (w/2, 0);
425
426         draw_staff_if_debugging (-2, 2);
427 fet_endchar;
428
429
430 fet_beginchar ("Semi flat", "mirroredflat");
431         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
432                       0.6 staff_space#, 1.9 staff_space#);
433
434         draw_meta_flat (0, w, 0.31 staff_space, false, false);
435         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
436 fet_endchar;
437
438
439 fet_beginchar ("Semi flat", "mirroredflat.backslash");
440         set_char_box (.4 staff_space#, .8 staff_space#,
441                       0.6 staff_space#, 1.9 staff_space#);
442
443         draw_meta_flat (0, w, 0.31 staff_space, false, false);
444
445         clearxy;
446
447         save slope, slash_width;
448         slope = 0.5;
449         slash_width = w;
450
451         z11 = (0, h / 2);
452         z12 = z11 - (slash_width, slash_width * slope) / 2;
453         z13 = z11 + (slash_width, slash_width * slope) / 2;
454         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
455         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
456
457         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
458         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
459
460         fill z13r
461              .. z15
462              .. z13l
463              -- z12l
464              .. z14
465              .. z12r
466              -- z13r
467              .. cycle;
468
469         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
470
471         labels (1, 2, 3);
472 fet_endchar;
473
474
475 fet_beginchar ("Double Flat", "flatflat");
476         save left_wid, overlap, right_wid;
477
478         left_wid = .7;
479         right_wid = .8;
480         overlap = .05;
481
482         set_char_box (1.2 stafflinethickness#,
483                       (left_wid + right_wid - overlap) * staff_space#,
484                       .6 staff_space#, 1.9 staff_space#);
485         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space,
486                         false, false);
487         draw_meta_flat (hround ((left_wid - overlap) * staff_space),
488                         right_wid * staff_space, 1/3 staff_space,
489                         false, false);
490 fet_endchar;
491
492
493 fet_beginchar ("3/4 Flat", "flatflat.slash");
494         save left_wid, overlap, right_wid;
495
496         left_wid = .7;
497         right_wid = .8;
498         overlap = .05;
499
500         set_char_box (1.2 stafflinethickness#,
501                       (left_wid + right_wid - overlap) * staff_space#,
502                       .6 staff_space#, 1.9 staff_space#);
503         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space,
504                         false, false);
505         draw_meta_flat (hround ((left_wid - overlap) * staff_space),
506                         right_wid * staff_space, 1/3 staff_space,
507                         false, false);
508
509         %% maybe we should clip part of the stems?
510         %% or make the 1st flat smaller?
511         %% or reverse it?
512         pickup pencircle scaled 2 stafflinethickness;
513
514         z12 = round (-.25 w - b, .55 staff_space) + feta_offset;
515         z13 = round (.75 w, 1.45 staff_space) + feta_offset;
516         penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
517         penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
518
519         z14 = z12 - stafflinethickness * unitvector (z13 - z12);
520         z15 = z13 + stafflinethickness * unitvector (z13 - z12);
521
522         fill z13r
523              .. z15
524              .. z13l
525              -- z12l
526              .. z14
527              .. z12r
528              -- z13r
529              .. cycle;
530
531         penlabels (12, 13);
532         labels (14, 15);
533
534         draw_staff_if_debugging (-2, 2);
535 fet_endchar;