]> git.donarmstrong.com Git - lilypond.git/blob - ps/lily.ps
patch::: 1.3.149.jcn3
[lilypond.git] / ps / lily.ps
1 %!PS-Adobe-1.0: lily.ps 
2 %
3 % Functions for direct and embedded PostScript
4
5 % round cappings 
6 1 setlinecap
7
8 /euclidean_length  
9
10         1 copy mul exch 1 copy mul add sqrt 
11 } bind def 
12
13 /draw_beam % width slope thick 
14
15         2 div /beam_thick exch def 
16         /beam_slope exch def 
17         /beam_wd exch def 
18         beam_slope beam_wd mul /beam_ht exch def 
19         0 beam_thick neg moveto  
20         beam_wd beam_ht rlineto  
21         0 beam_thick 2 mul rlineto 
22         0 beam_thick lineto 
23         closepath fill 
24 } bind def 
25
26 /draw_repeat_slash % width slope thick
27 {
28   /beamthick exch def
29   /slope exch def
30   /width exch def
31   beamthick beamthick slope div euclidean_length
32     /xwid exch def 
33   0 0 moveto
34   xwid 0  rlineto
35   width slope width mul rlineto
36   xwid neg 0 rlineto
37 %  width neg width angle sin mul neg rlineto
38   closepath fill
39 } bind def
40
41 /draw_hairpin % width start_h end_h thick
42 {
43   setlinewidth
44   /end_h exch def 
45   /start_h exch def
46   /wid exch def
47   0 start_h moveto
48   wid end_h lineto
49   stroke
50   0 start_h neg moveto
51   wid end_h neg lineto
52   stroke
53 } bind def
54
55 /draw_tuplet % height gap dx dy thick dir 
56
57         /dir exch def 
58         setlinewidth 
59         1 setlinecap 
60         1 setlinejoin 
61         /tuplet_dy exch def 
62         /tuplet_dx exch def 
63         /tuplet_gapx exch def 
64         /tuplet_h exch def 
65         tuplet_dy tuplet_dx div tuplet_gapx mul /tuplet_gapy exch def 
66
67
68         0 0 moveto 
69         0 tuplet_h dir mul lineto  
70         tuplet_dx tuplet_gapx sub 2 div  
71                 tuplet_dy tuplet_gapy sub 2 div tuplet_h dir mul add lineto 
72         tuplet_dx tuplet_gapx add 2 div  
73                 tuplet_dy tuplet_gapy add 2 div tuplet_h dir mul add moveto 
74         tuplet_dx tuplet_dy tuplet_h dir mul add lineto 
75         tuplet_dx tuplet_dy lineto 
76         stroke 
77 } bind def 
78
79 /difficult_draw_ez_ball % ch letter_col ball_col font
80 {
81         % font
82         findfont 0.7 scalefont setfont 
83         0.1 setlinewidth
84         0 0 moveto
85         0 setgray
86         0.5 0 0.5 0 360 arc closepath fill stroke
87         % ball_col
88         1 eq {
89                 0.01 setlinewidth
90                 1 setgray
91                 0.5 0 0.4 0 360 arc closepath
92                 fill stroke
93         } if 
94         % letter_col
95         setgray
96         % 0.25 is empiric centering. Change to taste
97         0.25 -0.25 moveto
98         % ch
99         show
100 } bind def
101
102 % Simple, but does it work everywhere?
103 % The filled circles are drawn by setting the linewidth
104 % to 2*radius and drawing a point.  Is that (defined to be)
105 % a nice filled circle?
106 /draw_ez_ball % ch letter_col ball_col font
107 {
108         % font
109         findfont 0.85 scalefont setfont
110         /origin { 0.45 0 } def
111         0 setgray
112         1.1 setlinewidth
113         origin moveto
114         origin lineto stroke
115         % ball_col
116         setgray
117         0.9 setlinewidth
118         origin moveto
119         origin lineto stroke
120         % letter_col
121         setgray
122         % 0.25 is empiric centering. Change to taste
123         origin moveto
124         -0.28 -0.30 rmoveto
125         % ch
126         show
127 } bind def
128
129 /draw_volta % h w thick vert_start vert_end 
130
131         /vert_end exch def 
132         /vert_start exch def 
133         setlinewidth 
134         /volta_w exch def 
135         /volta_h exch def 
136         1 setlinecap 
137         1 setlinejoin 
138         vert_start 0 eq { 
139                 0 0 moveto 
140                 0 volta_h lineto 
141         } if 
142         0 volta_h moveto 
143         volta_w volta_h lineto 
144         vert_end 0 eq { 
145                 volta_w 0 lineto 
146         } if 
147         stroke 
148 } bind def 
149
150 % this is for drawing slurs. 
151 /draw_bezier_sandwich  % thickness controls 
152
153         setlinewidth 
154         moveto 
155         curveto 
156         lineto 
157         curveto 
158         gsave 
159         fill 
160         grestore 
161         stroke 
162 } bind def 
163
164 /draw_dashed_line % dash thickness dx dy
165
166         1 setlinecap 
167         1 setlinejoin 
168         setdash 
169         setlinewidth 
170         0 0 moveto
171         lineto
172         stroke 
173 } bind def 
174
175 /draw_dashed_slur % dash thickness controls
176
177         1 setlinecap 
178         1 setlinejoin 
179         setdash 
180         setlinewidth 
181         8 -2 roll 
182         moveto 
183         curveto 
184         stroke 
185 } bind def 
186
187
188
189 /bracket_traject 
190
191         /traject_ds exch def 
192         /traject_alpha exch def 
193         traject_ds traject_alpha sin mul add 
194         exch 
195         traject_ds traject_alpha cos mul add 
196         exch 
197 } bind def 
198
199
200
201 /half_bracket
202
203 %6 
204         0 0 
205 %5a 
206         bracket_thick arch_height add half_height arch_thick sub arch_width add 
207         arch_angle arch_height -0.15 mul bracket_traject 
208 %5b 
209         bracket_thick 0.5 mul half_height 
210         0 arch_height 0.5 mul bracket_traject 
211 %5c 
212         0 half_height 
213 %4a 
214         bracket_thick half_height arch_thick sub 
215         0 arch_height 0.4 mul bracket_traject 
216 %4b 
217         bracket_thick arch_height add half_height arch_thick sub arch_width add 
218         arch_angle arch_height -0.25 mul bracket_traject 
219 %4c 
220         bracket_thick arch_height add half_height arch_thick sub arch_width add 
221 %3 
222         bracket_thick half_height arch_thick sub 
223 %2 
224         bracket_thick 0 
225 %1 
226         0 0 
227 } bind def 
228
229 /draw_half_bracket { 
230         moveto 
231         lineto 
232         lineto 
233         curveto 
234         curveto 
235         lineto 
236         gsave 
237         fill 
238         grestore 
239 } bind def 
240
241 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
242
243         % urg
244
245         /bracket_thick exch def
246         /arch_thick exch def
247         /bracket_height exch def
248         /arch_height exch def
249         /arch_width exch def
250         /arch_angle exch def
251
252         bracket_height 2 div bracket_thick add /half_height exch def 
253         bracket_thick 0.5 mul setlinewidth
254         1 setlinecap 
255         1 setlinejoin 
256         half_bracket 
257         20 copy 
258         1 -1 scale 
259         draw_half_bracket 
260         stroke 
261         1 -1 scale 
262         draw_half_bracket 
263         stroke 
264 } bind def 
265