Update Exercise_14.4.html

This commit is contained in:
Karan
2022-01-03 17:29:15 +05:30
committed by GitHub
parent a11f698fb1
commit 03e645be50
+16 -36
View File
@@ -1,5 +1,6 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>Canvas HTML5</title> <title>Canvas HTML5</title>
<style> <style>
@@ -8,45 +9,24 @@
} }
</style> </style>
</head> </head>
<body> <body>
<canvas id="canvas" width="640" height="640">Not Supported</canvas> <canvas id="canvas" width="640" height="640">Not Supported</canvas>
<script> <script>
const canvas = document.querySelector("#canvas"); const canvas = document.querySelector('#canvas');
const ctx = canvas.getContext("2d"); const ctx = canvas.getContext('2d');
ctx.beginPath(); const str = "Hello World";
ctx.fillStyle = "red"; ctx.font = 'italic 50px Comic';
ctx.arc(300, 130, 100, 0, Math.PI * 2); ctx.fillStyle = 'blue';
ctx.fill(); //ctx.textAlign = 'left';
ctx.beginPath(); ctx.fillText(str, 100, 100);
ctx.fillStyle = "black"; ctx.font = 'bold 20px Arial';
ctx.arc(250, 120, 20, 0, Math.PI * 2); ctx.fillStyle = 'red';
ctx.moveTo(370, 120); for (let x = 1; x < 11; x++) {
ctx.arc(350, 120, 20, 0, Math.PI * 2); ctx.fillText("counter:" + x, 50, (200 + (40 * x)));
ctx.moveTo(240, 160); }
ctx.arc(300, 160, 60, 0, Math.PI);
ctx.fill();
ctx.moveTo(300, 130);
ctx.lineTo(300, 150);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(300, 230);
ctx.lineTo(300, 270);
ctx.lineTo(400, 270);
ctx.lineTo(200, 270);
ctx.lineTo(300, 270);
ctx.lineTo(300, 350);
ctx.lineTo(400, 500);
ctx.moveTo(300, 350);
ctx.lineTo(200, 500);
ctx.stroke();
ctx.beginPath();
ctx.fillStyle = "blue";
ctx.moveTo(200, 50);
ctx.lineTo(400, 50);
ctx.lineTo(300, 20);
ctx.lineTo(200, 50);
ctx.fill();
ctx.stroke();
</script> </script>
</body> </body>
</html> </html>