微信小程序API繪圖createCircularGradient,創(chuàng)建微信小程序圓形漸變
2017-12-22
導(dǎo)讀:繪圖接口和方法 canvasContext.createCircularGradient 定義 創(chuàng)建一個(gè)圓形的漸變顏色。 Tip : 起點(diǎn)在圓心,終點(diǎn)在圓環(huán)。 Tip : 需要使用 addColorStop() 來(lái)指定漸變點(diǎn),至少要兩個(gè)。 參數(shù) 參數(shù) 類型...
canvasContext.createCircularGradient
定義
創(chuàng)建一個(gè)圓形的漸變顏色。
Tip: 起點(diǎn)在圓心,終點(diǎn)在圓環(huán)。
Tip: 需要使用addColorStop()
來(lái)指定漸變點(diǎn),至少要兩個(gè)。
參數(shù)
參數(shù) | 類型 | 定義 |
---|---|---|
x | Number | 圓心的x坐標(biāo) |
y | Number | 圓心的y坐標(biāo) |
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()
更多微信小程序開(kāi)發(fā)教程,可以關(guān)注hi小程序。
第二部分:如何開(kāi)通一個(gè)小商店