Code that I used:
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
var x = 0;
var y = 0;
var width = canvas.width;
var height = canvas.height;
context.beginPath();
context.rect(x, y, width, height);
context.fillStyle = 'rgb(150,150,255)';
context.fill();
context.stroke();
var x1 = 400
var y1 = 500
var controlX1 = 100
var controlY1 = 300
var controlX2 = 200
var controlY2 = 100
var endX1 = 400
var endY1 = 200
var controlX3 = 600
var controlY3 = 100
var controlX4 = 700
var controlY4 = 300
var endX2 = 400
var endY2 = 500
context.beginPath();
context.moveTo(x1,y1);
context.bezierCurveTo(controlX1, controlY1, controlX2, controlY2, endX1, endY1);
context.bezierCurveTo(controlX3, controlY3, controlX4, controlY4, endX2, endY2);
context.fillStyle = 'rgb(255,0,0)';
context.fill();
context.stroke();
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
No comments:
Post a Comment