Blob
1 .TH ADDPT 32 .SH NAME3 addpt, subpt, mulpt, divpt, rectaddpt, rectsubpt, insetrect, canonrect, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, combinerect, Dx, Dy, Pt, Rect, Rpt \- arithmetic on points and rectangles4 .SH SYNOPSIS5 .B #include <u.h>6 .br7 .B #include <libc.h>8 .br9 .B #include <draw.h>10 .PP11 .B12 Point addpt(Point p, Point q)13 .PP14 .B15 Point subpt(Point p, Point q)16 .PP17 .B18 Point mulpt(Point p, int a)19 .PP20 .B21 Point divpt(Point p, int a)22 .PP23 .B24 Rectangle rectaddpt(Rectangle r, Point p)25 .PP26 .B27 Rectangle rectsubpt(Rectangle r, Point p)28 .PP29 .B30 Rectangle insetrect(Rectangle r, int n)31 .PP32 .B33 Rectangle canonrect(Rectangle r)34 .PP35 .B36 int eqpt(Point p, Point q)37 .PP38 .B39 int eqrect(Rectangle r, Rectangle s)40 .PP41 .B42 int ptinrect(Point p, Rectangle r)43 .PP44 .B45 int rectinrect(Rectangle r, Rectangle s)46 .PP47 .B48 int rectXrect(Rectangle r, Rectangle s)49 .PP50 .B51 int rectclip(Rectangle *rp, Rectangle b)52 .PP53 .B54 void combinerect(Rectangle *rp, Rectangle b)55 .PP56 .B57 int Dx(Rectangle r)58 .PP59 .B60 int Dy(Rectangle r)61 .PP62 .B63 Point Pt(int x, int y)64 .PP65 .B66 Rectangle Rect(int x0, int y0, int x1, int y1)67 .PP68 .B69 Rectangle Rpt(Point p, Point q)70 .SH DESCRIPTION71 The functions72 .IR Pt ,73 .I Rect74 and75 .I Rpt76 construct geometrical data types from their components.77 .PP78 .I Addpt79 returns the Point80 sum of its arguments:81 .BI Pt( p .x+ q .x,82 .IB p .y+ q .y) \f1.83 .I Subpt84 returns the Point85 difference of its arguments:86 .BI Pt( p .x- q .x,87 .IB p .y- q .y) \f1.88 .I Mulpt89 returns the Point90 .BI Pt( p .x* a ,91 .IB p .y* a ) \f1.92 .I Divpt93 returns the Point94 .BI Pt( p .x/ a ,95 .IB p .y/ a ) \f1.96 .PP97 .I Rectaddpt98 returns the Rectangle99 .BI Rect(add( r .min,100 .IB p ) \f1,101 .BI add( r .max,102 .IB p )) \f1;103 .I rectsubpt104 returns the Rectangle105 .BI Rpt(sub( r .min,106 .IB p ),107 .BI sub( r .max,108 .IB p ))\fR.109 .PP110 .I Insetrect111 returns the Rectangle112 .BI Rect( r .min.x+ n \f1,113 .IB r .min.y+ n \f1,114 .IB r .max.x- n \f1,115 .IB r .max.y- n ) \f1.116 .PP117 .I Canonrect118 returns a rectangle with the same extent as119 .IR r ,120 canonicalized so that121 .B min.x122 ≤123 .BR max.x ,124 and125 .B min.y126 ≤127 .BR max.y .128 .PP129 .I Eqpt130 compares its argument Points and returns131 0 if unequal,132 1 if equal.133 .I Eqrect134 does the same for its argument Rectangles.135 .PP136 .I Ptinrect137 returns 1 if138 .I p139 is a point within140 .IR r ,141 and 0 otherwise.142 .PP143 .I Rectinrect144 returns 1 if all the pixels in145 .I r146 are also in147 .IR s ,148 and 0 otherwise.149 .PP150 .I RectXrect151 returns 1 if152 .I r153 and154 .I s155 share any point, and 0 otherwise.156 .PP157 .I Rectclip158 clips in place159 the Rectangle pointed to by160 .I rp161 so that it is completely contained within162 .IR b .163 The return value is 1 if any part of164 .RI * rp165 is within166 .IR b .167 Otherwise, the return value is 0 and168 .RI * rp169 is unchanged.170 .PP171 .I Combinerect172 overwrites173 .B *rp174 with the smallest rectangle sufficient to cover all the pixels of175 .B *rp176 and177 .BR b .178 .PP179 The functions180 .I Dx181 and182 .I Dy183 give the width (Δx) and height (Δy) of a Rectangle.184 They are implemented as macros.185 .SH SOURCE186 .B /usr/local/plan9/src/libdraw187 .SH SEE ALSO188 .IR graphics (3)