This is the magic sauce you need. (more visual demo here: http://sol.gfxile.net/interpolation/index.html)