CanvasContext.transform

A method in which a matrix is superimposed multiple times on the current transformation, and the matrix is described by the parameters of the method. You can scale, rotate, move, and tilt the context.

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.transform(1, 1, 0, 1, 0, 0)
ctx.setFillStyle('#000')
ctx.fillRect(0, 0, 100, 100)

ctx.draw()