牛骨文教育服务平台(让学习变的简单)

在微信小程序中调用scale方法对横纵坐标进行缩放


scale


定义

在调用scale方法后,之后创建的路径其横纵坐标会被缩放。多次调用scale,倍数会相乘。

参数

QQ截图20170208145233.png

例子

const ctx = wx.createCanvasContext('myCanvas')

ctx.strokeRect(10, 10, 25, 15)
ctx.scale(2, 2)
ctx.strokeRect(10, 10, 25, 15)
ctx.scale(2, 2)
ctx.strokeRect(10, 10, 25, 15)

ctx.draw()

201612241806425160.png