WeChat applet API drawing stroke (stroke the current path)
stroke
Definition
Draws the border of the current path. The default color is black.
Tip: stroke()
The path drawn is calculated starting from beginPath()
, but strokeRect( )
is included, see Example 2 for details.
Example
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()