for (int x=0 ; x < width ; x++){
for (int y=0 ; y < height ; y++){
double r=0;
double g=0;
double b=0;
int totalHits = getTotalPixelHitsInAllVariations(drawableVariations,x,y);
boolean pixelHit=false;
for (int i=0 ; i < drawableVariations.length ; i++){
Variation v = drawableVariations[i];
if (!v.isDraw())
continue;
int hits= v.getHits()[x][y][0];
if ( hits >0 ){
pixelHit=true;
double weightFactor=(1d*hits)/(1d*totalHits);
r+=v.getColor().getRed()*weightFactor;
g+=v.getColor().getGreen()*weightFactor;
b+=v.getColor().getBlue()*weightFactor;
}
}
if (pixelHit){ //RGB is now weigthed average
totalPixelsHit++;
double logFactor=Math.log(totalHits)/Math.log(maxSinglePixelHit);
r=Math.min(255,Math.pow(r*logFactor/255,1/config.getGamma())*255);
g=Math.min(255,Math.pow(g*logFactor/255,1/config.getGamma())*255);
b=Math.min(255,Math.pow(b*logFactor/255,1/config.getGamma())*255);
screen.setPixel(x,y,new Color((int) r,(int)g,(int) b).getRGB()); // < All that work to do this
}
}
}
}
