Fix bug when drawing outside the screen