-
Expanding mask script in a 3D comp (space transform issues)
Hi there,
I’m working on motion graphics for a documentary that’s going need to a lot of expanding masks.
I thought I’d try and save a little time by writing a script that would create mask paths based on the position value of a null.
Surely someone has written exactly this script before, and I’d see the answer right in front of me if I understood the space transform functions a little better.
If y’all don’t mind taking a look, I’d be much obliged,
Thank you very much!
-Theo B.
//this mask expands right to left
//this section translates the start position from the controller’s layer space to the mask’s layer space.
var Start_Time = thisComp.layer(“Write-on_Controller-RectangularMask”).effect(“Start_Time”)(“Slider”);
var controllerSpace_Position = thisComp.layer(“Write-on_Controller-RectangularMask”).transform.position;
var compSpace_Position = thisComp.layer(“Write-on_Controller-RectangularMask”).toComp([controllerSpace_Position[0],controllerSpace_Position[1],controllerSpace_Position[2]]);//this section defines start and end positions for the expanding mask based on controller’s position.
var layerSpace_StartPosition = thisLayer.fromComp(compSpace_Position, Start_Time);
var layerSpace_EndPosition = thisLayer.fromComp(compSpace_Position);//this section seperates the start and end variables into X and Y values.
var StartPoint_Xpos = layerSpace_StartPosition[0];
var StartPoint_Ypos = layerSpace_StartPosition[1];
var EndPoint_Xpos = layerSpace_EndPosition[0];
var EndPoint_Ypos = layerSpace_EndPosition[1];//this section creates mask verticies using the above X and Y values.
var maskDiameter = (thisComp.layer(“Write-on_Controller-RectangularMask”).effect(“Mask_Width”)(“Slider”))/2;
var top_right = [StartPoint_Xpos,(StartPoint_Ypos – maskDiameter)];
var bottom_right = [StartPoint_Xpos,(StartPoint_Ypos + maskDiameter)];
var bottom_left = [EndPoint_Xpos,(EndPoint_Ypos + maskDiameter)];
var top_left = [EndPoint_Xpos,(EndPoint_Ypos – maskDiameter)];
var maskVerticies = [top_left,top_right,bottom_right, bottom_left];
createPath(maskVerticies, inTangents = [], outTangents(), isClosed = true);