codecamp

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

微信小程序 canvas接口和方法绘图接口和方法

canvasContext.scale


定义

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

参数

参数类型说明
scaleWidthNumber横坐标缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%)
scaleHeightNumber纵坐标轴缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%)

例子

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()


微信小程序 canvas接口和方法绘图接口和方法

在微信小程序API绘图中创建三次方贝塞尔曲线路径
微信小程序API 绘图对坐标轴进行顺时针旋转
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定