Fix invalid positions when drawing outside of the canvas