Advertisement
xeromino

fire

Dec 7th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. int edge = 100;
  2. int units = 200;
  3. int col;
  4. float unit_width, theta;
  5. RBStrain[] rainbow = new RBStrain[units];
  6. color palette[] = {#EFAC41 , #DE8531 , #B32900 , #6C1305 , #330A04};
  7. color bg = #202020;
  8.  
  9. void setup() {
  10.   size(500, 500);
  11.   float max = width-2*edge;
  12.   unit_width = max/units;
  13.  
  14.   for (int i=0; i<units; i++) {
  15.     theta = random(TAU);
  16.     float maxh = random(100,150);
  17.     color col = palette[int(random(5))];  
  18.     rainbow[i]= new RBStrain(i, theta, col, maxh);
  19.   }
  20. }
  21.  
  22. void draw() {
  23.   background(bg);
  24.   for (int i=0; i<rainbow.length; i++) {
  25.     rainbow[i].display();
  26.   }
  27.  
  28.   //if (frameCount % 5 == 0 && frameCount < 241) saveFrame("image-####.gif");
  29.    
  30. }
  31.  
  32.  
  33. class RBStrain {
  34.   float i, theta, max;
  35.   color col;
  36.  
  37.   RBStrain(float _i, float _theta, color _col, float _max) {
  38.     i = _i;
  39.     theta = _theta;
  40.     col = _col;
  41.     max = _max;
  42.   }
  43.  
  44.   void display() {
  45.  
  46.     strokeWeight(.5);
  47.     stroke(255,25);  
  48.     float rblength = map(sin(theta*2), -1, 1, 30, max);
  49.     float alpha = map(sin(theta/2), -1, 1, 200, 255);
  50.     float str = map(sin(theta/2), -1, 1, 10, 1);
  51.     fill(col, alpha);
  52.     rect(edge+(i*unit_width), height-edge, unit_width, -(edge/2+rblength));
  53.     theta += 0.0523;
  54.   }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement