Homework of a Heart in HTML Coding
Code for this picture:
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line
//curve 1
context.beginPath();
context.moveTo(125, 200);
context.quadraticCurveTo(125, 50, 250, 50);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 2
context.beginPath();
context.moveTo(250, 50);
context.quadraticCurveTo(375, 50, 400, 200);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 3
context.beginPath();
context.moveTo(400, 200);
context.quadraticCurveTo(425, 50, 550, 50);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 4
context.beginPath();
context.moveTo(550, 50);
context.quadraticCurveTo(675, 50, 675, 200);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 5
context.beginPath();
context.moveTo(125, 200);
context.quadraticCurveTo(130, 300, 200, 393);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 6
context.beginPath();
context.moveTo(675, 200);
context.quadraticCurveTo(670, 300, 600, 393);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 7
context.beginPath();
context.moveTo(200, 393);
context.quadraticCurveTo(250, 450, 400, 590);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
//curve 8
context.beginPath();
context.moveTo(600, 393);
context.quadraticCurveTo(550, 450, 400, 590);
context.lineWidth = 15;
context.lineCap = 'round';
// line color
context.strokeStyle = "black";
context.stroke();
////////////////////////////////////// end above this line
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
No comments:
Post a Comment