Canvas.drawPoly

Syntax

drawPoly(pointArr: Array, drawFill: Boolean, drawStroke: Boolean);

Parameters

pointsArr. Array of points as instances of the PP.Point class or an object that contains the x and y fields.

drawFill. It determines whether polyline is filled. If the parameter is set to True, polyline is filled.

drawStroke. It determines whether polyline borders are rendered. If the parameter is set to True, borders are rendered.

Description

The drawPoly method draws a polyline on the canvas.

Comments

The polyline is displayed on the canvas after calling the Canvas.flush method.

Polyline is a continuous line formed from one or more joined lines.

Example

To execute the example the page must contain the Canvas component named canvas (see Example of Creating the Canvas Component). Render a filled circle and a filled line on the canvas:

// Set shape fill style
canvas.setFillStyle("#FFE23D");
// Enable rendering of polyline
canvas.beginPath(True, False);
canvas.drawPoly([
    {
        x: 60,
        y: 100
    },
    {
        x: 200,
        y: 20
    },
    {
        x: 340,
        y: 100
    },
    {
        x: 200,
        y: 180
    },
    {
        x: 60,
        y: 100
    }
], True, False);
// Disable rendering of polyline
canvas.endPath(False);
// Set shape fill style
canvas.setFillStyle("#60A1FA");
// Draw a filled circle but without borders
canvas.drawCircle(200, 100, 50, True, False);
// Get canvas changes
canvas.flush();

As a result a circle and a line are rendered on the canvas:

See also:

Canvas