Rope physics in html5 canvas