Just so people know, this is not the game snake. How it works is you move the mouse and the head of the creature tries to get to the mouse. In doing so, it pulls on the rest of the body segments and can create very interesting shapes. You can change the number of segments with the slider. Click the green flag to start.
The basics of how it works is that there is a purple circle sprite that makes a bunch of clones of itself that may appear depending on the number of segments. Every circle checks to see if it's touching the circle in front of it, and if not it moves towards it (except the starting circle which moves towards the mouse).