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
16 % It's possible to eliminate the coordinate variables by doing [ /Rect [ 7 3
17 % roll. That is, however, kind of ugly. It would be nice if this procedure
18 % were only included when PDF marks are enabled.
26 /Rect [ llx lly urx ury ]
41 % from adobe tech note 5002.
43 /b4_Inc_state save def % Save state for cleanup
44 /dict_count countdictstack def % Count objects on dict stack
45 /op_count count 1 sub def % Count objects on operand stack
46 userdict begin % Push userdict on dict stack
47 /showpage { } def % Redefine showpage, { } = null proc
48 0 setgray 0 setlinecap % Prepare graphics state
49 1 setlinewidth 0 setlinejoin
50 10 setmiterlimit [ ] 0 setdash newpath
51 /languagelevel where % If level not equal to 1 then
52 {pop languagelevel % set strokeadjust and
53 1 ne % overprint to their defaults.
54 {false setstrokeadjust false setoverprint
60 count op_count sub {pop} repeat % Clean up stacks
61 countdictstack dict_count sub {end} repeat
66 %<font> <encoding> <name> reencode-font
73 1 index /FID ne {def} {pop
98 /vector_add { % x1 y1 x2 y2 vector_add x1+x2 y1+y2
107 /draw_round_box % width height x y blot
109 setlinewidth % w h x y
114 currentpoint % w h x1 y1
121 /draw_polygon % fill? x(n) y(n) x(n-1) y(n-1) ... x(0) y(0) n blot
123 setlinewidth %set to blot
134 { polygon_x polygon_y vector_add lineto } repeat % n times
143 /draw_repeat_slash % x-width width height draw_repeat_slash
145 2 index % duplicate x-width
149 0 rlineto % x-width 0
150 rlineto % width height
151 neg 0 rlineto % -x-width 0
155 % this is for drawing slurs.
156 /draw_bezier_sandwich % thickness controls
159 currentpoint translate
160 % round ending and round beginning
161 1 setlinejoin 1 setlinecap
172 /draw_dot % radius x y draw_dot
177 0 360 arc closepath stroke_and_fill
180 /draw_circle % filled? radius thickness draw_circle
183 currentpoint % f? r x0 y0
184 3 2 roll % f? x0 y0 r
193 /draw_line % dx dy x1 y1 thickness draw_line
195 setlinewidth % dx dy x1 y1
203 /draw_dashed_line % dx dy thickness dashpattern draw_dashed_line
207 setdash % dx dy thickness
211 [] 0 setdash % reset dash pattern
214 /draw_dashed_slur % controls thickness dash
217 currentpoint translate
229 /print_glyphs % dx dy glyph print_glyphs
232 currentpoint %dx dy glyph x0 y0
233 3 2 roll %dx dy x0 y0 glyph
234 glyphshow % dx dy x0 y0
239 %end music-drawing-routines.ps