Advertisement
xeromino

collabo2

Oct 10th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 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.   float sz = 100;
  43.   float sz2 = 0;
  44.   if (t<t1) y = map(t, 0, t1, -50, 50); // entry
  45.   if (t>t2) y = map(t, t2, 1, 450, 550); // exit
  46.   if (t>=t1 && t<=t2) {
  47.     y = map(t, t1, t2, 50, 450);
  48.     x = 250 + random(-5, 5);
  49.     float temp = map(t, t1, t2, PI, TWO_PI+PI);
  50.     sz = map(cos(temp), -1, 1, 100, 200);
  51.     sz2 = map(cos(temp), -1, 1, 0, sz/2);
  52.   }
  53.   fill(0);
  54.   ellipse(x, y, sz, sz);
  55.   fill(255);
  56.   ellipse(x, y, sz2, sz2);
  57.   doLines();
  58.   a+=s;
  59. }
  60.  
  61. //////////////////
  62.  
  63. float pingpong(float t) { //  / => /\
  64.   return 1-2*abs(t-0.5);
  65. }
  66.  
  67. float ease(float t, float e) {
  68.   return t < 0.5 ? 0.5 * pow(2*t, e) : 1 - 0.5 * pow(2*(1 - t), e);
  69. }
  70.  
  71. float ease(float t, float in, float out) {
  72.   return (1-t)*ease(t, in) + t*ease(t, out);
  73. }
  74.  
  75. // original source code: http://www.openprocessing.org/sketch/151044
  76.  
  77. void doLines() {
  78.   //background(226, 210, 184);
  79.   for (int j=50; j<450; j+=25) {
  80.     for (int i=50; i<450; i++) {
  81.       if (j!=50 && j!=440) { //grid
  82.         float step = sin(a)*(sin((450-i)*PI/400.0));
  83.         float swing = j+step*(120.0*noise(a+i/300.0, a+j/300.0, a/10.0)-60.0);
  84.         float dx = randomC()/2;
  85.         float dy = randomC()/2;
  86.         float px = i+dx;
  87.         float py = swing+dy;
  88.         fill(255, 150+150*sqrt(sq(dx)+sq(dy))); // pencil effect
  89.         ellipse(px, py, 2, 2);
  90.       }
  91.     }
  92.   }
  93. }
  94.  
  95.  
  96. float randomC() {
  97.   float r = random(0, 1);
  98.   float ang = sin(TWO_PI*random(0, 1));
  99.   return r*ang;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement