Skip to content

Instantly share code, notes, and snippets.

@bevkcan
Last active March 31, 2024 07:18
Show Gist options
  • Save bevkcan/3cf59825e8dc6ec1f5dc3b123c540daf to your computer and use it in GitHub Desktop.
Save bevkcan/3cf59825e8dc6ec1f5dc3b123c540daf to your computer and use it in GitHub Desktop.
import peasy.*;
PeasyCam cam;
float inc=0.1;
float linelen=200;
float scl=20;
float hue=0;
float toff=0;
int depth=600;
int cols,rows,dpt;
float a=PI;
PVector v;
void setup(){
cam = new PeasyCam(this,height/2,width/2,depth/2,500);
size(600,600,P3D);
background(255);
cols = floor(width/scl);
rows = floor(height/scl);
dpt = floor(depth/scl);
}
void draw(){
//camera(1200,1200,1200,width/2, height/2, depth/2, 1.0, 1.0, 0.0);
background(0);
//colorMode(RGB);
//strokeWeight(1);
//stroke(255,0,0);
//line(width/2,height/2,depth/2,3000,height/2,depth/2);
//stroke(0,255,0);
//line(width/2,height/2,depth/2,width/2,3000,depth/2);
//stroke(0,0,255);
//line(width/2,height/2,depth/2,width/2,height/2,3000);
float zoff = 0;
for(int z = 0; z < dpt; z++){
float yoff = 0;
for(int y = 0; y < cols; y++){
float xoff=0;
for(int x = 0; x < rows; x++){
float r = noise(xoff,yoff,zoff)*a;
xoff += inc;
toff = frameCount/frameRate;
v = new PVector(map(r*noise(toff,0,0),0,a,-100,100),map(r*noise(0,toff,0),0,a,-100,100),map(r*noise(0,0,toff),0,a,-100,100));
hue = map(r*noise(toff),0,1,0,360);
v.normalize();
colorMode(HSB);
stroke(hue,255,255,20);
strokeWeight(3);
pushMatrix();
//rotate(r*map(noise(toff),0,1,-TWO_PI,TWO_PI),x,y,z);
translate(x*scl,y*scl,z*scl);
// rotateX(map(r*noise(toff/5,0,0),0,1,-TWO_PI,TWO_PI));
// rotateY(map(r*noise(0,toff/5,0),0,1,-TWO_PI,TWO_PI));
// rotateZ(map(r*noise(0,0,toff/5),0,1,-TWO_PI,TWO_PI));
rotate(r*map(noise(toff/5),0,1,-TWO_PI,TWO_PI),x,y,z);
line(0,0,0,-linelen*v.x,-linelen*v.y,-linelen*v.z);
// line(0,0,0,100,100,100);
popMatrix();
}
yoff +=inc;
}
zoff += inc;
}
//saveFrame("vector-#####.jpg");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment