#include "Primitives.h" #include struct Box *newBox(int x, int y, int w, int h, int flags) { struct Box *box = malloc(sizeof(struct Box)); if (box == NULL) return NULL; box->x = x; box->y = y; box->w = w; box->h = h; box->flags = flags; return box; } int cleanBox(struct Box *box) { box->h = 0; box->w = 0; box->x = 0; box->y = 0; box->flags = 0; } int freeBox(struct Box *box) { if (box == NULL) return 1; free(box); return 0; } int inBox(struct Box box, int x, int y) { if (x >= box.x && x <= box.x+box.w) { if (y >= box.y && y <= box.y+box.h) { return 1; } } return 0; }