1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
6 %% TODO: use dicts or prefixes to prevent namespace pollution.
9 {pop} {userdict /pdfmark /cleartomark load put} ifelse
11 % from adobe tech note 5002.
13 /b4_Inc_state save def % Save state for cleanup
14 /dict_count countdictstack def % Count objects on dict stack
15 /op_count count 1 sub def % Count objects on operand stack
16 userdict begin % Push userdict on dict stack
17 /showpage { } def % Redefine showpage, { } = null proc
18 0 setgray 0 setlinecap % Prepare graphics state
19 1 setlinewidth 0 setlinejoin
20 10 setmiterlimit [ ] 0 setdash newpath
21 /languagelevel where % If level not equal to 1 then
22 {pop languagelevel % set strokeadjust and
23 1 ne % overprint to their defaults.
24 {false setstrokeadjust false setoverprint
31 count op_count sub {pop} repeat % Clean up stacks
32 countdictstack dict_count sub {end} repeat
37 %<font> <encoding> <name> reencode-font
44 1 index /FID ne {def} {pop
64 /Rect [ llx lly urx ury ]
87 1 copy mul exch 1 copy mul add sqrt
90 % FIXME. translate to middle of box.
91 % Nice rectangle with rounded corners
92 /draw_box % breapth width depth height
94 % currentdict /testing known {
95 %% real thin lines for testing
98 % /blot blot-diameter def
105 blot 2 div sub /h exch def
106 blot 2 div sub /d exch def
107 blot 2 div sub /w exch def
108 blot 2 div sub /b exch def
113 b w add neg 0 rlineto
114 0 d h add neg rlineto
116 currentdict /testing known {
117 %% outline only, for testing:
120 closepath gsave stroke grestore fill
125 /draw_round_box % breapth width depth height blot
133 blot 2 div sub /h exch def
134 blot 2 div sub /d exch def
135 blot 2 div sub /w exch def
136 blot 2 div sub /b exch def
141 b w add neg 0 rlineto
142 0 d h add neg rlineto
144 currentdict /testing known {
145 %% outline only, for testing:
148 closepath gsave stroke grestore fill
152 % Nice beam with rounded corners
153 /draw_beam % slope width thick blot
165 blot 2 div t 2 div neg moveto
171 currentdict /testing known {
172 %% outline only, for testing:
175 closepath gsave stroke grestore fill
179 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot fill
191 1 1 points { pop lineto } for
194 gsave stroke grestore fill
200 /draw_repeat_slash % width slope thick
208 beamthick beamthick slope div euclidean_length
212 width slope width mul rlineto
214 % width neg width angle sin mul neg rlineto
218 % this is for drawing slurs.
219 /draw_bezier_sandwich % thickness controls
221 % round ending and round beginning
222 1 setlinejoin 1 setlinecap
237 % 0 360 arc fill stroke
238 0 360 arc closepath fill stroke
248 gsave stroke grestore
253 %%%% JUNKME. use color & circle.
254 /draw_white_dot % x1 y2 R
256 % 0 360 arc fill stroke
257 0 360 arc closepath % fill stroke
261 % 0 360 arc closepath % fill stroke
262 0.05 setlinewidth 0 setgray stroke
266 %% JUNKME: Use color.
267 /draw_white_text % text scale font
272 exch scalefont setfont
281 /draw_dashed_line % dash thickness dx dy
292 /draw_dashed_slur % dash thickness controls
305 %end music-drawing-routines.ps