Simples e Básico

Position fade

a = [value[0],value[1]];
b = a + [0,200];
t = 1.5,
easeOut(time-inPoint, 0, t, a, b)

Position animation

t = (inPoint - time) *150;
x = value[0] + t;
y = value [1];
[x, y]

Opacity fade

easeIn(time-inPoint, 0,1, -100, 100) + easeOut(time-(outPoint-1), 0,1, 100, -100)

_____________ or ______________

a = linear (time, inPoint, inPoint + .5, 0, 100);
b = linear (time, outPoint - .5, outPoint, 0, 100)
a-b

Strobe Opacity

wiggle(1, 1, octaves = 4, amp_mult = 30)

_____________ or ______________

octaves = 4;
amp_mult = 30;
wiggle(1, 1, octaves, amp_mult)

Rotation time

time*60

_____________ or ______________

t = 60;
time*t

Rotation random

random(0, 5)

_____________ or ______________

amp = 0;
freq = 5;
random(amp, freq)

Rotation wiggle

wiggle(2,50)

_____________ or ______________

amp = 2;
freq = 50;
wiggle(amp,freq)

Rotation loop

t = 0.5;
easeIn(time-inPoint, 0,t, -90, 90) + easeOut(time-(outPoint-t), 0,t, 90, -90)

_____________ or ______________

t = 0.5;
val1 = -90;
val2 = 90;
easeIn(time-inPoint, 0,t, val1, val2) + easeOut(time-(outPoint-t), 0,t, val2, val1)

Scale fade

ease(time-inPoint, 0,.5,[0,0],[100,100]) + ease(time-(outPoint-1), 0, .5, [0,0 ], [-100,-100 ])

_____________ or ______________

t = 0.5;
a = [0,0];
b = [100,100];
ease(time-inPoint, 0,t,a,b) + ease(time-(outPoint-t), 0, t, a, -b)

Scale Bounce Animation

amp = .03;
freq = 2.0;
decay = 6.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n;
}}
if (n == 0){ t = 0;
}else{
t = time - key(n).time;
}
if (n > 0 && t < 1){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}

Wiggle

wiggle (5,100);

_____________ or ______________

freq = 5;
amp = 50;
wiggle(freq, amp)

Wiggle separate values

a = wiggle (5,50);
b = value;
[a[0], b[1]]

Position equal distance

//add in duplicate bars
a = thisComp.layer(index+1).transform.position;
dist = parseInt(thisComp.layer("VALUE").text.sourceText);
a - [0,dist]

_____________ and ______________

//add in sourceText
Math.round(effect("Slider Control")("Slider"))

Index animation

//add to the scale of copies
thisComp.layer(index-1).transform.scale.valueAtTime(time-.15)

_____________ or ______________

//add to the positoin of copies
thisComp.layer(index-1).transform.position.valueAtTime(time-.10)

PosterizeTime

posterizeTime(5);
box1 = wiggle(5,5);
box2 = wiggle(10,15);
box3 = wiggle(20,30);

//determine output
box1

Vertical Speed

//(pixels per second)
//add Slider in the layer and add keyframes

veloc = effect("Slider Control")("Slider");
x = position[0];
y = position[1] + (time - inPoint) *veloc;
[x,y]

Countdown

//paste in sourceTex
start="3";
end="0";

//timeTransition
t = 2;
val=easeOut(time, startTime+.2, t,start, end);
val.toFixed(1)

Digital Clock

function pad(str, max) {
	str = str.toString();
	return str.length < max ? pad("0" + str, max) : str;
}

function digits(myVal, myNumDigits, myPad) {
	var s = myVal.toString();
	while (s.length < myNumDigits) s = '0' + s;	
	return pad(Math.floor(s), myPad);
}

hr = digits(time / 3600, 1, 1);
min = digits(time % 3600 / 60, 2, 2);
sec = digits(time % 60, 2, 2);

