Advertisement
xeromino

arcs

Jan 20th, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. ArrayList bows = new ArrayList();
  2. int fr;
  3. int step = 100;
  4. boolean clicked = false;
  5.  
  6. void setup() {
  7.   size(500, 500);
  8.   background(#202020);
  9.   strokeCap(SQUARE);
  10.   //strokeWeight(step/4);
  11.   strokeWeight(2);
  12.  
  13.   bows.clear();
  14.  
  15.   for (int x=0; x<width+1; x += step) {
  16.     for (int y=0; y<height+1; y += step) {
  17.       for (int i=0; i<4; i++) {
  18.         Bow bow = new Bow(x, y, i*PI/2, (i+1)*PI/2, random(1));
  19.         bows.add(bow);
  20.       }
  21.     }
  22.   }
  23. }
  24.  
  25. void draw() {
  26.  
  27.   background(#202020);
  28.   for (int i=0; i<bows.size();i++) {
  29.     Bow bow = (Bow) bows.get(i);
  30.     bow.display();
  31.   }
  32.  
  33.   if (clicked==true) {
  34.     if (frameCount % 2 == 0 && frameCount < fr+121) saveFrame("image-####.gif");
  35.   }
  36. }
  37.  
  38. void mousePressed() {
  39.   setup();
  40. }
  41.  
  42. void keyPressed() {
  43.   fr = frameCount;
  44.   clicked = true;
  45. }
  46.  
  47. class Bow {
  48.   int x, y;
  49.   float r, start, end, end2, theta;
  50.  
  51.   Bow(int _x, int _y, float _start, float _end, float _r) {
  52.     x = _x;
  53.     y = _y;
  54.     start = _start;
  55.     end = _end;
  56.     r = _r;
  57.   }
  58.  
  59.   void display() {
  60.  
  61.     noFill();
  62.     int c = 0;
  63.     if (r > .35) {
  64.       stroke(#f5e638);
  65.       if (r > .5) {
  66.         end2 = map(sin(theta), -1, 1, start, end);
  67.       }
  68.       else {
  69.         end2 = end;
  70.       }
  71.     }
  72.     else {
  73.       noStroke();
  74.     }      
  75.     arc(x, y, step, step, start, end2);
  76.     theta += 0.0523;
  77.   }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement