CanvasContext.setFillStyle

2020-08-26 16:39 更新

解釋:設(shè)置填充色。

方法參數(shù)

Color color

示例 

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


圖片示例

代碼示例

<canvas canvas-id="myCanvas" class="myCanvas" />

    Page({
        onLoad() {
            const canvasContext = this.createCanvasContext('myCanvas');
            canvasContext.setFillStyle('blue');
            canvasContext.fillRect(0, 0, 50, 50);
            // 使用十六進(jìn)制函數(shù)
            canvasContext.setFillStyle('#ffff00');
            canvasContext.fillRect(70, 0, 50, 50);
            // 使用 rgba()函數(shù)
            canvasContext.setFillStyle('rgba(255,255,0, 0.3)');
            canvasContext.fillRect(140, 0, 50, 50);
            canvasContext.draw();
        }
    });


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

    掃描二維碼

    下載編程獅App

    公眾號
    微信公眾號

    編程獅公眾號