Avoid overflowing the canvas bounds