]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-accordion.mf
Run `make grand-replace'.
[lilypond.git] / mf / feta-accordion.mf
1 %
2 % feta-accordion.mf -- draw accordion symbols
3 %
4 % source file of the GNU LilyPond music typesetter
5 %
6 % (c) 1998--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 fet_begingroup ("accordion");
9
10 %
11 % These dimensions are the same for all register symbols.
12 % The different symbols should calculate their other dimensions from them.
13 %
14
15 accreg_dot_size# := .5 staff_space#;
16 accreg_linethickness# := 1.3 stafflinethickness#;
17 accreg_lh# := 1.0 staff_space#;
18
19 define_pixels (accreg_dot_size, accreg_linethickness, accreg_lh);
20
21
22 fet_beginchar ("accDiscant", "accDiscant")
23         save r, pat, lh, lt;
24         path pat;
25
26         r# = 3/2 accreg_lh#;
27         define_pixels (r);
28
29         set_char_box (r# + accreg_linethickness# / 2,
30                       r# + accreg_linethickness# / 2,
31                       0, 2 r# + 0.7 accreg_linethickness#);
32
33         lh = vround (2/3 r);
34         lt = vround (0.7 accreg_linethickness);
35
36         h := 3 lh + lt;
37         b := w := (3 lh + hround accreg_linethickness) / 2;
38
39         penpos1 (hround accreg_linethickness, 0);
40         penpos2 (lt, 90);
41         penpos3 (hround accreg_linethickness, 180);
42         penpos4 (lt, 270);
43
44         z1r = (w, h / 2);
45         z2r = (0, h);
46         z3r = (-b, h / 2);
47         z4r = (0, 0);
48
49         penlabels (1, 2, 3, 4);
50
51         % mf doesn't handle pixel dropouts in outline objects, so we use
52         % `draw' if not called by mpost
53         if known miterlimit:
54                 fill z1r
55                      .. z2r
56                      .. z3r
57                      .. z4r
58                      .. cycle;
59                 unfill z1l
60                        .. z2l
61                        .. z3l
62                        .. z4l
63                        .. cycle;
64         else:
65                 pickup pencircle xscaled accreg_linethickness yscaled lt;
66                 draw z1
67                      .. z2
68                      .. z3
69                      .. z4
70                      .. cycle;
71         fi;
72
73         pat := z4{right}
74                .. z1{up}
75                .. {left}z2;
76
77         pickup penrazor scaled lt rotated 90;
78
79         top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
80         z6 = z5 xscaled -1;
81         bot z7 = pat intersectionpoint ((0, 2 lh) -- (w, 2 lh));
82         z8 = z7 xscaled -1;
83
84         labels (5, 6, 7, 8);
85
86         draw z5
87              -- z6;
88         draw z7
89              -- z8;
90 fet_endchar;
91
92
93 fet_beginchar ("accDot", "accDot")
94         set_char_box (accreg_dot_size# / 2, accreg_dot_size# / 2,
95                       accreg_dot_size# / 2, accreg_dot_size# / 2);
96
97         pickup pencircle scaled accreg_dot_size;
98
99         rt x0 = hround (accreg_dot_size / 2);
100         top y0 = vround (accreg_dot_size / 2);
101
102         drawdot z0;
103 fet_endchar;
104
105
106 fet_beginchar ("accFreebase", "accFreebase")
107         save r, lh, lt;
108
109         r# = accreg_lh#;
110         define_pixels (r);
111
112         set_char_box (r# + accreg_linethickness# / 2,
113                       r# + accreg_linethickness# / 2,
114                       0, 2 r# + 0.7 accreg_linethickness#);
115
116         lh = vround r;
117         lt = vround (0.7 accreg_linethickness);
118
119         h := 2 lh + lt;
120         b := w := (2 lh + hround accreg_linethickness) / 2;
121
122         penpos1 (hround accreg_linethickness, 0);
123         penpos2 (lt, 90);
124         penpos3 (accreg_linethickness, 180);
125         penpos4 (lt, 270);
126
127         z1r = (w, h / 2);
128         z2r = (0, h);
129         z3r = (-b, h / 2);
130         z4r = (0, 0);
131
132         penlabels (1, 2, 3, 4);
133
134         % mf doesn't handle pixel dropouts in outline objects, so we use
135         % `draw' if not called by mpost
136         if known miterlimit:
137                 fill z1r
138                      .. z2r
139                      .. z3r
140                      .. z4r
141                      .. cycle;
142                 unfill z1l
143                        .. z2l
144                        .. z3l
145                        .. z4l
146                        .. cycle;
147         else:
148                 pickup pencircle xscaled accreg_linethickness yscaled lt;
149                 draw z1
150                      .. z2
151                      .. z3
152                      .. z4
153                      .. cycle;
154         fi;
155
156         pickup penrazor scaled lt rotated 90;
157
158         draw z1
159              -- z3;
160 fet_endchar;
161
162
163 fet_beginchar ("accStdbase", "accStdbase")
164         save r, p, lh, lt;
165         path pat;
166
167         r# = 2 accreg_lh#;
168         define_pixels (r);
169
170         set_char_box (r# + accreg_linethickness# / 2,
171                       r# + accreg_linethickness# / 2,
172                       0, 2 r# + 0.7 accreg_linethickness#);
173
174         lh = vround (1/2 r);
175         lt = vround (0.7 accreg_linethickness);
176
177         h := 4 lh + lt;
178         b := w := (4 lh + hround accreg_linethickness) / 2;
179
180         penpos1 (hround accreg_linethickness, 0);
181         penpos2 (lt, 90);
182         penpos3 (hround accreg_linethickness, 180);
183         penpos4 (lt, 270);
184
185         z1r = (w, h / 2);
186         z2r = (0, h);
187         z3r = (-b, h / 2);
188         z4r = (0, 0);
189
190         penlabels (1, 2, 3, 4);
191
192         % mf doesn't handle pixel dropouts in outline objects, so we use
193         % `draw' if not called by mpost
194         if known miterlimit:
195                 fill z1r
196                      .. z2r
197                      .. z3r
198                      .. z4r
199                      .. cycle;
200                 unfill z1l
201                        .. z2l
202                        .. z3l
203                        .. z4l
204                        .. cycle;
205         else:
206                 pickup pencircle xscaled accreg_linethickness yscaled lt;
207                 draw z1
208                      .. z2
209                      .. z3
210                      .. z4
211                      .. cycle;
212         fi;
213
214         pat := z4{right}
215                .. z1{up}
216                .. {left}z2;
217
218         pickup penrazor scaled lt rotated 90;
219
220         top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
221         z6 = z5 xscaled -1;
222         bot z7 = pat intersectionpoint ((0, 3 lh) -- (w, 3 lh));
223         z8 = z7 xscaled -1;
224
225         labels (5, 6, 7, 8);
226
227         draw z1
228              -- z3;
229         draw z5
230              -- z6;
231         draw z7
232              -- z8;
233 fet_endchar;
234
235
236 fet_beginchar ("accBayanbase", "accBayanbase")
237         save lh, lt;
238
239         lh = vround accreg_lh;
240         lt = vround accreg_linethickness;
241
242         set_char_box (accreg_lh# + accreg_linethickness# / 2,
243                       accreg_lh# + accreg_linethickness# / 2,
244                       0, 3 accreg_lh# + accreg_linethickness#);
245
246         h := 3 lh + lt;
247
248         draw_rounded_block ((-w, 0), (-w + lt, h), lt);
249         draw_rounded_block ((w - lt, 0), (w, h), lt);
250
251         pickup penrazor scaled lt rotated 90;
252
253         bot z1 = (-w + lt / 2, 0);
254         bot z2 = (-w + lt / 2, lh);
255         bot z3 = (-w + lt / 2, 2 lh);
256         bot z4 = (-w + lt / 2, 3 lh);
257
258         bot z5 = (w - lt / 2, 0);
259         bot z6 = (w - lt / 2, lh);
260         bot z7 = (w - lt / 2, 2 lh);
261         bot z8 = (w - lt / 2, 3 lh);
262
263         draw z1
264              -- z5;
265         draw z2
266              -- z6;
267         draw z3
268              -- z7;
269         draw z4
270              -- z8;
271 fet_endchar;
272
273
274 def def_B (expr w, h) =
275         pickup pencircle scaled 0.15 linethickness;
276
277         penpos10 (thin, -90);
278         penpos11 (thin, -90);
279         penpos12 (thick, 0);
280         penpos13 (thin, 90);
281         penpos14 (thin, 90);
282
283         penpos15 (thick, 180);
284         penpos16 (thin, -90);
285         penpos17 (thin, -90);
286         penpos18 (thick, 0);
287         penpos19 (thick, 0);
288
289         z10 = (0, 0);
290         z11 = (cOne * w, 0);
291         z12 = (w, .5 mb * h);
292         z13 = (cTwo * w, mb * h);
293         z14 = (2 thick, mb * h);
294         z15 = (.94 w, h - .5 mt * h);
295         z16 = z13 + (0, mt * h);
296         z17 = (0, h);
297         z18 = (1.5 thick, 0);
298         z19 = (1.5 thick, h);
299 enddef;
300
301
302 def def_S (expr w, h) =
303         pickup pencircle scaled 0.03 linethickness;
304
305         penpos1 (thin, 180);
306         penpos2 (thin, -90);
307         penpos3 (thick, 0);
308         penpos4 (.5 thick, 90);
309         penpos5 (thick, 0);
310         penpos6 (thin, -90);
311         penpos7 (thin, 180);
312         penpos8 (thin, 180);
313         penpos9 (thin, 0);
314
315         z1 = (0, hs);
316         z2 = (w / 2, 0);
317         z3 = (w - .5 thick, .5 mb * h);
318         z4 = (w / 2, mb * h);
319         z5 = (.5 thick, h - .5 mt * h);
320         z6 = (w / 2, h);
321         z7 = (w, h - hs);
322         z8 = (0, y2r);
323         z9 = (w, y6l);
324
325         path bue, bueoverst;
326
327         bue := z2{left}
328                .. z1{up};
329
330         t := xpart (bue intersectiontimes (z8l -- z7l));
331
332         bueoverst := z6{right}
333                      .. z7{down};
334 enddef;
335
336
337 def def_some_vars =
338         save hs, mb, mt, thin, thick, height, width, cOne, cTwo;
339         save bx, hx;
340
341         width = .8 (4 staff_space);
342         height = 2.4 staff_space;
343         % URG.  smaller sizes should be wider and fatter
344         % thin = 0.05 staff_space;
345         % thick = 0.2 staff_space;
346
347         4 hx + bx = 1.15;
348         10 hx + bx = 1;
349         fatten := designsize * hx + bx * 1.2;
350         thick := 0.2 staff_space * fatten;
351
352         % urg: mustn't ever go thinner than blot!
353         thin# := blot_diameter#;
354         define_pixels (thin);
355
356         hs = 0.4 staff_space;
357         mb = .53;
358         mt = .47;
359         cOne = 0.65;
360         cTwo = 0.60;
361 enddef;
362
363
364 fet_beginchar ("accOldEE", "accOldEE")
365         save r, pp, ir, lh, lt, stroke_width;
366
367         r# = staff_space#;
368         define_pixels (r);
369
370         lr = .4 staff_space - linethickness;
371         ir = .6 staff_space;
372         stroke_width = .05 staff_space + .5 linethickness;
373
374         set_char_box (r# + accreg_linethickness# / 2,
375                       r# + accreg_linethickness# / 2,
376                       0, 2 r# + 0.7 accreg_linethickness#);
377
378         z1 = (0, 0);
379         z2 = (0, ir);
380         z3 = (0, -ir);
381
382         penpos1 (blot_diameter, 0);
383         penpos2 (stroke_width + blot_diameter, 0);
384         penpos3 (stroke_width + blot_diameter, 0);
385
386         pickup pencircle scaled (lr + blot_diameter);
387
388         for pp := 0 step 45 until 135:
389                 drawdot z2 rotated pp;
390                 drawdot z3 rotated pp;
391
392                 penstroke (z2e
393                            -- z1e
394                            -- z3e) rotated pp;
395         endfor;
396
397         pickup pencircle scaled lr;
398
399         drawdot (0, 0);
400
401         currentpicture := currentpicture shifted (0, h / 2);
402
403         lh = vround (2 r);
404         lt = vround (0.7 accreg_linethickness);
405
406         h := lh + lt;
407         b := w := (lh + hround accreg_linethickness) / 2;
408
409         penpos10 (hround accreg_linethickness, 0);
410         penpos11 (lt, 90);
411         penpos12 (hround accreg_linethickness, 180);
412         penpos13 (lt, 270);
413
414         z10r = (w, h / 2);
415         z11r = (0, h);
416         z12r = (-b, h / 2);
417         z13r = (0, 0);
418
419         % penlabels (1, 2, 10, 11, 12, 13);
420
421         % mf doesn't handle pixel dropouts in outline objects, so we use
422         % `draw' if not called by mpost
423         if known miterlimit:
424                 fill z10r
425                      .. z11r
426                      .. z12r
427                      .. z13r
428                      .. cycle;
429                 unfill z10l
430                        .. z11l
431                        .. z12l
432                        .. z13l
433                        .. cycle;
434         else:
435                 pickup pencircle xscaled accreg_linethickness yscaled lt;
436                 draw z10
437                      .. z11
438                      .. z12
439                      .. z13
440                      .. cycle;
441         fi;
442 fet_endchar;
443
444
445 fet_endgroup ("accordion");