1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
7 {pop} {userdict /pdfmark /cleartomark load put} ifelse
20 /Rect [ llx lly urx ury ]
43 1 copy mul exch 1 copy mul add sqrt
46 % FIXME. translate to middle of box.
47 % Nice rectangle with rounded corners
48 /draw_box % breapth width depth height
50 % currentdict /testing known {
51 %% real thin lines for testing
54 % /blot blot-diameter def
61 blot 2 div sub /h exch def
62 blot 2 div sub /d exch def
63 blot 2 div sub /w exch def
64 blot 2 div sub /b exch def
72 currentdict /testing known {
73 %% outline only, for testing:
76 closepath gsave stroke grestore fill
81 /draw_round_box % breapth width depth height blot
89 blot 2 div sub /h exch def
90 blot 2 div sub /d exch def
91 blot 2 div sub /w exch def
92 blot 2 div sub /b exch def
100 currentdict /testing known {
101 %% outline only, for testing:
104 closepath gsave stroke grestore fill
108 % Nice beam with rounded corners
109 /draw_beam % slope width thick blot
121 blot 2 div t 2 div neg moveto
127 currentdict /testing known {
128 %% outline only, for testing:
131 closepath gsave stroke grestore fill
135 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
146 1 1 points {pop lineto} for
147 currentdict /testing known {
148 %% outline only, for testing:
151 closepath gsave stroke grestore fill
155 /draw_repeat_slash % width slope thick
163 beamthick beamthick slope div euclidean_length
167 width slope width mul rlineto
169 % width neg width angle sin mul neg rlineto
174 /draw_white_text % text scale font
179 exch scalefont setfont
187 /draw_ez_ball % ch letter_col ball_col font
190 findfont 0.7 scalefont setfont
194 0.5 0 0.5 0 360 arc closepath fill stroke
199 0.5 0 0.4 0 360 arc closepath
204 % 0.25 is empiric centering. Change to taste
210 % Simple, but does it work everywhere?
211 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
212 % reverted for now -- jcn
214 % The filled circles are drawn by setting the linewidth
215 % to 2*radius and drawing a point.
216 /simple_draw_ez_ball % ch letter_col ball_col font
219 findfont 0.85 scalefont setfont
220 /origin { 0.45 0 } def
232 % 0.25 is empiric centering. Change to taste
239 % this is for drawing slurs.
240 /draw_bezier_sandwich % thickness controls
242 % round ending and round beginning
243 1 setlinejoin 1 setlinecap
258 % 0 360 arc fill stroke
259 0 360 arc closepath fill stroke
262 /draw_white_dot % x1 y2 R
264 % 0 360 arc fill stroke
265 0 360 arc closepath % fill stroke
269 % 0 360 arc closepath % fill stroke
270 0.05 setlinewidth 0 setgray stroke
273 /draw_dashed_line % dash thickness dx dy
284 /draw_dashed_slur % dash thickness controls
297 % a b c d subvec == a-c b-d
305 % centre? zzwidth zzheight thickness x0 y0 x1 y1
310 4 2 roll % zzuw zzh th x1 y1 x0 y0
313 subvec % zzuw zzh th dx dy
315 2 copy euclidean_length /l exch def
320 l exch div round /n exch def
322 /zzw l n 2 mul div def
324 uy zzh mul 2 div ux zzh mul -2 div rmoveto
327 ux zzw mul uy zzh mul sub
328 uy zzw mul ux zzh mul add
330 ux zzw mul uy zzh mul add
331 uy zzw mul ux zzh mul sub
336 ux l mul uy l mul rlineto
345 /traject_alpha exch def
346 traject_ds traject_alpha sin mul add
348 traject_ds traject_alpha cos mul add
359 bracket_thick arch_height add half_height arch_thick sub arch_width add
360 arch_angle arch_height -0.15 mul bracket_traject
362 bracket_thick 0.5 mul half_height
363 0 arch_height 0.5 mul bracket_traject
367 bracket_thick half_height arch_thick sub
368 0 arch_height 0.4 mul bracket_traject
370 bracket_thick arch_height add half_height arch_thick sub arch_width add
371 arch_angle arch_height -0.25 mul bracket_traject
373 bracket_thick arch_height add half_height arch_thick sub arch_width add
375 bracket_thick half_height arch_thick sub
394 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
398 /bracket_thick exch def
400 /bracket_height exch def
401 /arch_height exch def
405 bracket_height 2 div bracket_thick add /half_height exch def
406 bracket_thick 0.5 mul setlinewidth
419 %end music-drawing-routines.ps