微信小程式開發(fā)文檔
/ 微信小程序API 繪圖stroke(對當前路徑進行描邊)
微信小程序API 繪圖stroke(對當前路徑進行描邊)
stroke
定義
畫出當前路徑的邊框。默認顏色色為黑色。
Tip: stroke()
描繪的的路徑是從 beginPath()
開始計算,但是不會將 strokeRect()
包含進去,詳情見例二。
例子
const ctx = wx.createCanvasContext('myCanvas') ctx.moveTo(10, 10) ctx.lineTo(100, 10) ctx.lineTo(100, 100) ctx.stroke() ctx.draw()
const ctx = wx.createCanvasContext('myCanvas')// begin pathctx.rect(10, 10, 100, 30) ctx.setStrokeStyle('yellow') ctx.stroke()// begin another pathctx.beginPath() ctx.rect(10, 40, 100, 30)// only stoke this rect, not in current pathctx.setStrokeStyle('blue') ctx.strokeRect(10, 70, 100, 30) ctx.rect(10, 100, 100, 30)// it will stroke current pathctx.setStrokeStyle('red') ctx.stroke() ctx.draw()