Advertisement
Guest User

InsertSign with Positioning and Fade support

a guest
Mar 25th, 2010
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function insertsign(clip mainclip, clip overlayclip, int startframe, int "endframe", int "x", int "y", int "fad1", int "fad2") {
  2.  
  3.     x = default(x,0)
  4.     y = default(y,0)
  5.     fad1 = default(fad1,0)
  6.     fad2 = default(fad2,0)
  7.    
  8.     # make the endframe parameter optional (defaulting to where the overlay clip ends)
  9.     endframe = default(endframe,startframe+overlayclip.framecount()-1) # is endframe not specified?
  10.     endframe = (endframe == 0) ? startframe+overlayclip.framecount()-1 : endframe # is it specified but zero?
  11.     # is it specified but >= the main clip's last frame? (may have been caused by the previous line or specified by the user)
  12.     # in that case make it equal to the last frame of the main clip (this is important later)
  13.     endframe = (endframe >= mainclip.framecount()-1) ? mainclip.framecount()-1 : endframe
  14.    
  15.  
  16.     # make sure the special case startframe=1 is dealt with correctly
  17.     # (needed because trim(0,0) returns the entire clip, which is obviously not what we want)
  18.     # note that the first frame of the clip is zero, NOT one!
  19.     begin   = (startframe == 1) ? mainclip.trim(0,-1) : mainclip.trim(0,startframe-1)
  20.     middle  = mainclip.trim(startframe,endframe)
  21.     # make sure the special case endframe = last frame of the clip is handled properly.
  22.     end = (endframe == mainclip.framecount()-1) ? blankclip(mainclip,length=0) : mainclip.trim(endframe+1,0)
  23.    
  24.     middleoverlay = Overlay(middle, overlayclip,x,y,overlayclip.trim(0,endframe-startframe).showalpha().FadeIn0(fad1).FadeOut0(fad2))
  25.  
  26.     # deal with the special case startframe=0 (in which case we don't have anything before the overlay)
  27.     # note that trim(-1,0) does nothing (it returns the same as trim(0,0)...)
  28.     final = (startframe == 0) ? middleoverlay ++ end : begin ++ middleoverlay ++ end
  29.     return final
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement