You'll want to familiarize yourself with the drawing canvas plugin.
Keep track of where your mouse position is in a variable at the end of every tick, so you have the information of where the mouse was the last tick, and the current position of the mouse at any given tick. You can use that information to create a line between those two points.