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.
10 % Emulation code from Postscript Language Reference.
15 dup type /arraytype eq
28 { /selectfont /*SF load def }
34 {pop} {userdict /pdfmark /cleartomark load put} ifelse
39 % It's possible to eliminate the coordinate variables by doing [ /Rect [ 7 3
40 % roll. That is, however, kind of ugly. It would be nice if this procedure
41 % were only included when PDF marks are enabled.
49 /Rect [ llx lly urx ury ]
64 % from adobe tech note 5002.
66 /b4_Inc_state save def % Save state for cleanup
67 /dict_count countdictstack def % Count objects on dict stack
68 /op_count count 1 sub def % Count objects on operand stack
69 userdict begin % Push userdict on dict stack
70 /showpage { } def % Redefine showpage, { } = null proc
71 0 setgray 0 setlinecap % Prepare graphics state
72 1 setlinewidth 0 setlinejoin
73 10 setmiterlimit [ ] 0 setdash newpath
74 /languagelevel where % If level not equal to 1 then
75 {pop languagelevel % set strokeadjust and
76 1 ne % overprint to their defaults.
77 {false setstrokeadjust false setoverprint
83 count op_count sub {pop} repeat % Clean up stacks
84 countdictstack dict_count sub {end} repeat
89 %<font> <encoding> <name> reencode-font
96 1 index /FID ne {def} {pop
121 /vector_add { % x1 y1 x2 y2 vector_add x1+x2 y1+y2
130 /draw_round_box % width height x y blot
132 setlinewidth % w h x y
137 currentpoint % w h x1 y1
144 /draw_polygon % fill? x(n) y(n) x(n-1) y(n-1) ... x(0) y(0) n blot
146 setlinewidth %set to blot
157 { polygon_x polygon_y vector_add lineto } repeat % n times
166 /draw_repeat_slash % x-width width height draw_repeat_slash
168 2 index % duplicate x-width
172 0 rlineto % x-width 0
173 rlineto % width height
174 neg 0 rlineto % -x-width 0
178 % this is for drawing slurs.
179 /draw_bezier_sandwich % thickness controls
182 currentpoint translate
183 % round ending and round beginning
184 1 setlinejoin 1 setlinecap
195 /draw_dot % radius x y draw_dot
200 0 360 arc closepath stroke_and_fill
203 /draw_circle % filled? radius thickness draw_circle
206 currentpoint % f? r x0 y0
207 3 2 roll % f? x0 y0 r
216 /draw_line % dx dy x1 y1 thickness draw_line
218 setlinewidth % dx dy x1 y1
226 /draw_dashed_line % dx dy thickness dashpattern draw_dashed_line
230 setdash % dx dy thickness
234 [] 0 setdash % reset dash pattern
237 /draw_dashed_slur % controls thickness dash
240 currentpoint translate
252 /print_glyphs % dx dy glyph print_glyphs
255 currentpoint %dx dy glyph x0 y0
256 3 2 roll %dx dy x0 y0 glyph
257 glyphshow % dx dy x0 y0
262 %end music-drawing-routines.ps