Guest User

Untitled

a guest
Nov 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. int[][] result;
  2. float t, c;
  3.  
  4. float ease(float p) {
  5. return 3*p*p - 2*p*p*p;
  6. }
  7.  
  8. float ease(float p, float g) {
  9. if (p < 0.5)
  10. return 0.5 * pow(2*p, g);
  11. else
  12. return 1 - 0.5 * pow(2*(1 - p), g);
  13. }
  14.  
  15. float mn = .5*sqrt(3), ia = atan(sqrt(.5));
  16.  
  17. void push() {
  18. pushMatrix();
  19. pushStyle();
  20. }
  21.  
  22. void pop() {
  23. popStyle();
  24. popMatrix();
  25. }
  26.  
  27. void draw() {
  28.  
  29. if (!recording) {
  30. t = mouseX*1.0/width;
  31. c = mouseY*1.0/height;
  32. if (mousePressed)
  33. println(c);
  34. draw_();
  35. } else {
  36. for (int i=0; i<width*height; i++)
  37. for (int a=0; a<3; a++)
  38. result[i][a] = 0;
  39.  
  40. c = 0;
  41. for (int sa=0; sa<samplesPerFrame; sa++) {
  42. t = map(frameCount-1 + sa*shutterAngle/samplesPerFrame, 0, numFrames, 0, 1);
  43. draw_();
  44. loadPixels();
  45. for (int i=0; i<pixels.length; i++) {
  46. result[i][0] += pixels[i] >> 16 & 0xff;
  47. result[i][1] += pixels[i] >> 8 & 0xff;
  48. result[i][2] += pixels[i] & 0xff;
  49. }
  50. }
  51.  
  52. loadPixels();
  53. for (int i=0; i<pixels.length; i++)
  54. pixels[i] = 0xff << 24 |
  55. int(result[i][0]*1.0/samplesPerFrame) << 16 |
  56. int(result[i][1]*1.0/samplesPerFrame) << 8 |
  57. int(result[i][2]*1.0/samplesPerFrame);
  58. updatePixels();
  59.  
  60. saveFrame("fr###.png");
  61. println(frameCount,"/",numFrames);
  62. if (frameCount==numFrames)
  63. exit();
  64. }
  65. }
  66.  
  67. //////////////////////////////////////////////////////////////////////////////
  68.  
  69. int samplesPerFrame = 5;
  70. int numFrames = 80;
  71. float shutterAngle = .8;
  72.  
  73. boolean recording = true;
  74.  
  75. OpenSimplexNoise noise;
  76.  
  77. void setup(){
  78. size(500,500);
  79. result = new int[width*height][3];
  80.  
  81. noiseDetail(1);
  82.  
  83. noise = new OpenSimplexNoise();
  84. }
  85.  
  86. int N = 75;
  87. int n = 100;
  88. float l = 250;
  89. float scl = 0.01;
  90. float r = 0.5;
  91.  
  92. void draw_(){
  93. background(0);
  94.  
  95. noStroke();
  96. stroke(255);
  97. strokeWeight(2);
  98.  
  99. for(int i=0;i<N;i++){
  100. float y = map(i,0,N-1,0,height);
  101.  
  102. fill(255*(i%2));
  103. fill(0);
  104.  
  105. beginShape();
  106. vertex(-1,height+10);
  107. for(int j=0;j<n;j++){
  108. float x = map(j,0,n-1,-1,width);
  109.  
  110. float intensity = ease(constrain(map(dist(x,y,width/2,height/2),0,0.5*width,1,0),0,1),2.0);
  111.  
  112. float yy = y + intensity*l*(float)noise.eval(100*y+scl*x,10+r*cos(TWO_PI*t + 0.05*i),10+r*sin(TWO_PI*t + 0.05*i));
  113.  
  114. vertex(x,yy);
  115. }
  116. vertex(width,height+10);
  117. endShape();
  118. }
  119.  
  120. }
Add Comment
Please, Sign In to add comment