In this blog post, I am going to explain how to solve the below hands on.
Embed a canvas of width 600 and height 400 in your HTML5 page. draw a red rectangle of width 200 and height 100 on canvas,leaving a margin of 20 on both x axis and y axis.Add a stroke using 'strokeRect' method.
.........................................................................................................................................
Answer:
Code inside the index.html is provided below :
Code inside the index.html is provided below :
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="favicon.png" type="image/png">
<title>Destiny</title>
<link href="mystyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<canvas id="temp" width="600" height="400" ></canvas>
<script>
var x= document.getElementById("temp");
var ctx=x.getContext("2d");
ctx.strokeRect(20,20,200,100);
ctx.stroke();
</script>
</body>
</html>
Comments
Post a Comment