Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- import java.util.List;
- int numPoints = 6;
- int numCopies = 5;
- int numFrames = 90;
- float rotation = TWO_PI / (numFrames * numCopies);
- float copyAngle = TWO_PI / numCopies;
- List<PVector> points = new ArrayList<PVector>(numPoints);
- List<PVector> rotations = new ArrayList<PVector>(numPoints);
- color[] palette = {#EA5455, #F07B3F, #FFD460};
- color backgroundColor = #2D4059;
- DateTimeFormatter timeFormat = DateTimeFormatter.ofPattern("yyMMdd-HHmmss");
- String frameName = timestamp() + "\\jack-###.png";
- boolean savingFrames = false;
- void setup() {
- size(540, 540, P3D);
- smooth(8);
- ortho();
- frameRate(50);
- for (int i = 0; i < numPoints; i++) {
- PVector p = PVector.random3D();
- //float size = random(200, 250);
- float size = 150;
- p.mult(size);
- points.add(p);
- PVector r = PVector.random3D();
- rotations.add(r);
- }
- }
- void draw() {
- background(backgroundColor);
- translate(width/2, height/2);
- for (int i = 0; i < points.size(); i++) {
- PVector p = points.get(i);
- PVector r = rotations.get(i);
- stroke(palette[i % palette.length]);
- for (int j = 0; j < numCopies; j++) {
- pushMatrix();
- rotateX(r.x + copyAngle * j);
- rotateY(r.y + copyAngle * j);
- strokeWeight(5);
- line(0, 0, 0, p.x, p.y, p.z);
- strokeWeight(15);
- point(p.x, p.y, p.z);
- popMatrix();
- }
- r.add(rotation, rotation, rotation);
- }
- if (savingFrames) {
- saveFrame(frameName);
- if (frameCount >= numFrames) {
- exit();
- }
- }
- }
- String timestamp() {
- return LocalDateTime.now().format(timeFormat);
- }
Advertisement
Add Comment
Please, Sign In to add comment