]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-sharps.mf
46937f9e4d47c44461791a3e34bdd38913fc4bfc
[lilypond.git] / mf / feta-sharps.mf
1
2 save sharp_beamheight;
3 sharp_beamheight# := 0.3 staff_space# + stafflinethickness#;
4
5 %
6 % The beams of most sharps have horizontal endings (as if drawn with
7 % a square pen).  [Wanske] does not mention this, so we'll just ignore
8 % this fact.
9 %
10
11 def draw_meta_sharp (expr width, offset) =
12         save beamwidth, beamslope;
13         save ne, nw_dist;
14         pair ne, nw_dist;
15
16         beamwidth := width;
17
18         define_whole_vertical_blacker_pixels (sharp_beamheight);
19
20         clearxy;
21
22         beamslope = sharp_beamheight / beamwidth;
23
24         pickup pencircle scaled 2 blot_diameter;
25
26         rt x2 - lft x1 = beamwidth;
27         z2 = z1 + whatever * (beamwidth, sharp_beamheight);
28         .5 [z1, z3] = (.5 w, offset);
29         x3 = x2;
30         top y2 - bot y3 = sharp_beamheight;
31         x4 = x1;
32         top y1 - bot y4 = sharp_beamheight;
33
34         ne = unitvector (z2 - z1);
35         nw_dist = (ne rotated 90) * blot_diameter;
36
37         fill lft z1{up}
38              ... (z1 + nw_dist){ne}
39              -- (z2 + nw_dist){ne}
40              ... rt z2{down}
41              -- rt z3{down}
42              ... (z3 - nw_dist){-ne}
43              -- (z4 - nw_dist){-ne}
44              ... lft z4{up}
45              -- cycle;
46
47         labels (1, 2, 3, 4);
48 enddef;
49
50
51 def draw_sharp(expr arrowup, arrowdown) =
52         save stem, stemx, stemwidth;
53         save outer_space, interbeam;
54         save stemlength, extendleft, extendright, height, depth;
55
56         stemwidth# := stafflinethickness# + .05 staff_space#;
57         define_whole_blacker_pixels (stemwidth);
58
59         interbeam := 1.05 staff_space_rounded;
60
61         stemlength# := 1.5 staff_space#;
62         define_pixels (stemlength);
63
64         height# = stemlength#;
65         depth# = stemlength#;
66         extendright# = 0;
67         extendleft# = 0;
68         if arrowup:
69                 height# := height# + 1.2 staff_space#;
70                 extendright# := extendright# + 1.5 stafflinethickness#;
71         fi;
72         if arrowdown:
73                 depth# := depth# + 1.2 staff_space#;
74                 extendleft# := extendleft# + 1.5 stafflinethickness#;
75         fi;
76         define_pixels (extendleft, extendright);
77         set_char_box (extendleft#, 1.1 staff_space#, depth#, height#);
78
79         stem := 7 / 16 * w;
80         stemx := hround stem;
81         outer_space := hround ((w - stemx - stemwidth) / 2);
82
83         w := 2 outer_space + stemx + stemwidth;
84         d := d - feta_space_shift;
85
86         draw_meta_sharp (w, -.5 interbeam);
87         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
88
89         % expand the charbox so that it encloses the whole arrow;
90         % this must not happen earlier because some commands above
91         % still rely on the old width
92         w := w + extendright;
93
94         pickup pencircle scaled stemwidth;
95
96         lft x5 = lft x6 = outer_space;
97         lft x7 = lft x8 = outer_space + stemx;
98         bot y5 = -stemlength;
99         top y6 = vround (1.5 staff_space - stem * beamslope);
100         bot y7 = -top y6 + feta_space_shift;
101         top y8 = stemlength;
102
103         labels (5, 6, 7, 8);
104
105         draw_gridline (z5, z6, stemwidth);
106         draw_gridline (z7, z8, stemwidth);
107
108         if arrowup:
109                 draw_arrow (z8, stemwidth, up,
110                             stafflinethickness / 2 + stemwidth / 2, false);
111         fi;
112         if arrowdown:
113                 draw_arrow (z5, stemwidth, up,
114                             stafflinethickness / 2 + stemwidth / 2, true);
115         fi;
116
117         draw_staff_if_debugging (-2, 2);
118 enddef;
119
120
121 fet_beginchar ("Sharp", "sharp");
122         draw_sharp (false, false);
123 fet_endchar;
124
125
126 fet_beginchar ("Arrowed Sharp (arrow up)", "sharp.arrowup");
127         draw_sharp (true, false);
128 fet_endchar;
129
130
131 fet_beginchar ("Arrowed Sharp (arrow down)", "sharp.arrowdown");
132         draw_sharp (false, true);
133 fet_endchar;
134
135
136 fet_beginchar ("Arrowed Sharp (arrows up and down)", "sharp.arrowboth");
137         draw_sharp (true, true);
138 fet_endchar;
139
140
141 fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem");
142         save stem, stemwidth;
143         save outer_space, interbeam;
144
145         stemwidth# := stafflinethickness# + .05 staff_space#;
146         define_whole_blacker_pixels (stemwidth);
147
148         interbeam := 1.05 staff_space_rounded;
149
150         set_char_box (0, 0.7 staff_space#,
151                       1.5 staff_space#, 1.5 staff_space#);
152
153         stem := 7 / 16 * w;
154         outer_space := hround ((w - stemwidth) / 2);
155
156         w := 2 outer_space + stemwidth;
157         d := d - feta_space_shift;
158
159         draw_meta_sharp (w, -.5 interbeam);
160         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
161
162         pickup pencircle scaled stemwidth;
163
164         lft x5 = lft x6 = outer_space;
165         top y6 = vround (1.5 staff_space - .5 stem);
166         bot y5 = -top y6 + feta_space_shift;
167
168         labels (5, 6);
169
170         draw_gridline (z5, z6, stemwidth);
171
172         draw_staff_if_debugging (-2, 2);
173 fet_endchar;
174
175
176 fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem");
177         save stem, stemx, stemwidth;
178         save outer_space, interbeam;
179         save sharp_beamheight;
180
181         sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
182
183         stemwidth# := stafflinethickness# + .05 staff_space#;
184         define_whole_blacker_pixels (stemwidth);
185
186         interbeam := 1.2 staff_space_rounded;
187
188         set_char_box (0, 1.1 staff_space#,
189                       1.5 staff_space#, 1.5 staff_space#);
190
191         stem := 7 / 16 * w;
192         stemx := hround stem;
193         outer_space := hround ((w - stemx - stemwidth) / 2);
194
195         w := 2 outer_space + stemx + stemwidth;
196         d := d - feta_space_shift;
197
198         draw_meta_sharp (.88 w, -.5 interbeam);
199         draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam);
200         sharp_beamheight# := 1/.88 sharp_beamheight#;
201         draw_meta_sharp (w, 0);
202
203         pickup pencircle scaled stemwidth;
204
205         lft x5 = lft x6 = outer_space;
206         lft x7 = lft x8 = outer_space + stemx;
207         bot y5 = -d;
208         top y6 = vround (1.5 staff_space - stem * beamslope);
209         bot y7 = -top y6 + feta_space_shift;
210         top y8 = h;
211
212         labels (5, 6, 7, 8);
213
214         draw_gridline (z5, z6, stemwidth);
215         draw_gridline (z7, z8, stemwidth);
216
217         draw_staff_if_debugging (-2, 2);
218 fet_endchar;
219
220
221 fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem");
222         save stem, stemx, stemwidth;
223         save outer_space, interbeam;
224         save sharp_beamheight;
225
226         sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
227
228         stemwidth# := stafflinethickness# + .05 staff_space#;
229         define_whole_blacker_pixels (stemwidth);
230
231         interbeam := 1.2 staff_space_rounded;
232
233         set_char_box (0, 0.95 staff_space#,
234                       1.3 staff_space#, 1.3 staff_space#);
235
236         stem := 7 / 16 * w;
237         outer_space := hround ((w - stemwidth) / 2);
238
239         w := 2 outer_space + stemwidth;
240         d := d - feta_space_shift;
241
242         draw_meta_sharp (.8 w, -.5 interbeam);
243         draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam);
244         sharp_beamheight# := 1/.8 sharp_beamheight#;
245         draw_meta_sharp (w, 0);
246
247         pickup pencircle scaled stemwidth;
248
249         lft x5 = lft x6 = outer_space;
250         top y6 = vround (1.5 staff_space - .5 stem);
251         bot y5 = -top y6 + feta_space_shift;
252         labels (5, 6);
253
254         draw_gridline (z5, z6, stemwidth);
255
256         draw_staff_if_debugging (-2, 2);
257 fet_endchar;
258
259
260 fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem");
261         save stem, stemx, stemwidth;
262         save outer_space, interbeam;
263
264         stemwidth# := stafflinethickness# + .05 staff_space#;
265         define_whole_blacker_pixels (stemwidth);
266
267         interbeam := 1.05 staff_space_rounded;
268
269         set_char_box (0, 1.6 staff_space#,
270                       1.5 staff_space#, 1.5 staff_space#);
271
272         stem := 9 / 32 * w;
273         stemx := hround stem;
274         outer_space := hround ((w - 2 stemx - stemwidth) / 2);
275
276         w := 2 outer_space + 2 stemx + stemwidth;
277         d := d - feta_space_shift;
278
279         draw_meta_sharp (w, -.5 interbeam);
280         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
281
282         pickup pencircle scaled stemwidth;
283
284         lft x5 = lft x6 = outer_space;
285         lft x7 = lft x8 = outer_space + stemx;
286         lft x9 = lft x10 = outer_space + 2 stemx;
287         bot y5 = -d;
288         top y6 = vround (1.5 staff_space - 2 stem * beamslope);
289         bot y9 = -top y6 + feta_space_shift;
290         top y10 = h;
291         y7 = .5 [y5, y9];
292         y8 = .5 [y6, y10];
293
294         labels (5, 6, 7, 8, 9, 10);
295
296         draw_gridline (z5, z6, stemwidth);
297         draw_gridline (z7, z8, stemwidth);
298         draw_gridline (z9, z10, stemwidth);
299
300         draw_staff_if_debugging (-2, 2);
301 fet_endchar;
302
303
304 fet_beginchar ("Double Sharp", "doublesharp");
305         save klaverblad, klaversteel;
306         save pat;
307         path pat;
308
309         klaversteel = 1/15 staff_space;
310         klaverblad = .4 staff_space - .5 stafflinethickness;
311
312         set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
313
314         z1 = (klaversteel, 0);
315         z2 = (w / 2 - klaverblad / 10, h - klaverblad);
316         z3 = (w / 2, h);
317         z4 = z2 reflectedabout ((0, 0), (1, 1));
318         z5 = z1 reflectedabout ((0, 0), (1, 1));
319
320         labels (1, 2, 3, 4, 5);
321
322         pickup pencircle scaled blot_diameter;
323
324         x2 := hfloor (rt x2) - blot_diameter / 2;
325         x3 := hfloor (rt x3) - blot_diameter / 2;
326         y3 := vfloor (top y3) - blot_diameter / 2;
327         y4 := vfloor (top y4) - blot_diameter / 2;
328
329         pat = (rt z1){dir45}
330               .. {right}(bot z2)
331               .. rt z2
332               -- rt z3{z3 - z2}
333               .. top z3{z4 - z3}
334               -- top z4{z4 - z3}
335               .. (lft z4){down}
336               .. {dir 225}(top z5);
337         pat := pat
338                -- reverse pat xscaled -1 shifted (-feta_eps, 0);
339
340         % assure symmetry -- it's more important to center the glyph on the
341         % staff line than centering it between staff lines, so we use
342         % feta_shift, not feta_space_shift.
343         h := h + feta_shift;
344
345         fill pat shifted (0, feta_shift)
346              -- reverse pat yscaled -1 shifted (0, -feta_eps)
347              -- cycle;
348
349         % ugh
350         currentpicture := currentpicture shifted (hround (w / 2), 0);
351
352         draw_staff_if_debugging (-2, 2);
353 fet_endchar;