Sooda
Diversity enchants
- Reaction score
- 318
Compares two rects and tells how they are positioned towards each other.
Use it like that:
'tempRect1' and 'tempRect2' are region variables.
JASS:
function IsRectOnTop takes rect whichRect, rect comparedTo returns boolean
return GetRectMinX(whichRect) == GetRectMinX(comparedTo) and GetRectMaxX(whichRect) == GetRectMaxX(comparedTo) and GetRectMinY(whichRect) > GetRectMinY(comparedTo) and GetRectMaxY(whichRect) > GetRectMaxY(comparedTo)
endfunction
function IsRectOnBottom takes rect whichRect, rect comparedTo returns boolean
return GetRectMinX(whichRect) == GetRectMinX(comparedTo) and GetRectMaxX(whichRect) == GetRectMaxX(comparedTo) and GetRectMinY(whichRect) < GetRectMinY(comparedTo) and GetRectMaxY(whichRect) < GetRectMaxY(comparedTo)
endfunction
function IsRectOnRight takes rect whichRect, rect comparedTo returns boolean
return GetRectMinY(whichRect) == GetRectMinY(comparedTo) and GetRectMaxY(whichRect) == GetRectMaxY(comparedTo) and GetRectMinX(whichRect) > GetRectMinX(comparedTo) and GetRectMaxX(whichRect) > GetRectMaxX(comparedTo)
endfunction
function IsRectOnLeft takes rect whichRect, rect comparedTo returns boolean
return GetRectMinY(whichRect) == GetRectMinY(comparedTo) and GetRectMaxY(whichRect) == GetRectMaxY(comparedTo) and GetRectMinX(whichRect) < GetRectMinX(comparedTo) and GetRectMaxX(whichRect) < GetRectMaxX(comparedTo)
endfunction
function IsRectOnRightTop takes rect whichRect, rect comparedTo returns boolean
return GetRectMinX(whichRect) > GetRectMinX(comparedTo) and GetRectMaxX(whichRect) > GetRectMaxX(comparedTo) and GetRectMinY(whichRect) > GetRectMinY(comparedTo) and GetRectMaxY(whichRect) > GetRectMaxY(comparedTo)
endfunction
function IsRectOnRightBottom takes rect whichRect, rect comparedTo returns boolean
return GetRectMinX(whichRect) > GetRectMinX(comparedTo) and GetRectMaxX(whichRect) > GetRectMaxX(comparedTo) and GetRectMinY(whichRect) < GetRectMinY(comparedTo) and GetRectMaxY(whichRect) < GetRectMaxY(comparedTo)
endfunction
function IsRectOnLeftTop takes rect whichRect, rect comparedTo returns boolean
return GetRectMinX(whichRect) < GetRectMinX(comparedTo) and GetRectMaxX(whichRect) < GetRectMaxX(comparedTo) and GetRectMinY(whichRect) > GetRectMinY(comparedTo) and GetRectMaxY(whichRect) > GetRectMaxY(comparedTo)
endfunction
function IsRectOnLeftBottom takes rect whichRect, rect comparedTo returns boolean
return GetRectMinX(whichRect) < GetRectMinX(comparedTo) and GetRectMaxX(whichRect) < GetRectMaxX(comparedTo) and GetRectMinY(whichRect) < GetRectMinY(comparedTo) and GetRectMaxY(whichRect) < GetRectMaxY(comparedTo)
endfunction
function GetRectPos takes rect whichRect, rect comparedTo returns nothing
if IsRectOnTop(whichRect, comparedTo) then
call BJDebugMsg("Rect is on top!")
elseif IsRectOnBottom(whichRect, comparedTo) then
call BJDebugMsg("Rect is on bottom!")
elseif IsRectOnRight(whichRect, comparedTo) then
call BJDebugMsg("Rect is on right!")
elseif IsRectOnLeft(whichRect, comparedTo) then
call BJDebugMsg("Rect is on left!")
elseif IsRectOnRightTop(whichRect, comparedTo) then
call BJDebugMsg("Rect is on right top!")
elseif IsRectOnRightBottom(whichRect, comparedTo) then
call BJDebugMsg("Rect is on right bottom!")
elseif IsRectOnLeftTop(whichRect, comparedTo) then
call BJDebugMsg("Rect is on left top!")
elseif IsRectOnLeftBottom(whichRect, comparedTo) then
call BJDebugMsg("Rect is on left bottom!")
else
call BJDebugMsg("Unknown rect position!")
endif
endfunction
Use it like that:
Code:
Test
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Set tempRect1 = Region 001 <gen>
Set tempRect2 = Region 000 <gen>
Custom script: call GetRectPos(udg_tempRect1, udg_tempRect2)