1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
6 /blot-diameter { lilypondpaperblotdiameter } bind def
16 1 copy mul exch 1 copy mul add sqrt
19 % FIXME. translate to middle of box.
20 % Nice rectangle with rounded corners
21 /draw_box % breapth width depth height
23 currentdict /testing known {
24 %% real thin lines for testing
27 /blot blot-diameter def
34 blot 2 div sub /h exch def
35 blot 2 div sub /d exch def
36 blot 2 div sub /w exch def
37 blot 2 div sub /b exch def
45 currentdict /testing known {
46 %% outline only, for testing:
49 closepath gsave stroke grestore fill
54 /draw_symmetric_x_triangle % h w th
65 /draw_round_box % breapth width depth height blot
73 blot 2 div sub /h exch def
74 blot 2 div sub /d exch def
75 blot 2 div sub /w exch def
76 blot 2 div sub /b exch def
84 currentdict /testing known {
85 %% outline only, for testing:
88 closepath gsave stroke grestore fill
92 % Nice beam with rounded corners
93 /draw_beam % slope width thick
95 currentdict /testing known {
96 %% real thin lines for testing
99 /blot blot-diameter def
110 blot 2 div t 2 div neg moveto
116 currentdict /testing known {
117 %% outline only, for testing:
120 closepath gsave stroke grestore fill
124 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
135 1 1 points {pop lineto} for
136 currentdict /testing known {
137 %% outline only, for testing:
140 closepath gsave stroke grestore fill
144 /draw_repeat_slash % width slope thick
152 beamthick beamthick slope div euclidean_length
156 width slope width mul rlineto
158 % width neg width angle sin mul neg rlineto
163 /draw_ez_ball % ch letter_col ball_col font
166 findfont 0.7 scalefont setfont
170 0.5 0 0.5 0 360 arc closepath fill stroke
175 0.5 0 0.4 0 360 arc closepath
180 % 0.25 is empiric centering. Change to taste
186 % Simple, but does it work everywhere?
187 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
188 % reverted for now -- jcn
190 % The filled circles are drawn by setting the linewidth
191 % to 2*radius and drawing a point.
192 /simple_draw_ez_ball % ch letter_col ball_col font
195 findfont 0.85 scalefont setfont
196 /origin { 0.45 0 } def
208 % 0.25 is empiric centering. Change to taste
215 % this is for drawing slurs.
216 /draw_bezier_sandwich % thickness controls
218 % round ending and round beginning
219 1 setlinejoin 1 setlinecap
234 % 0 360 arc fill stroke
235 0 360 arc closepath fill stroke
238 /draw_dashed_line % dash thickness dx dy
249 /draw_dashed_slur % dash thickness controls
262 % a b c d subvec == a-c b-d
270 % centre? zzwidth zzheight thickness x0 y0 x1 y1
275 4 2 roll % zzuw zzh th x1 y1 x0 y0
278 subvec % zzuw zzh th dx dy
280 2 copy euclidean_length /l exch def
285 l exch div round /n exch def
287 /zzw l n 2 mul div def
289 uy zzh mul 2 div ux zzh mul -2 div rmoveto
292 ux zzw mul uy zzh mul sub
293 uy zzw mul ux zzh mul add
295 ux zzw mul uy zzh mul add
296 uy zzw mul ux zzh mul sub
301 ux l mul uy l mul rlineto
310 /traject_alpha exch def
311 traject_ds traject_alpha sin mul add
313 traject_ds traject_alpha cos mul add
324 bracket_thick arch_height add half_height arch_thick sub arch_width add
325 arch_angle arch_height -0.15 mul bracket_traject
327 bracket_thick 0.5 mul half_height
328 0 arch_height 0.5 mul bracket_traject
332 bracket_thick half_height arch_thick sub
333 0 arch_height 0.4 mul bracket_traject
335 bracket_thick arch_height add half_height arch_thick sub arch_width add
336 arch_angle arch_height -0.25 mul bracket_traject
338 bracket_thick arch_height add half_height arch_thick sub arch_width add
340 bracket_thick half_height arch_thick sub
359 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
363 /bracket_thick exch def
365 /bracket_height exch def
366 /arch_height exch def
370 bracket_height 2 div bracket_thick add /half_height exch def
371 bracket_thick 0.5 mul setlinewidth