小程序創(chuàng)建一個(gè)矩形路徑CanvasContext.rect
CanvasContext.rect(number x, number y, number width, number height)
創(chuàng)建一個(gè)矩形路徑。需要用 fill 或者 <code>stroke 方法將矩形真正的畫到 canvas 中
小程序插件:支持
參數(shù)
number x
矩形路徑左上角的橫坐標(biāo)
number y
矩形路徑左上角的縱坐標(biāo)
number width
矩形路徑的寬度
number height
矩形路徑的高度
示例代碼
const ctx = wx.createCanvasContext('myCanvas')
ctx.rect(10, 10, 150, 75)
ctx.setFillStyle('red')
ctx.fill()
ctx.draw()
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)
發(fā)布時(shí)間:2025-04-14 閱讀: