1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
7 {pop} {userdict /pdfmark /cleartomark load put} ifelse
10 % llx lly urx ury command
19 /Rect [ llx lly urx ury ]
26 %% following for acroread
46 1 copy mul exch 1 copy mul add sqrt
49 % FIXME. translate to middle of box.
50 % Nice rectangle with rounded corners
51 /draw_box % breapth width depth height
53 % currentdict /testing known {
54 %% real thin lines for testing
57 % /blot blot-diameter def
64 blot 2 div sub /h exch def
65 blot 2 div sub /d exch def
66 blot 2 div sub /w exch def
67 blot 2 div sub /b exch def
75 currentdict /testing known {
76 %% outline only, for testing:
79 closepath gsave stroke grestore fill
84 /draw_round_box % breapth width depth height blot
92 blot 2 div sub /h exch def
93 blot 2 div sub /d exch def
94 blot 2 div sub /w exch def
95 blot 2 div sub /b exch def
100 b w add neg 0 rlineto
101 0 d h add neg rlineto
103 currentdict /testing known {
104 %% outline only, for testing:
107 closepath gsave stroke grestore fill
111 % Nice beam with rounded corners
112 /draw_beam % slope width thick blot
124 blot 2 div t 2 div neg moveto
130 currentdict /testing known {
131 %% outline only, for testing:
134 closepath gsave stroke grestore fill
138 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
149 1 1 points {pop lineto} for
150 currentdict /testing known {
151 %% outline only, for testing:
154 closepath gsave stroke grestore fill
158 /draw_repeat_slash % width slope thick
166 beamthick beamthick slope div euclidean_length
170 width slope width mul rlineto
172 % width neg width angle sin mul neg rlineto
177 /draw_white_text % text scale font
182 exch scalefont setfont
190 /draw_ez_ball % ch letter_col ball_col font
193 findfont 0.7 scalefont setfont
197 0.5 0 0.5 0 360 arc closepath fill stroke
202 0.5 0 0.4 0 360 arc closepath
207 % 0.25 is empiric centering. Change to taste
213 % Simple, but does it work everywhere?
214 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
215 % reverted for now -- jcn
217 % The filled circles are drawn by setting the linewidth
218 % to 2*radius and drawing a point.
219 /simple_draw_ez_ball % ch letter_col ball_col font
222 findfont 0.85 scalefont setfont
223 /origin { 0.45 0 } def
235 % 0.25 is empiric centering. Change to taste
242 % this is for drawing slurs.
243 /draw_bezier_sandwich % thickness controls
245 % round ending and round beginning
246 1 setlinejoin 1 setlinecap
261 % 0 360 arc fill stroke
262 0 360 arc closepath fill stroke
265 /draw_white_dot % x1 y2 R
267 % 0 360 arc fill stroke
268 0 360 arc closepath % fill stroke
272 % 0 360 arc closepath % fill stroke
273 0.05 setlinewidth 0 setgray stroke
276 /draw_dashed_line % dash thickness dx dy
287 /draw_dashed_slur % dash thickness controls
300 % a b c d subvec == a-c b-d
308 % centre? zzwidth zzheight thickness x0 y0 x1 y1
313 4 2 roll % zzuw zzh th x1 y1 x0 y0
316 subvec % zzuw zzh th dx dy
318 2 copy euclidean_length /l exch def
323 l exch div round /n exch def
325 /zzw l n 2 mul div def
327 uy zzh mul 2 div ux zzh mul -2 div rmoveto
330 ux zzw mul uy zzh mul sub
331 uy zzw mul ux zzh mul add
333 ux zzw mul uy zzh mul add
334 uy zzw mul ux zzh mul sub
339 ux l mul uy l mul rlineto
348 /traject_alpha exch def
349 traject_ds traject_alpha sin mul add
351 traject_ds traject_alpha cos mul add
362 bracket_thick arch_height add half_height arch_thick sub arch_width add
363 arch_angle arch_height -0.15 mul bracket_traject
365 bracket_thick 0.5 mul half_height
366 0 arch_height 0.5 mul bracket_traject
370 bracket_thick half_height arch_thick sub
371 0 arch_height 0.4 mul bracket_traject
373 bracket_thick arch_height add half_height arch_thick sub arch_width add
374 arch_angle arch_height -0.25 mul bracket_traject
376 bracket_thick arch_height add half_height arch_thick sub arch_width add
378 bracket_thick half_height arch_thick sub
397 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
401 /bracket_thick exch def
403 /bracket_height exch def
404 /arch_height exch def
408 bracket_height 2 div bracket_thick add /half_height exch def
409 bracket_thick 0.5 mul setlinewidth
422 %end music-drawing-routines.ps