home *** CD-ROM | disk | FTP | other *** search
- %BEGIN Polygons
-
- % 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
-
- %%%%%%%%%%%%%
- % Notes:
- % PICTline is defined in the common file. As is penWidth and penHeight
- %%%%%%%%%%%%%
-
- %%%%%%%%%%%%%
- % Name: polyPath
- % Syntax: [x1 y1] ... [xN yN] N rect polyPath -
- % About: Builds a path corresponding to the polygon passed as set of x,y coords
- % (each coord in an array), count of these points, and bounding rectangle.
- % Notes: This changes the clip path. Call inside a gsave/restore. We deliberately
- % end with an open path, since mac polygons aren't always closed(?)
- %%%%%%%%%%%%%
- /polyPath
- {
- /right exch def
- /bottom exch def
- /left exch def
- /top exch def
- /points exch def
- %
- % Build the bounding/clipping rect, and intersect it with the current clip
- %
- newpath
- left top moveto
- right top lineto
- right bottom lineto
- left bottom lineto
- closepath
- clip
- %
- % move to the first point on the stack, then, connect lines to each of the others
- %
- newpath
- /ptarray exch def
- ptarray 0 get
- ptarray 1 get
- moveto
- points 1 sub
- {
- /ptarray exch def
- ptarray 0 get
- ptarray 1 get
- lineto
- }
- repeat % for (points-1) times
- } def
-
- %%%%%%%%%%%%%
- % Name: framePoly [0070]
- % Syntax: [x1 y1] ... [xN yN] N rect framePoly -
- % About: For each coordinate pair of the polygon, call PICTline so it is drawn with
- % the right thickness and overhand.
- % Note: framed polys don't seem affected by the bounding rect.
- %%%%%%%%%%%%%
- /framePoly
- {
- /right exch def
- /bottom exch def
- /left exch def
- /top exch def
- /points exch def
- gsave
- penPattern usePattern
- %
- % Retrieve the first point off the stack, and store.
- %
- /ptarray exch def
- /lastX ptarray 0 get def
- /lastY ptarray 1 get def
- points 1 sub
- {
- %
- % Fetch next point, push last pt, and then define lastX and Y as the new
- % point. Call PICTline with pushed pt. and 'last' pt.
- %
- /ptarray exch def
- lastX lastY
- /lastX ptarray 0 get def
- /lastY ptarray 1 get def
- lastX lastY PICTline
- }
- repeat % for (points-1) times
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: paintPoly [0071]
- % Syntax: [x1 y1] ... [xN yN] N rect paintPoly -
- % About: Given polygon data, build a path, fill with pen pattern
- %%%%%%%%%%%%%
- /paintPoly
- {
- gsave
- penPattern usePattern
- polyPath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: erasePoly [0072]
- % Syntax: [x1 y1] ... [xN yN] N rect erasePoly -
- % About: Given polygon data, build a path, fill with background pattern
- %%%%%%%%%%%%%
- /erasePoly
- {
- gsave
- backPattern usePattern
- polyPath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: invertPoly [0073]
- % Syntax: [x1 y1] ... [xN yN] N rect invertPoly -
- % About: Call polyPath to consume arguments. But don't invert (dunno how)
- %%%%%%%%%%%%%
- /invertPoly
- {
- gsave
- polyPath
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: fillPoly [0074]
- % Syntax: [x1 y1] ... [xN yN] N rect fillPoly -
- % About: Passed a polygon, this builds the path, and fills it
- %%%%%%%%%%%%%
- /fillPoly
- {
- gsave
- fillPattern usePattern
- polyPath
- fill
- grestore
- } def
-
- %%%%%%%%%%%%%
- % Name: frameSamePoly [0078]
- % Syntax: - frameSamePoly -
- % About: This is not implemented by Apple, so we do nothing here
- %%%%%%%%%%%%%
- /frameSamePoly
- { }
- def
-
- %%%%%%%%%%%%%
- % Name: paintSamePoly [0079]
- % Syntax: - paintSamePoly -
- % About: This is not implemented by Apple, so we do nothing here
- %%%%%%%%%%%%%
- /paintSamePoly
- { }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseSamePoly [007A]
- % Syntax: - eraseSamePoly -
- % About: This is not implemented by Apple, so we do nothing here
- %%%%%%%%%%%%%
- /eraseSamePoly
- { }
- def
-
- %%%%%%%%%%%%%
- % Name: invertSamePoly [007B]
- % Syntax: - invertSamePoly -
- % About: This is not implemented by Apple, so we do nothing here
- %%%%%%%%%%%%%
- /invertSamePoly
- { }
- def
-
- %%%%%%%%%%%%%
- % Name: fillSamePoly [007C]
- % Syntax: - fillSamePoly -
- % About: This is not implemented by Apple, so we do nothing here
- %%%%%%%%%%%%%
- /fillSamePoly
- { }
- def
-
- %END Polygons
-