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.
Property | Type | Description |
scaleX | Number | Scale horizontally. |
skewX | Number | Skew horizontally. |
skewY | Number | Skew vertically. |
scaleY | Number | Scale vertically. |
translateX | Number | Translate horizontally. |
translateY | Number | Translate 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()