Minor optimization
This commit is contained in:
@@ -172,7 +172,7 @@ public class Generators{
|
||||
int radius = 4;
|
||||
GenRegion region = (GenRegion)regions[regions.length - 1];
|
||||
Image base = ImagePacker.get(region);
|
||||
Image out = last = new Image(region.getWidth(), region.getHeight());
|
||||
Image out = last = new Image(region.width, region.height);
|
||||
for(int x = 0; x < out.width; x++){
|
||||
for(int y = 0; y < out.height; y++){
|
||||
|
||||
@@ -330,7 +330,7 @@ public class Generators{
|
||||
image.save(type.name + "-cell");
|
||||
}
|
||||
|
||||
Image cell = new Image(type.cellRegion.getWidth(), type.cellRegion.getHeight());
|
||||
Image cell = new Image(type.cellRegion.width, type.cellRegion.height);
|
||||
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
|
||||
|
||||
image.draw(cell, image.width / 2 - cell.width / 2, image.height / 2 - cell.height / 2);
|
||||
@@ -339,8 +339,8 @@ public class Generators{
|
||||
weapon.load();
|
||||
|
||||
image.draw(weapon.region,
|
||||
(int)(weapon.x / Draw.scl + image.width / 2f - weapon.region.getWidth() / 2f),
|
||||
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f),
|
||||
(int)(weapon.x / Draw.scl + image.width / 2f - weapon.region.width / 2f),
|
||||
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.height / 2f),
|
||||
weapon.flipSprite, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ class Image{
|
||||
|
||||
/** Draws a region at the center. */
|
||||
void drawCenter(TextureRegion region){
|
||||
draw(region, (width - region.getWidth()) / 2, (height - region.getHeight()) / 2, false, false);
|
||||
draw(region, (width - region.width) / 2, (height - region.height) / 2, false, false);
|
||||
}
|
||||
|
||||
/** Draws a region at the center. */
|
||||
void drawCenter(TextureRegion region, boolean flipx, boolean flipy){
|
||||
draw(region, (width - region.getWidth()) / 2, (height - region.getHeight()) / 2, flipx, flipy);
|
||||
draw(region, (width - region.width) / 2, (height - region.height) / 2, flipx, flipy);
|
||||
}
|
||||
|
||||
void drawScaled(Image image){
|
||||
@@ -114,12 +114,12 @@ class Image{
|
||||
|
||||
graphics.drawImage(ImagePacker.get(region).image,
|
||||
x, y,
|
||||
x + region.getWidth(),
|
||||
y + region.getHeight(),
|
||||
(flipx ? region.getWidth() : 0) + ofx,
|
||||
(flipy ? region.getHeight() : 0) + ofy,
|
||||
(flipx ? 0 : region.getWidth()) + ofx,
|
||||
(flipy ? 0 : region.getHeight()) + ofy,
|
||||
x + region.width,
|
||||
y + region.height,
|
||||
(flipx ? region.width : 0) + ofx,
|
||||
(flipy ? region.height : 0) + ofy,
|
||||
(flipx ? 0 : region.width) + ofx,
|
||||
(flipy ? 0 : region.height) + ofy,
|
||||
null);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,28 +42,12 @@ public class ImagePacker{
|
||||
BufferedImage image = ImageIO.read(path.file());
|
||||
|
||||
if(image == null) throw new IOException("image " + path.absolutePath() + " is null for terrible reasons");
|
||||
GenRegion region = new GenRegion(fname, path){
|
||||
|
||||
@Override
|
||||
public int getX(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return image.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return image.getHeight();
|
||||
}
|
||||
};
|
||||
GenRegion region = new GenRegion(fname, path){{
|
||||
width = image.getWidth();
|
||||
height = image.getHeight();
|
||||
u2 = v2 = 1f;
|
||||
u = v = 0f;
|
||||
}};
|
||||
|
||||
regionCache.put(fname, region);
|
||||
imageCache.put(fname, image);
|
||||
@@ -105,7 +89,7 @@ public class ImagePacker{
|
||||
}
|
||||
};
|
||||
|
||||
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
|
||||
Draw.scl = 1f / Core.atlas.find("scale_marker").width;
|
||||
|
||||
Time.mark();
|
||||
Generators.generate();
|
||||
|
||||
Reference in New Issue
Block a user