1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
5 /blot-diameter { lilypondpaperblotdiameter } bind def
9 1 copy mul exch 1 copy mul add sqrt
12 % FIXME. translate to middle of box.
13 % Nice rectangle with rounded corners
14 % FIXME: linewidth hardcoded. check: too round?
15 /draw_box % breapth width depth height
18 currentdict /testing known {
19 %% real thin lines for testing
22 /blot blot-diameter def
29 blot 2 div sub /h exch def
30 blot 2 div sub /d exch def
33 %% Where does this correction come from?
34 %% Why don't we need this in x direction?
35 h blot 2 div sub /h exch def
36 d blot 2 div sub /d exch def
38 blot 2 div sub /w exch def
39 blot 2 div sub /b exch def
47 currentdict /testing known {
48 %% outline only, for testing:
51 closepath gsave stroke grestore fill
55 % Nice beam with rounded corners
56 % FIXME: linewidth hardcoded. check: too round?
57 /draw_beam % slope width thick
60 currentdict /testing known {
61 %% real thin lines for testing
64 /blot blot-diameter def
71 blot 2 mul sub /t exch def
72 blot 2 mul sub /w exch def
75 blot t 2 div neg moveto
81 currentdict /testing known {
82 %% outline only, for testing:
85 closepath gsave stroke grestore fill
89 /draw_repeat_slash % width slope thick
97 beamthick beamthick slope div euclidean_length
101 width slope width mul rlineto
103 % width neg width angle sin mul neg rlineto
107 /draw_hairpin % width start_h end_h thick
124 /draw_tuplet % height gap dx dy thick dir
133 /tuplet_gapx exch def
135 tuplet_dy tuplet_dx div tuplet_gapx mul /tuplet_gapy exch def
138 0 tuplet_h neg dir mul moveto
140 tuplet_dx tuplet_gapx sub 2 div
141 tuplet_dy tuplet_gapy sub 2 div lineto
142 tuplet_dx tuplet_gapx add 2 div
143 tuplet_dy tuplet_gapy add 2 div moveto
144 tuplet_dx tuplet_dy lineto
145 tuplet_dx tuplet_dy tuplet_h dir neg mul add lineto
149 /draw_ez_ball % ch letter_col ball_col font
152 findfont 0.7 scalefont setfont
156 0.5 0 0.5 0 360 arc closepath fill stroke
161 0.5 0 0.4 0 360 arc closepath
166 % 0.25 is empiric centering. Change to taste
172 % Simple, but does it work everywhere?
173 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
174 % reverted for now -- jcn
176 % The filled circles are drawn by setting the linewidth
177 % to 2*radius and drawing a point.
178 /simple_draw_ez_ball % ch letter_col ball_col font
181 findfont 0.85 scalefont setfont
182 /origin { 0.45 0 } def
194 % 0.25 is empiric centering. Change to taste
201 /draw_volta % h w thick vert_start vert_end
216 volta_w volta_h lineto
223 % this is for drawing slurs.
224 /draw_bezier_sandwich % thickness controls
237 /draw_dashed_line % dash thickness dx dy
248 /draw_dashed_slur % dash thickness controls
265 /traject_alpha exch def
266 traject_ds traject_alpha sin mul add
268 traject_ds traject_alpha cos mul add
279 bracket_thick arch_height add half_height arch_thick sub arch_width add
280 arch_angle arch_height -0.15 mul bracket_traject
282 bracket_thick 0.5 mul half_height
283 0 arch_height 0.5 mul bracket_traject
287 bracket_thick half_height arch_thick sub
288 0 arch_height 0.4 mul bracket_traject
290 bracket_thick arch_height add half_height arch_thick sub arch_width add
291 arch_angle arch_height -0.25 mul bracket_traject
293 bracket_thick arch_height add half_height arch_thick sub arch_width add
295 bracket_thick half_height arch_thick sub
314 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
318 /bracket_thick exch def
320 /bracket_height exch def
321 /arch_height exch def
325 bracket_height 2 div bracket_thick add /half_height exch def
326 bracket_thick 0.5 mul setlinewidth