addPoint(x: Number, y: Number);
x. Horizontal extension value.
y. Vertical extension value.
The addPoint method extends a rectangle vertically and horizontally to the specified point.
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");
Extend a rectangle by all sides by 5 pixels:
// Extend rectangle rect.addPoint(5, 5); // Output coordinates of the top left corner, rectangle's height and width console.log('Coordinate X of rectangle's top left corner: ' + rect.getLeft()); console.log('Coordinate Y 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's height: 15
Rectangle's width: 15
See also: