小程序畫布填充一個矩形CanvasContext.fillRect
CanvasContext.fillRect(number x, number y, number width, number height)
填充一個矩形。用 setFillStyle 設(shè)置矩形的填充色,如果沒設(shè)置默認(rèn)是黑色。
小程序插件:支持
參數(shù)
number x
矩形路徑左上角的橫坐標(biāo)
number y
矩形路徑左上角的縱坐標(biāo)
number width
矩形路徑的寬度
number height
矩形路徑的高度
示例代碼
const ctx = wx.createCanvasContext('myCanvas')
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 75)
ctx.draw()
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)
發(fā)布時(shí)間:2025-04-14 閱讀: