ExtendScript + Expression

<= Previous article ExtendScript Working with Compositions





Hello.





In the previous article, we made the basis of the model for building titles in the After Effects scene. We add a scene to the project, or several scenes. Now we need to add the credits to the scene. In order to add titles, you need to create models in the AE layout, which will serve us for copying.





We go into the project, where the composition ModelScene_1x1 has already been created . In the same 1x1 folder, create two compositions. We will name one of them ModelTitre_simple_1x1 , the other ModelTitre_double_1x1 .





Let's start with the composition ModelTitre_simple_1x1 . Let's add it to the ModelScene_1x1 composition .





In the ModelTitre_simple_1x1 itself , we will create a text box. Let's call it reference_text .





. , -. After Effects, . , . . Expression, Javascript, , . . reference_text, Transform, Position.





Animation > Add Expression. Position Expression , .





:





var width = Math.round(thisLayer.sourceRectAtTime().width);
var padding = 20;
var hideX = -width - padding;
var showX = padding;
var posY = transform.position[1];
var animationTime = 0.5;

var timeIn = comp("ModelScene_1x1")
   .layer(thisComp.name)
   .inPoint;

var timeOut = comp("ModelScene_1x1")
   .layer(thisComp.name)
   .outPoint;

if (time <= animationTime) {
   easeOut(
       time,
       0,
       animationTime,
       [hideX, posY],
       [showX, posY]
   );
} else {
   easeOut(
       time,
       timeOut - timeIn - animationTime,
       timeOut - timeIn,
       [showX, posY],
       [hideX, posY]
   );
}
      
      



, . . . thisLayer, , sourceRectAtTime, .





thisLayer.sourceRectAtTime().width
      
      



. . , , .





var hideX = -width - padding;
var showX = padding;
      
      



Y ,





var posY = transform.position[1];
      
      



, . , .





var animationTime = 0.5;

var timeIn = comp("ModelScene_1x1")
   .layer(thisComp.name)
   .inPoint;

var timeOut = comp("ModelScene_1x1")
   .layer(thisComp.name)
   .outPoint;
      
      



, ModelScene_1x1, . , , thisComp.name. inPoint outPoint   .





, . , 0. animationTime, , .





if (time <= animationTime) {
   easeOut(
       time,
       0,
       animationTime,
       [hideX, posY],
       [showX, posY]
   );
}
      
      



easeOut, , 5 . 





  • time -





  • startTime - , time >= startTime





  • endTime -





  • startPosition -





  • endPosition -





position , X Y. , , X, - Y.





, ,





easeOut(
       time,
       timeOut - timeIn - animationTime,
       timeOut - timeIn,
       [showX, posY],
       [hideX, posY]
   );
      
      



-





timeOut - timeIn
      
      



animationTime





timeOut - timeIn - animationTime
      
      



, , ModelScene_1x1. , , .





, ModelTiter_double_1x1. . , . , , . reference_text, strin_1 string_2





reference_text Guide Layer.





, . , string_1 string_2. ? . , reference_text. , .





, Expression. sourceText string_1 Animation > Add Expression









var refText = thisComp.layer("reference_text")
    .text.sourceText.split("\r");

var stringID = parseInt(thisLayer.name.split("_")[1]);

refText[stringID - 1]
      
      



reference_text . , \r. refText[0], , id, refText id. sourceText string_2. string_1 reference_text, string_2 - .





. simple, , . , .





Position string_1Expression ModelTitre_simple_1x1. delay.





var delay = 0.3;
      
      



( 0.3 ):





easeOut(time,
   timeOut - timeIn - animationTime - delay,
   timeOut - timeIn - delay,
   [showX, posY],
   [hideX, posY]
);
      
      



, delay , .





Now we have layouts of two types of titles and everything is ready to put them on stage. But we'll talk about how to do this next time. 





You can download all Expressions from this article here





Expression documentation here





That's all for today.





<= Previous article ExtendScript Working with Compositions








All Articles