Advertisement
xeromino

collabo

Oct 10th, 2014
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. // Code by @MetaGlitch
  2.  
  3. float fps = 16.666;
  4.  
  5. int inFrames = 15;
  6. int outFrames = 15;
  7. int otherFrames = 60;
  8. int numFrames = inFrames + otherFrames + outFrames;
  9.  
  10. float t1 = inFrames * 1.0/numFrames;
  11. float t2 = (inFrames+otherFrames) * 1.0/numFrames;
  12.  
  13. int samplesPerFrame = 8;
  14. float exposure = 0.75; // exposure time in frames. >1 allowed for blending multiple frames
  15. float subFrameAttenuation = 1; // 1 for weighting every subframe the same. <1 for attenuation effect.
  16. boolean looping = true; // false: t=1 on the last frame; true: t=1-1/nummFrames on last frame.
  17.  
  18. boolean recording = true;
  19.  
  20. float a = 0;
  21. float s = TWO_PI/120;
  22.  
  23. void setup_() {
  24.   size(500, 500, P3D);
  25.   smooth(8);
  26.   noStroke();
  27.   noiseDetail(4);
  28. }
  29.  
  30. float exposureCopy = exposure;
  31. void draw_() {
  32.   // collab settings: hit t=1 and remove motion blur on first and last frame.
  33.   looping = false;
  34.   if (frameCount==1 || frameCount==numFrames) exposure=0;
  35.   else exposure=exposureCopy;
  36.  
  37.   background(255);
  38.  
  39.  
  40.   float x = 250;
  41.   float y = 0;
  42.  
  43.   if (t<t1) y = map(t, 0, t1, -50, 50); // entry
  44.   if (t>t2) y = map(t, t2, 1, 450, 550); // exit
  45.   if (t>=t1 && t<=t2) {
  46.     y = map(t, t1, t2, 50, 450);
  47.     x = 250 + random(-5,5);
  48.   }
  49.   fill(0);
  50.   ellipse(x, y, 100, 100);
  51.   doLines();
  52.   a+=s;
  53. }
  54.  
  55. //////////////////
  56.  
  57. float pingpong(float t) { //  / => /\
  58.   return 1-2*abs(t-0.5);
  59. }
  60.  
  61. float ease(float t, float e) {
  62.   return t < 0.5 ? 0.5 * pow(2*t, e) : 1 - 0.5 * pow(2*(1 - t), e);
  63. }
  64.  
  65. float ease(float t, float in, float out) {
  66.   return (1-t)*ease(t, in) + t*ease(t, out);
  67. }
  68.  
  69. // original source code: http://www.openprocessing.org/sketch/151044
  70.  
  71. void doLines() {
  72.   //background(226, 210, 184);
  73.   for (int j=50; j<450; j+=25) {
  74.     for (int i=50; i<450; i++) {
  75.       if (j!=50 && j!=440) { //grid
  76.         float step = sin(a)*(sin((450-i)*PI/400.0));
  77.         float swing = j+step*(120.0*noise(a+i/300.0, a+j/300.0, a/10.0)-60.0);
  78.         float dx = randomC()/2;
  79.         float dy = randomC()/2;
  80.         float px = i+dx;
  81.         float py = swing+dy;
  82.         fill(255, 150+150*sqrt(sq(dx)+sq(dy))); // pencil effect
  83.         ellipse(px, py, 2, 2);
  84.       }
  85.     }
  86.   }
  87. }
  88.  
  89.  
  90. float randomC() {
  91.   float r = random(0, 1);
  92.   float ang = sin(TWO_PI*random(0, 1));
  93.   return r*ang;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement