add texture coordinate scaling helper methods
This commit is contained in:
parent
8de3d0fba3
commit
0dacf1eea1
|
@ -2,7 +2,10 @@ package com.blarg.gdx.graphics;
|
|||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.blarg.gdx.math.MathHelpers;
|
||||
|
||||
public abstract class TextureAtlas {
|
||||
public static final float TEXCOORD_EDGE_BLEED_OFFSET = 0.02f;
|
||||
|
@ -24,4 +27,17 @@ public abstract class TextureAtlas {
|
|||
public int count() {
|
||||
return tiles.size;
|
||||
}
|
||||
|
||||
public static void scaleTexCoord(Vector2 texCoord, TextureRegion tile, Vector2 out) {
|
||||
out.x = scaleTexCoordU(texCoord.x, tile);
|
||||
out.y = scaleTexCoordV(texCoord.y, tile);
|
||||
}
|
||||
|
||||
public static float scaleTexCoordU(float u, TextureRegion tile) {
|
||||
return MathHelpers.scaleRange(u, 0.0f, 1.0f, tile.getU(), tile.getU2());
|
||||
}
|
||||
|
||||
public static float scaleTexCoordV(float v, TextureRegion tile) {
|
||||
return MathHelpers.scaleRange(v, 0.0f, 1.0f, tile.getV(), tile.getV2());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue