CanvasContext.createCircularGradient

2020-08-26 16:38 更新

解釋:創(chuàng)建一個圓形的漸變顏色。

方法參數(shù)

Number x,Number y,Number z

參數(shù)名屬性必填默認值說明

x

Number

圓心的 x 坐標

y

Number

圓心的 y 坐標

z

Number

圓的半徑

示例 

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


圖片示例

圖片

代碼示例

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

        // Create circular gradient
        const grd = canvasContext.createCircularGradient(75, 50, 50);
        grd.addColorStop(0, 'red');
        grd.addColorStop(1, 'blue');

        // Fill with gradient
        canvasContext.setFillStyle(grd);
        canvasContext.fillRect(30, 30, 150, 80);
        canvasContext.draw();
    }
});


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號