xxxxxxxxxx
// PImage img;
PGraphics pg1, pg2;
void setup() {
fullScreen();
// img = loadImage('https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/face-wash-2-1561136582.jpg');
pg1 = createGraphics(width,height);
pg2 = createGraphics(width,height);
background(0);
}
void drawPG(){
pg1.beginDraw();
pg1.loadPixels();
pg2.beginDraw();
pg2.loadPixels();
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
float bright = random(1)
// Set each pixel onscreen to a grayscale value
pg1.pixels[x+y*width] = color(bright > .5 ? 255 : 0);
pg2.pixels[x+y*width] = color(bright > .5 ? 0 : 255);
}
}
pg1.updatePixels();
pg1.endDraw();
pg2.updatePixels();
pg2.endDraw();
}
void draw() {
drawPG();
pg2.blend(pg1, 0, 0, width, height, 0, 0, width, height, ADD);
image(pg2,0,0);
}