Simple Rectangle conversion code

For those of you who want to use one type of rectangle or another, here
is code to convert the two types:

typedef struct {
int x, y;
int w, h;
} rect;

typedef struct {
int minx, maxx;
int miny, maxy;
} area;

void RectToArea(rect *r, area *a)
{
area->minx = rect->x;
area->miny = rect->y;
area->maxx = rect->x+rect->w-1;
area->maxy = rect->y+rect->h-1;
}

void AreaToRect(area *a, rect *r)
{
rect->x = area->minx;
rect->y = area->miny;
rect->h = area->maxx-area->minx+1;
rect->w = area->maxy-area->miny+1;
}

Using these, you can use areas internally and convert them to rects to
pass to SDL, or vice versa if SDL rectangles change.

I had a header that provided full manipulation macros for both types, but
I erased it… oops.

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/