Advertisement
Guest User

t

a guest
Feb 5th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. void setup() {
  2.   size(600, 600);
  3.   noStroke();
  4.   // noSmooth();
  5. }
  6. float t;
  7. color a = #FA003F;
  8. int frames = 600;
  9. float radius = 70;
  10. int size = 200;
  11. color back = #2D3339;
  12. int num = 13;
  13. float ss = ((2 * PI * size) / num) * 0.9;
  14. float theta = 0;
  15. void draw() {
  16.   t = (frameCount%frames)/(float)frames;
  17.   // VERY CRUDE HERE
  18.   if ((frameCount%frames)==0) {
  19.     fill(random(255), random(255), random(255));
  20.   }
  21.   background(back);
  22.   translate((int)width/2, (int)height/2);
  23.   pushMatrix();  
  24.   rotate(theta);
  25.   program();
  26.   popMatrix();
  27. }
  28.  
  29. void a() {
  30.   fill(a);
  31. }
  32.  
  33. void program() {
  34.   if ( t < 0.5) {
  35.  
  36.     float tt = map(t, 0, 0.5, 0, 1);
  37.     // FIRST QUARTER
  38.     if (tt < 0.5) {
  39.       for (int i = 0; i < num; i++) {
  40.         pushMatrix();
  41.         float r = map(tt, 0, 0.5, ss, 0);
  42.  
  43.         float move = map(i, 0, num, 0, TWO_PI);    
  44.         rotate(move);
  45.         translate(size, 0);
  46.         rotate(PI/2);
  47.         arc(0, 0, ss, r, 0, PI);
  48.         arc(0, 0, ss, ss, PI, TWO_PI); //doesn't move
  49.         popMatrix();
  50.       }
  51.     }
  52.     // SECOND QUARTER
  53.     else {
  54.  
  55.       for (int i = 0; i < num; i++) {
  56.         pushMatrix();
  57.         float move = map(i, 0, num, 0, TWO_PI);    
  58.         rotate(move);
  59.         translate(size, 0);
  60.         rotate(PI/2);
  61.         float r = map(tt, 0.5, 1, 0, ss);
  62.         arc(0, 0, ss, ss, PI, TWO_PI); // doesn't move
  63.         fill(back);
  64.         arc(0, 0, ss, r, PI, TWO_PI);
  65.         fill(255);
  66.         popMatrix();
  67.       }
  68.     }
  69.   }
  70.   // HALF TWO
  71.   else {
  72.     float tt = map(t, 0.5, 1, 0, 1);
  73.     if (tt < 0.5) {
  74.       for (int i = 0; i<num; i++) {
  75.         pushMatrix();
  76.         float move = map(i, 0, num, 0, TWO_PI);    
  77.         rotate(move);
  78.  
  79.         translate(size, 0);
  80.         rotate(PI/2);
  81.         float r = map(tt, 0, 0.5, ss, 0);
  82.         fill(255);
  83.         arc(0, 0, ss, ss, PI, TWO_PI);
  84.         fill(back);
  85.         arc(0, 0, ss, r, PI, TWO_PI);
  86.         popMatrix();
  87.       }
  88.     } else {
  89.       for (int i=0; i<num; i++) {
  90.         pushMatrix();
  91.         float move = map(i, 0, num, 0, TWO_PI);    
  92.         rotate(move);
  93.         translate(size, 0);
  94.         rotate(PI/2);
  95.         float r = map(tt, 0.5, 1, 0, ss);
  96.         fill(255);
  97.         arc(0, 0, ss, ss, PI, TWO_PI);
  98.         arc(0, 0, ss, r, 0, PI);
  99.         fill(255);
  100.         popMatrix();
  101.       }
  102.     }
  103.   }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement