Rect.addBezierCurve

Syntax

addBezierCurve(p0x: Number, p0y: Number, p1x: Number, p1y: Number, p2x: Number, p2y: Number, p3x: Number, p3y: Number);

Parameters

p0x. The X coordinate of the first point.

p0y. The Y coordinate of the first point.

p1x. The X coordinate of the second point.

p1y. The Y coordinate of the second point.

p2x. The X coordinate of the third point.

p2y. The Y coordinate of the third point.

p3x. The X coordinate of the forth point.

p3y. The Y coordinate of the forth point.

Description

The addBezierCurve method extends a rectangle on adding a Bezier cubic curve.

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

Add a Bezier cubic curve built by 4 points with the following coordinates: (10, 20), (20, 10), (20, 20), (30, 10):

// Add a Bezier cubic curve
rect.addBezierCurve(10, 20, 20, 10, 20, 20, 30, 10);
// Output top left corner coordinates, rectangle width and height
console.log('The X coordinate of the rectangle's top left corner: ' + rect.getLeft());
console.log('The Y coordinate of the rectangle's top left corner: ' + rect.getTop());
console.log('Rectangle height: ' + rect.getHeight());
console.log('Rectangle 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: 10

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

Rectangle height: 10

Rectangle's width: 20

See also:

Rect