home *** CD-ROM | disk | FTP | other *** search
- %BEGIN Rectangles
-
- % Copyright (C) 1993 David John Burrowes
- % Distributed under terms of GNU General Public License.
- % See COPYING.text in Convert PICT's CommentedPSCode for a copy
-
- %%%%%%%%%%%%%
- % Name: rectpath
- % Syntax: t l b r rectpath -
- % About: Given the bounds of the rectangle, build a path describing the outside
- % edge of the rectangle.
- % Note: defines new values for last* values in the process
- %%%%%%%%%%%%%
- /rectpath
- {
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
-
- newpath
- lastleft lasttop moveto
- lastright lasttop lineto
- lastright lastbottom lineto
- lastleft lastbottom lineto
- closepath
- }
- def
-
- %%%%%%%%%%%%%
- % Name: frameRect [0030]
- % Syntax: t l b r frameRect -
- % About: Given the bounds of the rectangle, build a pair of paths, one forming the
- % outside edge of the framed rectagle, and one the inside. Fill between then.
- % Note: defines new values for last* values in the process
- %%%%%%%%%%%%%
- /frameRect
- {
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
- %
- % only do this if the pen sizes are > 0
- %
- penWidth 0 gt
- penHeight 0 gt
- and
- {
- gsave
- penPattern usePattern
- newpath
- lastleft lasttop moveto
- lastright lasttop lineto
- lastright lastbottom lineto
- lastleft lastbottom lineto
- closepath
- lastleft penWidth add lasttop penHeight add moveto
- lastleft penWidth add lastbottom penHeight sub lineto
- lastright penWidth sub lastbottom penHeight sub lineto
- lastright penWidth sub lasttop penHeight add lineto
- closepath
- fill
- grestore
- }
- if
- }
- def
-
- %%%%%%%%%%%%%
- % Name: paintRect [0031]
- % Syntax: t l b r paintRect -
- % About: Paints the rectangle formed by the bounds we are passed.
- %%%%%%%%%%%%%
- /paintRect
- {
- gsave
- penPattern usePattern
- rectpath
- fill
- grestore
- } def
-
- %%%%%%%%%%%%%
- % Name: invertRect [0032]
- % Syntax: t l b r invertRect -
- % About: Erases the rectangle formed by the bounds we are passed.
- % Note: erasing always means filling with the background pattern
- %%%%%%%%%%%%%
- /eraseRect
- {
- gsave
- backPattern usePattern
- rectpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: invertRect [0033]
- % Syntax: t l b r invertRect -
- % About: Call rectpath to properly consume arguments, but do nothing since
- % we don't know how to invert in PS.
- %%%%%%%%%%%%%
- /invertRect
- {
- gsave
- rectpath
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: fillRect [0034]
- % Syntax: t l b r fillRect -
- % About: Fills the path formed by the rectangle bounds we are passed
- %%%%%%%%%%%%%
- /fillRect
- {
- gsave
- fillPattern usePattern
- rectpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: frameSameRect [0038]
- % Syntax: - frameSameRect -
- % About: Frames the last rectangle used
- %%%%%%%%%%%%%
- /frameSameRect
- { lasttop lastleft lastbottom lastright frameRect }
- def
-
- %%%%%%%%%%%%%
- % Name: paintSameRect [0039]
- % Syntax: - paintSameRect -
- % About: paints the last rectangle used
- %%%%%%%%%%%%%
- /paintSameRect
- { lasttop lastleft lastbottom lastright paintRect }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseSameRect [003A]
- % Syntax: - eraseSameRect -
- % About: Erases the last rectangle used
- %%%%%%%%%%%%%
- /eraseSameRect
- { lasttop lastleft lastbottom lastright eraseRect }
- def
-
- %%%%%%%%%%%%%
- % Name: invertSameRect [003B]
- % Syntax: - invertSameRect -
- % About: Inverts the last rectangle used
- %%%%%%%%%%%%%
- /invertSameRect
- { lasttop lastleft lastbottom lastright invertRect }
- def
-
- %%%%%%%%%%%%%
- % Name: fillSameRect [003C]
- % Syntax: - fillSameRect -
- % About: Fills the last rectangle used
- %%%%%%%%%%%%%
- /fillSameRect
- { lasttop lastleft lastbottom lastright fillRect }
- def
-
- %END Rectangles
-