Magnetic Pendulum in Visual Basic 6

Magnetic Pendulum in Visual Basic 6

Aug 21, 2026

Another nostalgia project: a magnetic pendulum fractal, written entirely in classic VB6. A pendulum bob swings above five magnets. For every pixel on screen I release it from rest at that point, integrate the equations of motion with RK4, and color the pixel by the magnet it eventually settles on. Brightness encodes how long the settling took.

imageThe result is a map of basins of attraction with chaotic boundaries. The system is fully deterministic, no randomness anywhere, yet two starting points a fraction of a pixel apart can end up on different magnets. You can see it live: click anywhere on the rendered fractal and the actual trajectory gets drawn on top, wandering between magnets before it commits.

Rendering is raw GDI, a 32-bit DIB blitted scanline by scanline into a PictureBox, so the image builds up before your eyes, just like we watched fractals render in 1998.

VB6 shipped in 1998 and has been declared dead roughly every year since. It still compiles to a native EXE that renders this in seconds. Some things take longer to settle than a chaotic pendulum.

Sources: https://github.com/makarov-mm/magnetic-pendulum-vb6

Gefällt dir dieser Beitrag?

Kaufe Michael Makarov einen Coffee

Mehr von Michael Makarov