使用canvas标签绘图

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>使用canvas标签绘图</title>
	</head>
	<body>
		<canvas id="MyCanvas">your browser does not support the canvas tag </canvas>
		<script type="text/javascript">
			var canvas = document.getElementById("MyCanvas");
			var ctx = canvas.getContext('2d');
			ctx.fillStyle='#FF0000';
			ctx.fillRect(0,0,100,100);/*结果得出的是一个红色的边长为100px的正方形*/
		</script>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/Gadxiong/article/details/80170275