/

HTML / CSS / JavaScript Tutorial

JavaScript canvas2d object method: translate()

[this page | pdf | back links]

The translate() method of the JavaScript DOM object returned by the getContext("2d") method applied to the HTML <canvas> element applies a translation to current drawing, i.e. adjusts the position of its origin, remapping the position of the coordinate (0,0).

 

It has the following syntax with the following parameters.

 

context.translate(x, y)

 

Parameter

Required / Optional

Description

x

Required

Value added to x-coordinates

y

Required

Value added to y-coordinates

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile