Rect.addX

Syntax

addX(x: Number);

Parameters

x. Extension value.

Description

The addX method extends a rectangle horizontally for a specified value.

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");

Extend the rectangle left and right by 5 pixels:

// Extend the rectangle
rect.addX(5);
// Output the X coordinate value of rectangle's top left corner and rectangle's width
console.log('The X coordinate of rectangle's top left corner: ' + rect.getLeft());
console.log('Rectangle's width: ' + rect.getWidth());

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

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

Rectangle's width: 15

See also:

Rect