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;
162 ulong drawld2chan[] = {
170 setalpha(ulong color, uchar alpha)
172 int red, green, blue;
174 red = (color >> 3*8) & 0xFF;
175 green = (color >> 2*8) & 0xFF;
176 blue = (color >> 1*8) & 0xFF;
177 /* ignore incoming alpha */
178 red = (red * alpha)/255;
179 green = (green * alpha)/255;
180 blue = (blue * alpha)/255;
181 return (red<<3*8) | (green<<2*8) | (blue<<1*8) | (alpha<<0*8);