AE(After Effects) Expressions and Scripts
1.16K subscribers
3 photos
15 videos
14 files
8 links
Usefull expression and scripts for AE (After Effects). Automate your routine, speed up motion design process with the power of coding.
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
Parallax animation
The easy to use and customize parallax animation for multiply object. You just need to animate null (or other layer) position, then apply the multiply index value with slider contol for each layer.

Apply to position property:

let nullRefer = thisComp.layer("Null 1");
let multyplyerSlider = effect("index")("Slider");
let xReffer = nullRefer.transform.position[0] * multyplyerSlider;
let yReffer = nullRefer.transform.position[1] * multyplyerSlider;
let thisX = transform.position.value[0];
let thisY = transform.position.value[1];
x = thisX + xReffer;
y = thisY + yReffer;
[x, y]
👍1
This media is not supported in your browser
VIEW IN TELEGRAM
Custom variables based animation 🤔

I want to show you very specific trick witch allow you to animate object position of the layer with changeable size. It's allow you to animate objects based on variable(like Width, Height etc.) you have set inside expression and multiply by keyframe values that you set on the timeline. In this example below the keyframe values are set to -1, 0, 1. The position of the text animate from left side to center and right side does not matter what the length of the text.

let xValue = value[0];
let yValue = value[1];
let xCenter = thisComp.width / 2; let yCenter = thisComp.height / 2;
let layerWidth = thisLayer.sourceRectAtTime().width;
let layerHeight = thisLayer.sourceRectAtTime().height;
let thisScalePercentage = transform.scale[0]/100;
let widthScale = layerWidth * thisScalePercentage;
let heightScale = layerHeight * thisScalePercentage;
x = (xValue * (thisComp.width + widthScale) / 2) + xCenter;
y = (yValue * (thisComp.height + heightScale) / 2) + yCenter;
[x , yCenter]
This media is not supported in your browser
VIEW IN TELEGRAM
Repeater Text animation

1. Create Control layer. With slider control zRotation.

2. Create text layer "Original" that will be main refferance text. Make the text 3D layer

3. Copy text layer tha will reffer to layer "Original". Apply this expression to reffer to the text styles and source text:

var sourceTextProperty = thisComp.layer("Original").text.sourceText; var newStyle = sourceTextProperty.getStyleAt(0,time); newStyle.setText(sourceTextProperty);

4. Apply to the position property:

let x = thisComp.layer("Original").transform.position[0]; let y = thisComp.layer("Original").transform.position[1]; let z = -index-2; [x, y, z]

5. Apply to Orientation property:

let thisIndex = index-2; let zRotation = thisComp.layer("Control").effect("zRotation")("Slider"); let refferZ = thisComp.layer("Original").transform.zRotation; let z = refferZ + thisIndex * zRotation; [0, 0, z]

6. Dublicate layer with the expression as many times as you need.
Animate with slider control zRotation.
👍21
Spiral matrix layer duplicates based on layer index🌀



var user_id = index;
let margin = 0; //margin
function get_coordinates_from_user_id() {
var k = Math.ceil((Math.sqrt(user_id) - 1) / 2);
var t = 2 * k + 1;
var m = t * t;
t = t - 1;
if (user_id >= m - t) {
return [-k, k - (m - user_id)]
} else m = m - t;
if (user_id >= m - t) {
return [-k + (m - user_id), -k]
} else m = m - t;
if (user_id >= m - t) {
return [k, -k + (m - user_id)]
};
return [k - (m - user_id - t), k];
}
get_coordinates_from_user_id(user_id);
let sIndex = get_coordinates_from_user_id(user_id);
let width = thisLayer.sourceRectAtTime().width + margin;
let height = thisLayer.sourceRectAtTime().height + margin;
let thisScalePercentage = thisLayer.transform.scale[0] / 100;
let widthScale = width * thisScalePercentage * sIndex[0];
let heightScale = height * thisScalePercentage * sIndex[1];
[widthScale + value[0], heightScale + value[1]]
This media is not supported in your browser
VIEW IN TELEGRAM
Quick tip to debug your expression😱

Simply drag and drop property into comp window and AE automaticly create text layer witch shows you the current property value.
This media is not supported in your browser
VIEW IN TELEGRAM
Fit (Scale) one layer to another layer Width. and Height

Apply to Scale

targetL = thisComp.layer("Reffer Layer");
sourceW = sourceRectAtTime().width;
sourceH = sourceRectAtTime().height;
targetScW = targetL.transform.scale[0] / 100;
targetScH = targetL.transform.scale[1] / 100;
targetW = targetL.sourceRectAtTime().width * targetScW;
targetH = targetL.sourceRectAtTime().height * targetScH;
percentW = (targetW / sourceW * 100);
percentH = (targetH / sourceH * 100);
[percentW, percentH]
2
This media is not supported in your browser
VIEW IN TELEGRAM
Loop of any property from Min to Max value.
Based on index property

let ctrl = thisComp.layer("Control"); //control Layer
index = index - ctrl.index;
let count = thisComp.numLayers - ctrl.index;
let proppertyMax = ctrl.effect("Max")("Slider");
let proppertyOffset = ctrl.effect("Offest")("Slider")/100;
let baseProperrty = ctrl.effect("Min")("Slider");
index = index + proppertyOffset;
var reset = 0;
for (var i = 0; i < index; i++) {
if(i % count) continue;
reset = i;
}
index = index - reset;
x = linear(index, 0 ,count , 0 , 1);
x = x * proppertyMax + baseProperrty;
[x, x]
4
This media is not supported in your browser
VIEW IN TELEGRAM
Hi there👋

I'd like to show you my new After Effects Comps and Layers Renamer Script. It allows you to rename selected layers and comps inside the Project panel based on their order. This is one of the first scripts I've created for AE, and it's very simple and easy to use.

Download for Free from Gumroad👈

#script
👍71
This media is not supported in your browser
VIEW IN TELEGRAM
Typewrighter with keyframe animation? Easy

Apply it to source text and then set two keyframes on the timeline:

var key1 = key(1).value; var key2 = key(2).value; var key2Lenght = key2.length; var numChars = Math.round(linear(time, key(1).time, key(2).time, 0, key2Lenght)); text.sourceText = key(2).value.substring(0, numChars);
👍15
Hello. Here is the new version of my script - Item Renamer v1.1🎉

Download below👇
1
This media is not supported in your browser
VIEW IN TELEGRAM
This script allows you to create a grid of multiple layers in seconds. Simply select the desired elements and click the "Create Grid" button. The script will generate a grid from these elements.

With the "Control" layer, you can:

▪️ Change the number of columns.
▪️ Set the spacing between elements.
▪️ Scale the grid.
▪️ Move the grid along the x or y axis.

You can also bake expressions for memory optimization and further manipulation of grid units.