如何使用HTML5中canvas绘制一个立体金字塔图形?(javascript可以)
发布网友
发布时间:2022-05-12 06:48
我来回答
共2个回答
热心网友
时间:2022-05-12 08:18
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>MYJZT</title>
<body onload="draw('canvas')">
<div style="text-align:center;">
<canvas id="myCanvas" width="400" height="500" solid #c3c3c3;"></canvas>
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.strokeStyle="black";
cxt.beginPath();
cxt.moveTo(200,0);
cxt.lineTo(0,400);
cxt.lineTo(400,400);
cxt.lineTo(200,0);
cxt.moveTo(200,0);
cxt.lineTo(50,200);
cxt.lineTo(0,400);
cxt.moveTo(200,0);
cxt.lineTo(350,200);
cxt.lineTo(400,400);
cxt.closePath();
cxt.stroke();
</script>
</body>
</head>
</html>
热心网友
时间:2022-05-12 09:36
在右边在绘制一条直线,角度和右边的棱大约25°,要稍微短一些,然后连接