https://editor.p5js.org/Yurriii/sketches/aKFTZSujn

Interactive Magnetic Field Simulation in p5.js

The Idea

I created an interactive particle system that simulates magnetic attraction. Particles respond to both gravity and a magnetic force controlled by the mouse. The magnet's strength increases when clicked, creating dynamic particle movements and colorful visual effects.

How It Works

The simulation uses:

Each particle responds to:

Interesting Challenges

The trickiest part was balancing the forces. Too much magnetic strength made particles fly everywhere, while too little made the interaction boring. I solved this by: