Drawing color filled rectangle with Canvas Example

<!DOCTYPE html>
<html>
	<head>
		<title>Drawing color filled rectangle with Canvas Example</title>
		<meta charset="utf-8">
 
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
		<script>
			$(document).ready(function() {
				var canvas = document.getElementById("myCanvas");
				var ctx = canvas.getContext("2d");
				ctx.fillStyle = "rgb(255, 0, 0)";  //red
				ctx.fillRect(50, 50, 100, 100);  
			});
		</script>
	</head>
 
	<body>
		<canvas id="myCanvas" width="500" height="500">
			<!-- Insert fallback content here -->
		</canvas>
	</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.