Use the lineTo method to add a new point in the WeChat applet


lineTo


Definition

lineTo method adds a new point and then creates a line from the last specified point to the target point.

Tip: Use the stroke() method to draw lines

Parameters

QQ截图20170208142047.png

Example

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

line-to.png