Advertisement
xeromino

unstable

Aug 13th, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. float unit, theta;
  2. int num = 20;
  3.  
  4. void setup() {
  5. size(500, 500);
  6. unit = width/num;
  7. noStroke();
  8. rectMode(CENTER);
  9. }
  10.  
  11. void draw() {
  12. randomSeed(60);
  13. background(0);
  14. for (int y=0; y<=num; y++) {
  15. for (int x=0; x<=num; x++) {
  16. float distance = dist(width/2, height/2, x*unit, y*unit);
  17. float offSet = map(distance, 0, width/2+height/2, 0, TWO_PI);
  18. float sz = unit;
  19. float lerpAmount = map(distance, 0, width/2+height/2, 0, 1);
  20. float e = map(sin(theta+offSet*2), -1, 1, 0, unit/2);
  21. color col = lerpColor(#71A1FF, #0E103E, lerpAmount);
  22. if (random(1)>.2) {
  23. fill(col);
  24. } else {
  25. fill(#dddddd);
  26. }
  27. pushMatrix();
  28. translate(x*unit, y*unit);
  29. rect(0, 0, sz, sz,e);
  30. popMatrix();
  31. }
  32. }
  33. theta -= 0.0523;
  34. //if (frameCount%3==0 && frameCount<121) saveFrame("image-###.gif");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement