Seeing that you're referencing the canvas object in two places in two different functions makes me think it'd be worth creating an object that held the canvas as well as some of the functions that manipulate it.