This is a basic physics simulation using Verelet Integration. This does use the canvas transform stack for drawing the elements independent of one another, but then applies physics across all of them due to the sequential nature of the stack. Use the mouse to snip the nearest stick to see the physics play, "C" on your keyboard works as well. You can reset the simulation by hitting R. The blue points at the top are "Frozen", use "F" on your keyboard to freeze/unfreeze the nearest point.