29 #include "common/memstream.h" 36 void set(int16 nx, int16 ny) {
63 return Point16(a.x + b.x, a.y + b.y);
71 return Point16(a.x - b.x, a.y - b.y);
75 return Point16(a.x * (int16)b, a.y * (int16)b);
79 return Point16(a.x / (int16)b, a.y / (int16)b);
83 return Point16(a.x >> (int16)b, a.y >> (int16)b);
87 return Point16(a.x << (int16)b, a.y << (int16)b);
91 return a.x == b.x && a.y == b.y;
95 return a.x != b.x || a.y != b.y;
106 void operator*= (
int a) {
110 void operator/= (
int a) {
114 void operator>>=(
int a) {
118 void operator<<=(
int a) {
123 void debugPrint(
int level = 0,
const char *msg =
"Point32:") {
124 debug(level,
"%s %d,%d", msg, x, y);
143 void set(int16 nx, int16 ny) {
201 return Point16((int16)x, (int16)y);
211 return Point32(a.x + b.x, a.y + b.y);
219 return Point32(a.x - b.x, a.y - b.y);
223 return Point32(a.x * (int32)b, a.y * (int32)b);
227 return Point32(a.x / (int32)b, a.y / (int32)b);
231 return Point32(a.x >> (int32)b, a.y >> (int32)b);
235 return Point32(a.x << (int32)b, a.y << (int32)b);
239 return a.x == b.x && a.y == b.y;
243 return a.x != b.x || a.y != b.y;
254 void operator*= (
int a) {
258 void operator/= (
int a) {
262 void operator>>=(
int a) {
266 void operator<<=(
int a) {
271 void debugPrint(
int level = 0,
const char *msg =
"Point32:") {
272 debug(level,
"%s %d,%d", msg, x, y);
283 int16 x, y, width, height;
296 Rect16() { x = y = width = height = 0; }
297 Rect16(int16 nx, int16 ny, int16 nw, int16 nh) {
312 width = (int16)(b.x - a.x);
313 height = (int16)(b.y - a.y);
331 && a.width == b.width
332 && a.height == b.height;
338 || a.width != b.width
339 || a.height != b.height;
343 return Rect16(a.x + b.x, a.y + b.y, a.width, a.height);
347 return Rect16(a.x + b.x, a.y + b.y, a.width, a.height);
351 return Rect16(a.x - b.x, a.y - b.y, a.width, a.height);
365 void expand(int16 dx, int16 dy);
366 void expand(int16 left, int16 top, int16 right, int16 bottom);
369 return width <= 0 || height <= 0;
372 bool ptInside(int16 px, int16 py)
const {
373 return px >= x && px < (x + width) && py >= y && py < (y + height);
375 bool ptInside(
const Point16 p)
const {
376 return ptInside(p.x, p.y);
378 bool overlap(
const Rect16 &r)
const;
396 Rect32() { x = y = width = height = 0; }
397 Rect32(int32 nx, int32 ny, int32 nw, int32 nh) {
412 width = (int32)(b.x - a.x);
413 height = (int32)(b.y - a.y);
424 width = (int32)(b.x - a.x);
425 height = (int32)(b.y - a.y);
435 return Rect16((int16)x, (int16)y, (int16)width, (int16)height);
443 && a.width == b.width
444 && a.height == b.height;
450 || a.width != b.width
451 || a.height != b.height;
455 return Rect32(a.x + b.x, a.y + b.y, a.width, a.height);
459 return Rect32(a.x + b.x, a.y + b.y, a.width, a.height);
463 return Rect32(a.x - b.x, a.y - b.y, a.width, a.height);
467 return Rect32(a.x + b.x, a.y + b.y, a.width, a.height);
471 return Rect32(a.x - b.x, a.y - b.y, a.width, a.height);
494 void expand(int32 dx, int32 dy);
495 void expand(int32 left, int32 top, int32 right, int32 bottom);
498 return width <= 0 || height <= 0;
501 bool ptInside(int32 px, int32 py)
const {
502 return px >= x && px < (x + width) && py >= y && py < (y + height);
504 bool ptInside(
const Point16 p)
const {
505 return ptInside(p.x, p.y);
508 bool overlap(
const Rect32 &r)
const;
Definition: memstream.h:194
void debug(MSVC_PRINTF const char *s,...) GCC_PRINTF(1