Partager via


rect method

Creates a new closed rectangular subpath.

 

Syntax

object.rect(x, y, w, h);

Parameters

  • x [in]
    Type: number

    The x-coordinate, in pixels, of the upper-left corner of the rectangle in relation to the coordinates of the canvas.

  • y [in]
    Type: number

    The y-coordinate, in pixels, of the upper-left corner of the rectangle in relation to the coordinates of the canvas.

  • w [in]
    Type: number

    The width, in pixels, of the rectangle in relation to the coordinates of the canvas.

  • h [in]
    Type: number

    The height, in pixels, of the rectangle in relation to the coordinates of the canvas.

Return value

This method does not return a value.

Standards information

Remarks

The ICanvasRenderingContext2D::rect method creates a closed path for the rectangle and then starts a new subpath at the point (x, y). You can fill the rectangle by using the ICanvasRenderingContext2D::fillStyle property and the ICanvasRenderingContext2D::fill method.

See also

ICanvasRenderingContext2D::fillStyle

ICanvasRenderingContext2D::beginPath

ICanvasRenderingContext2D::fillRect