Rect.addBoundingBox

Syntax

addBoundingBox(bb: PP.Rect);

Parameters

bb. Rectangle.

Description

The addBoundingBox method combines a rectangle with another rectangle.

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 (25, 25).

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

Combine the rectangle with the other rectangle that has the following parameters: top left corner coordinates (5, 5), height and width: 10:

// Combine the rectangle with the other rectangle
rect.addBoundingBox(PP.Rect(5, 5, 10, 10));
// Output value of top left corner coordinates, rectangle's height and width
console.log('The X coordinate of rectangle's top left corner: ' + rect.getLeft());
console.log('The Y coordinate of rectangle's top left corner: ' + rect.getTop());
console.log('Rectangle's height: ' + rect.getHeight());
console.log('Rectangle's width: ' + rect.getWidth());

As a result, the console displays values of top left corner coordinates, rectangle's height and width:

The X coordinate of rectangle's top left corner: 5

The Y coordinate of rectangle's top left corner: 5

Rectangle height: 30

Rectangle width: 30

See also:

Rect