小程序畫布旋轉(zhuǎn) CanvasContext.rotate(number rotate)
以原點(diǎn)為中心順時針旋轉(zhuǎn)當(dāng)前坐標(biāo)軸。多次調(diào)用旋轉(zhuǎn)的角度會疊加。原點(diǎn)可以用 translate 方法修改。
小程序插件:支持
參數(shù)
number rotate
旋轉(zhuǎn)角度,以弧度計 degrees * Math.PI/180;degrees 范圍為 0-360
示例代碼
const ctx = wx.createCanvasContext('myCanvas')
ctx.strokeRect(100, 10, 150, 100)
ctx.rotate(20 * Math.PI / 180)
ctx.strokeRect(100, 10, 150, 100)
ctx.rotate(20 * Math.PI / 180)
ctx.strokeRect(100, 10, 150, 100)
ctx.draw()
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)