Rect.addQuadraticCurve

Syntax

addQuadraticCurve(p0x: Number, p0y: Number, p1x: Number, p1y: Number, p2x: Number, p2y: 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.

Description

The addQuadraticCurve method extends a rectangle on adding a Bezier quadratic 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 quadratic curve built by 3 points with the following coordinates: (10, 20), (20, 10), (30, 10):

// Add a Bezier quadratic curve
rect.addQuadraticCurve(10, 20, 20, 10, 30, 10);
// Output top left corner coordinates, rectangle's width and height
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: 10

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

Rectangle's height: 10.534979423868370

Rectangle's width: 20

See also:

Rect