feat: dynamic texture coloring
This commit is contained in:
parent
026c2aaef9
commit
f5d9cbc011
|
@ -34,21 +34,18 @@ public class Player extends EntityQuad {
|
|||
pm.setBlending(Pixmap.Blending.None);
|
||||
for (int x = 0; x < pm.getWidth(); x++) {
|
||||
for (int y = 0; y < pm.getHeight(); y++) {
|
||||
int p = pm.getPixel(x, y);
|
||||
int r = (int)( (p & 0xff000000)>>24 );
|
||||
int g = (int)( (p & 0x00ff0000)>>16 );
|
||||
int b = (int)( (p & 0x0000ff00)>>8 );
|
||||
int a = (int)( p & 0x000000ff );
|
||||
if (p != 0) {
|
||||
if (r == 255 && g == 255 && b == 255) {
|
||||
r = 255;
|
||||
g = 0;
|
||||
b = 0;
|
||||
a = 255;
|
||||
p = (int)( r <<24 | g << 16 | b << 8 | a );
|
||||
|
||||
Color pc = new Color();
|
||||
Color.rgba8888ToColor(pc, pm.getPixel(x, y));
|
||||
|
||||
if (pc.equals(Color.WHITE)) { // pc.r == 1 && pc.g == 1 && pc.b == 1
|
||||
pc = Color.RED;
|
||||
// pc.r = 1;
|
||||
// pc.g = 0;
|
||||
// pc.b = 0;
|
||||
}
|
||||
}
|
||||
pm.drawPixel(x, y, p);
|
||||
|
||||
pm.drawPixel(x, y, Color.rgba8888(pc));
|
||||
}
|
||||
}
|
||||
texture = new Texture(pm);
|
||||
|
|
Loading…
Reference in a new issue