fix rectangle y-coordinate order when flipped