]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-flats.mf
feta accidentals: split into several files
[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         remember_pic := currentpicture;
191
192         draw_staff (-2, 2, 0);
193 fet_endchar;
194
195
196 draw_shifted_too;
197
198
199 fet_beginchar ("Arrowed Flat (arrow up)", "flat.arrowup");
200         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
201                                 true, false);
202         penlabels (range 0 thru 23);
203
204         remember_pic := currentpicture;
205
206         draw_staff (-2, 2, 0);
207 fet_endchar;
208
209
210 draw_shifted_too;
211
212
213 fet_beginchar ("Arrowed Flat (arrow down)", "flat.arrowdown");
214         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
215                                 false, true);
216         penlabels (range 0 thru 23);
217
218         remember_pic := currentpicture;
219
220         draw_staff (-2, 2, 0);
221 fet_endchar;
222
223
224 draw_shifted_too;
225
226
227 fet_beginchar ("Arrowed Flat (arrow up and down)", "flat.arrowboth");
228         draw_arrowed_meta_flat (0, 0.8 staff_space#, 0.31 staff_space,
229                                 true, true);
230         penlabels (range 0 thru 23);
231
232         remember_pic := currentpicture;
233
234         draw_staff (-2, 2, 0);
235 fet_endchar;
236
237
238 draw_shifted_too;
239
240
241 fet_beginchar ("Flat (slashed)", "flat.slash");
242         set_char_box (.4 staff_space#, .8 staff_space#,
243                       0.6 staff_space#, 1.9 staff_space#);
244
245         draw_meta_flat (0, w, 0.31 staff_space, false, false);
246
247         clearxy;
248
249         save slope, slash_width;
250         slope = 0.5;
251         slash_width = w;
252
253         z11 = (0, h / 2);
254         z12 = z11 - (slash_width, slash_width * slope) / 2;
255         z13 = z11 + (slash_width, slash_width * slope) / 2;
256         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
257         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
258
259         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
260         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
261
262         fill z13r
263              .. z15
264              .. z13l
265              -- z12l
266              .. z14
267              .. z12r
268              -- z13r
269              .. cycle;
270
271         penlabels (12, 13);
272         labels (14, 15);
273
274         remember_pic := currentpicture;
275
276         draw_staff (-2, 2, 0);
277 fet_endchar;
278
279
280 fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
281         set_char_box (.4 staff_space#, .8 staff_space#,
282                       0.6 staff_space#, 1.9 staff_space#);
283
284         draw_meta_flat (0, w, 0.31 staff_space, false, false);
285
286         clearxy;
287
288         save slope, slash_width;
289         slope = 0.5;
290         slash_width = w;
291
292         z11 = (0, 5/12 h);
293         z12 = z11 - (slash_width, slash_width * slope) / 2;
294         z13 = z11 + (slash_width, slash_width * slope) / 2;
295         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
296         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
297
298         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
299         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
300
301         fill z13r
302              .. z15
303              .. z13l
304              -- z12l
305              .. z14
306              .. z12r
307              -- z13r
308              .. cycle;
309
310         penlabels (12, 13);
311         labels (14, 15);
312
313         z21 = (0, 2/3 h);
314         z22 = z21 - (slash_width, slash_width * slope) / 2;
315         z23 = z21 + (slash_width, slash_width * slope) / 2;
316         penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
317         penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
318
319         z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
320         z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
321
322         fill z23r
323              .. z25
324              .. z23l
325              -- z22l
326              .. z24
327              .. z22r
328              -- z23r
329              .. cycle;
330
331         penlabels (22, 23);
332         labels (24, 25);
333
334         remember_pic := currentpicture;
335
336         draw_staff (-2, 2, 0);
337 fet_endchar;
338
339
340 fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
341         set_char_box (0, 1.6 staff_space#,
342                       0.6 staff_space#, 1.9 staff_space#);
343
344         % This is a modified version of `draw_meta_flat'.
345
346         save crook_thinness, crook_fatness;
347         save bottom_overshoot, bot_crook_dir;
348         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
349         save top_crook_thinness;
350         save zwiep;
351         save center;
352         pair center, bot_crook_dir;
353         save clearing, wid;
354         save pat;
355         path pat;
356
357         clearxy;
358
359         wid = w / 2;
360
361         % the stem shouldn't reach the top staff line.
362         %% TODO: should take from height.
363         %
364         % TODO: parameterize this
365         %
366         if wid >= 0.75 staff_space:
367                 smaller_hole = 0.35 stafflinethickness;
368         else:
369                 smaller_hole = 0;
370         fi;
371         clearing = 1.7 stafflinethickness;
372         crook_thinness = .7 stafflinethickness + .06 staff_space;
373         crook_fatness = 0.31 staff_space;
374         top_crook_thinness = 1 stafflinethickness + .065 staff_space;
375         bottom_overshoot = stafflinethickness;
376
377         bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
378         top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
379         define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
380
381         if odd (top_stem_thick - bottom_stem_thick):
382                 top_stem_thick := top_stem_thick - 1;
383         fi;
384
385         center = (0, 0);
386
387         x1l = hround (-.5 top_stem_thick);
388         y1 = vround (2 staff_space - clearing);
389         x2l = hround (-.5 bottom_stem_thick);
390         y2 = -.5 staff_space - .5 stafflinethickness;
391
392         penpos1 (top_stem_thick, 0);
393         penpos2 (bottom_stem_thick, 0);
394
395         y3l = vfloor ((staff_space - stafflinethickness) / 2);
396         z3l = whatever [z2r, z1r];
397         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
398         x3r := hceiling x3r;
399
400         z10 = whatever [z2r, z1r] + (smaller_hole, 0);
401         y10 = -1/10 staff_space;
402         x10 := hceiling x10;
403
404         x11 = bottom_overshoot / 3;
405         y11 = -vround (.5 (staff_space + stafflinethickness)
406                        + bottom_overshoot);
407
408         penpos4 (whatever, 53);
409
410         y4l - y4r = top_crook_thinness;
411         y5r = .15 staff_space;
412         x5l = hround (wid);
413         y4 = staff_space / 2;
414         x4r = .45 [x5r, x3r];
415         y4l := vround y4l;
416
417         penpos5 (crook_fatness, -175);
418
419         bot_crook_dir = unitvector ((x5l, 0) - z11);
420         z8 = z11 + whatever * bot_crook_dir;
421         y8 = -staff_space / 2;
422
423         z7 = z8
424              + whatever * bot_crook_dir
425              + crook_thinness * (bot_crook_dir rotated 90);
426         x7 = .1 [x3r, x8];
427
428         pat := z3r{z3r - z10}
429                .. z4r{right}
430                .. z5r{down}
431                .. z7{-bot_crook_dir}
432                & z7
433                .. z10{z3r - z10}
434                -- cycle;
435         unfill pat;
436         unfill pat xscaled -1;
437
438         pat := z11{right}
439                .. z8{bot_crook_dir}
440                .. z5l{up}
441                .. z4l{left}
442                .. z3l;
443         fill pat
444              -- simple_serif (z1r, z1l, 30)
445              -- reverse pat xscaled -1 shifted (-feta_eps, 0)
446              -- cycle;
447
448         currentpicture := currentpicture shifted (w/2, 0);
449
450         remember_pic := currentpicture;
451
452         draw_staff (-2, 2, 0);
453 fet_endchar;
454
455
456 draw_shifted_too;
457
458
459 fet_beginchar ("Semi flat", "mirroredflat");
460         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
461                       0.6 staff_space#, 1.9 staff_space#);
462
463         draw_meta_flat (0, w, 0.31 staff_space, false, false);
464         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
465 fet_endchar;
466
467
468 fet_beginchar ("Semi flat", "mirroredflat.backslash");
469         set_char_box (.4 staff_space#, .8 staff_space#,
470                       0.6 staff_space#, 1.9 staff_space#);
471
472         draw_meta_flat (0, w, 0.31 staff_space, false, false);
473
474         clearxy;
475
476         save slope, slash_width;
477         slope = 0.5;
478         slash_width = w;
479
480         z11 = (0, h / 2);
481         z12 = z11 - (slash_width, slash_width * slope) / 2;
482         z13 = z11 + (slash_width, slash_width * slope) / 2;
483         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
484         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
485
486         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
487         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
488
489         fill z13r
490              .. z15
491              .. z13l
492              -- z12l
493              .. z14
494              .. z12r
495              -- z13r
496              .. cycle;
497
498         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
499
500         labels (1, 2, 3);
501 fet_endchar;
502
503
504 fet_beginchar ("Double Flat", "flatflat");
505         save left_wid, overlap, right_wid;
506
507         left_wid = .7;
508         right_wid = .8;
509         overlap = .05;
510
511         set_char_box (1.2 stafflinethickness#,
512                       (left_wid + right_wid - overlap) * staff_space#,
513                       .6 staff_space#, 1.9 staff_space#);
514         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space,
515                         false, false);
516         draw_meta_flat (hround ((left_wid - overlap) * staff_space),
517                         right_wid * staff_space, 1/3 staff_space,
518                         false, false);
519 fet_endchar;
520
521
522 fet_beginchar ("3/4 Flat", "flatflat.slash");
523         save left_wid, overlap, right_wid;
524
525         left_wid = .7;
526         right_wid = .8;
527         overlap = .05;
528
529         set_char_box (1.2 stafflinethickness#,
530                       (left_wid + right_wid - overlap) * staff_space#,
531                       .6 staff_space#, 1.9 staff_space#);
532         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space,
533                         false, false);
534         draw_meta_flat (hround ((left_wid - overlap) * staff_space),
535                         right_wid * staff_space, 1/3 staff_space,
536                         false, false);
537
538         %% maybe we should clip part of the stems?
539         %% or make the 1st flat smaller?
540         %% or reverse it?
541         pickup pencircle scaled 2 stafflinethickness;
542
543         z12 = round (-.25 w - b, .55 staff_space) + feta_offset;
544         z13 = round (.75 w, 1.45 staff_space) + feta_offset;
545         penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
546         penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
547
548         z14 = z12 - stafflinethickness * unitvector (z13 - z12);
549         z15 = z13 + stafflinethickness * unitvector (z13 - z12);
550
551         fill z13r
552              .. z15
553              .. z13l
554              -- z12l
555              .. z14
556              .. z12r
557              -- z13r
558              .. cycle;
559
560         penlabels (12, 13);
561         labels (14, 15);
562
563         remember_pic := currentpicture;
564
565         draw_staff (-2, 2, 0);
566 fet_endchar;
567
568
569 draw_shifted_too;