# CanvasContext. bezierCurveTo(number cp1x, number cp1y, number cp2x, number cp2y, number x, number and)

with Promise style call: Not supported

Mini Program plugin: Support

Create a cubic bezier curve path. The starting point of a curve is the previous point in the path.

# parameter

# number cp1x

Of the first Bezier control point. x coordinate

# number cp1y

Of the first Bezier control point. and coordinate

# number cp2x

Of the second Bessel control point. x coordinate

# number cp2y

Of the second Bessel control point. and coordinate

# number x

Ending point x coordinate

# number and

Ending point and coordinate

# sample code

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.arc(200, 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(150, 75)

ctx.moveTo(200, 20)
ctx.lineTo(200, 100)
ctx.lineTo(70, 75)
ctx.setStrokeStyle('#AAAAAA')
ctx.stroke()

// Draw quadratic curve
ctx.beginPath()
ctx.moveTo(20, 20)
Ctx.bezierCurveTo(20, 100, 200, 100, 200, 20)
ctx.setStrokeStyle('black' )
ctx.stroke()

ctx.draw()

In the light of moveTo(20, 20) BezierCurveTo(20, 100, 200, 100, 200, 20) The three key coordinates are as follows:

  • Red: starting point(20, 20)
  • Blue: Two control points(20, 100) (200, 100)
  • Green: The End Point(200, 20)