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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
<!doctype html>
<html>
<head>
<title>Canvas HTML5</title>
<style>
@ -8,45 +9,24 @@
}
</style>
</head>
<body>
<canvas id="canvas" width="640" height="640">Not Supported</canvas>
<script>
const canvas = document.querySelector("#canvas");
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.fillStyle = "red";
ctx.arc(300, 130, 100, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.fillStyle = "black";
ctx.arc(250, 120, 20, 0, Math.PI * 2);
ctx.moveTo(370, 120);
ctx.arc(350, 120, 20, 0, Math.PI * 2);
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();
const canvas = document.querySelector('#canvas');
const ctx = canvas.getContext('2d');
const str = "Hello World";
ctx.font = 'italic 50px Comic';
ctx.fillStyle = 'blue';
//ctx.textAlign = 'left';
ctx.fillText(str, 100, 100);
ctx.font = 'bold 20px Arial';
ctx.fillStyle = 'red';
for (let x = 1; x < 11; x++) {
ctx.fillText("counter:" + x, 50, (200 + (40 * x)));
}
</script>
</body>
</html>