小程序畫布路徑縮放CanvasContext.scale
CanvasContext.scale(number scaleWidth, number scaleHeight)
在調用后,之后創建的路徑其橫縱坐標會被縮放。多次調用倍數會相乘。
小程序插件:支持
參數
number scaleWidth
橫坐標縮放的倍數 (1 = 100%,0.5 = 50%,2 = 200%)
number scaleHeight
縱坐標軸縮放的倍數 (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()