May 19, 2021 WeChat Mini Program Development Document
Drawing interfaces and methods
Create a secondary Bezier curve path.
Tip : The starting point of the curve is the previous point in the path.
Parameters | Type | Description |
---|---|---|
cpx | Number | The x coordinates of the Bezier control point |
cpy | Number | The y coordinates of the Bezier control point |
Ⅹ | Number | The x coordinates of the end point |
Y | Number | The y coordinates of the end point |
const ctx = wx.createCanvasContext('myCanvas')
// Draw points
ctx.beginPath()
ctx.arc(20, 20, 2, 0, 2 * Math.PI)
ctx.setFillStyle('red')
ctx.fill()
ctx.beginPath()
ctx.arc(200, 20, 2, 0, 2 * Math.PI)
ctx.setFillStyle('lightgreen')
ctx.fill()
ctx.beginPath()
ctx.arc(20, 100, 2, 0, 2 * Math.PI)
ctx.setFillStyle('blue')
ctx.fill()
ctx.setFillStyle('black')
ctx.setFontSize(12)
// Draw guides
ctx.beginPath()
ctx.moveTo(20, 20)
ctx.lineTo(20, 100)
ctx.lineTo(200, 20)
ctx.setStrokeStyle('#AAAAAA')
ctx.stroke()
// Draw quadratic curve
ctx.beginPath()
ctx.moveTo(20, 20)
ctx.quadraticCurveTo(20, 100, 200, 20)
ctx.setStrokeStyle('black')
ctx.stroke()
ctx.draw()
The
moveTo(20, 20)
quadraticCurveTo(20, 100, 200, 20)
are as follows: