CanvasContext.translate

Translate the original point of the coordinate. The default original point is the upper-left corner

Parameters

It is Object type.

PropertyTypeDescription
xNumberThe offset of x coordinate.
yNumberThe offset of y coordinate.

Sample Code

copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')

ctx.strokeRect(20, 20, 250, 80)
ctx.translate(30, 30)
ctx.strokeRect(20, 20, 250, 80)
ctx.translate(30, 30)
ctx.strokeRect(20, 20, 250, 80)

ctx.draw()