1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
5 % Don't use double % as comment prefix. These are interpreted as DSC comments.
7 % TODO: use dicts or prefixes to prevent namespace pollution.
10 {pop} {userdict /pdfmark /cleartomark load put} ifelse
12 % from adobe tech note 5002.
14 /b4_Inc_state save def % Save state for cleanup
15 /dict_count countdictstack def % Count objects on dict stack
16 /op_count count 1 sub def % Count objects on operand stack
17 userdict begin % Push userdict on dict stack
18 /showpage { } def % Redefine showpage, { } = null proc
19 0 setgray 0 setlinecap % Prepare graphics state
20 1 setlinewidth 0 setlinejoin
21 10 setmiterlimit [ ] 0 setdash newpath
22 /languagelevel where % If level not equal to 1 then
23 {pop languagelevel % set strokeadjust and
24 1 ne % overprint to their defaults.
25 {false setstrokeadjust false setoverprint
32 count op_count sub {pop} repeat % Clean up stacks
33 countdictstack dict_count sub {end} repeat
38 %<font> <encoding> <name> reencode-font
45 1 index /FID ne {def} {pop
65 /Rect [ llx lly urx ury ]
88 1 copy mul exch 1 copy mul add sqrt
91 % FIXME. translate to middle of box.
92 % Nice rectangle with rounded corners
93 /draw_box % breapth width depth height
95 % currentdict /testing known {
96 %% real thin lines for testing
99 % /blot blot-diameter def
106 blot 2 div sub /h exch def
107 blot 2 div sub /d exch def
108 blot 2 div sub /w exch def
109 blot 2 div sub /b exch def
114 b w add neg 0 rlineto
115 0 d h add neg rlineto
117 currentdict /testing known {
118 %% outline only, for testing:
121 closepath gsave stroke grestore fill
126 /draw_round_box % breapth width depth height blot
134 blot 2 div sub /h exch def
135 blot 2 div sub /d exch def
136 blot 2 div sub /w exch def
137 blot 2 div sub /b exch def
142 b w add neg 0 rlineto
143 0 d h add neg rlineto
145 currentdict /testing known {
146 %% outline only, for testing:
149 closepath gsave stroke grestore fill
153 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot fill
165 1 1 points { pop lineto } for
168 gsave stroke grestore fill
174 /draw_repeat_slash % width slope thick
182 beamthick beamthick slope div euclidean_length
186 width slope width mul rlineto
188 % width neg width angle sin mul neg rlineto
192 % this is for drawing slurs.
193 /draw_bezier_sandwich % thickness controls
195 % round ending and round beginning
196 1 setlinejoin 1 setlinecap
211 % 0 360 arc fill stroke
212 0 360 arc closepath fill stroke
222 gsave stroke grestore
227 % JUNKME. use color & circle.
228 /draw_white_dot % x1 y2 R
230 % 0 360 arc fill stroke
231 0 360 arc closepath % fill stroke
235 % 0 360 arc closepath % fill stroke
236 0.05 setlinewidth 0 setgray stroke
241 /draw_white_text % text scale font
246 exch scalefont setfont
255 /draw_dashed_line % dash thickness dx dy
266 /draw_dashed_slur % dash thickness controls
279 %end music-drawing-routines.ps