Created
December 8, 2017 04:04
-
-
Save Trimad/fa40fe0052b6970f493bf98dc4c64f0d to your computer and use it in GitHub Desktop.
Lorenz Ball
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
//Lorenz Attractor Constants | |
int La = 10; | |
int Lb = 28; | |
float Lc = 8/3.0; | |
//My variables | |
int vScale = 2; | |
//int phases = 10; | |
float dt = .005; | |
class Itinerant { | |
float x; | |
float y; | |
float z; | |
float Lx = 0.01; | |
float Ly = 0.01; | |
float Lz = 0.01; | |
float dx; | |
float dy; | |
float dz; | |
int col; | |
//int bri; | |
//float angle; | |
Itinerant(int [] arr) { | |
this.col = arr[0]; | |
//this.bri = arr[1]; | |
this.x = arr[2]; | |
this.y = arr[3]; | |
this.z = arr[4]; | |
//this.angle = map(bri, 0, 255, 0, phases); | |
} | |
void update() { | |
this.dx = (La*(Ly-Lx))*dt; | |
this.dy = (Lx*(Lb-Lz)-Ly)*dt; | |
this.dz = (Lx*Ly)-(Lc*Lz)*dt; | |
this.x += this.dx;// * Math.cos(this.angle); | |
this.y += this.dy;// * Math.sin(this.angle); | |
this.z += this.dz;// *Math.tan(this.angle); | |
if (this.y >= height/2) { | |
this.y = height; | |
} | |
if (this.x >= width/2) { | |
this.x = width; | |
} | |
} | |
public float getZ() { | |
return this.z; | |
} | |
void makePoints() { | |
rotateY(radians(this.x)); | |
rotateX(radians(this.y)); | |
rotateZ(radians(this.z)); | |
stroke(this.col); | |
strokeWeight(3); | |
point(this.x, this.y, this.z); | |
} | |
} |
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
//ffmpeg -i test.mp4 -i lol.mp3 -codec copy -shortest output.mp4 | |
//ffmpeg -r 60 -f image2 -s 3840x2160 -i frame-%04d.tif -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low test.mp4 | |
import peasy.*; | |
import peasy.org.apache.commons.math.*; | |
import peasy.org.apache.commons.math.geometry.*; | |
import ch.bildspur.postfx.builder.*; | |
import ch.bildspur.postfx.pass.*; | |
import ch.bildspur.postfx.*; | |
PostFX fx; | |
PeasyCam cam; | |
ArrayList<Itinerant> itinerant = new ArrayList<Itinerant>(); | |
ArrayList<Itinerant> sorted; | |
PImage img; | |
PGraphics pg; | |
int framesToDraw = 6360; | |
float cameraZoom = -11680; | |
//float cameraZoom = -5900; | |
void setup() { | |
frameRate(60); | |
size(3840, 2160, P3D); | |
smooth(4); | |
background(0); | |
img = loadImage("r3.jpg"); | |
fx = new PostFX(this); | |
convertPixelsToObjects(); | |
sorted = new ArrayList(itinerant); | |
} | |
void draw() { | |
saveFrame("frame-####.tif"); | |
if (frameCount >= framesToDraw+2) { | |
exit(); | |
} | |
camera(cameraZoom, 0.0, 0.0, // eyeX, eyeY, eyeZ | |
0.0, 0.0, 0.0, // centerX, centerY, centerZ | |
0.0, 1.0, 0.0); // upX, upY, upZ | |
background(0); | |
for (int i = 0; i < itinerant.size()-1; i++) { | |
itinerant.get(i).update(); | |
itinerant.get(i).makePoints(); | |
} | |
fx.render() | |
.bloom(0.1, 100, 10) | |
.blur(2, 10) | |
.compose(); | |
if (cameraZoom < -8500) { | |
cameraZoom+=5; | |
} | |
} | |
public void convertPixelsToObjects() { | |
img.loadPixels(); | |
for (int x = 0; x < img.width/vScale; x +=vScale) { | |
for (int y = 0; y < img.height/vScale; y +=vScale) { | |
int index = (x+y*img.width); | |
int xModifier = (width/2-img.width/2); | |
int yModifier = (height/2-img.height/2); | |
int zModifier = 0; | |
int [] info = new int[5]; //Contains all information needed for the object | |
if (index < floor(width*height/vScale)) { | |
info[0] = img.get(floor(x*vScale), floor(y*vScale)); //color | |
//info[1] = round(brightness(info[0])); | |
info[2] = xModifier+(x*vScale);//x-position | |
info[3] = yModifier+(y*vScale); //y-position | |
//info[4] = zModifier; | |
itinerant.add(new Itinerant(info)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment