小程序畫(huà)布旋轉(zhuǎn) CanvasContext.rotate(number rotate)
以原點(diǎn)為中心順時(shí)針旋轉(zhuǎn)當(dāng)前坐標(biāo)軸。多次調(diào)用旋轉(zhuǎn)的角度會(huì)疊加。原點(diǎn)可以用 translate 方法修改。
小程序插件:支持
參數(shù)
number rotate
旋轉(zhuǎn)角度,以弧度計(jì) 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) 來(lái)源:大學(xué)生新聞網(wǎng)
發(fā)布時(shí)間:2025-04-15 閱讀: