PP.fixPosition

Syntax

fixPosition(box: Object, angle: Number, width: Number, height: Number);

Parameters

box. Rectangle defined with a JSON object that has the following properties: x and y - coordinates of the top left corner of the initial rectangle, width and height - its width and height.

angle. Rectangle rotation angle.

width. New width of the rectangle.

height. New height of the rectangle.

Description

The fixPosition method changes size and rotation angle for specified rectangle.

Comments

This method returns a JSON object with the following properties: x - rectangle width, y - rectangle height.

Example

To execute the example, the HTML page must contain links to the PP.js and PP.GraphicsBase.js scenario files. Create a rectangle, then change its size and rotation angle:

// Determine rectangle area
var box = {
    x: 20, // Horizontal coordinate of the top left corner
    y: 30, // Vertical coordinate of the top left corner
    width: 150, // Width
    height: 100 // Height
};
// Change settings of this rectangle area
var result = PP.fixPosition(box, 45, 75, 50);
console.log("Initial coordinates of the top left corner: (" + box.x + ", " + box.y + ")");
console.log("New coordinates of the top left corner: (" + result.x + ", " + result.y + ")");

After executing the example the browser console displays coordinates of the top left corner for the initial and changed rectangles:

Initial coordinates of the top left corner: (20, 30)
New coordinates of the top left corner: (-75, -50)

See also:

PP