<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
window.onload=function(){
var canvas=document.getElementById("canvas")
canvas.width=800;
canvas.height=600;
var context=canvas.getContext("2d");
context.beginPath();
for(var i= 0;i<5;i++){
context.lineTo(Math.cos((18+i*72)/180*Math.PI)*300+400,
-Math.sin((18+i*72)/180*Math.PI)*300+400);
context.lineTo(Math.cos((54+i*72)/180*Math.PI)*150+400,
-Math.sin((54+i*72)/180*Math.PI)*150+400);
}
context.closePath();
}
</script>
</body>
</html>
1、之前少了<canvas id=canvas......></canvas>的一系列内容
2、然后路径规划完后少了绘制的过程,context.stroke()或者填充之类的
不客气