Blame |
Last modification |
View Log
| RSS feed
package com.gebauz.bauzoid.graphics.spritex;
import com.badlogic.gdx.graphics.Texture;
public class SpriteRegion
{
public float left;
public float top;
public float bottom;
public float right;
/** Constructor. */
public SpriteRegion(Texture referenceTexture, float x, float y, float w, float h)
{
setAbsolute(referenceTexture, x, y, w, h);
}
/** Constructor - sets region by relative texture coordinates. */
public SpriteRegion(float _top, float _left, float _right, float _bottom)
{
top = _top;
left = _left;
right = _right;
bottom = _bottom;
}
/** Set region by absolute pixel coordinates relative to the specified texture.
* Coordinates are in absolute texel space.
*/
public void setAbsolute(Texture referenceTexture, float x, float y, float w, float h)
{
left = x / referenceTexture.getWidth();
top = y / referenceTexture.getHeight();
right = left + (w / referenceTexture.getWidth());
bottom = top + (h / referenceTexture.getHeight());
}
public float getWidth()
{
return (right-left);
}
public float getHeight()
{
return (bottom-top);
}
}