public Color getColor ( int x , int y ) { if ( pixelData == null ) { pixelData = texture . getTextureData ( ) ; } int xo = ( int ) ( textureOffsetX * texture . getTextureWidth ( ) ) ; int yo = ( int ) ( textureOffsetY * texture . getTextureHeight ( ) ) ; if ( textureWidth < 0 ) { x = xo - x ; } else { x = xo + x ; } if ( textureHeight < 0 ) { y = yo - y ; } else { y = yo + y ; } // Clamp to texture dimensions x %= texture . getTextureWidth ( ) ; y %= texture . getTextureHeight ( ) ; int offset = x + ( y * texture . getTextureWidth ( ) ) ; offset *= texture . hasAlpha ( ) ? 4 : 3 ; if ( texture . hasAlpha ( ) ) { return new Color ( translate ( pixelData [ offset ] ) , translate ( pixelData [ offset + 1 ] ) , translate ( pixelData [ offset + 2 ] ) , translate ( pixelData [ offset + 3 ] ) ) ; } else { return new Color ( translate ( pixelData [ offset ] ) , translate ( pixelData [ offset + 1 ] ) , translate ( pixelData [ offset + 2 ] ) ) ; } }
Get the colour of a pixel at a specified location in this image