.TH ADD 2G .SH NAME add, sub, mul, div, raddp, rsubp, rmul, rdiv, rshift, inset, rcanon, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, Dx, Dy, Pt, Rect, Rpt \- arithmetic on points and rectangles .SH SYNOPSIS .B #include .br .B #include .br .B #include .PP .B .ta 12n +12n +12n +12n +12n Point add(Point p, Point q) .PP .B Point sub(Point p, Point q) .PP .B Point mul(Point p, int a) .PP .B Point div(Point p, int a) .PP .B Rectangle raddp(Rectangle r, Point p) .PP .B Rectangle rsubp(Rectangle r, Point p) .PP .B Rectangle rmul(Rectangle r, int a) .PP .B Rectangle rdiv(Rectangle r, int a) .PP .B Rectangle rshift(Rectangle r, int a) .PP .B Rectangle inset(Rectangle r, int n) .PP .B Rectangle rcanon(Rectangle r) .PP .B int eqpt(Point p, Point q) .PP .B int eqrect(Rectangle r, Rectangle s) .PP .B int ptinrect(Point p, Rectangle r) .PP .B int rectinrect(Rectangle r, Rectangle s) .PP .B int rectXrect(Rectangle r, Rectangle s) .PP .B int rectclip(Rectangle *rp, Rectangle b) .PP .B int Dx(Rectangle r) .PP .B int Dy(Rectangle r) .PP .B Point Pt(int x, int y) .PP .B Rectangle Rect(int x0, int y0, int x1, int y1) .PP .B Rectangle Rpt(Point p, Point q) .SH DESCRIPTION The functions .IR Pt , .I Rect and .I Rpt construct geometrical data types from their components. These are implemented as macros. .PP .I Add returns the Point sum of its arguments: .BI Pt( p .x+ q .x, .IB p .y+ q .y) . .I Sub returns the Point difference of its arguments: .BI Pt( p .x- q .x, .IB p .y- q .y) . .I Mul returns the Point .BI Pt( p .x* a , .IB p .y* a ) . .I Div returns the Point .BI Pt( p .x/ a , .IB p .y/ a ) . .PP .I Raddp returns the Rectangle .BI Rect(add( r .min, .IB p ), .BI add( r .max, .IB p ))\fR; .I rsubp returns the Rectangle .BI Rpt(sub( r .min, .IB p ), .BI sub( r .max, .IB p ))\fR. .I Rmul returns the Rectangle .BI Rpt(mul( r .min, a ), .BI mul( r .max, a ))\fR; .I Rdiv returns the Rectangle .BI Rpt(div( r .min, a ), .BI div( r .max, a )) . .PP .I Rshift returns the rectangle .I r with all coordinates either left-shifted or right-shifted by .IR a , depending on whether .I a is positive or negative, respectively. .PP .I Inset returns the Rectangle .BI Rect( r .min.x+ n , .IB r .min.y+ n , .IB r .max.x- n , .IB r .max.y- n ) . .PP .I Rcanon returns a rectangle with the same extent as .IR r , canonicalized so that .B min.x .if t \(<= .if n <= .BR max.x , and .B min.y .if t \(<= .if n <= .BR max.y . .PP .I Eqpt compares its argument Points and returns 0 if unequal, 1 if equal. .I Eqrect does the same for its argument Rectangles. .PP .I Ptinrect returns 1 if .I p is a point within .IR r , and 0 otherwise. .PP .I Rectinrect returns 1 if all the pixels in .I r are also in .IR s , and 0 otherwise. .PP .I RectXrect returns 1 if .I r and .I s share any point, and 0 otherwise. .PP .I Rectclip clips in place the Rectangle pointed to by .I rp so that it is completely contained within .IR b . The return value is 1 if any part of .RI * rp is within .IR b . Otherwise, the return value is 0 and .RI * rp is unchanged. .PP The functions .I Dx and .I Dy give the width (Δx) and height (Δy) of a Rectangle. They are implemented as macros. .SH SEE ALSO .IR graphics (2)