xxxxxxxxxx
PGraphics frames_mask;
PGraphics pg1;
int fw, fh;
float p0 = .2;
float p1 = .05;
float scale = 7./16.;
int bg = 0;
boolean s0= false,
s1 = false,
s2 = false,
s3 = false;
void setup() {
fullScreen(P2D);
strokeWeight(.6);
fill(bg, 4);
stroke(bg, 3);
//size(320, 180, P2D);
frames_mask = createGraphics(width, height, P2D);
fw = floor(height*scale);
fh = floor(width*scale);
frames_mask.beginDraw();
frames_mask.fill(255);
frames_mask.noStroke();
frames_mask.endDraw();
createMask();
pg1 = createGraphics(width, height, P2D);
pg1.beginDraw();
pg1.stroke(0);
pg1.background(255-bg);
pg1.fill(255-bg, 100);
pg1.endDraw();
}
void createMask() {
frames_mask.beginDraw();
frames_mask.noStroke();
frames_mask.background(0);
//if (random(1)<.01) {
// bg=255-bg;
//}
if (random(1)<p0/10.) {
s0 = !s0;
}
if (s0)frames_mask.rect(0, 0, width, height);
frames_mask.pushMatrix();
frames_mask.translate(0, (height-fh)/2);
if (random(1)<p1)
s1 = !s1;
if (s1)
frames_mask.rect(fw/9, 0, fw, fh);
frames_mask.translate((width-fw)/2, 0);
if (random(1)<p1)
s2 = !s2;
if (s2)
frames_mask.rect(0, 0, fw, fh);
frames_mask.translate((width-fw)/2-fw/9, 0);
if (random(1)<p1)
s3 = !s3;
if (s3)
frames_mask.rect(0, 0, fw, fh);
frames_mask.popMatrix();
frames_mask.endDraw();
}
void draw() {
background(bg);
rect(-1, -1, width+2, height+2);
pg1.beginDraw();
pg1.rect(-1, -1, width+2, height+2);
pg1.stroke(bg);
pg1.pushMatrix();
pg1.translate(0, height/2);
float h = scale*height/2.5;
for (int x = 0; x < width; x++) {
for (int n = 0; n < 21; n++) {
float y = random(-h, h)*(1+cos(TWO_PI*(x+width*noise(millis()))/width));
pg1.point(x, y);
}
}
pg1.popMatrix();
pg1.stroke(255-bg, 0, 0);
float x = (100*millis()/width) % width;
pg1.line(x, 0, x, height);
pg1.endDraw();
// createMask();
// pg1.mask(frames_mask);
image(pg1, 0, 0);
stroke(255-bg);
for (int n = 0; n < 20; n++) {
x = random(width);
line(x, 0, x, height);
}
}