use of com.badlogic.gdx.graphics.Texture in project Eidolons by IDemiurge.
the class TextureCache method _createTexture.
public Texture _createTexture(String path, boolean putIntoCache) {
Path p = Paths.get(imagePath, path);
String filePath = p.toString();
Texture t = null;
if (checkAltTexture(filePath))
try {
t = new Texture(new FileHandle(getAltTexturePath(filePath)), Pixmap.Format.RGBA8888, false);
if (putIntoCache)
cache.put(path, t);
} catch (Exception e) {
}
if (t == null)
try {
t = new Texture(new FileHandle(filePath), Pixmap.Format.RGBA8888, false);
if (putIntoCache) {
cache.put(path, t);
}
} catch (Exception e) {
// main.system.ExceptionMaster.printStackTrace(e);
if (!cache.containsKey(getEmptyPath())) {
if (putIntoCache)
cache.put(getEmptyPath(), getEmptyTexture());
return getEmptyTexture();
}
return cache.get(getEmptyPath());
}
return t;
}
use of com.badlogic.gdx.graphics.Texture in project Eidolons by IDemiurge.
the class TextureManager method getXY.
public static Pair<Integer, Integer> getXY(String origPath) {
int x = 1;
int y = 1;
List<Integer> xs = new ArrayList<>();
List<Integer> ys = new ArrayList<>();
Texture texture = TextureCache.getOrCreate(origPath);
for (int i = 7; i >= 1; i--) {
if (texture.getWidth() % i == 0) {
x = i;
xs.add(i);
}
if (texture.getHeight() % i == 0) {
y = i;
ys.add(i);
}
}
// prefer square
{
for (int x1 : xs) {
if (x1 == 0) {
continue;
}
final int w = texture.getWidth() / x1;
for (int y1 : ys) {
if (y1 == 0) {
continue;
}
int h = texture.getHeight() / y1;
if (w == h) {
return new ImmutablePair<>(x1, y1);
}
}
}
}
if (x == 0) {
x = 1;
}
if (y == 0) {
y = 1;
}
return new ImmutablePair<>(x, y);
}
use of com.badlogic.gdx.graphics.Texture in project Eidolons by IDemiurge.
the class TextureTransformer method mirror.
// must be a power of two size
public void mirror() {
Texture imgTexture = new Texture(Gdx.files.internal("badlogic.jpg"));
imgTexture.setWrap(Texture.TextureWrap.MirroredRepeat, Texture.TextureWrap.MirroredRepeat);
TextureRegion imgTextureRegion = new TextureRegion(imgTexture);
imgTextureRegion.setRegion(0, 0, imgTexture.getWidth() * 3, imgTexture.getHeight() * 3);
}
use of com.badlogic.gdx.graphics.Texture in project Eidolons by IDemiurge.
the class Anim method draw.
@Override
public boolean draw(Batch batch) {
// if (getX() == 0 && getY() == 0) {
// getX();
// }
// switch(template){
// }
float delta = Gdx.graphics.getDeltaTime();
time += delta;
if (time < 0) {
// delay
return true;
}
checkAddFloatingText();
Texture currentFrame = textureSupplier.get();
if (lifecycleDuration != 0) {
cycles = (int) (time / lifecycleDuration);
lifecycle = time % lifecycleDuration / lifecycleDuration;
}
if (// || finished // lifecycle duration for continuous?
duration >= 0 || isContinuous()) {
if (checkFinished()) {
if (AnimMaster.isSmoothStop(this)) {
if (!isEmittersWaitingDone()) {
emittersWaitingDone = true;
duration += getTimeToFinish();
emitterList.forEach(e -> e.getEffect().allowCompletion());
return true;
}
}
LogMaster.log(LogMaster.ANIM_DEBUG, this + " finished; duration = " + duration);
finished();
dispose();
return false;
}
}
if (currentFrame != null) {
setWidth(currentFrame.getWidth());
setHeight(currentFrame.getHeight());
}
updatePosition(delta);
emitterList.forEach(e -> {
e.setFlipX(flipX);
e.setFlipX(flipY);
e.act(delta);
});
sprites.forEach(s -> {
// s.setFlipX(flipX);
// s.setFlipX(flipY);
});
applyAnimMods();
if (isDrawTexture() && getActions().size == 0) {
draw(batch, alpha);
}
sprites.forEach(s -> {
s.draw(batch);
});
emitterList.forEach(e -> {
e.draw(batch, 1f);
main.system.auxiliary.log.LogMaster.log(1, e.getName() + " drawn at x " + e.getX() + " y " + e.getY());
e.getEffect().getEmitters().forEach(em -> {
main.system.auxiliary.log.LogMaster.log(1, em.getName() + " emitter at at x " + em.getX() + " y " + em.getY());
});
});
return true;
}
use of com.badlogic.gdx.graphics.Texture in project Mindustry by Anuken.
the class MapEditor method resize.
public void resize(int width, int height) {
Pixmap out = Pixmaps.resize(pixmap, width, height, ColorMapper.getColor(Blocks.stone));
pixmap.dispose();
pixmap = out;
texture.dispose();
texture = new Texture(out);
if (filterPixmap != null) {
filterPixmap.dispose();
filterTexture.dispose();
filterPixmap = null;
filterTexture = null;
}
pixmap.setColor(ColorMapper.getColor(drawBlock));
}
Aggregations