performance optimization

changed canvas.width=canvas.width to a call to the clearRect method to
avoid canvas state changes