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 ]
42 1 copy mul exch 1 copy mul add sqrt
45 % FIXME. translate to middle of box.
46 % Nice rectangle with rounded corners
47 /draw_box % breapth width depth height
49 % currentdict /testing known {
50 %% real thin lines for testing
53 % /blot blot-diameter def
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
80 /draw_round_box % breapth width depth height blot
88 blot 2 div sub /h exch def
89 blot 2 div sub /d exch def
90 blot 2 div sub /w exch def
91 blot 2 div sub /b exch def
99 currentdict /testing known {
100 %% outline only, for testing:
103 closepath gsave stroke grestore fill
107 % Nice beam with rounded corners
108 /draw_beam % slope width thick blot
120 blot 2 div t 2 div neg moveto
126 currentdict /testing known {
127 %% outline only, for testing:
130 closepath gsave stroke grestore fill
134 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
145 1 1 points {pop lineto} for
146 currentdict /testing known {
147 %% outline only, for testing:
150 closepath gsave stroke grestore fill
154 /draw_repeat_slash % width slope thick
162 beamthick beamthick slope div euclidean_length
166 width slope width mul rlineto
168 % width neg width angle sin mul neg rlineto
173 /draw_white_text % text scale font
178 exch scalefont setfont
186 /draw_ez_ball % ch letter_col ball_col font
189 findfont 0.7 scalefont setfont
193 0.5 0 0.5 0 360 arc closepath fill stroke
198 0.5 0 0.4 0 360 arc closepath
203 % 0.25 is empiric centering. Change to taste
209 % Simple, but does it work everywhere?
210 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
211 % reverted for now -- jcn
213 % The filled circles are drawn by setting the linewidth
214 % to 2*radius and drawing a point.
215 /simple_draw_ez_ball % ch letter_col ball_col font
218 findfont 0.85 scalefont setfont
219 /origin { 0.45 0 } def
231 % 0.25 is empiric centering. Change to taste
238 % this is for drawing slurs.
239 /draw_bezier_sandwich % thickness controls
241 % round ending and round beginning
242 1 setlinejoin 1 setlinecap
257 % 0 360 arc fill stroke
258 0 360 arc closepath fill stroke
261 /draw_white_dot % x1 y2 R
263 % 0 360 arc fill stroke
264 0 360 arc closepath % fill stroke
268 % 0 360 arc closepath % fill stroke
269 0.05 setlinewidth 0 setgray stroke
272 /draw_dashed_line % dash thickness dx dy
283 /draw_dashed_slur % dash thickness controls
296 % a b c d subvec == a-c b-d
304 % centre? zzwidth zzheight thickness x0 y0 x1 y1
309 4 2 roll % zzuw zzh th x1 y1 x0 y0
312 subvec % zzuw zzh th dx dy
314 2 copy euclidean_length /l exch def
319 l exch div round /n exch def
321 /zzw l n 2 mul div def
323 uy zzh mul 2 div ux zzh mul -2 div rmoveto
326 ux zzw mul uy zzh mul sub
327 uy zzw mul ux zzh mul add
329 ux zzw mul uy zzh mul add
330 uy zzw mul ux zzh mul sub
335 ux l mul uy l mul rlineto
344 /traject_alpha exch def
345 traject_ds traject_alpha sin mul add
347 traject_ds traject_alpha cos mul add
358 bracket_thick arch_height add half_height arch_thick sub arch_width add
359 arch_angle arch_height -0.15 mul bracket_traject
361 bracket_thick 0.5 mul half_height
362 0 arch_height 0.5 mul bracket_traject
366 bracket_thick half_height arch_thick sub
367 0 arch_height 0.4 mul bracket_traject
369 bracket_thick arch_height add half_height arch_thick sub arch_width add
370 arch_angle arch_height -0.25 mul bracket_traject
372 bracket_thick arch_height add half_height arch_thick sub arch_width add
374 bracket_thick half_height arch_thick sub
393 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
397 /bracket_thick exch def
399 /bracket_height exch def
400 /arch_height exch def
404 bracket_height 2 div bracket_thick add /half_height exch def
405 bracket_thick 0.5 mul setlinewidth
418 %end music-drawing-routines.ps