Mar 29, 2025
index.html: For HTML markup.style.css: For styling the canvas.script.js: For JavaScript functionality.index.html<canvas> element with id="canvas1".style.css in the <head>.script.js before the closing </body> tag.style.cssscript.jscanvas referencing the <canvas> element.ctx for the 2D drawing context using getContext('2d').
fillStyle, fillRect, and arc to draw shapes.ctx.fillStyle and use ctx.fillRect(x, y, width, height).window.addEventListener('resize', ...) to adjust canvas size on resize events.ctx.beginPath() to start a new shape.ctx.arc(x, y, radius, startAngle, endAngle) to create a circular path.ctx.fill() to fill the circle, or ctx.stroke() to outline it.mouse object to store x and y coordinates of mouse clicks.addEventListener('click', ...) to update mouse coordinates.drawCircle function to accept parameters for the coordinates.requestAnimationFrame() to create a loop that updates and redraws the canvas.ctx.clearRect().Particle class to manage particle behavior and positioning.
x, y, size, speedX, and speedY.update() and draw() methods for particle movement and rendering.