2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Graphics function AndRectRect()
9 #include <graphics/gfx.h>
10 #include <clib/macros.h>
12 /*****************************************************************************
15 #include <proto/alib.h>
20 struct Rectangle
*rect1
,
21 struct Rectangle
*rect2
,
22 struct Rectangle
*intersect
)
25 Calculate the intersection rectangle between the
26 given Rectangle rect1 and the given Rectangle rect2
27 leaving the result in intersect (if intersect != NULL).
30 rect1 - pointer to 1st Rectangle
31 rect2 - pointer to 2nd Rectangle
32 intersect - pointer to rectangle which will hold result.
35 TRUE if rect1 and rect2 do intersect. In this case intersect
36 will contain the intersection rectangle.
38 FALSE if rect1 and rect2 do not overlap. "intersect" will
39 then be left unchanged.
52 15-12-2000 stegerg implemented
54 *****************************************************************************/
56 WORD MinX
= MAX(rect1
->MinX
, rect2
->MinX
);
57 WORD MinY
= MAX(rect1
->MinY
, rect2
->MinY
);
58 WORD MaxX
= MIN(rect1
->MaxX
, rect2
->MaxX
);
59 WORD MaxY
= MIN(rect1
->MaxY
, rect2
->MaxY
);
61 if ((MinX
> MaxX
) || (MinY
> MaxY
))
66 intersect
->MinX
= MinX
;
67 intersect
->MinY
= MinY
;
68 intersect
->MaxX
= MaxX
;
69 intersect
->MaxY
= MaxY
;