*/
private PImage getReflection(PApplet pa, PImage image) {
int width = image.width;
int height = image.height;
PImage copyOfImage = pa.createImage(image.width, image.height, PApplet.ARGB);
image.loadPixels();
copyOfImage.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int imageIndex = y*image.width+x;
// int currA = (image.pixels[imageIndex] >> 32) & 0xFF;
int currR = (image.pixels[imageIndex] >> 16) & 0xFF;
int currG = (image.pixels[imageIndex] >> 8) & 0xFF;
int currB = image.pixels[imageIndex] & 0xFF;
int col = image.pixels[imageIndex];
float alpha = pa.alpha(col);
int reflectImageIndex = (image.height-y-1) * image.width+x;
//TOD clamp 0-255, map 0-255, 255- y*y * x
// copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*0.8));
// copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y * (0.005f*y) * 0.5));
// copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(Tools3D.clamp(255 - y*y , 0, 255)));
// copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*y*y * (0.00003f) - 20)); //WORKS
if (alpha <= 0.0f){
copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , 0.0f);
}else{
copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*y*y * (0.00003f) - 60)); //WORKS
}
}
}
copyOfImage.updatePixels();
return copyOfImage;
}