bezierCurveTo(路徑命令)
context.bezierCurveTo(control1X, control1Y, control2X, control2Y, endingX, endingY)
繪製從當前筆位置開始到給定結束座標的三次貝塞爾曲線。另外兩個給定的控制座標確定曲線的形狀(曲率)。
<!doctype html>
<html>
<head>
<style>
body{ background-color:white; }
#canvas{border:1px solid red; }
</style>
<script>
window.onload=(function(){
// get a reference to the canvas element and it's context
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
// arguments
var startX=25;
var startY=50;
var controlX1=75;
var controlY1=10;
var controlX2=75;
var controlY2=90;
var endX=125;
var endY=50;
// A cubic bezier curve drawn using "moveTo" and "bezierCurveTo" commands
ctx.beginPath();
ctx.moveTo(startX,startY);
ctx.bezierCurveTo(controlX1,controlY1,controlX2,controlY2,endX,endY);
ctx.stroke();
}); // end window.onload
</script>
</head>
<body>
<canvas id="canvas" width=200 height=150></canvas>
</body>
</html>