# DropShadow function: adds a fading dropshadow to clips
# Written by mikeytown2 and Gavino (http://forum.doom9.org/showthread.php?t=141032)

Function DropShadow(clip Background, clip Overlayed, int CenterX, int CenterY)
{
    #Set Defaults
    Shadow = BlankClip(width=width(Overlayed), height=height(Overlayed), color=$000000)
    StartOpacity = 0.4
    Steps = 6

	#Generate Background with blank clip and dropshadow
	Background = AddShadows(Background, Shadow, CenterX, CenterY, StartOpacity, Steps)

    #Add Overlayed clip
	Background = Overlay(Background, Overlayed, x=CenterX, y=CenterY, mode="blend", opacity=1)

    return Background  
}

Function AddShadows(clip Background, clip shadow, int x, int y, float opacity, int Steps)
{
  Background = Overlay(Background, shadow, x=x+1, y=y+1, mode="blend", opacity=opacity)
  Steps > 1 ? AddShadows(Background, shadow, x+1, y+1, opacity*(Steps-1)/Steps, Steps-1) : Background
}  