Create stroked circle highlight with stub for text.
This script takes a layer with a round mask on it, and adds a stroke (set to paint on transparent) and a drop shadow. It sets the pivot point to the center of the mask. It adds keyframes to animate the stroke so the circle animates in and then extends with a little stub on the right. The drop shadow's direction is set to an expression so you can rotate the stub to any direction and the shadow is still looking good. It's harder than I thought to describe it, so check out the attached video for a quick sample.
//Make mask into circling pointer thing
var initialLayer = null;
var activeItem = app.project.activeItem;
if (activeItem == null || !(activeItem instanceof CompItem))
{
alert("You need to select a composition before running this script");
}
else
{
var selectedLayers = activeItem.selectedLayers;
if (selectedLayers.length > 0 )
{
DoWork(selectedLayers[0]);
}
else
{
alert("You must select a layer to add the mask to.");
}
}
function DoWork(initialLayer)
{
app.beginUndoGroup("Generate encirlcing mask");
if(initialLayer.property("mask").numProperties > 0)
{
var initialMask = initialLayer.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];
pArray = new Array(point1[0], point2[1]);
var circumference = (22/7)*(point1[1]-point3[1]);
var stubLength = 30;
var circleEndPercent = (stubLength/circumference*100)+100;
initialLayer.property("Anchor Point").setValue(pArray);
initialLayer.property("Position").setValue(pArray);
initialLayer.property("Rotation").setValue(90);
var newPoint1 = [point1[0], point1[1]-stubLength];
newMask = initialLayer.Masks.addProperty("Mask");
newMask.inverted = false;
myMaskShape = newMask.property("maskShape");
myShape = myMaskShape.value;
myShape.vertices = [point1,newPoint1];
myShape.closed = false;
myMaskShape.setValue(myShape);
if(initialLayer("Effects").canAddProperty("Stroke"))
{
var stroke = initialLayer("Effects").addProperty("Stroke");
stroke.allMasks.setValue(1);
var endProp = stroke.end;
var startTime = initialLayer.inPoint;
endProp.setValueAtTime(startTime,0);
endProp.setValueAtTime(startTime+.5, circleEndPercent);
endProp.setValueAtTime(startTime+1, 100);
endProp.setInterpolationTypeAtKey(1,5013);
endProp.setInterpolationTypeAtKey(2,5013);
endProp.setInterpolationTypeAtKey(3,5013);
var ease = new KeyframeEase(0, 33);
endProp.setTemporalEaseAtKey(1, [ease], [ease]);
endProp.setTemporalEaseAtKey(2, [ease], [ease]);
endProp.setTemporalEaseAtKey(3, [ease], [ease]);
stroke.paintStyle.setValue(2);
}
if(initialLayer("Effects").canAddProperty("Drop Shadow"))
{
var ds = initialLayer("Effects").addProperty("Drop Shadow");
ds.distance = 5;
ds.softness = 3;
ds.direction.expression = '(transform.rotation*-1)+135';
}
initialLayer.property("Opacity").setValue(100);
initialLayer.motionBlur = true;
}
}
else
{
alert("No mask on selected layer.");
}
app.endUndoGroup();
}
Comments