Rect.isPointInBox

Syntax

isPointInBox(x: Number, y: Number);

Parameters

x. The X coordinate of the point.

y. The Y coordinate of the point.

Description

The isPointInBox method checks if a point is in the rectangle area.

Comments

The method returns True if the point is in the rectangle's area, otherwise it returns False.

Example

To execute the example, add a link to PP.js scenario file to HTML page in the <head> tag. The following code is executed in the console browser. Create a rectangle 10 pixels high and wide, the top left corner of which has the coordinates (10, 10).

// Create a rectangle
var rect = new PP.Rect("10,10,10,10");

Check if the point with the coordinates (20, 20) is in the rectangle's area:

// Check if the point with the coordinates (20, 20) is in the rectangle's area
if (rect.isPointInBox(20, 20)) {
    console.log("The point is in the rectangle's area");
} else {
    console.log("The point is outside rectangle's area");
}

As a result, the console displays check result if the point is in the rectangle's area:

The point is in the rectangle's area

See also:

Rect