Scale Layer in With Bounce
The following script is nothing fancy, but helps increase workflow by putting several common tasks together. This will animate a layer from a scale of 0,0 to its current size, with a nice bounce effect. See details below:
/************************************************************
To use:
Run script for any layer
The script will:
Set a 0,0 scale keyframe at the inpoint of the layer
Animate the scale to the current size with a little bounce at the end
Turn motion blur on for the layer
Turn motion blur on for the composition (if it isn't already on)
If the layer has a mask on it, it will re-center the layer's anchor point so that it scales-in evenly
You can then:
Change the timing of the keyframes
Change the amount of "bump" by tweaking the scale values
Move the anchor point as needed
Anything else you may need
***************************************************************/
function fadeLayer(myLayer)
{
//If there is a mask, reset the anchor point
if(myLayer.property("mask").numProperties > 0)
{
var initialMask = myLayer.mask(1);
var point1, point2, point3, point4;
var vertsArray = initialMask.maskShape.value.vertices;
if(vertsArray.length == 4)
{
point1 = vertsArray[0];
point2 = vertsArray[1];
point3 = vertsArray[2];
point4 = vertsArray[3];
var maskWidth = Math.abs(vertsArray[0][0] - vertsArray[1][0]);
var maskHeight = Math.abs(vertsArray[1][1] - vertsArray[2][1]);
ap1 = point2[0]+maskWidth/2;
ap2 = point2[1]+maskHeight/2;
pArray = new Array(ap1, ap2);
var diffPoint = pArray - myLayer.property("Anchor Point").value;
myLayer.property("Anchor Point").setValue(pArray);
myLayer.property("Position").setValue(myLayer.property("Position").value+diffPoint);
}
}
myProp = myLayer.property("Scale");
inPoint = myLayer.inPoint;
outPoint = inPoint + (8/12);
bouncePoint = inPoint + (6/12);
outKey = myProp.addKey(outPoint);
myProp.setValueAtKey(outKey, myProp.value);
bounceKey = myProp.addKey(bouncePoint);
myProp.setValueAtKey(bounceKey, myProp.value*1.05);
inKey = myProp.addKey(inPoint);
myProp.setValueAtKey(inKey, [0,0]);
var ease = new KeyframeEase(0, 33);
myProp.setInterpolationTypeAtKey(1,5013);
myProp.setInterpolationTypeAtKey(2,5013);
myProp.setInterpolationTypeAtKey(3,5013);
myLayer.motionBlur = true;
}
// make sure a comp is selected
var activeItem = app.project.activeItem;
if (activeItem == null || !(activeItem instanceof CompItem))
{
alert("You need to select a layer before running this script");
}
else
{
// make sure at least one layer is selected
var selectedLayers = activeItem.selectedLayers;
if (selectedLayers.length == 0 )
{
alert("Select at least one layer before running this script.");
}
else
{
app.beginUndoGroup("Scale Layer 0 to current with bounce");
selectedLayers[0].containingComp.motionBlur = true;
for(i=0; i<selectedLayers.length; i++)
{
fadeLayer(selectedLayers[i]);
}
app.endUndoGroup();
}
}
Comments