Javascript Code to Create Drawing on HTML Canvas
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="1000" height="500" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.fillStyle="yellow";
ctx.fillRect(400,50,350,400);
ctx.fill();
ctx.stroke();
ctx.beginPath();
ctx.fillStyle="black";
ctx.arc(500,150,50,0,2*Math.PI);
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.fillStyle="white";
ctx.arc(500,180,20,0,2*Math.PI);
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.fillStyle="black";
ctx.arc(650,150,50,0,2*Math.PI);
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.fillStyle="white";
ctx.arc(650,180,20,0,2*Math.PI);
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.fillStyle="black";
ctx.fillRect(550,250,30,40,40);
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.fillStyle="red";
ctx.arc(580,350,30,90,2*Math.PI);
ctx.stroke();
ctx.fill();
</script>
</body>
</html>
Comments
Post a Comment