Partager via


translate method

Specifies values to move the origin point in a canvas.

 

Syntax

object.translate(x, y);

Parameters

  • x [in]
    Type: number

    The value to add to horizontal (or x) coordinates.

  • y [in]
    Type: number

    The value to add to vertical (or y) coordinates.

Return value

This method does not return a value.

Standards information

Remarks

The ICanvasRenderingContext2D::translate method effectively remaps the (0,0) origin on a canvas. You can specify one or both parameters. When you call a canvas method such as ICanvasRenderingContext2D::lineTo, the translate value is added to the respective x-coordinate and y-coordinate values. ICanvasRenderingContext2D::translate does not return an error if either value or any derived value is out of the canvas dimensions.