Code archives/Algorithms/Point in a rectangle detection
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This function will return zero if the given point (iPointX,iPointY) is inside the rect (iXPos1,iYPos1,iXPos2,iYPos2). There maybe be some odd results from coords that are negative. This function is best if it can be made 'inline'. Its also possible to modify it to make a faster rectoverlap command *evil grin*. Should help all the people out there coding GUI's for Blitz at the very least! The rectoverlap version of this is here!. | |||||
;Coded by Stephen Greener ;Shagwana@sublimegames.com ;Returns 0 if inside the box else another number if outside Function DetectPointInsideRect(iPointX,iPointY,iXPos1,iYPos1,iXPos2,iYPos2) ;[best if we can INLINE it *evil grin*] Return ((((iPointX-iXPos1) Xor (iPointX-iXPos2)) And ((iPointY-iYPos1) Xor (iPointY-iYPos2))) And $80000000) End Function ;Can be edited to make a faster rectoverlap command for blitz! |
Comments
None.
Code Archives Forum