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_symmetric_x_triangle % h w th
63 /draw_round_box % breapth width depth height blot
71 blot 2 div sub /h exch def
72 blot 2 div sub /d exch def
73 blot 2 div sub /w exch def
74 blot 2 div sub /b exch def
82 currentdict /testing known {
83 %% outline only, for testing:
86 closepath gsave stroke grestore fill
90 % Nice beam with rounded corners
91 /draw_beam % slope width thick blot
103 blot 2 div t 2 div neg moveto
109 currentdict /testing known {
110 %% outline only, for testing:
113 closepath gsave stroke grestore fill
117 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
128 1 1 points {pop lineto} for
129 currentdict /testing known {
130 %% outline only, for testing:
133 closepath gsave stroke grestore fill
137 /draw_repeat_slash % width slope thick
145 beamthick beamthick slope div euclidean_length
149 width slope width mul rlineto
151 % width neg width angle sin mul neg rlineto
156 /draw_white_text % text scale font
161 exch scalefont setfont
169 /draw_ez_ball % ch letter_col ball_col font
172 findfont 0.7 scalefont setfont
176 0.5 0 0.5 0 360 arc closepath fill stroke
181 0.5 0 0.4 0 360 arc closepath
186 % 0.25 is empiric centering. Change to taste
192 % Simple, but does it work everywhere?
193 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
194 % reverted for now -- jcn
196 % The filled circles are drawn by setting the linewidth
197 % to 2*radius and drawing a point.
198 /simple_draw_ez_ball % ch letter_col ball_col font
201 findfont 0.85 scalefont setfont
202 /origin { 0.45 0 } def
214 % 0.25 is empiric centering. Change to taste
221 % this is for drawing slurs.
222 /draw_bezier_sandwich % thickness controls
224 % round ending and round beginning
225 1 setlinejoin 1 setlinecap
240 % 0 360 arc fill stroke
241 0 360 arc closepath fill stroke
244 /draw_white_dot % x1 y2 R
246 % 0 360 arc fill stroke
247 0 360 arc closepath % fill stroke
251 % 0 360 arc closepath % fill stroke
252 0.05 setlinewidth 0 setgray stroke
255 /draw_dashed_line % dash thickness dx dy
266 /draw_dashed_slur % dash thickness controls
279 % a b c d subvec == a-c b-d
287 % centre? zzwidth zzheight thickness x0 y0 x1 y1
292 4 2 roll % zzuw zzh th x1 y1 x0 y0
295 subvec % zzuw zzh th dx dy
297 2 copy euclidean_length /l exch def
302 l exch div round /n exch def
304 /zzw l n 2 mul div def
306 uy zzh mul 2 div ux zzh mul -2 div rmoveto
309 ux zzw mul uy zzh mul sub
310 uy zzw mul ux zzh mul add
312 ux zzw mul uy zzh mul add
313 uy zzw mul ux zzh mul sub
318 ux l mul uy l mul rlineto
327 /traject_alpha exch def
328 traject_ds traject_alpha sin mul add
330 traject_ds traject_alpha cos mul add
341 bracket_thick arch_height add half_height arch_thick sub arch_width add
342 arch_angle arch_height -0.15 mul bracket_traject
344 bracket_thick 0.5 mul half_height
345 0 arch_height 0.5 mul bracket_traject
349 bracket_thick half_height arch_thick sub
350 0 arch_height 0.4 mul bracket_traject
352 bracket_thick arch_height add half_height arch_thick sub arch_width add
353 arch_angle arch_height -0.25 mul bracket_traject
355 bracket_thick arch_height add half_height arch_thick sub arch_width add
357 bracket_thick half_height arch_thick sub
376 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
380 /bracket_thick exch def
382 /bracket_height exch def
383 /arch_height exch def
387 bracket_height 2 div bracket_thick add /half_height exch def
388 bracket_thick 0.5 mul setlinewidth
401 %end music-drawing-routines.ps