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
131 currentdict /testing known
155 /draw_polygon % fill? x(n) y(n) x(n-1) y(n-1) ... x(0) y(0) n blot
157 setlinewidth %set to blot
168 { polygon_x polygon_y vector_add lineto } repeat % n times
177 /draw_repeat_slash % x-width width height
179 2 index % duplicate x-width
183 0 rlineto % x-width 0
184 rlineto % width height
185 neg 0 rlineto % -x-width 0
189 % this is for drawing slurs.
190 /draw_bezier_sandwich % thickness controls
193 currentpoint translate
194 % round ending and round beginning
195 1 setlinejoin 1 setlinecap
206 /draw_dot % radius x y
211 0 360 arc closepath stroke_and_fill
218 currentpoint 3 2 roll
226 /draw_line % dx dy x1 y1 thickness
236 /draw_dashed_line % dx dy thickness dashpattern
246 /draw_dashed_slur % controls thickness dash
249 currentpoint translate
269 %end music-drawing-routines.ps