This is the seventh day of my participation in the August More text Challenge. For details, see: August More Text Challenge
preface
Here’s what you’ll learn from reading this article
- loopIn(
type
.numKeyframes
) - loopOut(
type
.numKeyframes
) - loopInDuration(
type
.duration
) - loopOutDuration(
type
.duration
)
And how they differ under different types and numKeyframes/duration;
By default, you already have the basic concept of KeyFrame in AFTER Effects, and the following demos are based on four KeyFrame cars (left to right), as shown below
There are 4 key frames, and the current Position of the car is in the third key frame
Let’s start with a simple loopOut (the idea of loopIn is slightly anti-human, but it’s easy to understand when you turn the corner)
loopOut
The loopOut function loops from the beginning (the first keyframe) from the last keyframe until the time limit you set is exceeded.
First, let’s look at the form of the loopOut expression. It consists of two arguments. The first argument indicates the type of the loop (cycle by default), and the second parameter indicates the number of key frames in the loop fragment (0 by default, meaning all key frames will be looped).
loopOut(type="cycle", numKeyframes=0)
Copy the code
1. numKeyframes = 0
The actual effect is shown here
loopOut("cycle".0)
Copy the code
The position of the keyframe in the Timeline
From the curve relationship between Position and time, it can be seen that the movement of the car from left to right is repeated periodically (cyclic all key frames) until it reaches the end of the timeline.
A graph of Position and time
2. numKeyframes = 1
Now let’s try setting numKeyFrame to 1 and see what happens
loopOut("cycle".1)
Copy the code
numKeyframes = 1
From the diagram of Position and time, we can see that loopOut loops at the Position between the last frame and the penultimate frame, that is, the positions of N and n-1 (where N represents the total number of key frames).
Similarly, we can make a bold inference that if numKeyframes = 2, then we loop between N and n-2
numKeyframes = 2
The figure above supports our reasoning.
Some savvy readers might wonder: What happens if the numKeyframes value goes out of range? NumKeyframes >= N)
Here I first press the table, after the text will be mentioned later.
loopIn
The loopIn and loopOut functions look similar, but have opposite effects. They loop from the beginning of the timeline (from the Position of the last keyframe), then at a certain point to the first keyframe, and continue execution until the last keyframe is reached (the loop stops).
loopIn(type="cycle", numKeyframes=0)
Copy the code
1. numKeyframes = 0
Let’s use cycle type and numKeyframes = 0 as an example. The result is as follows
loopIn("cycle".0)
Copy the code
Note the position of the keyframe on the timeline. A period of time before the keyframe is required for loopIn loops
Leave a period of time before the keyframe
The corresponding Position curve is shown below, and it is clear that two loops are executed before the first keyframe is encountered, until the move stops at the Position of the last keyframe.
The curve of Position over time
If the time between the first keyframe and the last keyframe (time0) is not an integer multiple of the time between the first and the last keyframe (time1), One of the following positions may occur (the starting Position runs to the Position of the last frame)
loopIn("cycle".0)
Copy the code
The curve of Position over time
2. numKeyframes = 1
Now let’s try setting numKeyframes to 1
loopIn("cycle".1)
Copy the code
It is easy to see from the Position curve that numKeyframes = 1 causes the loop to proceed only between the first Position and the second Position
The curve of Position over time
If you’re interested, you can try other numKeyframes, but I’m not going to show you the details here, but what numKeyframes do is “specify the scope of the segment to loop: A loop fragment is the portion of the layer from the first keyframe to numKeyframes+1. The default value of 0 means that all keyframes are looped.
You can theoretically use it for most properties. There are some exceptions — including properties in the timeline panel that cannot be represented by simple values, such as the source text property, the path shape property, and the histogram property for level effects;
Keyframes or duration values that are too large will be clipped to the maximum allowable value;
A value too small will result in a constant loop.
(To be continued)