Advertisement
xeromino

revolver

Nov 27th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. float org_x, org_y, r;
  2. int num = 100;
  3. Thingie[] things = new Thingie[num];
  4. color bg = #ECD078;
  5. color f = #542437;
  6.  
  7. void setup() {
  8.   size(500, 500);
  9.   background(bg);
  10.   stroke(f,220);
  11.   fill(bg,50);
  12.   strokeWeight(3);
  13.   rectMode(CENTER);
  14.  
  15.   org_x = width/2;
  16.   org_y = height/2;
  17.  
  18.   float start = 150;
  19.   float theta = 0;
  20.  
  21.   for (int i=0; i<num; i++) {
  22.     float x = sin(theta)*start;
  23.     float y = cos(theta)*start;
  24.     things[i]=new Thingie(x, y, theta);
  25.     theta += TAU/num;
  26.   }
  27. }
  28.  
  29. void draw() {
  30.   background(bg);
  31.  
  32.   for (int i=0; i<things.length;i++) {
  33.   things[i].display();
  34.   }
  35.   r += 0.0523;
  36.  
  37.   //if (frameCount % 4 ==0 && frameCount < 121) saveFrame("image-####.gif");
  38.    
  39. }
  40. class Thingie {
  41.   float x, y, theta, diam;
  42.  
  43.   Thingie(float _x, float _y, float _theta) {
  44.     x = _x;
  45.     y = _y;
  46.     theta = _theta;
  47.   }
  48.  
  49.   void display() {
  50.    
  51.     diam=map(sin(theta),-1,1,20,80);
  52.     translate(org_x, org_y);
  53.     rotate(r);
  54.     rect(x,y, diam, diam);
  55.     resetMatrix();
  56.    
  57.     theta += 0.0523;
  58.    
  59.    
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement