Guest User

Untitled

a guest
Nov 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. OpenSimplexNoise noise;
  2.  
  3. int numFrames = 100;
  4.  
  5. int margin = 50;
  6.  
  7. int m;
  8.  
  9. class Line{
  10. float lr;
  11. float scl;
  12. float h;
  13.  
  14. Line(float lr_,float scl_, float h_){
  15. lr = lr_;
  16. scl = scl_;
  17. h = h_;
  18. }
  19. }
  20.  
  21. ArrayList<Line> lines = new ArrayList<Line>();
  22.  
  23.  
  24. void setup(){
  25. size(600,600);
  26. background(0);
  27.  
  28. noise = new OpenSimplexNoise();
  29.  
  30. float sumh = 0;
  31. while(true){
  32. float lr = 0.5*pow(random(0.5,2.0),2);
  33. float scl = 0.1*pow(random(0.4,2),2);
  34. float h = 100.0*pow(random(0.2,1),4.0);
  35. sumh += h;
  36. if(sumh>=height-2*margin){
  37. h -= sumh - (height-2*margin);
  38. lines.add(new Line(lr,scl,h));
  39. m++;
  40. break;
  41. }
  42. lines.add(new Line(lr,scl,h));
  43. m++;
  44. }
  45.  
  46. println(m);
  47. }
  48.  
  49. void draw(){
  50. blendMode(BLEND);
  51. background(15);
  52.  
  53. float t = 1.0*(frameCount-1)%numFrames/numFrames;
  54.  
  55. float sumh = 0;
  56.  
  57. for(int j = 0;j<m;j++){
  58. for(int x = margin;x<width-margin;x++){
  59. float loop_radius = lines.get(j).lr;
  60. double ns = noise.eval(100*j+lines.get(j).scl*x,loop_radius*cos(TWO_PI*t),loop_radius*sin(TWO_PI*t));
  61. float col = constrain(map((float)ns,-0.05,0.05,0,255),0,255);
  62. stroke(col);
  63. line(x,margin+sumh,x,margin+lines.get(j).h+sumh);
  64. }
  65. sumh+=lines.get(j).h;
  66. }
  67.  
  68. stroke(255);
  69. noFill();
  70. rect(margin,margin,width-2*margin,height-2*margin);
  71.  
  72. blendMode(EXCLUSION);
  73. noStroke();
  74. fill(255);
  75. ellipse(width/2,height/2,0.7*width,0.7*width);
  76.  
  77. if(frameCount<=numFrames){
  78. saveFrame("fr####.png");
  79. }
  80. if(frameCount==numFrames){
  81. println("finished");
  82. }
  83. }
Add Comment
Please, Sign In to add comment