Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mloco committed Oct 28, 2011
0 parents commit 552d6ca
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git repo for processing projects
116 changes: 116 additions & 0 deletions circles/circles.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// import UDP library
import hypermedia.net.*;
import codeanticode.gsvideo.*;

// Globals
int ledsPerStrip = 157;
int bytesPerLed = 3;
int bytesPerStrip = ledsPerStrip * bytesPerLed;
int numStripsPerPacket = 16;
int numStripsPerSystem = 128;
int bufSize = bytesPerStrip * numStripsPerPacket + 4 + 4; // Strip data (471*16) + 8 byte UDP header)+ 4 bytes type + 4 bytes seq.
byte[] buf = new byte[bufSize];

String[]ipaddr = {"192.168.1.177", // stripctrl0 remote IP address
"192.168.1.178", // stripctrl1
"192.168.1.179", // stripctrl2
"192.168.1.180", // stripctrl3
"192.168.1.181", // stripctrl4
"192.168.1.182", // stripctrl5
"192.168.1.183", // stripctrl6
"192.168.1.184"}; // stripctrl7
int destPort = 6000; // the destination port
int srcPort = 6000; // the source port
int pps = 30; // Packets per second
long seq; // tx packet sequence number

UDP udp; // define the UDP object

GSMovie myMovie;

void setup() {

size(ledsPerStrip, numStripsPerSystem);

udp = new UDP( this, srcPort ); // create a new datagram connection on port 6000

print("UDP Buffer Size: ");
println(UDP.BUFFER_SIZE);

frameRate(pps);

seq = 1; // seq # starts at 1

for(int i= 0; i < bufSize; i++) {
buf[i] = (byte)0xFF;
} // set pattern in buf

//myMovie = new GSMovie(this, "Isotropic labs animation#1.mov"); //451x380
//myMovie = new GSMovie(this, "tubular fullness_1.mov");
//myMovie = new GSMovie(this, "tubular fullness_2.mov");
//myMovie = new GSMovie(this, "sample_iTunes.mov");
//myMovie = new GSMovie(this, "tubular fullness_4.mov");
//myMovie = new GSMovie(this, "tubular fullness.mov");
//myMovie = new GSMovie(this, "blip_automatic_Camera2_2.mov");
//myMovie.loop();
}

void draw() {

//image(myMovie, 0, 0, ledsPerStrip, numStripsPerSystem);
variableEllipse(mouseX, mouseY, pmouseX, pmouseY);

sendImage(); // Send out the current frame
}


// The simple method variableEllipse() was created specifically
// for this program. It calculates the speed of the mouse
// and draws a small ellipse if the mouse is moving slowly
// and draws a large ellipse if the mouse is moving quickly

void variableEllipse(int x, int y, int px, int py)
{
float speed = abs(x-px) + abs(y-py);
stroke(speed);
ellipse(x, y, speed, speed);
}

// Called every time a new frame is available to read
void movieEvent(GSMovie m) {
m.read();
}

void sendImage() {
loadPixels();

int ipidx = 0; // index into array of IP addresses for strip controllers

for(int lineidx = 0; lineidx < numStripsPerSystem; lineidx += numStripsPerPacket)
{
int pixelIdx = ledsPerStrip * lineidx;

for(int i= 8; i < bytesPerStrip * numStripsPerPacket + 8 - 1; i += 3) {
color curPixel = pixels[pixelIdx];
buf[i] = (byte) blue(curPixel); // Blue
buf[i+1] = (byte) green(curPixel); // Green
buf[i+2] = (byte) red(curPixel); // Red

pixelIdx++;
} // set pattern in buf
// Put a type 0 in the first long to signify this is a Strip Data packet
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;

// put a sequence # in the next 4 bytes of buf (little endien)
buf[4] = (byte)(seq & 0xFF);
buf[5] = (byte)((seq & 0xFF00) >> 8);
buf[6] = (byte)((seq & 0xFF0000) >> 16);
buf[7] = (byte)((seq & 0xFF000000) >> 24);
udp. send(buf, ipaddr[ipidx++], destPort ); // the message to send
}
seq++;
}

Binary file added circles/data/sample_iTunes.mov
Binary file not shown.
45 changes: 45 additions & 0 deletions sketch_oct27a/Mover.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Mover {
PVector location;
PVector velocity;
PVector acceleration;
float mass;

Mover(float m, float x, float y) {
mass = m;
location = new PVector(x,y);
velocity = new PVector(0,0);
acceleration = new PVector(0,0);
}

void applyForce(PVector force) {
PVector f = PVector.div(force,mass);
acceleration.add(f);
}

void update() {
velocity.add(acceleration);
location.add(velocity);
acceleration.mult(0);
}

void display() {
stroke(0);
fill(random(255), random(255), random(255));
ellipse(location.x,location.y,16,16);
}

void checkEdges() {
if (location.x > width) {
location.x = 0;
} else if (location.x < 0) {
location.x = width;
}

if(location.y > height) {
velocity.y *= -1;
location.y = height;
}

}

}
30 changes: 30 additions & 0 deletions sketch_oct27a/sketch_oct27a.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Mover[] movers = new Mover[100];

void setup() {
size(800, 800);
background(0);
smooth();
for (int i = 0; i < movers.length; i++) {
movers[i] = new Mover(random(0.1,5),0,0);
}
}

void draw() {
//noStroke();
//fill(0,10);
//rect(0,0,width,height);

PVector wind = new PVector(0.001,0);
PVector gravity = new PVector(0,0.1);

for (int i = 0; i < movers.length; i++) {
movers[i].applyForce(wind);
movers[i].applyForce(gravity);

movers[i].update();
movers[i].display();
movers[i].checkEdges();
}
}


0 comments on commit 552d6ca

Please sign in to comment.