home *** CD-ROM | disk | FTP | other *** search
- head 1.8;
- branch ;
- access ;
- symbols beta10:1.7;
- locks death:1.8;
- comment @# @;
-
-
- 1.8
- date 93.04.04.23.31.12; author death; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 93.01.09.21.07.43; author death; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 93.01.01.11.51.48; author death; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 92.12.31.15.35.34; author death; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 92.12.05.23.07.48; author death; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 92.12.03.18.02.19; author death; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 92.11.27.19.38.25; author death; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 92.11.08.09.29.07; author death; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.8
- log
- @Sun Apr 4 23:31:12 PDT 1993
- @
- text
- @%BEGIN ReoundRectangles
-
- %%%%%%%%%%%%%
- % Define the default values to be used for the width and height of the
- % cuves on the corners of the round rectangles.
- %%%%%%%%%%%%%
- /ovWidth 0 def
- /ovHeight 0 def
-
- %%%%%%%%%%%%%
- % Name: ovSize [000B]
- % Syntax: width height ovSize -
- % About: Sets the width and height of curves on round-rectangle corners
- %%%%%%%%%%%%%
- /ovSize
- {
- /ovHeight exch def
- /ovWidth exch def
- }
- def
-
- %%%%%%%%%%%%%
- % Name: buildRRpath
- % Syntax: t l b r buildRRpath -
- % About: Given a rectangle, build a round-rect path in that rect
- % using the values of ovWidth and ovHeight. This necessarily
- % distorts userspace to get the ovaled corners.
- % Note: This assumes there is a current path. It does not
- % create a new one because it is called 2ce by frameRRect
- % Remove trapping for big oval sizes for pretty results
- %%%%%%%%%%%%%
- /buildRRpath
- {
- /rightCoord exch def
- /bottomCoord exch def
- /leftCoord exch def
- /topCoord exch def
-
- /startmatrix matrix currentmatrix def
- %
- % Compute half ovheight and half ovwith, trapping for (a) case when
- % width or height larger than corresponding rect dimension, and
- % (b) cases when ovwidth or ovheight is 0. In case of (b), we make
- % the half value non-zero, but very small. We divide by this value
- % later, so a 0 value would be bad.
- %
- ovHeight 0 le
- { /halfheight .0001 def }
- {
- ovHeight bottomCoord topCoord sub gt
- {/halfheight bottomCoord topCoord sub 2 div def}
- {/halfheight ovHeight 2 div def}
- ifelse
- }
- ifelse
-
- ovWidth 0 le
- { /halfwidth .0001 def }
- {
- ovWidth rightCoord leftCoord sub gt
- {/halfwidth rightCoord leftCoord sub 2 div def}
- {/halfwidth ovWidth 2 div def}
- ifelse
- }
- ifelse
- %
- % Distort space properly for ovals, and compute where the
- % rectangle edges should be in this distorted space (so they
- % lie on the same screen locations despite distortion)
- %
- halfwidth halfheight gt
- {
- /unscale halfwidth halfheight div def
- 1 halfheight halfwidth div scale
- /radius halfwidth def
- /newleft leftCoord def
- /newright rightCoord def
- /newtop topCoord unscale mul def
- /newbottom bottomCoord unscale mul def
- }
- {
- /unscale halfheight halfwidth div def
- halfwidth halfheight div 1 scale
- /radius halfheight def
- /newleft leftCoord unscale mul def
- /newright rightCoord unscale mul def
- /newtop topCoord def
- /newbottom bottomCoord def
- }
- ifelse
- %
- % Finally, draw the round rect using arct which draws both an
- % arced corner, as well as the edge to it.
- %
- newleft halfwidth add newtop moveto
- newright newtop newright newbottom radius arct
- newright newbottom newleft newbottom radius arct
- newleft newbottom newleft newtop radius arct
- newleft newtop newright newtop radius arct
- closepath
- startmatrix setmatrix
- }
- def
-
-
- %%%%%%%%%%%%%
- % Name: roundrectpath
- % Syntax: t l b r roundrectpath -
- % About: Provides a wrapper around buildRRpath so we can declare
- % a newpath first. Note that we define last* values here for
- % all the routines below that call this.
- %%%%%%%%%%%%%
- /roundrectpath
- {
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
-
- newpath
- lasttop lastleft lastbottom lastright buildRRpath
- }
- def
-
- %%%%%%%%%%%%%
- % Name: frameRRect [0040]
- % Syntax: t l b r frameRRect -
- % About: Frames the specified round rect. If the pen sizes are 1,
- % stroke the path. Otherwise, build an inner path, and
- % fill between them.
- %%%%%%%%%%%%%
- /frameRRect
- {
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
- %
- % Do something if pen sizes > 0
- %
- penWidth 0 gt
- penHeight 0 gt
- and
- {
- gsave
- penPattern usePattern
- newpath
- penWidth 1 eq
- penHeight 1 eq
- and
- {
- lasttop lastleft lastbottom 1 sub lastright 1 sub buildRRpath
- stroke
- }
- {
- lasttop lastleft lastbottom lastright buildRRpath
- %
- % Compute parameters for inner edge of rrect frame.
- % Note: we temporarily change ovWidth & ovHeight to
- % produce aesthetically pleasing inner curves.
- %
- save
- /ovHeight ovHeight penHeight 2 mul sub def
- /ovWidth ovWidth penWidth 2 mul sub def
- lasttop penHeight add
- lastleft penWidth add
- lastbottom penHeight sub
- lastright penWidth sub
- buildRRpath
- eofill
- restore
- }
- ifelse
- grestore
- }
- if
- } def
-
- %%%%%%%%%%%%%
- % Name: paintRRect [0041]
- % Syntax: t l b r paintRRect -
- % About: Fills the path of a round rectangle with the pen pattern
- %%%%%%%%%%%%%
- /paintRRect
- {
- gsave
- penPattern usePattern
- roundrectpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseRRect [0042]
- % Syntax: t l b r eraseRRect -
- % About: Fills the path of a round rectangle with the background pattern
- %%%%%%%%%%%%%
- /eraseRRect
- {
- gsave
- backPattern usePattern
- roundrectpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: invertRRect [0043]
- % Syntax: t l b r invertRRect -
- % About: Calls roundrectpath to properly consume parameters.
- % We don't know how to invert it, though, so don't.
- %%%%%%%%%%%%%
- /invertRRect
- {
- gsave
- roundrectpath
- grestore
- } def
-
- %%%%%%%%%%%%%
- % Name: fillRRect [0044]
- % Syntax: t l b r fillRRect -
- % About: Fills the path of a round rectangle with the fill pattern
- %%%%%%%%%%%%%
- /fillRRect
- {
- gsave
- fillPattern usePattern
- roundrectpath
- fill
- grestore
- } def
-
- %%%%%%%%%%%%%
- % Name: frameSameRRect [0048]
- % Syntax: - frameSameRRect -
- % About: Frames the last roundrectangle used
- %%%%%%%%%%%%%
- /frameSameRRect
- { lasttop lastleft lastbottom lastright frameRRect }
- def
-
- %%%%%%%%%%%%%
- % Name: paintSameRRect [0049]
- % Syntax: - paintSameRRect -
- % About: Paints the last roundrectangle used
- %%%%%%%%%%%%%
- /paintSameRRect
- { lasttop lastleft lastbottom lastright paintRRect }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseSameRRect [004A]
- % Syntax: - eraseSameRRect -
- % About: Erases the last roundrectangle used
- %%%%%%%%%%%%%
- /eraseSameRRect
- { lasttop lastleft lastbottom lastright eraseRRect }
- def
-
- %%%%%%%%%%%%%
- % Name: invertSameRRect [004B]
- % Syntax: - invertSameRRect -
- % About: Inverts the last roundrectangle used
- %%%%%%%%%%%%%
- /invertSameRRect
- { lasttop lastleft lastbottom lastright invertRRect }
- def
-
- %%%%%%%%%%%%%
- % Name: fillSameRRect [004C]
- % Syntax: - fillSameRRect -
- % About: Fills the last roundrectangle used
- %%%%%%%%%%%%%
- /fillSameRRect
- { lasttop lastleft lastbottom lastright fillRRect }
- def
-
- %END RoundRectangles
- @
-
-
- 1.7
- log
- @Sat Jan 9 21:07:43 PST 1993
- @
- text
- @@
-
-
- 1.6
- log
- @Fri Jan 1 11:51:48 PST 1993
- @
- text
- @@
-
-
- 1.5
- log
- @Thu Dec 31 15:35:34 PST 1992
- @
- text
- @@
-
-
- 1.4
- log
- @Sat Dec 5 23:07:47 PST 1992
- @
- text
- @d3 4
- a6 3
- %
- % Define the default height and width for the ovals on round rectangles
- %
- d10 11
- d22 2
- a23 2
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % utility: buildRRpath
- d25 7
- a31 12
- % Description:
- % Given a rectangle, this routine actually constructs the path of a round rectangle
- % with those bounds. Because the corners are ovals (sometimes circles), it is
- % necessary to play silly games distorting user space to get those ovals.
- % this does so, and restores the CTM before returning, with the necessary
- % closed path in place.
- % Note:
- % remove the trapping for oval sizes that are too big, and you can get
- % some cute results! =)
- % I don't like the way I trap for 0 ovWidth or Height. It seems inelegant, but my brain
- % can't think of a better way right now.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d34 2
- a35 2
- /rightCoord exch 1 add def
- /bottomCoord exch 1 add def
- d41 5
- a45 4
- % If ovHeight <= 0, then set the halfheight to a near-zero positive value
- % (a nicer algorithm might deal with 0's below) Otherwise, if the ovalheight
- % is > the height of the bounding rect, set the half(oval)height to be
- % half the rectangle height. Otherwise use half ovHeight (unless is 0, then make it very small)
- d52 1
- a52 1
- { /halfheight ovHeight 2 div def}
- d56 1
- a56 3
- %
- % same as above, but with widith instead
- %
- d62 1
- a62 1
- { /halfwidth ovWidth 2 div def}
- d67 3
- a69 3
- % compute distortion needed to produce ovals of the right size. Distort space, but
- % then *undistort* the edges (along the distorted axis) of our rectangle so they will
- % appear in the right places, even though the corners are scaled.
- a81 1
- /scalefactor halfwidth halfheight div def
- d83 1
- a83 1
- scalefactor 1 scale
- d92 2
- a93 1
- % Using arct, which will draws the leading line and then an arc,
- d106 2
- a107 3
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % utility: roundrectpath
- d109 4
- a112 8
- % Description:
- % takes a rectangle (top left bottom right) and makes the current path a round
- % cornered rectangle within these bounds. Note that this is little more than
- % a fancy wrapper aound buildRRpath. (obviously).
- % Weirdnesses:
- % We use the lastrect globals for local variable use here...
- % Note:
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d125 7
- a131 25
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 000B
- % Name: ovSize
- % Syntax: width height ovSize -
- % Description:
- % Sets the width and height of the ovals to appear on round rectangles
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- /ovSize
- {
- /ovHeight exch def
- /ovWidth exch def
- }
- def
-
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0040
- % Name: frameRRect
- % Syntax: t l b r frameRRect -
- % Description:
- % Frames the specified round rect. Now, if the penwidth and height are zero, we just build
- % the path and stroke it. If not, however, we build an inner path and fill between them,
- % producing the effect of the roundrect drawn by an irregularly shaped pen,as requested.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d139 1
- a139 1
- % Do nothing if we've been asked to build with a 0 width or height pen
- d141 2
- a142 2
- penWidth 0 ne
- penHeight 0 ne
- a147 7
- %
- % If our penwidth is not 1, then draw an inner and outer round rect.
- % otherwise, just uild one path and stroke it. Note that in this case
- % we subtract 1 from the bottom and right coords because we are displaying
- % the NON-MODULAR knowledge that buildRRPath will turn around and add one
- % to these numbers, and we don't want them made bigger (so we are subtracting to compensate)
- %
- d152 1
- a152 1
- lasttop lastleft lastbottom 1 sub lastright 1 sub buildRRpath
- d158 3
- a160 6
- % Compute parameters for inner rectangle (inner side of the RRect's thicknes)
- % and pass to buildRRpath. Then, do an eofil between the two we've build
- % First, reduce the size of the ovals by the ammount of the pen dimensions.
- % This APPEARS to be something like what the Mac is doing. And, anyway, it
- % is more aethetically pleasing. =) We do this by creating temporary
- % ovHeigh and ovWidth values to fake buildRRpath out, and then resotre them later.
- d162 10
- a171 12
- /tempHeight ovHeight def
- /tempWidth ovWidth def
- /ovHeight ovHeight penHeight 2 mul sub def
- /ovWidth ovWidth penWidth 2 mul sub def
- lasttop penHeight add
- lastleft penWidth add
- lastbottom penHeight sub
- lastright penWidth sub
- buildRRpath
- eofill
- /ovHeight tempHeight def
- /ovWidth tempWidth def
- d179 5
- a183 10
-
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0041
- % Name: paintRRect
- % Syntax: t l b r paintRRect -
- % Description:
- % Takes a rectangle, and passes it to roundrectpath which builds a path.
- % Paints the resulting path.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d194 5
- a198 9
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0042
- % Name: eraseRRect
- % Syntax: t l b r eraseRRect -
- % Description:
- % Takes a rectangle, and passes it to roundrectpath which builds a path.
- % erase the resulting path.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d209 6
- a214 11
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0043
- % Name: invertRRect
- % Syntax: t l b r invertRRect -
- % Description:
- % Takes a rectangle, and passes it to roundrectpath which builds a path.
- % Then, do nothing. Presumably we should invert it. But, this isn't easy in
- % PS, and I also haven't any examples on the Mac to prove to me how this
- % actually works. So. This does nothing.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d222 5
- a226 9
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0044
- % Name: fillRRect
- % Syntax: t l b r fillRRect -
- % Description:
- % Takes a rectangle, and passes it to roundrectpath which builds a path.
- % Fill the resulting path.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d236 5
- a240 8
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0048
- % Name: frameSameRRect
- % Syntax: - frameSameRRect -
- % Description:
- % frames, in the last rectangle used, the border of a round rectangle.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d245 5
- a249 8
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0049
- % Name: paintSameRRect
- % Syntax: - paintSameRRect -
- % Description:
- % paints, in the last rectangle used, the area of a round rectangle.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d254 5
- a258 8
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 004A
- % Name: eraseSameRRect
- % Syntax: - eraseSameRRect -
- % Description:
- % erase, in the last rectangle used, the area of a round rectangle.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d263 5
- a267 8
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 004B
- % Name: invertSameRRect
- % Syntax: - invertSameRRect -
- % Description:
- % in theory inverts the last rectangle used.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d272 5
- a276 8
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 004C
- % Name: fillSameRRect
- % Syntax: - fillSameRRect -
- % Description:
- % What a surprise! This fills the last round rectangle used!
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- a281 1
-
- @
-
-
- 1.3
- log
- @Thu Dec 3 18:02:19 PST 1992
- @
- text
- @@
-
-
- 1.2
- log
- @Fri Nov 27 19:38:25 PST 1992
- @
- text
- @@
-
-
- 1.1
- log
- @Sun Nov 8 09:29:07 PST 1992
- @
- text
- @@
-