falling particles
in
Core Library Questions
•
2 years ago
Hi
We are trying to create a light sensitive sketch...where instead of the particles falling down, we want them to fade away ..this is the code we are using...but we want the fireworklike particles to react to the light not the darkness and then instead of dropping to the bottom of the screen and becoming not so sensitive, we want them to be active disappear and then be active again depending on who is passing the camera etc
ANy help would be greatly appreciated
Thank you
Beth and Maria
// Mirror1
// Daniel Shiffman <
http://www.shiffman.net>
// Each pixel from the video source is drawn as a
// rectangle with size based on brightness.
// Created 2 May 2005
import processing.video.*;
// Size of each cell in the grid
int cellsize = 30;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;
float pixcolR = random(2550);
float pixcolG = random(2550);
float pixcolB = random(2550);
ParticleSystem ps;
void setup()
{
size(640, 480);
frameRate(3000);
//set up columns and rows
cols = width/cellsize;
rows = height/cellsize;
colorMode(RGB,255,255,255,100);
ps = new ParticleSystem(1, new PVector(width/2,height/2,0));
smooth();
// Using the default capture device
video = new Capture(this, 640, 480, 15);
background(0);
}
void captureEvent(Capture camera)
{
camera.read();
}
void draw()
{
background(0);
pixcolR = random(255);
pixcolG = random(255);
pixcolB = random(255);
ps.run();
// Begin loop for columns
for ( int i = 0; i < cols;i++) {
// Begin loop for rows
for ( int j = 0; j < rows;j++) {
// Where are we, pixel-wise?
int x = i*cellsize;
int y = j*cellsize;
int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror the image
// Each rect is colored white with a size determined by brightness
color c = video.pixels[loc];
float sz = (brightness(c)/255.0f)*cellsize;
if (sz <=0.2){
ps.addParticle(x+cellsize/2,y+cellsize/2);
}
rectMode(CENTER);
//fill(255);
//stroke(255);
//noFill();
noStroke();
ellipse(x+cellsize/2,y+cellsize/2,sz,sz);
//line(x+cellsize/2,y+cellsize/2,sz,sz);
}
}
}
1