fix repaint bug when x and y is negative or too large