]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/addpt
/sys/man/*/*: fix perms (sorry)
[plan9front.git] / sys / man / 2 / addpt
1 .TH ADDPT 2
2 .SH NAME
3 addpt, subpt, mulpt, divpt, rectaddpt, rectsubpt, insetrect, canonrect, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, combinerect, badrect, Dx, Dy, Pt, Rect, Rpt \- arithmetic on points and rectangles
4 .SH SYNOPSIS
5 .B #include <u.h>
6 .br
7 .B #include <libc.h>
8 .br
9 .B #include <draw.h>
10 .PP
11 .B
12 Point   addpt(Point p, Point q)
13 .PP
14 .B
15 Point   subpt(Point p, Point q)
16 .PP
17 .B
18 Point   mulpt(Point p, int a)
19 .PP
20 .B
21 Point   divpt(Point p, int a)
22 .PP
23 .B
24 Rectangle       rectaddpt(Rectangle r, Point p)
25 .PP
26 .B
27 Rectangle       rectsubpt(Rectangle r, Point p)
28 .PP
29 .B
30 Rectangle       insetrect(Rectangle r, int n)
31 .PP
32 .B
33 Rectangle       canonrect(Rectangle r)
34 .PP
35 .B
36 int             eqpt(Point p, Point q)
37 .PP
38 .B
39 int             eqrect(Rectangle r, Rectangle s)
40 .PP
41 .B
42 int             ptinrect(Point p, Rectangle r)
43 .PP
44 .B
45 int             rectinrect(Rectangle r, Rectangle s)
46 .PP
47 .B
48 int             rectXrect(Rectangle r, Rectangle s)
49 .PP
50 .B
51 int             rectclip(Rectangle *rp, Rectangle b)
52 .PP
53 .B
54 void            combinerect(Rectangle *rp, Rectangle b)
55 .PP
56 .B
57 int             badrect(Rectangle r)
58 .PP
59 .B
60 int             Dx(Rectangle r)
61 .PP
62 .B
63 int             Dy(Rectangle r)
64 .PP
65 .B
66 Point   Pt(int x, int y)
67 .PP
68 .B
69 Rectangle       Rect(int x0, int y0, int x1, int y1)
70 .PP
71 .B
72 Rectangle       Rpt(Point p, Point q)
73 .SH DESCRIPTION
74 The functions
75 .IR Pt ,
76 .I Rect
77 and
78 .I Rpt
79 construct geometrical data types from their components.
80 .PP
81 .I Addpt
82 returns the Point
83 sum of its arguments:
84 .BI Pt( p .x+ q .x,
85 .IB p .y+ q .y) \f1.
86 .I Subpt
87 returns the Point
88 difference of its arguments:
89 .BI Pt( p .x- q .x,
90 .IB p .y- q .y) \f1.
91 .I Mulpt
92 returns the Point
93 .BI Pt( p .x* a ,
94 .IB p .y* a ) \f1.
95 .I Divpt
96 returns the Point
97 .BI Pt( p .x/ a ,
98 .IB p .y/ a ) \f1.
99 .PP
100 .I Rectaddpt
101 returns the Rectangle
102 .BI Rect(add( r .min,
103 .IB p ) \f1,
104 .BI add( r .max,
105 .IB p )) \f1;
106 .I rectsubpt
107 returns the Rectangle
108 .BI Rpt(sub( r .min,
109 .IB p ),
110 .BI sub( r .max,
111 .IB p ))\fR.
112 .PP
113 .I Insetrect
114 returns the Rectangle
115 .BI Rect( r .min.x+ n \f1,
116 .IB r .min.y+ n \f1,
117 .IB r .max.x- n \f1,
118 .IB r .max.y- n ) \f1.
119 .PP
120 .I Canonrect
121 returns a rectangle with the same extent as
122 .IR r ,
123 canonicalized so that
124 .B min.x
125
126 .BR max.x ,
127 and
128 .B min.y
129
130 .BR max.y .
131 .PP
132 .I Eqpt
133 compares its argument Points and returns
134 0 if unequal,
135 1 if equal.
136 .I Eqrect
137 does the same for its argument Rectangles.
138 .PP
139 .I Ptinrect
140 returns 1 if
141 .I p
142 is a point within
143 .IR r ,
144 and 0 otherwise.
145 .PP
146 .I Rectinrect
147 returns 1 if all the pixels in
148 .I r
149 are also in
150 .IR s ,
151 and 0 otherwise.
152 .PP
153 .I RectXrect
154 returns 1 if
155 .I r
156 and
157 .I s
158 share any point, and 0 otherwise.
159 .PP
160 .I Rectclip
161 clips in place
162 the Rectangle pointed to by
163 .I rp
164 so that it is completely contained within
165 .IR b .
166 The return value is 1 if any part of
167 .RI * rp
168 is within
169 .IR b .
170 Otherwise, the return value is 0 and
171 .RI * rp
172 is unchanged.
173 .PP
174 .I Combinerect
175 overwrites
176 .B *rp
177 with the smallest rectangle sufficient to cover all the pixels of
178 .B *rp
179 and
180 .BR b .
181 .PP
182 .I Badrect
183 returns 1 if
184 .I r
185 is zero, negative size or insanely huge rectangle.
186 It returns 0 otherwise.
187 .PP
188 The functions
189 .I Dx
190 and
191 .I Dy
192 give the width (Δx) and height (Δy) of a Rectangle.
193 They are implemented as macros.
194 .SH SOURCE
195 .B /sys/src/libdraw
196 .SH SEE ALSO
197 .IR graphics (2)