谁能解答一下这段代码,三角形堆叠成的一个花朵
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>叠放三角形</title>
<script type="text/javascript">
window.onload = function draw()
{
// body...
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0,0,400,300);
var n=0,dx=170,dy=150,s=140;
ctx.beginPath();
ctx.fillStyle="blue";
ctx.strokeStyle="yellow";
var x=Math.sin(0);
var y=Math.cos(0);
var dig=Math.PI*15/11;
for (var i = 0; i < 30; i++) {
var x=Math.sin(i*dig);
var y=Math.cos(i*dig);
ctx.lineTo(dx+x*s,dy+y*s);
}
ctx.closePath();
ctx.fill();
ctx.stroke();
}
</script>
</head>
<body>
<canvas id="canvas" width="400" height="300"></canvas>
</body>
</html>