Javascript/HTML5 canvas wave generator