Is there a func. to find if a point is in a rect?

BlitzMax Forums/BlitzMax Beginners Area/Is there a func. to find if a point is in a rect?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I did a speed comparison between my final InRect() function (the flexible one), and fredborg's code.

Fredborg your code took 4518 millisecs to do 10 million calls. My code took 4662. Yours is very slightly faster. Not all the time though. Sometimes I got better numbers on mine, not sure why.

My fixed-position code is about 4620 - getting closer. Strangely my square routine is a bit slower than my rect one. lol

But anyway, yes, Fredborg, congrats, your routine is actually the fastest so far (just ;-D)

Although THIS:
Function PointInRect:Int(x:Int,y:Int,bx:Int,by:Int,bx2:Int,by2:Int)

        Return (x < bx2) & (y < by2) & (x > bx) & (y > by)

End Function


should be faster still. (It is, 4543 millisecs :-)

Interestingly >= and <= are slower than > and <.