16 Rect(int x, int y, int bx, int by)
28 Rpt(Point min, Point max)
38 addpt(Point a, Point b)
46 subpt(Point a, Point b)
54 insetrect(Rectangle r, int n)
80 rectsubpt(Rectangle r, Point p)
90 rectaddpt(Rectangle r, Point p)
100 eqpt(Point p, Point q)
102 return p.x==q.x && p.y==q.y;
106 eqrect(Rectangle r, Rectangle s)
108 return r.min.x==s.min.x && r.max.x==s.max.x &&
109 r.min.y==s.min.y && r.max.y==s.max.y;
113 rectXrect(Rectangle r, Rectangle s)
115 return r.min.x<s.max.x && s.min.x<r.max.x &&
116 r.min.y<s.max.y && s.min.y<r.max.y;
120 rectinrect(Rectangle r, Rectangle s)
122 return s.min.x<=r.min.x && r.max.x<=s.max.x && s.min.y<=r.min.y && r.max.y<=s.max.y;
126 ptinrect(Point p, Rectangle r)
128 return p.x>=r.min.x && p.x<r.max.x &&
129 p.y>=r.min.y && p.y<r.max.y;
133 canonrect(Rectangle r)
136 if (r.max.x < r.min.x) {
141 if (r.max.y < r.min.y) {
150 combinerect(Rectangle *r1, Rectangle r2)
152 if(r1->min.x > r2.min.x)
153 r1->min.x = r2.min.x;
154 if(r1->min.y > r2.min.y)
155 r1->min.y = r2.min.y;
156 if(r1->max.x < r2.max.x)
157 r1->max.x = r2.max.x;
158 if(r1->max.y < r2.max.y)
159 r1->max.y = r2.max.y;
171 setalpha(u32int color, uchar alpha)
173 int red, green, blue;
175 red = (color >> 3*8) & 0xFF;
176 green = (color >> 2*8) & 0xFF;
177 blue = (color >> 1*8) & 0xFF;
178 /* ignore incoming alpha */
179 red = (red * alpha)/255;
180 green = (green * alpha)/255;
181 blue = (blue * alpha)/255;
182 return (red<<3*8) | (green<<2*8) | (blue<<1*8) | (alpha<<0*8);
192 r = va_arg(f->args, Rectangle);
193 return fmtprint(f, "%P %P", r.min, r.max);
201 p = va_arg(f->args, Point);
202 return fmtprint(f, "[%d %d]", p.x, p.y);