CanvasContext.rotate

2020-08-26 16:39 更新

解釋:以原點(diǎn)為中心,原點(diǎn)可以用 translate 方法修改。順時(shí)針旋轉(zhuǎn)當(dāng)前坐標(biāo)軸。多次調(diào)用 rotate ,旋轉(zhuǎn)的角度會(huì)疊加。

方法參數(shù)

Number rotate :旋轉(zhuǎn)角度,以弧度計(jì)( degrees * Math.PI/180;degrees 范圍為 0~360 )。

示例 

在開(kāi)發(fā)者工具中打開(kāi)


圖片示例

圖片

代碼示例

<canvas canvas-id="myCanvas" class="myCanvas" />
Page({
    onLoad() {
        const canvasContext = swan.createCanvasContext('myCanvas');

        canvasContext.strokeRect(100, 10, 150, 100);
        canvasContext.rotate(20 * Math.PI / 180);
        canvasContext.strokeRect(100, 10, 150, 100);
        canvasContext.rotate(20 * Math.PI / 180);
        canvasContext.strokeRect(100, 10, 150, 100);

        canvasContext.draw();
    }
});


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)