CanvasContext.setTransform

Reset the transform and invoke the transform by unit matrix, the transform is described by the variable of the method.

Parameters

It is Object type.

PropertyTypeDescription
scaleXNumberScale horizontally.
skewXNumberSkew horizontally.
skewYNumberSkew vertically.
scaleYNumberScale vertically.
translateXNumberTranslate horizontally.
translateYNumberTranslate vertically.

Sample Code

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

ctx.rotate(45 * Math.PI / 180)
ctx.setFillStyle('red')
ctx.fillRect(70,0,100,30)

ctx.setTransform(1, 1, 0, 1, 0, 0)
ctx.setFillStyle('#000')
ctx.fillRect(0, 0, 100, 100)

ctx.draw()