Generate Animated Mask with Echo Effect

This will take a mask that you have drawn on a solid and add some effects to it to highlight a particular object.  See below for details:

/************************************************************
To use:
Create a new solid of any color
Select the pen tool and draw a mask with as many points as necessary
Run the script
The script will:
 Set the solid layer to white color
 Add keyframes for the mask opacity to flash in and then fade out
 Add a stroke for the mask
 Add an Echo effect
 Add keyframes for the mask shape
You must then go to the first mask shape keyframe and scale the mask shape up by double clickingon a point and draging the mouse out while holding CTRL and SHIFT

You can then:
 Change the color of the stroke
 Change the timing of the keyframes
 Change the color of the solid if necessary
 Anything else that strikes your fancy
 
***************************************************************/

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 with a closed mask.");
  }
 }
 
 function DoWork(initialLayer)
 {
  app.beginUndoGroup("Generate Mask Echo Effect");
  if(initialLayer.property("mask").numProperties > 0)
  {
   var initialMask = initialLayer.mask(1);
   
   initialLayer.source.mainSource.color = [1,1,1];
   
   var point1, point2, point3, point4;
   var vertsArray = initialMask.maskShape.value.vertices;
   
   var maskShape = initialMask("Mask Shape");
   
   var initialShapeKey = maskShape.addKey(initialLayer.inPoint);
   var secondShapeKey = maskShape.addKey(initialLayer.inPoint+6/12);
   
   var maskOpacity = initialMask("Mask Opacity");
   
   var initialOpacKey = maskOpacity.addKey(initialLayer.inPoint+5/12);
   var secondOpacKey = maskOpacity.addKey(initialLayer.inPoint+6/12);
   var thirdOpacKey = maskOpacity.addKey(initialLayer.inPoint+11/12);
   
   maskOpacity.setValueAtKey(1, 0);
   maskOpacity.setValueAtKey(2, 80);
   maskOpacity.setValueAtKey(3, 0);
   
   var opacityProp = initialLayer("Opacity");
   
   var initialOpacKeyframe = opacityProp.addKey(initialLayer.inPoint+12/12);
   var secondOpacKeyframe = opacityProp.addKey(initialLayer.inPoint+18/12);
   
   opacityProp.setValueAtKey(1,100);
   opacityProp.setValueAtKey(2,0);
   
   initialLayer.outPoint = initialLayer.inPoint+24/12;
   
   var stroke = initialLayer("Effects").addProperty("Stroke");
   stroke.allMasks.setValue(1);
   
   var echo = initialLayer("Effects").addProperty("Echo");
   echo(1).setValue(-.04);
   echo(2).setValue(4);
   echo(3).setValue(1);
   echo(4).setValue(.55);
   return;
  }
  app.endUndoGroup();
 }

*/

Generate Mask with Echo effect

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments
  • No comments exist for this entry.
Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.