小程序畫布畫一個非填充矩形CanvasContext.strokeRect
CanvasContext.strokeRect(number x, number y, number width, number height)
畫一個矩形(非填充)。 用 setStrokeStyle 設置矩形線條的顏色,如果沒設置默認是黑色。
小程序插件:支持
參數
number x
矩形路徑左上角的橫坐標
number y
矩形路徑左上角的縱坐標
number width
矩形路徑的寬度
number height
矩形路徑的高度
示例代碼
const ctx = wx.createCanvasContext('myCanvas')
ctx.setStrokeStyle('red')
ctx.strokeRect(10, 10, 150, 75)
ctx.draw()