注冊

微信小程序API繪圖createCircularGradient,創(chuàng)建微信小程序圓形漸變

2017-12-22
導讀:繪圖接口和方法 canvasContext.createCircularGradient 定義 創(chuàng)建一個圓形的漸變顏色。 Tip : 起點在圓心,終點在圓環(huán)。 Tip : 需要使用 addColorStop() 來指定漸變點,至少要兩個。 參數(shù) 參數(shù) 類型...

 


canvasContext.createCircularGradient


定義

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

Tip: 起點在圓心,終點在圓環(huán)。

Tip: 需要使用addColorStop()來指定漸變點,至少要兩個。

參數(shù)

參數(shù) 類型 定義
x Number 圓心的x坐標
y Number 圓心的y坐標
r Number 圓的半徑

例子

const ctx = wx.createCanvasContext('myCanvas')

// Create circular gradient
const grd = ctx.createCircularGradient(75, 50, 50)
grd.addColorStop(0, 'red')
grd.addColorStop(1, 'white')

// Fill with gradient
ctx.setFillStyle(grd)
ctx.fillRect(10, 10, 150, 80)
ctx.draw()

 

更多微信小程序開發(fā)教程,可以關注hi小程序。
重磅推薦:小程序開店目錄

第一部分:小商店是什么

第二部分:如何開通一個小商店

第三部分:如何登錄小商店

第四部分:開店任務常見問題

第五部分:小商店可以賣什么

第六部分:HiShop小程序特色功能

第七部分:小程序直播

第八部分:小程序收貨/物流

第九部分:小程序怎么結(jié)算

第十部分:小程序客服

第十一部分:電商創(chuàng)業(yè)

第十二部分:小程序游戲開發(fā)