Point in Rectangle

Rectangle bounds test

This simple method allows testing of a coordinate in 2D space against the X,Y position and Width and Height of a given rectangle to determine if the point falls within the rectangles bounds.

View example

function pointInRect(x, y, rx, ry, rw, rh)
{
	return (x>=rx && x<=(rx+rw) && y>=ry && y<=(ry+rh));
}

Page loaded in 0.015 second(s).