Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. // by dave @ 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 | (result[i][0]/samplesPerFrame) << 16 |
  35. (result[i][1]/samplesPerFrame) << 8 | (result[i][2]/samplesPerFrame);
  36. updatePixels();
  37.  
  38. saveFrame("g###.png");
  39. if (frameCount==numFrames)
  40. exit();
  41. }
  42. }
  43.  
  44. //////////////////////////////////////////////////////////////////////////////
  45.  
  46. int samplesPerFrame = 4;
  47. int numFrames = 72;
  48. float shutterAngle = .8;
  49.  
  50. boolean recording = false;
  51.  
  52. int N = 12;
  53. float d, y;
  54.  
  55. void setup_() {
  56. size(500, 500);
  57. colorMode(HSB, 1);
  58. strokeWeight(9);
  59. fill(.1);
  60. }
  61.  
  62. void draw_() {
  63. background(.1);
  64. pushMatrix();
  65. translate(width/2, height/2);
  66. for (int i=-N; i<4*N; i++) {
  67. stroke((i/float(N)+4)%1, .7, .9);
  68. y = 300*(t+i/float(N));
  69. pushMatrix();
  70. rotate(TWO_PI*i/N);
  71. d = lerp(250, 600, i/float(N)+t);
  72. ellipse(0, y, d, d);
  73. popMatrix();
  74. }
  75. popMatrix();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement