The main logic from this demo was stolen from this page https://husarnet.com/
The inspiring JavaScript code is far from optimistic though, crippled with duplicate calculations and unnecessary drawings to a point it was barely achieving 1fps on first run.