summaryrefslogtreecommitdiff
path: root/man/2/draw-rect
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 20:52:35 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 20:52:35 +0000
commit46439007cf417cbd9ac8049bb4122c890097a0fa (patch)
tree6fdb25e5f3a2b6d5657eb23b35774b631d4d97e4 /man/2/draw-rect
parent37da2899f40661e3e9631e497da8dc59b971cbd0 (diff)
20060303-partial
Diffstat (limited to 'man/2/draw-rect')
-rw-r--r--man/2/draw-rect138
1 files changed, 138 insertions, 0 deletions
diff --git a/man/2/draw-rect b/man/2/draw-rect
new file mode 100644
index 00000000..ca069378
--- /dev/null
+++ b/man/2/draw-rect
@@ -0,0 +1,138 @@
+.TH DRAW-RECT 2
+.SH NAME
+Rect \-
+rectangular portion of the plane
+.SH SYNOPSIS
+.EX
+include "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 DESCRIPTION
+The type
+.B Rect
+defines a rectangular portion of the integer grid.
+.TP 10
+.BR min ", " max
+These
+members 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.x
+and
+.BI "min.y\ \fR\(<=\ " "y\ \fR<\ " max.y\fR.
+In general,
+.B Rect
+coordinates should be in canonical form:
+.BR min.x "\ \(<=\ " max.x
+and
+.BR min.y "\ \(<=\ " max.y .
+Some functions give undefined results if the
+input 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 r
+and
+.I s
+have the same coordinates and zero otherwise.
+.TP
+.IB r .Xrect( s )
+Returns non-zero if the rectangles
+.I r
+and
+.I s
+intersect and zero otherwise.
+.I Intersection
+means the rectangles share at least one pixel; zero-sized rectangles do not intersect.
+.TP
+.IB r .inrect( s )
+Returns non-zero if
+.I r
+is completely inside
+.I s
+and 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 r
+and
+.IR s .
+If the input rectangles intersect,
+.B clip
+returns the resulting rectangle
+and a non-zero integer value.
+If the rectangles do not intersect,
+.B clip
+returns
+.I r
+and a zero value.
+.TP
+.IB r .combine( s )
+Returns the smallest rectangle sufficient
+to cover all the pixels of
+.I r
+and
+.IR s .
+.TP
+.IB r .contains( p )
+Returns non-zero if the rectangle
+.I r
+contains the pixel with the coordinates of
+.I p
+and 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 is
+too large for the rectangle.