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