小程序畫布路徑縮放CanvasContext.scale
CanvasContext.scale(number scaleWidth, number scaleHeight)
在調(diào)用后,之后創(chuàng)建的路徑其橫縱坐標(biāo)會被縮放。多次調(diào)用倍數(shù)會相乘。
小程序插件:支持
參數(shù)
number scaleWidth
橫坐標(biāo)縮放的倍數(shù) (1 = 100%,0.5 = 50%,2 = 200%)
number scaleHeight
縱坐標(biāo)軸縮放的倍數(shù) (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()
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)