Date: 04-23-2019
Click here to visit on p5 Web Editor
To interact, simply click anywhere on the canvas to create a ball object, which will attract and be attracted to all the existing ball objects. Nonetheless, the attraction between them does not simply pull one ball towards another; when their distance decreases to a certain point, the attraction changes to repulsion to prevent them from getting any closer, so that both balls remain at a balanced position. When there are more than two balls, they shake and move constantly until they reach the balanced point. Every time a new object is added, it takes the objects some time to find that new balanced point.
I added sine value in the movement, giving a constant shrinking and growing effect to the bigger circular shape that all the ball objects form.