-
-
Save anonymous/25351c16fe6bb97a9825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Fumiaki Takezawa | |
//Spring 2014 | |
//University of Illinois at Urbana-Champaign | |
int pdfCount = 30; | |
import processing.pdf.*; | |
int MaxAgents = 1000; | |
Agent[]agents = new Agent[MaxAgents]; | |
int numAgents = 0; | |
PGraphicsPDF pdf; | |
float xpos = 0; | |
float ypos = 0; | |
float interval = 100; | |
float interval2 = 100; | |
float interval3 = 100; | |
float jumpmin = 200; | |
float jumpmax = 500; | |
float xspeed = 5; | |
float yspeed = 5; | |
float c; | |
float sw = 1; | |
int counter = 0; | |
void setup() { | |
frameRate(30); | |
size(1000, 1000, OPENGL); | |
background(255); | |
for (int i = 0; i<agents.length; i++) { | |
agents[i] = new Agent(); | |
} | |
pdf = (PGraphicsPDF)createGraphics(width, height, PDF, "test"+pdfCount+".pdf"); | |
beginRaw(pdf); | |
} | |
void draw() { | |
counter++; | |
for (int i = 0; i <agents.length; i++) { | |
float xtrans = width/2; | |
float ytrans = height/2; | |
c=random(0, 45); | |
agents[i].drawPoints(xpos, ypos, xtrans, ytrans, interval, interval2, interval3, jumpmin, jumpmax); | |
} | |
if (counter >= 500) { | |
endRaw(); | |
exit(); | |
} | |
} | |
class Agent { | |
float zpos; | |
float zrot; | |
float xpos; | |
float ypos; | |
float zpos2; | |
float zrot2; | |
float xpos2; | |
float ypos2; | |
float div = 1; | |
int counter = 0; | |
int rotCounter =0; | |
int rotCounter2=0; | |
float rot = .1000000000; | |
float jump; | |
float xjump = 300; | |
float yjump = 300; | |
float xrot = random(500); | |
float yrot = random(500); | |
float xtrans = width/2; | |
float ytrans = height/2; | |
float rand; | |
float rand2; | |
void drawPoints(float xpos, float ypos, float xtrans, float ytrans, float interval, float interval2, float interval3, float jumpmin, float jumpmax) | |
{ | |
int r = int(random(1, 5)); | |
int r2 = int(random(0, 10)); | |
colorMode(HSB); | |
rectMode(CENTER); | |
strokeWeight(sw); | |
c = random(0, 30); | |
stroke(0, 16); | |
pushMatrix(); | |
translate(xtrans, ytrans); | |
// ------------------------------------------------------------------------------ | |
rotateX(xpos); | |
rotateY(yrot); | |
rotateZ(-zrot); | |
zpos++; | |
xpos = xjump; | |
ypos = yjump; | |
if (xpos>= width/div) { | |
xpos = 0; | |
} | |
if (ypos >= height/div) { | |
ypos = 0; | |
} | |
if (zpos >= width/div) { | |
zpos =0; | |
} | |
if (rotCounter2 >= 1000) { | |
zrot = 0; | |
rot = 0; | |
} | |
//yjump+=1; | |
//xjump+=1; | |
/*if (yjump >= 200) { | |
xjump+=1000; | |
yjump = 0; | |
}*/ | |
zrot += rot; | |
//-------------------------------------------------------------------------- | |
rotateX(-xpos); | |
rotateY(-yrot); | |
rotateZ(-zrot2); | |
rotateX(yrot); | |
rotateX(-yrot); | |
rotateX(yrot); | |
//rotateY(xrot); | |
rotateZ(zrot); | |
zpos2++; | |
point(xpos2, ypos2); | |
point(-xpos2, -ypos2); | |
xpos2 = xjump; | |
ypos2 = yjump; | |
if (xpos2>= width/div) { | |
xpos2 = 0; | |
} | |
if (ypos2 >= height/div) { | |
ypos2 = 0; | |
} | |
if (zpos2 >= width/div) { | |
zpos2 =0; | |
} | |
if (rotCounter2 >= 1000) { | |
zrot2 = 0; | |
rot = 0; | |
} | |
zrot2 -= rot; | |
//--------------------------------------------------------------------- | |
popMatrix(); | |
} | |
void agentsmove(float xpos, float ypos, float xspeed, float yspeed) { | |
xpos+= xspeed; | |
ypos+= yspeed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment