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 % h w th
62 /draw_round_box % breapth width depth height blot
70 blot 2 div sub /h exch def
71 blot 2 div sub /d exch def
72 blot 2 div sub /w exch def
73 blot 2 div sub /b exch def
81 currentdict /testing known {
82 %% outline only, for testing:
85 closepath gsave stroke grestore fill
89 % Nice beam with rounded corners
90 /draw_beam % slope width thick
92 currentdict /testing known {
93 %% real thin lines for testing
96 /blot blot-diameter def
107 blot 2 div t 2 div neg moveto
113 currentdict /testing known {
114 %% outline only, for testing:
117 closepath gsave stroke grestore fill
121 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
132 1 1 points {pop lineto} for
133 currentdict /testing known {
134 %% outline only, for testing:
137 closepath gsave stroke grestore fill
141 /draw_repeat_slash % width slope thick
149 beamthick beamthick slope div euclidean_length
153 width slope width mul rlineto
155 % width neg width angle sin mul neg rlineto
160 /draw_ez_ball % ch letter_col ball_col font
163 findfont 0.7 scalefont setfont
167 0.5 0 0.5 0 360 arc closepath fill stroke
172 0.5 0 0.4 0 360 arc closepath
177 % 0.25 is empiric centering. Change to taste
183 % Simple, but does it work everywhere?
184 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
185 % reverted for now -- jcn
187 % The filled circles are drawn by setting the linewidth
188 % to 2*radius and drawing a point.
189 /simple_draw_ez_ball % ch letter_col ball_col font
192 findfont 0.85 scalefont setfont
193 /origin { 0.45 0 } def
205 % 0.25 is empiric centering. Change to taste
212 % this is for drawing slurs.
213 /draw_bezier_sandwich % thickness controls
228 % 0 360 arc fill stroke
229 0 360 arc closepath fill stroke
232 /draw_dashed_line % dash thickness dx dy
243 /draw_dashed_slur % dash thickness controls
256 % a b c d subvec == a-c b-d
264 % centre? zzwidth zzheight thickness x0 y0 x1 y1
269 4 2 roll % zzuw zzh th x1 y1 x0 y0
272 subvec % zzuw zzh th dx dy
274 2 copy euclidean_length /l exch def
279 l exch div round /n exch def
281 /zzw l n 2 mul div def
283 uy zzh mul 2 div ux zzh mul -2 div rmoveto
286 ux zzw mul uy zzh mul sub
287 uy zzw mul ux zzh mul add
289 ux zzw mul uy zzh mul add
290 uy zzw mul ux zzh mul sub
295 ux l mul uy l mul rlineto
304 /traject_alpha exch def
305 traject_ds traject_alpha sin mul add
307 traject_ds traject_alpha cos mul add
318 bracket_thick arch_height add half_height arch_thick sub arch_width add
319 arch_angle arch_height -0.15 mul bracket_traject
321 bracket_thick 0.5 mul half_height
322 0 arch_height 0.5 mul bracket_traject
326 bracket_thick half_height arch_thick sub
327 0 arch_height 0.4 mul bracket_traject
329 bracket_thick arch_height add half_height arch_thick sub arch_width add
330 arch_angle arch_height -0.25 mul bracket_traject
332 bracket_thick arch_height add half_height arch_thick sub arch_width add
334 bracket_thick half_height arch_thick sub
353 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
357 /bracket_thick exch def
359 /bracket_height exch def
360 /arch_height exch def
364 bracket_height 2 div bracket_thick add /half_height exch def
365 bracket_thick 0.5 mul setlinewidth