1 %!PS-Adobe-1.0: music-drawing-routines.ps
3 % Functions for direct and embedded PostScript
5 % Careful with double % as comment prefix.
6 % Any %%X comment is interpreted as DSC comments.
8 % TODO: use dicts or prefixes to prevent namespace pollution.
11 {pop} {userdict /pdfmark /cleartomark load put} ifelse
13 % from adobe tech note 5002.
15 /b4_Inc_state save def % Save state for cleanup
16 /dict_count countdictstack def % Count objects on dict stack
17 /op_count count 1 sub def % Count objects on operand stack
18 userdict begin % Push userdict on dict stack
19 /showpage { } def % Redefine showpage, { } = null proc
20 0 setgray 0 setlinecap % Prepare graphics state
21 1 setlinewidth 0 setlinejoin
22 10 setmiterlimit [ ] 0 setdash newpath
23 /languagelevel where % If level not equal to 1 then
24 {pop languagelevel % set strokeadjust and
25 1 ne % overprint to their defaults.
26 {false setstrokeadjust false setoverprint
33 count op_count sub {pop} repeat % Clean up stacks
34 countdictstack dict_count sub {end} repeat
39 %<font> <encoding> <name> reencode-font
46 1 index /FID ne {def} {pop
66 /Rect [ llx lly urx ury ]
89 1 copy mul exch 1 copy mul add sqrt
92 % FIXME. translate to middle of box.
93 % Nice rectangle with rounded corners
94 /draw_box % breapth width depth height
96 % currentdict /testing known {
97 %% real thin lines for testing
100 % /blot blot-diameter def
107 blot 2 div sub /h exch def
108 blot 2 div sub /d exch def
109 blot 2 div sub /w exch def
110 blot 2 div sub /b exch def
115 b w add neg 0 rlineto
116 0 d h add neg rlineto
118 currentdict /testing known {
119 %% outline only, for testing:
122 closepath gsave stroke grestore fill
127 /draw_round_box % breapth width depth height blot
135 blot 2 div sub /h exch def
136 blot 2 div sub /d exch def
137 blot 2 div sub /w exch def
138 blot 2 div sub /b exch def
143 b w add neg 0 rlineto
144 0 d h add neg rlineto
146 currentdict /testing known {
147 %% outline only, for testing:
150 closepath gsave stroke grestore fill
154 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot fill
166 1 1 points { pop lineto } for
169 gsave stroke grestore fill
175 /draw_repeat_slash % width slope thick
183 beamthick beamthick slope div euclidean_length
187 width slope width mul rlineto
189 % width neg width angle sin mul neg rlineto
193 % this is for drawing slurs.
194 /draw_bezier_sandwich % thickness controls
196 % round ending and round beginning
197 1 setlinejoin 1 setlinecap
212 % 0 360 arc fill stroke
213 0 360 arc closepath fill stroke
223 gsave stroke grestore
228 % JUNKME. use color & circle.
229 /draw_white_dot % x1 y2 R
231 % 0 360 arc fill stroke
232 0 360 arc closepath % fill stroke
236 % 0 360 arc closepath % fill stroke
237 0.05 setlinewidth 0 setgray stroke
242 /draw_white_text % text scale font
247 exch scalefont setfont
256 /draw_dashed_line % dash thickness dx dy
267 /draw_dashed_slur % dash thickness controls
280 %end music-drawing-routines.ps