Home | Reviews | GUIpedia | Forum | Fun500


ksroverlaps()
FreeBASIC code that determines whether two windows overlap. Fast. [code]type rectangle x1 as integer y1 as integer x2 as integer y2 as integer end type '========== declare function overlaps(window1 as rectangle, window2 as rectangle) as byte declare function intersects(ax1 as integer, ay1 as integer,_ ax2 as integer, ay2 as integer,_ bx1 as integer, by1 as integer,_ bx2 as integer, by2 as integer) as byte '========== function overlaps(window1 as rectangle, window2 as rectangle) as byte if intersects(window1.x1, window1.y1, window1.x1, window1.y2,_ window2.x1, window2.y1, window2.x2, window2.y1) then return -1 '1v1 > 2h1 if intersects(window1.x1, window1.y1, window1.x1, window1.y2,_ window2.x1, window2.y2, window2.x2, window2.y2) then return -1 '1v1 > 2h2 if intersects(window1.x2, window1.y1, window1.x2, window1.y2,_ window2.x1, window2.y1, window2.x2, window2.y1) then return -1 '1v2 > 2h1 if intersects(window1.x2, window1.y1, window1.x2, window1.y2,_ window2.x1, window2.y2, window2.x2, window2.y2) then return -1 '1v2 > 2h2 if intersects(window1.x1, window1.y1, window1.x2, window1.y1,_ window2.x1, window2.y1, window2.x1, window2.y2) then return -1 '1h1 > 2v1 if intersects(window1.x1, window1.y1, window1.x2, window1.y1,_ window2.x2, window2.y1, window2.x2, window2.y2) then return -1 '1h1 > 2v2 if intersects(window1.x1, window1.y2, window1.x2, window1.y2,_ window2.x1, window2.y1, window2.x1, window2.y2) then return -1 '1h2 > 2v1 if intersects(window1.x2, window1.y2, window1.x2, window1.y2,_ window2.x2, window2.y1, window2.x2, window2.y2) then return -1 '1h2 > 2v2 end function function intersects(ax1 as integer, ay1 as integer,_ ax2 as integer, ay2 as integer,_ bx1 as integer, by1 as integer,_ bx2 as integer, by2 as integer) as byte if ax1 = ax2 then 'a is vertical return (ay1 < by1) and (by1 < ay2) and (bx1 < ax1) and (ax1 < bx2) else return (by1 < ay1) and (ay1 < by2) and (ax1 < bx1) and (bx1 < ax2) end if end function[/code]
2009-03-215:51 PM

agumaRe:overlaps()
Thanks, I'll be using this in Spark!
2009-03-216:58 PM

BASIC Programming Help


2021 Brandon Cornell