Charles.Forsyth20060303-partialeea662d19 years agoHistory
138 lines · 2.9 KB · Text
RawDownload
.TH DRAW-RECT 2.SH NAMERect \-rectangular portion of the plane.SH SYNOPSIS.EXinclude	"draw.m";draw := load Draw Draw->PATH; Rect: adt{  min:      Point;  max:      Point;   canon:    fn(r: self Rect):             Rect;  dx:       fn(r: self Rect):             int;  dy:       fn(r: self Rect):             int;  eq:       fn(r: self Rect, s: Rect):    int;  Xrect:    fn(r: self Rect, s: Rect):    int;  inrect:   fn(r: self Rect, s: Rect):    int;  clip:     fn(r: self Rect, s: Rect):    (Rect, int);  combine:  fn(r: self Rect, s: Rect):    Rect;  contains: fn(r: self Rect, p: Point):   int;  addpt:    fn(r: self Rect, p: Point):   Rect;  subpt:    fn(r: self Rect, p: Point):   Rect;  inset:    fn(r: self Rect; n: int):     Rect;};.EE.SH DESCRIPTIONThe type.B Rectdefines a rectangular portion of the integer grid..TP 10.BR min ", " maxThesemembers define the upper left.RB ( min )and lower right.RB ( max )points for the rectangle.The rectangle contains the pixels.BI "min.x\ \fR\(<=\ " "x\ \fR<\ " max.xand.BI "min.y\ \fR\(<=\ " "y\ \fR<\ " max.y\fR.In general,.B Rectcoordinates should be in canonical form:.BR min.x "\ \(<=\ " max.xand.BR min.y "\ \(<=\ " max.y .Some functions give undefined results if theinput rectangles are not canonical..TP.IB r .canon()Returns a canonical rectangle by sorting the coordinates of.IR r ..TP.IB r .dx()Returns the horizontal dimension of.IR r ..TP.IB r .dy()Returns the vertical dimension of.IR r ..TP.IB r .eq( s )Returns non-zero if the rectangles.I rand.I shave the same coordinates and zero otherwise..TP.IB r .Xrect( s )Returns non-zero if the rectangles.I rand.I sintersect and zero otherwise..I Intersectionmeans the rectangles share at least one pixel; zero-sized rectangles do not intersect..TP.IB r .inrect( s )Returns non-zero if.I ris completely inside.I sand zero otherwise.Rectangles with equal coordinates are considered to be inside each other.Zero-sized rectangles contain no rectangles..TP.IB r .clip( s )Computes the intersection between.I rand.IR s .If the input rectangles intersect,.B clipreturns the resulting rectangleand a non-zero integer value.If the rectangles do not intersect,.B clipreturns.I rand a zero value..TP.IB r .combine( s )Returns the smallest rectangle sufficientto cover all the pixels of.I rand.IR s ..TP.IB r .contains( p )Returns non-zero if the rectangle.I rcontains the pixel with the coordinates of.I pand zero otherwise.Zero-sized rectangles contain no points..TP.IB r .addpt( p )Returns the rectangle.BI ( r .min.add( p ),.IB r .max.add( p ))\fR..TP.IB r .subpt( p )Returns the rectangle.BI ( r .min.sub( p ),.IB r .max.sub( p ))\fR..TP.IB r .inset( n )Returns the rectangle.BI ( r .min.add(( n ,.IB n )),.IB r .max.sub(( n ,.IB n ))\fR.The result will not be in canonical form if the inset amount istoo large for the rectangle.