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
23 /Rect [ llx lly urx ury ]
38 % from adobe tech note 5002.
40 /b4_Inc_state save def % Save state for cleanup
41 /dict_count countdictstack def % Count objects on dict stack
42 /op_count count 1 sub def % Count objects on operand stack
43 userdict begin % Push userdict on dict stack
44 /showpage { } def % Redefine showpage, { } = null proc
45 0 setgray 0 setlinecap % Prepare graphics state
46 1 setlinewidth 0 setlinejoin
47 10 setmiterlimit [ ] 0 setdash newpath
48 /languagelevel where % If level not equal to 1 then
49 {pop languagelevel % set strokeadjust and
50 1 ne % overprint to their defaults.
51 {false setstrokeadjust false setoverprint
57 count op_count sub {pop} repeat % Clean up stacks
58 countdictstack dict_count sub {end} repeat
74 /vector_add { % x1 y1 x2 y2 vector_add x1+x2 y1+y2
83 /draw_round_box % width height x y blot
85 setlinewidth % w h x y
90 currentpoint % w h x1 y1
97 /draw_polygon % fill? x(n) y(n) x(n-1) y(n-1) ... x(0) y(0) n blot
99 setlinewidth %set to blot
110 { polygon_x polygon_y vector_add lineto } repeat % n times
119 /draw_repeat_slash % x-width width height draw_repeat_slash
121 2 index % duplicate x-width
125 0 rlineto % x-width 0
126 rlineto % width height
127 neg 0 rlineto % -x-width 0
131 % this is for drawing slurs and barre-indicators.
132 /draw_bezier_sandwich % thickness controls
135 currentpoint translate
136 % round ending and round beginning
137 1 setlinejoin 1 setlinecap
148 /draw_dot % radius x y draw_dot
153 0 360 arc closepath stroke_and_fill
156 /draw_circle % filled? radius thickness draw_circle
159 currentpoint % f? r x0 y0
160 3 2 roll % f? x0 y0 r
168 /draw_ellipse % filled? x-radius y-radius thickness draw_ellipse
170 setlinewidth % f? x-r y-r
171 /savematrix matrix currentmatrix def
175 1 0 360 arc closepath
182 /draw_line % dx dy x1 y1 thickness draw_line
184 setlinewidth % dx dy x1 y1
192 /draw_dashed_line % dx dy thickness dashpattern offset draw_dashed_line
196 setdash % dx dy thickness
200 [] 0 setdash % reset dash pattern
203 /draw_dashed_slur % controls thickness dash
206 currentpoint translate
218 /print_glyphs % dx dy glyph print_glyphs
221 currentpoint %dx dy glyph x0 y0
222 3 2 roll %dx dy x0 y0 glyph
223 glyphshow % dx dy x0 y0
228 %end music-drawing-routines.ps