an interactive animation where circles arranged in a hexagonal grid change size

Channel:
Subscribers:
831
Published on ● Video Link: https://www.youtube.com/watch?v=IFwYWrPxjuk



Duration: 0:00
23 views
2


This program creates an interactive animation where circles arranged in a hexagonal grid change size based on the movement of the mouse cursor. In the setup function, the positions of the hexagonal grid are calculated using the height of an equilateral triangle, and instances of the Circle class are created and stored in the circles array. The X coordinates of the circles are adjusted for odd-numbered rows to ensure an even hexagonal arrangement.

In the draw function, the distance between the mouse position (mouseX, mouseY) and each circle's center is calculated using the dist() function and normalized using screenSize. The distance ratio ratio is then inverted by computing 1 - ratio, which determines the circle’s radius. This creates an effect where circles closer to the cursor appear larger, while those farther away shrink. The stroke(0); function sets the outline color to black, and noFill(); ensures that the circles are not filled, enhancing the visual clarity of the animation.