
Fun accident
2 months ago
This was a complete accident (I was going for an affect so wildly different, it's kind of ridiculous). I acctually completely forgot to add something before hitting play.
But yeah, kinda pretty. Thought I would share. Here's the source.
import traer.physics.*;
import java.util.*;
import processing.video.*;
MovieMaker mm;
ParticleSystem physics;
Particle[] part;
Particle mouse;
Spring[] spring;
void setup() {
size(640, 480);
background(#83bdc9);
smooth();
colorMode(HSB,255);
mm = new MovieMaker(this, width, height, "drawing2.mov", 24, MovieMaker.JPEG , MovieMaker.MEDIUM );
physics = new ParticleSystem( 0, 0 );
part = new Particle[width];
mouse = physics.makeParticle();
mouse.makeFixed();
part[0] = physics.makeParticle( 1.0, 0, height/2, 0);
for ( int i = 1; i < part.length-1; i++ )
{
part[i] = physics.makeParticle( 1.0, i+1, height/2, 0 );
physics.makeSpring( part[i], part[i-1], 0.7, 0.1, 100 );
physics.makeAttraction( part[i], mouse, 5000, 40 );
}
}
void draw() {
physics.tick( 1.0);
mouse.position().set( mouseX, mouseY, 0);
//background( 255 );
for ( int i = 1; i < part.length-1; i++ )
{
Particle p = part[i];
Particle g = part[i-1];
fill(255);
stroke(p.age(), g.age()%255, random(0,255));
line(p.position().x(),p.position().y(),g.position().x(),g.position().y());
}
mm.addFrame();
}
void mouseClicked(){
saveFrame("p" + month() + day() + hour() + minute() + second() + ".png");
}
void keyPressed() {
if (key == ' ') {
// Finish the movie if space bar is pressed
mm.finish();
// Quit running the sketch once the file is written
exit();
}
}
But yeah, kinda pretty. Thought I would share. Here's the source.
import traer.physics.*;
import java.util.*;
import processing.video.*;
MovieMaker mm;
ParticleSystem physics;
Particle[] part;
Particle mouse;
Spring[] spring;
void setup() {
size(640, 480);
background(#83bdc9);
smooth();
colorMode(HSB,255);
mm = new MovieMaker(this, width, height, "drawing2.mov", 24, MovieMaker.JPEG , MovieMaker.MEDIUM );
physics = new ParticleSystem( 0, 0 );
part = new Particle[width];
mouse = physics.makeParticle();
mouse.makeFixed();
part[0] = physics.makeParticle( 1.0, 0, height/2, 0);
for ( int i = 1; i < part.length-1; i++ )
{
part[i] = physics.makeParticle( 1.0, i+1, height/2, 0 );
physics.makeSpring( part[i], part[i-1], 0.7, 0.1, 100 );
physics.makeAttraction( part[i], mouse, 5000, 40 );
}
}
void draw() {
physics.tick( 1.0);
mouse.position().set( mouseX, mouseY, 0);
//background( 255 );
for ( int i = 1; i < part.length-1; i++ )
{
Particle p = part[i];
Particle g = part[i-1];
fill(255);
stroke(p.age(), g.age()%255, random(0,255));
line(p.position().x(),p.position().y(),g.position().x(),g.position().y());
}
mm.addFrame();
}
void mouseClicked(){
saveFrame("p" + month() + day() + hour() + minute() + second() + ".png");
}
void keyPressed() {
if (key == ' ') {
// Finish the movie if space bar is pressed
mm.finish();
// Quit running the sketch once the file is written
exit();
}
}
-
Vimeo: About / Blog / Developers / Jobs / Community Guidelines / Community Forums / Help Center / Site Map / Merchandise
/ Get Vimeo

Previous Week