标签:body etc pat 正方形 context sep html tco net
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<canvas id="canvas" width="300" height="300"></canvas>
<script>
var canvas = document.getElementById(‘canvas‘);
var ctx = canvas.getContext(‘2d‘);
ctx.beginPath();
ctx.moveTo(100,100);
ctx.lineTo(200,100);
ctx.lineTo(200,200);
ctx.lineTo(100,200);
ctx.closePath();
ctx.stroke();
ctx.fillStyle = ‘red‘;
ctx.fill();
//正方形
ctx.beginPath();
ctx.moveTo(100, 100);
ctx.lineTo(200, 100);
ctx.lineTo(150, 30);
ctx.closePath();
ctx.stroke();
ctx.fillStyle = ‘yellow‘;
ctx.fill();
//三角形
</script>
</body>
</html>
标签:body etc pat 正方形 context sep html tco net
原文地址:https://www.cnblogs.com/weinixiong/p/10054481.html