1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
5 /blot-diameter { lilypondpaperblotdiameter } bind def
13 1 copy mul exch 1 copy mul add sqrt
16 % FIXME. translate to middle of box.
17 % Nice rectangle with rounded corners
18 % FIXME: linewidth hardcoded. check: too round?
19 /draw_box % breapth width depth height
22 currentdict /testing known {
23 %% real thin lines for testing
26 /blot blot-diameter def
33 blot 2 div sub /h exch def
34 blot 2 div sub /d exch def
37 %% Where does this correction come from?
38 %% Why don't we need this in x direction?
39 h blot 2 div sub /h exch def
40 d blot 2 div sub /d exch def
42 blot 2 div sub /w exch def
43 blot 2 div sub /b exch def
51 currentdict /testing known {
52 %% outline only, for testing:
55 closepath gsave stroke grestore fill
59 % Nice beam with rounded corners
60 % FIXME: linewidth hardcoded. check: too round?
61 /draw_beam % slope width thick
64 currentdict /testing known {
65 %% real thin lines for testing
68 /blot blot-diameter def
75 blot 2 mul sub /t exch def
76 blot 2 mul sub /w exch def
79 blot t 2 div neg moveto
85 currentdict /testing known {
86 %% outline only, for testing:
89 closepath gsave stroke grestore fill
93 /draw_repeat_slash % width slope thick
101 beamthick beamthick slope div euclidean_length
105 width slope width mul rlineto
107 % width neg width angle sin mul neg rlineto
111 /draw_hairpin % width start_h end_h thick
128 /draw_tuplet % height gap dx dy thick dir
137 /tuplet_gapx exch def
139 tuplet_dy tuplet_dx div tuplet_gapx mul /tuplet_gapy exch def
142 0 tuplet_h neg dir mul moveto
144 tuplet_dx tuplet_gapx sub 2 div
145 tuplet_dy tuplet_gapy sub 2 div lineto
146 tuplet_dx tuplet_gapx add 2 div
147 tuplet_dy tuplet_gapy add 2 div moveto
148 tuplet_dx tuplet_dy lineto
149 tuplet_dx tuplet_dy tuplet_h dir neg mul add lineto
153 /draw_ez_ball % ch letter_col ball_col font
156 findfont 0.7 scalefont setfont
160 0.5 0 0.5 0 360 arc closepath fill stroke
165 0.5 0 0.4 0 360 arc closepath
170 % 0.25 is empiric centering. Change to taste
176 % Simple, but does it work everywhere?
177 % Han-Wen reports that one printer (brand?) at cs.uu.nl chokes on this,
178 % reverted for now -- jcn
180 % The filled circles are drawn by setting the linewidth
181 % to 2*radius and drawing a point.
182 /simple_draw_ez_ball % ch letter_col ball_col font
185 findfont 0.85 scalefont setfont
186 /origin { 0.45 0 } def
198 % 0.25 is empiric centering. Change to taste
205 /draw_volta % h w thick vert_start vert_end
220 volta_w volta_h lineto
227 % this is for drawing slurs.
228 /draw_bezier_sandwich % thickness controls
241 /draw_dashed_line % dash thickness dx dy
252 /draw_dashed_slur % dash thickness controls
269 /traject_alpha exch def
270 traject_ds traject_alpha sin mul add
272 traject_ds traject_alpha cos mul add
283 bracket_thick arch_height add half_height arch_thick sub arch_width add
284 arch_angle arch_height -0.15 mul bracket_traject
286 bracket_thick 0.5 mul half_height
287 0 arch_height 0.5 mul bracket_traject
291 bracket_thick half_height arch_thick sub
292 0 arch_height 0.4 mul bracket_traject
294 bracket_thick arch_height add half_height arch_thick sub arch_width add
295 arch_angle arch_height -0.25 mul bracket_traject
297 bracket_thick arch_height add half_height arch_thick sub arch_width add
299 bracket_thick half_height arch_thick sub
318 /draw_bracket % arch_angle arch_width arch_height bracket_height arch_thick bracket_thick
322 /bracket_thick exch def
324 /bracket_height exch def
325 /arch_height exch def
329 bracket_height 2 div bracket_thick add /half_height exch def
330 bracket_thick 0.5 mul setlinewidth