xxxxxxxxxx
60
let buffer;
let ourMode = 1;
let a;
function setup() {
createCanvas(windowWidth, windowHeight);
buffer = createGraphics(400, 400);
buffer.background(255);
buffer.fill(0);
buffer.noStroke();
buffer.triangle(50, 100, 250, 100, 150, 300);
buffer.triangle(150, 100, 350, 100, 250, 300);
//buffer.ellipse(200, 200, 10);
//buffer.rect(200, 200, 30,400);
//buffer.rect(20, 20, 40, 400);
background(0);
}
function draw() {
background(255);
if(ourMode == 0) {
image(buffer,0,0,mouseX,mouseY);
} else if (ourMode == 1) {
push();
translate(0,0);
doubleyou();
pop();
}
}
function mousePressed() {
ourMode = ourMode == 1 ? 0:1;
}
function doubleyou(){
blendMode(DIFFERENCE);
a = map(50, 0, 10, 30, 600);
for (let i = 0; i < 15; i++) {
for (let j = 0; j < 15; j++) {
let x = sin((frameCount + j * 4 + i * 3) * 0.01) * 100;
let y = -tan((frameCount + i * 3) * 0.01) * a;
push();
translate(i * 10, j * 10);
image(buffer, 0, 0, 700 + x, 700);
pop();
}
}
blendMode(BLEND);
}
function keyPressed() {
if (key === 'f') {
let f = fullscreen();
fullscreen(!f);
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}