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 * was used by libmemlayer/line.c; made static, instead of deleting it,
171 * to avoid updating many binaries on sources.
173 static int log2[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 };
176 setalpha(ulong color, uchar alpha)
178 int red, green, blue;
180 red = (color >> 3*8) & 0xFF;
181 green = (color >> 2*8) & 0xFF;
182 blue = (color >> 1*8) & 0xFF;
183 /* ignore incoming alpha */
184 red = (red * alpha)/255;
185 green = (green * alpha)/255;
186 blue = (blue * alpha)/255;
187 return (red<<3*8) | (green<<2*8) | (blue<<1*8) | (alpha<<0*8);