private int applyFog( int rgb , float fraction ) {
		// avoid floating point math
		int adjustment = (int)(1000*fraction);

		int r = (rgb >> 16)&0xFF;
		int g = (rgb >> 8)&0xFF;
		int b = rgb & 0xFF;

		r = (r * adjustment + ((backgroundColor>>16)&0xFF)*(1000-adjustment)) / 1000;
		g = (g * adjustment + ((backgroundColor>>8)&0xFF)*(1000-adjustment)) / 1000;
		b = (b * adjustment + (backgroundColor&0xFF)*(1000-adjustment)) / 1000;

		return (r << 16) | (g << 8) | b;
	}
private int applyFog ( int rgb , float fraction ) { int adjustment = ( int ) ( 1000 * fraction ) ; int r = ( rgb > > 16 ) & 0xFF ; int g = ( rgb > > 8 ) & 0xFF ; int b = rgb & 0xFF ; r = ( r * adjustment + ( ( backgroundColor > > 16 ) & 0xFF ) * ( 1000 - adjustment ) ) / 1000 ; g = ( g * adjustment + ( ( backgroundColor > > 8 ) & 0xFF ) * ( 1000 - adjustment ) ) / 1000 ; b = ( b * adjustment + ( backgroundColor & 0xFF ) * ( 1000 - adjustment ) ) / 1000 ; return ( r << 16 ) | ( g << 8 ) | b ; }
Fades color into background as a function of distance