prevent drawing outside the canvas (workaround solution)