Advertisement
xeromino

rays

Mar 20th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. float distY, theta;
  2. int num = 30;
  3.  
  4. void setup() {
  5.   size(500, 500);
  6.   rectMode(CENTER);
  7.   noStroke();
  8. }
  9.  
  10. void draw() {
  11.   background(#FEDBC5);
  12.  
  13.   translate(width/2, height/2);
  14.  
  15.   createRing(1, -100, -180, #F55835);
  16.   createRing(1, -180, -100, #D82E48);
  17.   createRing(1, -150, -80, #8A0A43);
  18.  
  19.   theta += .0523;
  20.  
  21.   //if (frameCount%4==0 && frameCount<121) saveFrame("image-###.gif");
  22.  
  23. }
  24.  
  25. void createRing(int scal, float min, float max, color f) {
  26.   for (int i=0; i<num*scal; i++) {
  27.     pushMatrix();
  28.     rotate((TWO_PI/(num*scal))*i);
  29.     distY = map(sin(theta), -1, 1, min, max);
  30.     translate(0, distY);
  31.     fill(f);
  32.     rect(0, 0, (200/num)*(3-scal), (400/num)*(3-scal));
  33.     popMatrix();
  34.   }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement