Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. // by dw @ bees & bombs
  2.  
  3. int[][] result;
  4. float t;
  5.  
  6. void setup() {
  7. setup_();
  8. result = new int[width*height][3];
  9. }
  10.  
  11. void draw() {
  12.  
  13. if (!recording) {
  14. t = mouseX*1.0/width;
  15. draw_();
  16. } else {
  17. for (int i=0; i<width*height; i++)
  18. for (int a=0; a<3; a++)
  19. result[i][a] = 0;
  20.  
  21. for (int sa=0; sa<samplesPerFrame; sa++) {
  22. t = map(frameCount-1 + sa*shutterAngle/samplesPerFrame, 0, numFrames, 0, 1);
  23. draw_();
  24. loadPixels();
  25. for (int i=0; i<pixels.length; i++) {
  26. result[i][0] += pixels[i] >> 16 & 0xff;
  27. result[i][1] += pixels[i] >> 8 & 0xff;
  28. result[i][2] += pixels[i] & 0xff;
  29. }
  30. }
  31.  
  32. loadPixels();
  33. for (int i=0; i<pixels.length; i++)
  34. pixels[i] = 0xff << 24 |
  35. int(result[i][0]*1.0/samplesPerFrame) << 16 |
  36. int(result[i][1]*1.0/samplesPerFrame) << 8 |
  37. int(result[i][2]*1.0/samplesPerFrame);
  38. updatePixels();
  39.  
  40. saveFrame("f###.gif");
  41. if (frameCount==numFrames)
  42. exit();
  43. }
  44. }
  45.  
  46. //////////////////////////////////////////////////////////////////////////////
  47.  
  48. int samplesPerFrame = 8;
  49. int numFrames = 120;
  50. float shutterAngle = .6;
  51.  
  52. boolean recording = false;
  53.  
  54. void setup_() {
  55. size(500, 500, P2D);
  56. smooth(8);
  57. fill(32);
  58. noStroke();
  59. }
  60.  
  61. void leaf() {
  62. bezier(0, 0, 42, 0, 15, 27, 0, 50);
  63. bezier(0, 0, -42, 0, -15, 27, 0, 50);
  64. }
  65.  
  66. float x, y, tt;
  67. int N = 5;
  68. float t1;
  69.  
  70. void draw_() {
  71. background(250);
  72. pushMatrix();
  73. translate(width/2, height/2);
  74. rotate(QUARTER_PI);
  75. for (int a=-1; a<8; a++) {
  76. t1 = .16*(t+a);
  77. if (0<=t1 && t1<=1) {
  78. N = 2*int(4*pow(2, int(5*t1)));
  79. for (int i=0; i<N; i++) {
  80. tt = (5*t1)%1;
  81. tt = max(0, 1.7*tt-.7);
  82. tt = 3*tt*tt - 2*tt*tt*tt;
  83.  
  84. pushMatrix();
  85. rotate(TWO_PI/N);
  86. rotate(-PI*tt/N);
  87. rotate(2*TWO_PI*(i/2)/N);
  88. if (i%2 == 0)
  89. rotate(TWO_PI*tt/N);
  90. translate(0, -2+350*pow(t1,1));
  91. scale(pow(4, -t1));
  92. if(t1<=.12)
  93. scale(pow(sin(HALF_PI*t1/.12),.85));
  94. scale(1,pow(1+.5*t1,.8));
  95. leaf();
  96. popMatrix();
  97. }
  98. }
  99. }
  100. popMatrix();
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement