Determines the overlapping area between two rectangles.
fl! = rc_InterSect(x1,y1,w1,h1,x2,y2,w2,h2)
fl!:Boolean variable
x1,y1,w1,h1:integer expression;
x2,y2,w2,h2:variable names; return values
The rc_InterSect() function tests if two rectangles overlap. The upper left corner of the first rectangle is specified in x1 and y1, the width in w1 and the height in h1.
The upper left corner of the second rectangle is specified in x2 and y2, the width in w2 and the height in h2. If the two rectangles overlap the function returns True (-1), otherwise it returns a False (0).
The upper left corner of the overlapping area between the two rectangles is returned in x2 and y2, the width in w2 and the height in h2. Because of this the last four parameters in the rc_InterSect function must always be integer variables (ByRef parameter).
If the two rectangles do not overlap, the x2, y2, w2, and h2 variables contain the coordinates of a rectangle between the two given rectangles. The width and height are then either negative or 0.
The first four parameters can also be specified with expressions. The last four parameters must be given as variables. They are changed by rc_InterSect.
Auto a%, h%, w%, x%, y%
OpenW # 1
Box 10, 10, 400, 200
x% = 50 : y% = 50 : w% = 400 : h% = 400
Box x%, y%, x% + w%, y% + h%
If rc_InterSect(10, 10, 400, 200, x%, _
y%, w%, h%)
DefFill 4
PBox x%, y%, x% + w% - 10, y% + h% - 10
EndIf
Draws two rectangles and fills the overlappingarea with a pattern.
-
{Created by Sjouke Hamstra; Last updated: 22/10/2014 by James Gaite}