Tool Request: 147583764 - create_file
{"content":"<!DOCTYPE html>\n<html>\n<head>\n <title>Rotating Hexagon with Bouncing Balls</title>\n <style>body { margin: 0; overflow: hidden; }</style>\n</head>\n<body>\n<canvas id=\"myCanvas\" width=\"800\" height=\"600\"></canvas>\n<script>\nconst canvas = document.getElementById('myCanvas');\nconst ctx = canvas.getContext('2d');\n\n// Hexagon properties\nconst hexRadius = 100;\nlet hexAngle = 0;\n\n// Ball properties\nconst balls = [];\nfor (let i = 0; i < 10; i++) {\n balls.push({\n x: Math.random() * canvas.width,\n y: Math.random() * canvas.height,\n dx: (Math.random() - 0.5) * 4,\n dy: (Math.random() - 0.5) * 4,\n radius: 10 + Math.random() * 5\n });\n}\n\nfunction drawHexagon() {\n ctx.save();\n ctx.translate(canvas.width/2, canvas.height/2);\n ctx.beginPath();\n for (let i = 0; i < 6; i++) {\n const angle = hexAngle + i * Math.PI/3;\n const x = Math.cos(angle) * hexRadius;\n const y = Math.sin(angle) * hexRadius;\n if (i === 0) ctx.moveTo(x, y);\n else ctx.lineTo(x, y);\n }\n ctx.closePath();\n ctx.fillStyle = 'blue';\n ctx.fill();\n ctx.restore();\n}\n\nfunction drawBalls() {\n for (const ball of balls) {\n ctx.beginPath();\n ctx.arc(ball.x, ball.y, ball.radius, 0, Math.PI*2);\n ctx.fillStyle = 'red';\n ctx.fill();\n }\n}\n\nfunction animate() {\n // Clear canvas\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n // Draw hexagon\n drawHexagon();\n\n // Update and draw balls\n for (const ball of balls) {\n ball.x += ball.dx;\n ball.y += ball.dy;\n\n // Bounce off walls\n if (ball.x < ball.radius || ball.x > canvas.width - ball.radius) {\n ball.dx = -ball.dx;\n }\n if (ball.y < ball.radius || ball.y > canvas.height - ball.radius) {\n ball.dy = -ball.dy;\n }\n }\n\n drawBalls();\n\n // Rotate hexagon\n hexAngle += 0.01;\n\n requestAnimationFrame(animate);\n}\n\nanimate();\n</script>\n</body>\n</html>","file_name":"index.html"}