« October 2008 | Main | February 2009 »

January 2009 Archives

January 26, 2009

Processing: Ghosting Circles

I recently wrote a neat little program in processing that allows a user to place circles (by clicking the screen) and move them around by dragging the mouse. Each circle leaves a ghostly trail behind it as it moves. Paste the code into processing to experience it yourself!!!

-------

/* Sean's circle tracking extravaganza! it's the winningest!
* In this program, the user can click anywhere on
* screen and a ball of random color and size will
* appear on the screen! when the user moves the
* mouse around, the balls will move with some
* random correlation to the mouse movement
*
*/

//number of circles
int numCircs = 30;

circle[] circArray = new circle[numCircs];

void setup() {
//initialize all the circles
for(int i = 0; i < numCircs; i++) {
circArray[i] = new circle();
}


size(1024,768);
background(0);
fill(random(255),random(255),random(255));
noStroke();


//you can adjust the frame rate if you want O_O_O_O
//frameRate(100);

}

void draw() {
translate(1024/2, 768/2);
background(0);
for (int i = 0; i circArray[i].update();
}
}

void mousePressed() {
//draw an ellipse with a random size
for (int i = numCircs-1; i>0 ; i--) {
circArray[i]=circArray[i-1];
}
circArray[0] = new circle(mouseX-1024/2, mouseY-768/2, random(10,45), random(-2,2), random(-2,2), int(random(10,80)));
}


class circle {
float[] xPos;
float[] yPos;
float radius;
float factorX;
float factorY;
int numTrail;
int trackme = 0;

float c1 = random(255);
float c2 = random(255);
float c3 = random(255);

circle() {
numTrail = 1;
xPos = new float[numTrail];
yPos = new float[numTrail];
for(int i = 0; i xPos[i] = 0;
yPos[i] = 0;
}
radius = 0;
factorX = 0;
factorY = 0;
}

circle(float x,float y,float r,float fx, float fy, int Trails) {
numTrail = Trails;
xPos = new float[numTrail];
yPos = new float[numTrail];

for(int i = 0; i xPos[i] = x;
yPos[i] = y;
}
radius = r;
factorX = fx;
factorY = fy;
}

void update() {
trackme++;
rotate(PI*trackme*factorX*.5/4000);

float mouseChangeX = mouseX-pmouseX;
float mouseChangeY = mouseY-pmouseY;

// Reads throught the entire array
// and shifts the values to the left
for(int i=1; i xPos[i-1] = xPos[i];
yPos[i-1] = yPos[i];
}
// Add the new values to the end of the array
xPos[numTrail-1] += mouseChangeX*factorX;
yPos[numTrail-1] += mouseChangeY*factorY;

fill(c1,c2,c3, 28);
for(int i=0; i float divisor = (radius/numTrail)*i;
ellipse(xPos[i], yPos[i], divisor, divisor);
}

}

}

January 29, 2009

Processing: Pulsing Circles!

I created an extension of my last pulsing circles piece which incorporates "Minim," a sound library for processing. If you download the link below, you must change the input song name. In the code, search for "intotrees" and replace it with "<>.mp3". It's pretty fun to play with!

Download file

Processing: Sandy Paths

Here's another processing project created by myself and Jim Taylor, another first year MFA. You drag the mouse around the screen and it paints a sandy landscape colored by the sounds of the music.

Download file

To run this file, you need two libraries, the Minim audio library:

http://code.compartmental.net/tools/minim/

and the physics library:

http://www.cs.princeton.edu/%7Etraer/physics/

Also, you'll need to put an mp3 file in the same directory as the processing project and replace "missyou.mp3" with the appropriate song filename. I can't upload missyou.mp3 due to copyright purposes : ].

Enjoy!

-Sean

About January 2009

This page contains all entries posted to Sean Plott in January 2009. They are listed from oldest to newest.

October 2008 is the previous archive.

February 2009 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31