Only define LUA when lua is actually on the PATH
[notion/jeffpc.git] / ioncore / rectangle.c
blob3c9b90c37f8418cde1ff570352e3614bbb35684c
1 /*
2 * ion/ioncore/rectangle.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <libtu/minmax.h>
10 #include <libextl/extl.h>
12 #include "common.h"
13 #include "rectangle.h"
16 void rectangle_constrain(WRectangle *g, const WRectangle *bounds)
18 const WRectangle tmpg=*g;
20 g->x=minof(maxof(tmpg.x, bounds->x), tmpg.x+tmpg.w-1);
21 g->y=minof(maxof(tmpg.y, bounds->y), tmpg.y+tmpg.h-1);
22 g->w=maxof(1, minof(bounds->x+bounds->w, tmpg.x+tmpg.w)-g->x);
23 g->h=maxof(1, minof(bounds->y+bounds->h, tmpg.y+tmpg.h)-g->y);
27 bool rectangle_contains(const WRectangle *g, int x, int y)
29 return (x>=g->x && x<g->x+g->w && y>=g->y && y<g->y+g->h);
33 void rectangle_debugprint(const WRectangle *g, const char *n)
35 fprintf(stderr, "%s %d, %d; %d, %d\n", n, g->x, g->y, g->w, g->h);
39 int rectangle_compare(const WRectangle *g, const WRectangle *h)
41 return ((g->x!=h->x ? RECTANGLE_X_DIFF : 0) |
42 (g->y!=h->y ? RECTANGLE_Y_DIFF : 0) |
43 (g->w!=h->w ? RECTANGLE_W_DIFF : 0) |
44 (g->h!=h->h ? RECTANGLE_H_DIFF : 0));