hr + ":" + min + ":" + sec;

Number fade

//add in sourceText
//add slider in same layer
//add in and out markers in same layer

start=0;
end=20;
a = thisLayer.marker.key(1).time;
b = thisLayer.marker.key(2).time;
						
easeOut(time,a, b,start, end).toFixed();

Timer Regressive

//add in sourceText
startValue = 1500;
endValue = 2024;
dur = 1; //seconds

s = "" + Math.round(linear(time,inPoint,inPoint+dur,startValue,endValue));
if (s.length > 6)
s.substr(0,s.length-6) + "," + s.substr(-6,3) + "," + s.substr(-3,3)
else if (s.length > 3)
s.substr(0,s.length-3) + "." + s.substr(-3,3)
else
s

Clock with slider

//add in sourceText
//add slider wand keyframes
slider = parseInt (effect("Slider Control")("Slider"));
sec = slider%60;
min = Math.floor(slider/60)
function addZero(n) {
	if(n  0) {
addZero(min)+":" + addZero(sec) 
} else {
	"00:00"
}

First upperCase

//only first word
//Apply in sourceText

x = "first word";
x.toLowerCase().replace(/\b\w/, x => x.toUpperCase())

_____________ or ______________

//all words
x = "all words"
x.toLowerCase().replace(/\b\w/g, x => x.toUpperCase())

Round values

//add slider and keyframes

n = effect("Slider Control")("Slider");
d = 10; // set your decimal places: 10ths, 100ths, 1000ths, etc.
Math.round(n*d)/d

Add dots or commas

num = (200000)//set value
function addCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
addCommas(num)

_____________ or ______________

num = (200000)//set value
function addCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
addCommas(num)

Math.round

//you can add a slide and animate
Math.round(effect("Slider Control")("Slider"))

UTC Date

txt = "December 24, 2024 14:30:00";
date = new Date(txt);
parsed = date.toString();
parsed

Text box

marginx = 150;
marginy = 50;
	
text_width = thisComp.layer(index-1).sourceRectAtTime().width;
text_height = thisComp.layer(index-1).sourceRectAtTime().height;

box_width = text_width + marginx;
box_height = text_height + marginy;
[box_width, box_height]

Center of the object

//Add in AnchorPoint

a = thisLayer.sourceRectAtTime();
height = a.height;
width = a.width;
top = a.top;
left = a.left;

x = left + width/2;
y = top + height/2;
[x,y];

Loop in Mask/Path

if (numKeys >1 && time > key(numKeys).time){
t1 = key(1).time;
t2 = key(numKeys).time;
span = t2 - t1;
delta = time - t2;
t = delta%span;
valueAtTime(t1 + t)
}else
value

Create Linked Path

//add two nulls
//position and anchor point need to be zeroed

pos1 = thisComp.layer("object1").transform.position;
pos2 = thisComp.layer("object2").transform.position;

createPath(points=[pos1,pos2], inTangents=[], outTangents=[], is_closed=false)

Evolution Path

//add trim path and pasta this code
//add slider in this layer
effect("Slider Control")("Slider")

_____________ and ______________

//paste in sourceText
//link in slider the line
//sum caracter special in the end
parseInt(thisComp.layer("line1").effect("Slider Control")("Slider")) + "%"

Array values

//example
a = [12,5,9,10,3];
a[1]

Split lines of text

//select text
x = thisComp.layer("text data").text.sourceText;
x.split(/\n|\r/)[2]

Try and catch

// Checks to see if a property, effect, layer, comp, or object exists.
x = 10;
y = 20;

try {
    x >= y
	;
} catch(err) {
   
}

After Effects Expressions

Uma expressão no After Effects é um modificador aplicado a uma propriedade de um objeto para animar automaticamente a propriedade sem usar quadros-chave. É preciso habilitar, conforme imagem abaixo, para que o After Effects interprete seus códigos.