1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
5 /blot-diameter { lilypondpaperblotdiameter } bind def
13 1 copy mul exch 1 copy mul add sqrt
16 % FIXME. translate to middle of box.
17 % Nice rectangle with rounded corners
18 /draw_box % breapth width depth height
20 currentdict /testing known {
21 %% real thin lines for testing
24 /blot blot-diameter def
31 blot 2 div sub /h exch def
32 blot 2 div sub /d exch def
33 blot 2 div sub /w exch def
34 blot 2 div sub /b exch def
42 currentdict /testing known {
43 %% outline only, for testing:
46 closepath gsave stroke grestore fill
51 /draw_symmetric_x_triangle % th w h
63 /draw_round_box % breapth width depth height blot
71 blot 2 div sub /h exch def
72 blot 2 div sub /d exch def
73 blot 2 div sub /w exch def
74 blot 2 div sub /b exch def
82 currentdict /testing known {
83 %% outline only, for testing:
86 closepath gsave stroke grestore fill
90 % Nice beam with rounded corners
91 /draw_beam % slope width thick
93 currentdict /testing known {
94 %% real thin lines for testing
97 /blot blot-diameter def
108 blot 2 div t 2 div neg moveto
114 currentdict /testing known {
115 %% outline only, for testing:
118 closepath gsave stroke grestore fill
122 /draw_repeat_slash % width slope thick
130 beamthick beamthick slope div euclidean_length
134 width slope width mul rlineto
136 % width neg width angle sin mul neg rlineto
141 /draw_ez_ball % ch letter_col ball_col font
144 findfont 0.7 scalefont setfont
148 0.5 0 0.5 0 360 arc closepath fill stroke
153 0.5 0 0.4 0 360 arc closepath
158 % 0.25 is empiric centering. Change to taste
164 % Simple, but does it work everywhere?
165 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
166 % reverted for now -- jcn
168 % The filled circles are drawn by setting the linewidth
169 % to 2*radius and drawing a point.
170 /simple_draw_ez_ball % ch letter_col ball_col font
173 findfont 0.85 scalefont setfont
174 /origin { 0.45 0 } def
186 % 0.25 is empiric centering. Change to taste
193 % this is for drawing slurs.
194 /draw_bezier_sandwich % thickness controls
209 % 0 360 arc fill stroke
210 0 360 arc closepath fill stroke
213 /draw_dashed_line % dash thickness dx dy
224 /draw_dashed_slur % dash thickness controls
237 % a b c d subvec == a-c b-d
245 % centre? zzwidth zzheight thickness x0 y0 x1 y1
250 4 2 roll % zzuw zzh th x1 y1 x0 y0
253 subvec % zzuw zzh th dx dy
255 2 copy euclidean_length /l exch def
260 l exch div round /n exch def
262 /zzw l n 2 mul div def
264 uy zzh mul 2 div ux zzh mul -2 div rmoveto
267 ux zzw mul uy zzh mul sub
268 uy zzw mul ux zzh mul add
270 ux zzw mul uy zzh mul add
271 uy zzw mul ux zzh mul sub
276 ux l mul uy l mul rlineto
285 /traject_alpha exch def
286 traject_ds traject_alpha sin mul add
288 traject_ds traject_alpha cos mul add
299 bracket_thick arch_height add half_height arch_thick sub arch_width add
300 arch_angle arch_height -0.15 mul bracket_traject
302 bracket_thick 0.5 mul half_height
303 0 arch_height 0.5 mul bracket_traject
307 bracket_thick half_height arch_thick sub
308 0 arch_height 0.4 mul bracket_traject
310 bracket_thick arch_height add half_height arch_thick sub arch_width add
311 arch_angle arch_height -0.25 mul bracket_traject
313 bracket_thick arch_height add half_height arch_thick sub arch_width add
315 bracket_thick half_height arch_thick sub
334 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
338 /bracket_thick exch def
340 /bracket_height exch def
341 /arch_height exch def
345 bracket_height 2 div bracket_thick add /half_height exch def
346 bracket_thick 0.5 mul setlinewidth