# CanvasContext.quadraticCurveTo(number cpx, number cpy, number x, number and)

with Promise style call: Not supported

Mini Program plugin: Support

Creates a quadratic Bezier curve path. The starting point of a curve is the previous point in the path.

# parameter

# number cpx

Bezier Control Point x coordinate

# number cpy

Bezier 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.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()

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

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