Name
Intersection -- compute intersection of two rectangles (V6.1)
Synopsis
ix, iy, iw, ih = Intersection(x1, y1, w1, h1, x2, y2, w2, h2)
Function
This function computes the intersection between the two rectangles whose positions and dimensions are passed to it. If the two rectangles don't intersect, the returned dimensions will be 0.

Inputs
x1
x position of first rectangle
y1
y position of first rectangle
w1
width of first rectangle
h1
height of first rectangle
x2
x position of second rectangle
y2
y position of second rectangle
w2
width of second rectangle
h2
height of second rectangle
Results
ix
x position of intersecting rectangle
iy
y position of intersecting rectangle
iw
width of intersecting rectangle
ih
height of intersecting rectangle
Example
SetFillStyle(#FILLCOLOR)
Box(100, 100, 80, 100, #RED)
Box(160, 120, 100, 40, #YELLOW)

ix, iy, iw, ih = Intersection(100, 100, 80, 100, 160, 120, 100, 40)

Box(ix, iy, iw, ih, #GREEN)
The code above computes the intersection of the red and yellow rectangles and visualizes it by drawing a green rectangle.

Show TOC