Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API drawingstroke (stroke the current path)


May 19, 2021 WeChat Mini Program Development Document


Table of contents


WeChat small program API drawingstroke (stroke the current path) Drawing interfaces and methods

canvasContext.stroke


Defined

Draws the border of the current path. The default color color is black.

Tip : stroke() a path that beginPath() but strokeRect() see example two for details.

Example

const ctx = wx.createCanvasContext('myCanvas')
ctx.moveTo(10, 10)
ctx.lineTo(100, 10)
ctx.lineTo(100, 100)
ctx.stroke()
ctx.draw()

WeChat small program API drawingstroke (stroke the current path)

const ctx = wx.createCanvasContext('myCanvas')
// begin path
ctx.rect(10, 10, 100, 30)
ctx.setStrokeStyle('yellow')
ctx.stroke()

// begin another path
ctx.beginPath()
ctx.rect(10, 40, 100, 30)

// only stoke this rect, not in current path
ctx.setStrokeStyle('blue')
ctx.strokeRect(10, 70, 100, 30)

ctx.rect(10, 100, 100, 30)

// it will stroke current path
ctx.setStrokeStyle('red')
ctx.stroke()
ctx.draw()

WeChat small program API drawingstroke (stroke the current path)

WeChat small program API drawingstroke (stroke the current path) Drawing interfaces and methods