]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-naturals.mf
feta accidentals: split into several files
[lilypond.git] / mf / feta-naturals.mf
1
2 %
3 % The stems of the natural are brushed (at least, in Barenreiter SCS)
4 %
5
6 def draw_natural (expr arrowup, arrowdown) =
7         save stemwidth, top_stem_thick;
8         save ne, pat_top, pat_bottom;
9         save depth, height, extendleft, extendright, stemlength;
10         save brush_scale_up, brush_scale_down;
11         pair ne;
12         path pat_top, pat_bottom;
13
14         top_stem_thick# = stafflinethickness# + .10 staff_space#;
15         stemwidth# = 0.09 staff_space# + .5 stafflinethickness#;
16         define_whole_blacker_pixels (top_stem_thick, stemwidth);
17
18         stemlength# = 1.5 staff_space#;
19         define_pixels (stemlength);
20
21         height# = stemlength#;
22         depth# = stemlength#;
23         extendleft# = 0;
24         extendright# = 0;
25         if arrowup:
26                 extendleft# := 3 stafflinethickness#;
27                 height# := height# + 1.2 staff_space#;
28         fi;
29         if arrowdown:
30                 extendright# := 3.15 stafflinethickness#;
31                 depth# := depth# + 1.2 staff_space#;
32         fi;
33         define_pixels (extendright);
34
35         set_char_box (extendleft#, 2/3 staff_space#, depth#, height#);
36
37         d := d - feta_space_shift;
38
39         pickup pencircle scaled stemwidth;
40
41         brush_scale_up := 1.0;
42         brush_scale_down := 1.0;
43         % to look nice, arrowed stems must be less brushed
44         if arrowup:
45                 brush_scale_up := 0.85;
46         fi;
47         if arrowdown:
48                 brush_scale_down := 0.85;
49         fi;
50
51         penpos1 (top_stem_thick, 0);
52         penpos3 (top_stem_thick, 0);
53         penpos2 (stemwidth, 0);
54         penpos4 (stemwidth, 0);
55         % z1' and z3' are needed for the arrowed accidentals
56         penpos1' (top_stem_thick * brush_scale_up, 0);
57         penpos3' (top_stem_thick * brush_scale_down, 0);
58
59         x2r = w;
60         x4l = 0;
61         x3 = x3' = x2;
62         x1 = x1' = x4;
63
64         y1 = y1' = stemlength;
65         y3 = y3' = -stemlength;
66         top y2 = vround (staff_space - 3/2 stafflinethickness);
67         y4 = -y2 + feta_space_shift;
68
69         pat_bottom := z4r{z4r - z1r}
70                       .. bot z4
71                       .. z4l{z1l - z4l};
72         fill simple_serif (z1'l, z1'r, -30)
73              -- pat_bottom
74              -- cycle;
75
76         pat_top := z2r{z2r - z3r}
77                    .. top z2
78                    .. z2l{z3l - z2l};
79         fill simple_serif (z3'l, z3'r, 30)
80              -- pat_top
81              -- cycle;
82
83         ne = (x2 - x4, stafflinethickness);
84
85         z11' = z3l + whatever * (z2l - z3l);
86         y11' = vround (.5 (staff_space - stafflinethickness));
87         z11 = z11' + whatever * ne;
88         x11 = x12;
89         z12 = directionpoint -ne of pat_top;
90         z13 = z12 + whatever * ne;
91         x13 = x1;
92         z14 = z11 + whatever * ne;
93         x14 = x1;
94
95         z21' = z4r + whatever * (z1r - z4r);
96         y21' = -y11' + feta_space_shift;
97         z21 = z21' + whatever * ne;
98         x21 = x22;
99         z22 = directionpoint -ne of pat_bottom;
100         z23 = z22 + whatever * ne;
101         x23 = x3;
102         z24 = z21 + whatever * ne;
103         x24 = x3;
104
105         fill z11
106              -- z12
107              -- z13
108              -- z14
109              -- cycle;
110         fill z21
111              -- z22
112              -- z23
113              -- z24
114              -- cycle;
115
116         penlabels (1, 1', 2, 3, 3', 4);
117         labels (11, 11', 12, 13, 14, 21, 21', 22, 23, 24);
118
119         if arrowup:
120                 draw_arrow (z1, top_stem_thick * brush_scale_up,
121                             z1'l - z4l, stafflinethickness / 2, false);
122         fi;
123         if arrowdown:
124                 draw_arrow (z3, top_stem_thick * brush_scale_down,
125                             z2r - z3'r, stafflinethickness / 2, true);
126                 w := w + extendright;
127         fi;
128
129         remember_pic := currentpicture;
130
131         draw_staff (-2, 2, 0);
132 enddef;
133
134
135 fet_beginchar ("Natural", "natural");
136         draw_natural (false, false);
137 fet_endchar;
138
139
140 draw_shifted_too;
141
142
143 fet_beginchar ("Arrowed Natural (arrow up)", "natural.arrowup");
144         draw_natural (true, false);
145 fet_endchar;
146
147
148 draw_shifted_too;
149
150
151 fet_beginchar ("Arrowed Natural (arrow down)", "natural.arrowdown");
152         draw_natural (false, true);
153 fet_endchar;
154
155
156 draw_shifted_too;
157
158
159 fet_beginchar ("Arrowed Natural (arrows up and down)", "natural.arrowboth");
160         draw_natural (true, true);
161 fet_endchar;
162
163
164 draw_shifted_too;
165