]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-naturals.mf
Add '-dcrop' option to ps and svg backends
[lilypond.git] / mf / feta-naturals.mf
1
2 %
3 % The stems of the natural are brushed (at least, in Barenreiter SCS)
4 %
5
6 % general parameters:
7 save full_width, full_height;
8 save stem_thickness, stem_end_thickness_multiplier;
9 save beam_thickness, beam_slant, hole_highest_point;
10
11 full_height# := 3 staff_space#;
12 full_width# := 2/3 staff_space#;
13 stem_thickness# := 0.09 staff_space# + 0.5 stafflinethickness#;
14 stem_end_thickness_multiplier := 10/7;
15 beam_slant := 1.266 stafflinethickness;
16 beam_thickness := 0.485 staff_space -  stafflinethickness;
17 hole_highest_point := 0.5 (staff_space - stafflinethickness);
18
19
20 def draw_natural (expr arrowup, arrowdown) =
21         save upstem_factor, downstem_factor;
22         save upstem_end_thickness, downstem_end_thickness;
23         save half_height, half_box_height;
24         save beam_direction, r_stem_top_path, l_stem_bottom_path;
25         pair beam_direction;
26         path r_stem_top_path, l_stem_bottom_path;
27
28         upstem_factor = downstem_factor = stem_end_thickness_multiplier;
29
30         half_height# := 0.5 full_height#;
31         define_pixels (half_height);
32         define_pixels (full_width);
33
34         set_char_box (0, full_width#, half_height#, half_height#);
35         d := d - feta_space_shift;
36
37         if arrowup:
38                 b := b + 3 stafflinethickness;
39                 h := h + 1.2 staff_space;
40                 % to look nice, arrowed stems must be less brushed
41                 upstem_factor := 0.5 (1 + upstem_factor);
42         fi;
43         if arrowdown:
44                 w := w + 3 stafflinethickness;
45                 d := d + 1.2 staff_space;
46                 % to look nice, arrowed stems must be less brushed
47                 downstem_factor := 0.5 (1 + downstem_factor);
48         fi;
49
50         upstem_end_thickness# = upstem_factor * stem_thickness#;
51         downstem_end_thickness# = downstem_factor * stem_thickness#;
52         define_whole_blacker_pixels (upstem_end_thickness, downstem_end_thickness);
53         define_whole_blacker_pixels (stem_thickness);
54
55         half_box_height := hole_highest_point + beam_thickness
56                            %% correction for the fact that x11 != x12.
57                            %% ideally y2 should be calculated from y11
58                            %% and beam_thickness, but the brushed stems
59                            %% would cause a cyclic dependency:
60                            %% y2 -> x11 -> y14 -> y13 -> y12 -> y2
61                            + 0.5 stem_thickness * beam_slant / full_width;
62
63         %% stems:
64
65         pickup pencircle scaled stem_thickness;
66
67         penpos1 (upstem_end_thickness, 0);
68         penpos3 (downstem_end_thickness, 0);
69         penpos2 (stem_thickness, 0);
70         penpos4 (stem_thickness, 0);
71
72         x2r = full_width;
73         x4l = 0;
74         x3 = x2;
75         x1 = x4;
76
77         y1 = half_height;
78         y3 = -half_height;
79         top y2 = vround (half_box_height);
80         y4 = -y2 + feta_space_shift;
81
82         l_stem_bottom_path := z4r{z4r - z1r}
83                               .. bot z4
84                               .. z4l{z1l - z4l};
85
86         r_stem_top_path := z2r{z2r - z3r}
87                            .. top z2
88                            .. z2l{z3l - z2l};
89
90         fill simple_serif (z1l, z1r, -30)
91              -- l_stem_bottom_path
92              -- cycle;
93
94         fill simple_serif (z3l, z3r, 30)
95              -- r_stem_top_path
96              -- cycle;
97
98         %% beams:
99
100         beam_direction = (full_width, beam_slant);
101
102         z11 = z3l + whatever * (z2l - z3l);
103         y11 = vround (hole_highest_point);
104         z12 = directionpoint -beam_direction of r_stem_top_path;
105         z13 = z12 + whatever * beam_direction;
106         x13 = x1;
107         z14 = z11 + whatever * beam_direction;
108         x14 = x1;
109
110         z21 = z4r + whatever * (z1r - z4r);
111         y21 = -y11 + feta_space_shift;
112         z22 = directionpoint -beam_direction of l_stem_bottom_path;
113         z23 = z22 + whatever * beam_direction;
114         x23 = x3;
115         z24 = z21 + whatever * beam_direction;
116         x24 = x3;
117
118         fill z11
119              -- z12
120              -- z13
121              -- z14
122              -- cycle;
123
124         fill z21
125              -- z22
126              -- z23
127              -- z24
128              -- cycle;
129
130         if arrowup:
131                 draw_arrow (z1, upstem_end_thickness,
132                             z1l - z4l, stafflinethickness / 2, false);
133         fi;
134         if arrowdown:
135                 draw_arrow (z3, downstem_end_thickness,
136                             z2r - z3r, stafflinethickness / 2, true);
137         fi;
138
139         %% debugging:
140         penlabels (1, 2, 3, 4);
141         labels (11, 12, 13, 14, 21, 22, 23, 24);
142         draw_staff_if_debugging (-2, 2);
143 enddef;
144
145
146 fet_beginchar ("Natural", "natural");
147         draw_natural (false, false);
148 fet_endchar;
149
150
151 fet_beginchar ("Arrowed Natural (arrow up)", "natural.arrowup");
152         draw_natural (true, false);
153 fet_endchar;
154
155
156 fet_beginchar ("Arrowed Natural (arrow down)", "natural.arrowdown");
157         draw_natural (false, true);
158 fet_endchar;
159
160
161 fet_beginchar ("Arrowed Natural (arrows up and down)", "natural.arrowboth");
162         draw_natural (true, true);
163 fet_endchar;