Warcraft III resources & community, 2003–2006 · archived

IntersectionRects

not rated
Submitted by KaTTaNaVariable Change0 downloads
Returns the area where the two rects overlap. If the rects doesn't overlap, it returns null.

Source

function IntersectionRects takes rect r1, rect r2 returns rect
    local real x1 = RMaxBJ(GetRectMinX(r1), GetRectMinX(r2))
    local real x2 = RMinBJ(GetRectMaxX(r1), GetRectMaxX(r2))
    local real y1 = RMaxBJ(GetRectMinY(r1), GetRectMinY(r2))
    local real y2 = RMinBJ(GetRectMaxY(r1), GetRectMaxY(r2))
    if ( x1 > x2 ) or ( y1 > y2 ) then
        return null
    endif
    return Rect(x1, x2, y1, y2)
endfunction

Comments

0

No comments.