1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
14 1 copy mul exch 1 copy mul add sqrt
17 % FIXME. translate to middle of box.
18 % Nice rectangle with rounded corners
19 /draw_box % breapth width depth height
21 % currentdict /testing known {
22 %% real thin lines for testing
25 % /blot blot-diameter def
32 blot 2 div sub /h exch def
33 blot 2 div sub /d exch def
34 blot 2 div sub /w exch def
35 blot 2 div sub /b exch def
43 currentdict /testing known {
44 %% outline only, for testing:
47 closepath gsave stroke grestore fill
52 /draw_round_box % breapth width depth height blot
60 blot 2 div sub /h exch def
61 blot 2 div sub /d exch def
62 blot 2 div sub /w exch def
63 blot 2 div sub /b exch def
71 currentdict /testing known {
72 %% outline only, for testing:
75 closepath gsave stroke grestore fill
79 % Nice beam with rounded corners
80 /draw_beam % slope width thick blot
92 blot 2 div t 2 div neg moveto
98 currentdict /testing known {
99 %% outline only, for testing:
102 closepath gsave stroke grestore fill
106 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
117 1 1 points {pop lineto} for
118 currentdict /testing known {
119 %% outline only, for testing:
122 closepath gsave stroke grestore fill
126 /draw_repeat_slash % width slope thick
134 beamthick beamthick slope div euclidean_length
138 width slope width mul rlineto
140 % width neg width angle sin mul neg rlineto
145 /draw_white_text % text scale font
150 exch scalefont setfont
158 /draw_ez_ball % ch letter_col ball_col font
161 findfont 0.7 scalefont setfont
165 0.5 0 0.5 0 360 arc closepath fill stroke
170 0.5 0 0.4 0 360 arc closepath
175 % 0.25 is empiric centering. Change to taste
181 % Simple, but does it work everywhere?
182 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
183 % reverted for now -- jcn
185 % The filled circles are drawn by setting the linewidth
186 % to 2*radius and drawing a point.
187 /simple_draw_ez_ball % ch letter_col ball_col font
190 findfont 0.85 scalefont setfont
191 /origin { 0.45 0 } def
203 % 0.25 is empiric centering. Change to taste
210 % this is for drawing slurs.
211 /draw_bezier_sandwich % thickness controls
213 % round ending and round beginning
214 1 setlinejoin 1 setlinecap
229 % 0 360 arc fill stroke
230 0 360 arc closepath fill stroke
233 /draw_white_dot % x1 y2 R
235 % 0 360 arc fill stroke
236 0 360 arc closepath % fill stroke
240 % 0 360 arc closepath % fill stroke
241 0.05 setlinewidth 0 setgray stroke
244 /draw_dashed_line % dash thickness dx dy
255 /draw_dashed_slur % dash thickness controls
268 % a b c d subvec == a-c b-d
276 % centre? zzwidth zzheight thickness x0 y0 x1 y1
281 4 2 roll % zzuw zzh th x1 y1 x0 y0
284 subvec % zzuw zzh th dx dy
286 2 copy euclidean_length /l exch def
291 l exch div round /n exch def
293 /zzw l n 2 mul div def
295 uy zzh mul 2 div ux zzh mul -2 div rmoveto
298 ux zzw mul uy zzh mul sub
299 uy zzw mul ux zzh mul add
301 ux zzw mul uy zzh mul add
302 uy zzw mul ux zzh mul sub
307 ux l mul uy l mul rlineto
316 /traject_alpha exch def
317 traject_ds traject_alpha sin mul add
319 traject_ds traject_alpha cos mul add
330 bracket_thick arch_height add half_height arch_thick sub arch_width add
331 arch_angle arch_height -0.15 mul bracket_traject
333 bracket_thick 0.5 mul half_height
334 0 arch_height 0.5 mul bracket_traject
338 bracket_thick half_height arch_thick sub
339 0 arch_height 0.4 mul bracket_traject
341 bracket_thick arch_height add half_height arch_thick sub arch_width add
342 arch_angle arch_height -0.25 mul bracket_traject
344 bracket_thick arch_height add half_height arch_thick sub arch_width add
346 bracket_thick half_height arch_thick sub
365 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
369 /bracket_thick exch def
371 /bracket_height exch def
372 /arch_height exch def
376 bracket_height 2 div bracket_thick add /half_height exch def
377 bracket_thick 0.5 mul setlinewidth
390 %end music-drawing-routines.ps