% Functions for direct and embedded PostScript
+%% TODO: use dicts or prefixes to prevent namespace pollution.
+
/pdfmark where
{pop} {userdict /pdfmark /cleartomark load put} ifelse
+% from adobe tech note 5002.
+/BeginEPSF { %def
+ /b4_Inc_state save def % Save state for cleanup
+ /dict_count countdictstack def % Count objects on dict stack
+ /op_count count 1 sub def % Count objects on operand stack
+ userdict begin % Push userdict on dict stack
+ /showpage { } def % Redefine showpage, { } = null proc
+ 0 setgray 0 setlinecap % Prepare graphics state
+ 1 setlinewidth 0 setlinejoin
+ 10 setmiterlimit [ ] 0 setdash newpath
+ /languagelevel where % If level not equal to 1 then
+ {pop languagelevel % set strokeadjust and
+ 1 ne % overprint to their defaults.
+ {false setstrokeadjust false setoverprint
+ } if
+ } if
+} bind def
+
-% llx lly urx ury command
-/mark_file_line
+/EndEPSF { %def
+ count op_count sub {pop} repeat % Clean up stacks
+ countdictstack dict_count sub {end} repeat
+ b4_Inc_state restore
+} bind def
+
+% llx lly urx ury URI
+/mark_URI
{
/command exch def
/ury exch def
} ifelse
} bind def
-/draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
+/draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot fill
{
+ /fillp exch def
/blot exch def
0 setlinecap
/points exch def
2 copy
moveto
- 1 1 points {pop lineto} for
- currentdict /testing known {
- %% outline only, for testing:
- stroke
+ 1 1 points { pop lineto } for
+ closepath
+ fillp {
+ gsave stroke grestore fill
}{
- closepath gsave stroke grestore fill
+ stroke
} ifelse
} bind def
0 360 arc closepath fill stroke
} bind def
+/draw_circle % R T F
+{
+ /filled exch def
+ setlinewidth
+ dup 0 moveto
+ 0 exch 0 exch
+ 0 360 arc closepath
+ gsave stroke grestore
+ filled { fill } if
+} bind def
+
/draw_white_dot % x1 y2 R
{
% 0 360 arc fill stroke