CanvasContext.bezierCurveTo
Create cubic Bézier curve path.
Parameters
It is Object type.
Property | Type | Description |
cp1x | Number | The x coordinate of the first point. |
cp1y | Number | The y coordinate of the first point. |
cp2x | Number | The x coordinate of the second point. |
cp2y | Number | The y coordinate of the second point. |
x | Number | The x coordinate of the end point. |
y | Number | The y coordinate of the end point. |
Sample Code
copy
//.js
const ctx = my.createCanvasContext('myCanvas')
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)
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()
ctx.beginPath()
ctx.moveTo(20, 20)
ctx.bezierCurveTo(20, 100, 200, 100, 200, 20)
ctx.setStrokeStyle('black')
ctx.stroke()
ctx.draw()