Skip to content

Commit

Permalink
Add support for Flipped Icons
Browse files Browse the repository at this point in the history
  • Loading branch information
taelnia committed Dec 2, 2013
1 parent ffe73b6 commit 26a11c7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions BlockColourGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,27 @@ public class BlockColourGen {
private static int getIconMapColour(Icon icon, Texture terrainTexture) {
int iconX = (int) Math.round(((float) terrainTexture.w) * icon.getMinU());
int iconY = (int) Math.round(((float) terrainTexture.h) * icon.getMinV());
int iconWidth = (int) Math.round(((float) terrainTexture.w) * (icon.getMaxU() - icon.getMinU()));
int iconHeight = (int) Math.round(((float) terrainTexture.h) * (icon.getMaxV() - icon.getMinV()));

float maxU = icon.getMaxU();
float minU = icon.getMinU();
float diffU;
if (minU > maxU) {
diffU = minU - maxU;
} else {
diffU = maxU - minU;
}

float maxV = icon.getMaxV();
float minV = icon.getMinV();
float diffV;
if (minV > maxV) {
diffV = minV - maxV;
} else {
diffV = maxV - minV;
}

int iconWidth = (int) Math.round(((float) terrainTexture.w) * diffU);
int iconHeight = (int) Math.round(((float) terrainTexture.h) * diffV);

int[] pixels = new int[iconWidth * iconHeight];

Expand Down

0 comments on commit 26a11c7

Please sign in to comment.