Guest User

Untitled

a guest
Jul 16th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 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 = 40;
  71. float shutterAngle = .6;
  72.  
  73. boolean recording = true;
  74.  
  75. OpenSimplexNoise noise;
  76.  
  77. int n = 25;
  78.  
  79. int m = 3500;
  80.  
  81. void draw_curve(float q){
  82.  
  83. q = pow(q,4.0);
  84.  
  85. int m2 = 1 + floor(q*m);
  86.  
  87. stroke(255,75);
  88. strokeWeight(2);
  89.  
  90. float r = width*q;
  91.  
  92. for(int i=0;i<m2;i++){
  93. float p = 1.0*i/m2;
  94.  
  95. float x = r*cos(TWO_PI*p);
  96. float y = r*sin(TWO_PI*p);
  97.  
  98. float rad = 7.0*sin(PI*q);
  99.  
  100. float dx = 50*(float)noise.eval(rad*cos(TWO_PI*p),rad*sin(TWO_PI*p),0.5*q);
  101. float dy = 50*(float)noise.eval(10+q*rad*cos(TWO_PI*p),rad*sin(TWO_PI*p),0.5*q);
  102.  
  103. float sw = (1+5*q)*map((float)noise.eval(20+2*rad*cos(TWO_PI*p),2*rad*sin(TWO_PI*p),1.0*q),-1,1,0.25,3.0);
  104. strokeWeight(sw);
  105.  
  106. point(x+dx,y+dy);
  107. }
  108. }
  109.  
  110. void setup(){
  111. size(540,540,P3D);
  112. result = new int[width*height][3];
  113.  
  114. noise = new OpenSimplexNoise();
  115.  
  116. }
  117.  
  118. void draw_(){
  119. push();
  120. background(0);
  121. translate(width/2,0.6*height);
  122.  
  123. for(int i=0;i<n;i++){
  124. float q = 1.0*(i+t)/n;
  125. draw_curve(q);
  126. }
  127.  
  128. pop();
  129.  
  130. }
Add Comment
Please, Sign In to add comment