Advertisement
RiCON

insertsignxyfade

Jan 30th, 2012
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function InsertSignXYFade(clip mainclip, clip overlayclip, int "startframe", int "endframe", int "x", int "y", int "fad1", int "fad2", int "offset", int "offset2", float "opacity", int "nw", int "nh") {
  2.  
  3.     x           = default(x,0)                # X position of overlayclip
  4.     y           = default(y,0)                # Y position of overlayclip
  5.     fad1        = default(fad1,0)             # Number of frames to fade in
  6.     fad2        = default(fad2,0)             # Number of frames to fade out
  7.     offset      = default(offset,0)           # Offset of the start and end frames
  8.     offset2     = default(offset2,0)          # Offset of the start of overlayclip
  9.     startframe  = default(startframe,0)       # Mainclip startframe from whence to apply the overlay
  10.     opacity     = default(opacity,1.0)        # Set opacity of overlayclip
  11.     nw          = default(nw,mainclip.width)  # Set overlay's width in case it's not the same mainclip's
  12.     nh          = default(nh,mainclip.height) # Set overlay's height in case it's not the same mainclip's
  13.     startframe  = startframe+offset           # Apply offset to startframe
  14.  
  15.     # make the endframe parameter optional (defaulting to where the overlay clip ends)
  16.     endframe = default(endframe,startframe+overlayclip.framecount()-1) # is endframe not specified?
  17.     endframe = (endframe == 0) ? startframe+overlayclip.framecount()-1 : endframe+offset # is it specified but zero?
  18.     # is it specified but >= the main clip's last frame? (may have been caused by the previous line or specified by the user)
  19.     # in that case make it equal to the last frame of the main clip (this is important later)
  20.     endframe = (endframe >= mainclip.framecount()-1) ? mainclip.framecount()-1 : endframe
  21.  
  22.     # make sure the special case startframe=1 is dealt with correctly
  23.     # (needed because trim(0,0) returns the entire clip, which is obviously not what we want)
  24.     # note that the first frame of the clip is zero, NOT one!
  25.     begin  = (startframe == 1) ? mainclip.trim(0,-1) : mainclip.trim(0,startframe-1)
  26.     middle = mainclip.trim(startframe,endframe)
  27.     # make sure the special case endframe = last frame of the clip is handled properly.
  28.     end    = (endframe == mainclip.framecount()-1) ? blankclip(mainclip,length=0) : mainclip.trim(endframe+1,0)
  29.  
  30.     middleoverlay = Overlay(middle, overlayclip.spline36resize(nw,nh).trim(offset2,0),x,y,overlayclip.spline36resize(nw,nh).trim(offset2,endframe-startframe+offset2).ConvertToRGB32.showalpha.FadeIn0(fad1).FadeOut0(fad2),opacity)
  31.  
  32.     # deal with the special case startframe=0 (in which case we don't have anything before the overlay)
  33.     # note that trim(-1,0) does nothing (it returns the same as trim(0,0)...)
  34.     final = (startframe == 0) ? middleoverlay ++ end : begin ++ middleoverlay ++ end
  35.     return final
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement