make previous frame fading away when mouse clicked.
in
Programming Questions
•
11 months ago
(refer to Kostas Terzidis's Algorithms for Visual Design, pp.139)
A small tweak of the background alpha value can make the previous frame fading away ...
haven't figured out how to make this effect in 3D scene ... advices are appreciated!
A small tweak of the background alpha value can make the previous frame fading away ...
haven't figured out how to make this effect in 3D scene ... advices are appreciated!
- import processing.opengl.*;
//import peasy.*;
//PeasyCam cam;
PGraphicsOpenGL pg; // define a PGraphics type of buffer object
int dim =500;
void setup(){
size(dim, dim, OPENGL);
background(100);
// cam = new PeasyCam(this,600);
pg = (PGraphicsOpenGL)createGraphics(dim,dim,P3D); // create a buffer object
}
void draw(){
image(pg, 0, 0); // draw the buffer
}
int x1,y1,x2,y2;
void mouseClicked(){
pg.beginDraw(); // start writing to the buffer
pg.background(0,10); // previous frame will fade out, the smaller the alpha, the slower the fading
for (int i=0; i<100; i++){
x1 = int(random(dim)); y1 = int(random(dim));
x2 = int(random(dim)); y2 = int(random(dim));
pg.stroke(255);
pg.strokeWeight(1);
pg.line(x1,y1,x2,y2);
pg.stroke(random(255),random(255),random(255));
pg.strokeWeight(random(1,10));
pg.point(x1,y1);
pg.strokeWeight(random(10,20));
pg.point(x2,y2);
}
pg.endDraw(); // end writing to the buffer
}
1