Guest User

Fiveagon Jack

a guest
Dec 5th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. import java.time.LocalDateTime;
  2. import java.time.format.DateTimeFormatter;
  3. import java.util.List;
  4.  
  5. int numPoints = 6;
  6. int numCopies = 5;
  7. int numFrames = 90;
  8. float rotation = TWO_PI / (numFrames * numCopies);
  9. float copyAngle = TWO_PI / numCopies;
  10.  
  11. List<PVector> points = new ArrayList<PVector>(numPoints);
  12. List<PVector> rotations = new ArrayList<PVector>(numPoints);
  13.  
  14. color[] palette = {#EA5455, #F07B3F, #FFD460};
  15. color backgroundColor = #2D4059;
  16.  
  17. DateTimeFormatter timeFormat = DateTimeFormatter.ofPattern("yyMMdd-HHmmss");
  18. String frameName = timestamp() + "\\jack-###.png";
  19. boolean savingFrames = false;
  20.  
  21. void setup() {
  22.   size(540, 540, P3D);
  23.   smooth(8);
  24.   ortho();
  25.   frameRate(50);
  26.  
  27.   for (int i = 0; i < numPoints; i++) {
  28.     PVector p = PVector.random3D();
  29.     //float size = random(200, 250);
  30.     float size = 150;
  31.     p.mult(size);
  32.     points.add(p);
  33.    
  34.     PVector r = PVector.random3D();
  35.     rotations.add(r);
  36.   }
  37. }
  38.  
  39. void draw() {
  40.   background(backgroundColor);
  41.   translate(width/2, height/2);
  42.  
  43.   for (int i = 0; i < points.size(); i++) {
  44.     PVector p = points.get(i);
  45.     PVector r = rotations.get(i);    
  46.     stroke(palette[i % palette.length]);
  47.    
  48.     for (int j = 0; j < numCopies; j++) {
  49.       pushMatrix();
  50.       rotateX(r.x + copyAngle * j);
  51.       rotateY(r.y + copyAngle * j);    
  52.       strokeWeight(5);
  53.       line(0, 0, 0, p.x, p.y, p.z);
  54.       strokeWeight(15);
  55.       point(p.x, p.y, p.z);
  56.       popMatrix();
  57.     }
  58.     r.add(rotation, rotation, rotation);
  59.   }
  60.  
  61.   if (savingFrames) {
  62.     saveFrame(frameName);
  63.     if (frameCount >= numFrames) {
  64.       exit();
  65.     }
  66.   }
  67. }
  68.  
  69. String timestamp() {
  70.   return LocalDateTime.now().format(timeFormat);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment