Added missing offset calculations.

also changed the signs of offsetX and offsetY.