| 22 | } |
| 23 | |
| 24 | function animate() { |
| 25 | |
| 26 | |
| 27 | let r = c * Math.sqrt(n); |
| 28 | let angle = n * 137.5 * (Math.PI / 180); |
| 29 | |
| 30 | let dis = (h > w) ? w : h; |
| 31 | |
| 32 | if (r < dis / 2 - 10) { |
| 33 | |
| 34 | let x = r * Math.cos(angle); |
| 35 | let y = r * Math.sin(angle); |
| 36 | let h = (n % 255) / 2; |
| 37 | |
| 38 | ctx.fillStyle = "hsl(" + 1 + h + ",80%,50%)"; |
| 39 | ctx.strokeStyle = "white"; |
| 40 | ctx.lineWidth = this.z / 2; |
| 41 | ctx.beginPath(); |
| 42 | ctx.arc(x, y, c / 2, 0, Math.PI * 2); |
| 43 | ctx.fill(); |
| 44 | ctx.closePath(); |
| 45 | |
| 46 | n++; |
| 47 | requestAnimationFrame(animate); |
| 48 | } |
| 49 | |
| 50 | } |
| 51 | |