Advertisement
tophf

SmoothScrollingTitles

Nov 3rd, 2014
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # usage: trim(start,end).SmoothScrollingTitles(shift)
  2. # to calculate the shift use this formula: (glyph.Ypos.at.bottom - same.glyph.Ypos.at.top) / number.of.frames.between
  3. function SmoothScrollingTitles( clip c, float shift ) {
  4.     function shiftvert(clip c, float shift) { c.lanczosresize(c.width,c.height,0,shift,c.width,c.height) }
  5.     function m4p(float f) { return ceil(abs(f)/4+0.5)*4 }
  6.     assert(shift>0, "shift should be a positive number")
  7.     overlap = m4p(shift * 10)
  8.     vBackOvr = c.crop(0,0,0,overlap*2)
  9.     vForth = RAverageW(c, 0.2, c.trim(1,0).shiftvert(-shift), 0.2, c.trim(2,0).shiftvert(-shift*2), 0.2, c.trim(3,0).shiftvert(-shift*3), 0.2, c.trim(4,0).shiftvert(-shift*4), 0.2)
  10.     vBack = RAverageW(vBackOvr.duplicateframe(0,0,0,0).shiftvert(shift*4), 0.2,
  11.             \vBackOvr.duplicateframe(0,0,0).shiftvert(shift*3), 0.2, vBackOvr.duplicateframe(0,0).shiftvert(shift*2), 0.2,
  12.             \vBackOvr.duplicateframe(0).shiftvert(shift), 0.2, vBackOvr, 0.2)
  13.     stackvertical(vBack.crop(0,0,0,overlap), vForth.crop(0,overlap,0,0))
  14.    
  15.     #now fix the first and last 5 frames
  16.     vNNEDI = c.nnedi3()
  17.     function animateme(clip averaged, clip interpolated, float shift) {
  18.         shift4p = m4p(shift)
  19.         shift < 0 ? stackvertical(interpolated.crop(0,0,0,shift4p), averaged.shiftvert(shift).crop(0,shift4p,0,0))
  20.             \ : stackvertical(averaged.shiftvert(shift).crop(0,0,0,averaged.height-shift4p), interpolated.crop(0,interpolated.height-shift4p,0,0))
  21.     }
  22.     freezeframe(0,4,5).animate(0,4,"animateme",vNNEDI,-shift*5,vNNEDI,-shift).trim(0,4)
  23.     \+trim(5,c.framecount-6)
  24.     \+trim(c.framecount-6,0).freezeframe(1,5,0).animate(1,5,"animateme",vNNEDI.trim(c.framecount-6,0),shift,vNNEDI.trim(c.framecount-6,0),shift*5).trim(1,5)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement