package com.lucasdnd.ags.map;
/**
* Here, we FLOOR or CEIL the offset so we don't get annoying precision problems when converting positions to screen pixels.
*
* Not using the methods in this class will cause images to be rendered a few pixels off of where it should be. This happens because the screen pixels
* are measured in integer numbers, while all the offsets and scale are floating point numbers.
*
* @author tulio
*
*/
public abstract class OffsetUtil {
/**
* Corrects the xOffset to prevent rounding errors
* @param xOffset
* @return
*/
public static float getPreciseOffset(float offset) {
return (offset <= 0) ? (float)Math.ceil(offset) : (float)Math.floor(offset);
}
}