Está en la página 1de 10

EXPRESIONES

Escala (Círculo)
freq =3;
amplitude = 35;
decay = 1.0;

s = amplitude*Math.sin(freq*time*2*Math.PI)/Math.exp(decay*time);
scale + [s,s]

Escala2:
freq = 5;
amplitude = 25;
decay = 1.0;

t = time - inPoint;
x = scale[0] + amplitude*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
y = (1/x)*10000;
[x,y]

Rotación: (péndulo)
freq = 1.0; //oscillations per second
amplitude = 50;
decay = 0; //no decay

amplitude*Math.sin(freq*time*2*Math.PI)/Math.exp(decay*time)

Rotación con velocidad:


freq = 1.0; //oscillations per second
amplitude = 50;
decay = 0.7;

amplitude*Math.sin(freq*time*2*Math.PI)/Math.exp(decay*time)

Posición (pelota votando)


freq = 1.0; //oscillations per second
amplitude = 90;
decay = .5;

posCos = Math.abs(Math.cos(freq*time*2*Math.PI));
y = amplitude*posCos/Math.exp(decay*time);
position - [0,y]
Randomizar sólidos:
segMin = .3; //minimum segment duration
segMax = .7; //maximum segment duration
minVal = 0;
maxVal = thisComp.width;

end = 0;
j = 0;
while ( time >= end){
j += 1;
seedRandom(j,true);
start = end;
end += random(segMin,segMax);
}
endVal = random(minVal,maxVal);
seedRandom(j-1,true);
dummy=random(); //this is a throw-away value
startVal = random(minVal,maxVal);
y = position[1];
ease(time,start,end,[startVal,y],[endVal,y])

Expresiones en After FX para hacer bucles con claves


(keys) animadas.

En la capa en la que tenemos las claves, seleccionamos el parámetro que hemos animado en
la linea de tiempo (Posición, Escala, Rotación, Remapeo de tiempo.... etc), y con él
seleccionado, vamos al menú Animación / Agregar Expresión [ Alt + Shift + + (tecla "+" del
teclado normal, no del numérico)], esto nos abrirá un cuadro de texto junto al parámetro
seleccionado en la línea de tiempo, donde introduciremos una de estas expresiones:

loop_out("cycle",0)

loop_out("pingpong",0)

loop_out("offset",0)

loop_out("continue")

Ha de introducirse la expresión en cada valor que queremos que repita en loop. Pudiendo
controlar individualmente cada uno de ellos.

Estas expresiones sirven para valores de animación en parámetros de Transformación


como Posición, Escala, Rotación, Opacidad... Como para Remapeo de Tiempo, y valores
individuales en filtros (Desenfoque, Granulado, Resplandor... etc), en éstos, las expresiones
han de ser introducidas siempre por cada valor individual animado, no en todo el filtro.
No sirve para todos los filtros, como por ejemplo la mayoría de los de corrección de color,
donde estas expresiones no surten efecto. Y algún otro.

loop_out("cycle",0) Repite continuamente del primer al último fotograma animado, de


manera exacta, saltando al primero en cuanto acaba el último.
loop_out("pingpong",0) Reproduce del primer al último fotograma animado, vuelve a
reproducirlo en orden inverso hasta regresar al principio, y repite el proceso
continuamente.
loop_out("offset",0) Reproduce del primer al último fotograma animado, y vuelve a
reproducirlos de manera exponencial, de tal manera que si tenemos un objeto cuyo
valor animado va de 0 a 10, en la siguiente reproducción partirá del punto en que acabó
e irá de 10 a 20, de 20 a 30, y así sucesivamente. Sumando de manera global sus
valores animados en local.

loop_out("continue") Reproducirá los fofogramas animados una única vez, y al


acabar, continuará reproduciendo la secuencia alargando el valor del último fotograma
animado, con la inercia del valor que adquiere de esa última clave.

Efecto Bounce (se pone en posición)


e = .7;
g = 5000;
nMax = 9;

n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
v = -velocityAtTime(key(n).time - .001)*e;
vl = length(v);
if (value instanceof Array){
vu = (vl > 0) ? normalize(v) : [0,0,0];
}else{
vu = (v < 0) ? -1 : 1;
}
tCur = 0;
segDur = 2*vl/g;
tNext = segDur;
nb = 1; // number of bounces
while (tNext < t && nb <= nMax){
vl *= e;
segDur *= e;
tCur = tNext;
tNext += segDur;
nb++
}
if(nb <= nMax){
delta = t - tCur;
value + vu*delta*(vl - g*delta/2);
}else{
value
}
}else
value

Observaciones!
Donde g=5000; esta es la gravedad que tendrá el rebote, puedes moverla de acuerdo a tus composiciones.
Ahora nMax=9; Es el numero de rebotes que le daremos, esta cuenta despues del primer rebote, osease que si son 9,
se le añade 1 más y el total son 10 rebotes, igual modificala a tu composición.[/justify]
Nota: Recuerda solo mover los números, y recuerda que al finalizar el número tiene que tener el punto y coma
ejemplo g=7000; (No olvides poner esto al final del número ";" )

FADE O DESVANECIMIENTO
La expresión de desvanecimiento automático es útil cuando no desea molestarse en crear
fotogramas clave para una animación de desvanecimiento. De forma automática creará un
fundido en el inicio y en el final del clip.
transition = 20; // Duración en frames del desvanecimiento
if (marker.numKeys<2){
tSecs = transition / ( 1 / thisComp.frameDuration);
linear(time, inPoint, inPoint + tSecs, 0, 100)
- linear(time, outPoint - tSecs, outPoint, 0, 100)
}else{
linear(time, inPoint, marker.key(1).time, 0, 100)
- linear(time, marker.key(2).time, outPoint, 0, 100)
}
_________

SQUASH AND STRETCH (ESTIRAMIENTO)


La expresión de estiramiento y rebote hace que tu animación sea un poco más viva al
agregar una escala proporcional a tus formas o imágenes.
maxDev = 13; // max desviación en pixeles
spd = 30; // velocidad de oscilación
decay = 1.0; // cuán rápido se detiene
t = time - inPoint;
x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
y = scale[0]*scale[1]/x;
[x,y]
_________

WIGGLE
Esta expresión sirve para agitar o menear aleatoriamente cualquier valor de una propiedad.
Dentro incluye dos valores, el primero es la velocidad de la variación que va a realizar y el
segundo es la magnitud de esa variación.
Si lo aplicamos a la posición pondriamos wiggle(A,B) siendo A la velocidad con la que se va a
mover y B la cantidad de pixeles que se moverá como máximo. Si lo aplicamos a la rotación el
valor A sería la velocidad con la que va rotar y B la variación máxima en grados que va a rotar.
wiggle(5,10)
_________
TIME
Esta expresión hace que cualquier valor aumente mientras avanza el tiempo, podemos
multiplicar la velocidad añadiendo un * seguido del número por el que lo querramos multiplicar.
Si utilizamos un valor negativo la expresión funcionaria ensentido contrario, por ejemplo
«time*-100».
time*100
_________

INDEX
El index el número de una capa, si tenemos una sola capa esa capa tendría el valor de index de
1, si tenemos dos capas una sería index 1 y otra index 2. Podemos utilizar esta expresión en
After Effects para que cuando dupliquemos una capa varias veces esta varia algo de su
comportamiento en función del index. Por ejemplo la posición, rotación,etc.
index*360/20
_________

MOTION TRAIL
Un interesante efecto que podemos aplicar al movimiento. Tendremos que aplicar un código a la
opacidad y otro a la posición. Luego de poner los códigos duplicamos la capa la cantidad de
veces que queramos que se genere la repetición del efecto.
//Aplicar a la posición
delay = 3; //number of frames to delay
d = delay*thisComp.frameDuration*(index - 1);
thisComp.layer(1).position.valueAtTime(time - d)
//Aplicar a la opacidad
opacityFactor = .75;
Math.pow(opacityFactor,index - 1)*100
_________

BLINK (PARPADEO)
Se aplica en la opacidad para generar el efecto de parpadeo, podemos variar la velocidad con la
que nuestra capa va a aparecer y desaparecer cambiando el número de la primera línea.
blinkSpeed=15; // velocidad del parpadeo
n= Math.sin(time*blinkSpeed);
if(n<0) 0 else 100;
_________

SUAVIZAR
Muy útil cuando hemos animado algo con fotogramas claves y queremos que el movimiento sea
suavizado.
smooth(width = .2, samples = 5, t = time)

https://samueltroconis.com/las-10-mejores-expresiones-en-after-effects/
Overshoot Expresión:
freq = 3;
decay = 5;

n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
amp = velocityAtTime(key(n).time - .001);
w = freq*Math.PI*2;
value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
value

http://www.jjgifford.com/expressions/reference/index.html

Intertial Bounce v1.2


Essentially, Inertial Bounce creates a bouncing motion of any parameter from one keyframe to
the next, based on its velocity. Being that true “velocity” includes the vector (or traveling
direction in 3D space), the bounce happens in whatever direction the object is traveling. This
also accounts for scalar or array values, so you’ll find that this expression works just as well on
2D rotation as it does on 3D position. It’s very cool! This expression is a bit of a community
effort. The seeds were certainly planted by the great Dan Ebberts, and then a modified version
was posted on mograph.net. Although I’ve made a slight modification to it to make it a little
more user friendly, it’s nothing that I will lay claim to as my own code. Nonetheless, it’s a great
helper and I use it all the time. Modify “amp” for the amplitude or how much bounce is
present. The variable “freq” is the frequency, or how frequently the bounce occurs. The
“decay” is like a friction or mass setting, a higher value means a shorter decay over time.

amp = .1;

freq = 2.0;

decay = 2.0;

n = 0;

time_max = 4;

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 < time_max){

v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}else{value}

Autofade
This is nothing brilliant, but it is something I wrote and use all the time. You’ll also find
something similar in the After Effects preset “Behaviors” called Fade In + Out, which uses the
Solid Composite effect and a custom interface. But, I like a simpler version that I use on
Opacity. This is a slightly enhanced version that I’d revamped since I posted it in the “Auto
Slideshow” presets and added the option to use markers. If there are no markers, the
transition variable is used (where is says “transition=20″, this is in frames.) If there are *2*
markers, the first marker is used for end point of the fade in, and the second marker is used to
define the start of the fade out.

//Autofade: Add to opacity

transition = 20; // transition time in frames

if (marker.numKeys<2){

tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds

linear(time, inPoint, inPoint + tSecs, 0, 100) - linear(time, outPoint - tSecs, outPoint, 0, 100)

}else{

linear(time, inPoint, marker.key(1).time, 0, 100) - linear(time, marker.key(2).time, outPoint, 0,


100)

}
Snap Zoom In/Out
This is a cool expression to use on text. It creates a “snap” zoom on the in and out of the layer
by modifying scale.

//Snap zoom in and out: apply to scale

snapScale = 300; //percent of scale to zoom

trans = 4; // transition time in frames

trans = trans * thisComp.frameDuration;

inTrans = easeOut(time, inPoint, inPoint + trans, [snapScale,snapScale], [0,0]);

outTrans = easeIn(time, outPoint, outPoint - trans, [0,0], [snapScale, snapScale]);

value+ inTrans + outTrans

If you prefer to use Z space position instead of scale, try this one:

zoom = 5000; //distance to zoom

trans = 4; // transition time in frames

trans = trans * thisComp.frameDuration;

inTrans = easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);

outTrans = easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);

value+ inTrans - outTrans

Y Axis Jitter
This is from Lesson 5 of my expressions series. This creates a random jittery motion in the Y
axis. You can modify probability to make or less jitter, and the pos variable to define how large
the jitter is.

// Y Axis Jitter

probability = 8 ; //higher is less likely

pos = 50;
val = random(-probability-2, 1);

m = clamp(val, 0, 1);

y = wiggle(10, pos*m)-position;

value + [0, y[1]]

5 . toComp

This one you’ll have to watch a short tutorial for here, and you can read a lot more about it at
motionscript.com. The idea is that you can apply the equivalent 3D location to any 2D location.
This might not sound exciting. But, think of all the 2D parameters out there, like lens flare
location, Shine source, beams, etc. It is probably my most commonly used expression. But, the
basic idea is this:

layer = thisComp.layer("Null 1")

layer.toComp([0,0,0])

Note: I intentionally left off the semicolon, as you technically don’t need it in this case.
Therefore, all you need to do is pickwhip your layer where the “layer =” variable is.

REBOTe:

// Inertial
Bounce - Created
by Animoplex:
www.animoplex.com
// Original Version: http://www.graymachine.com/top-5-effects-expressions/
// Modified expression for a smoother bounce effect and easier editing. Use
this on any property with two keyframes to get a nice bounce effect that is
based on velocity of the value change. Perfect for a scale from 0 to 100 or
a speedy rotation that needs some extra life. Adjust amp, freq and decay
values to tweak the effect. Amp is intensity, freq is bounces per second,
and decay is the speed of decay, slow to fast.
// Full Tutorial: https://www.youtube.com/watch?v=653lxeVIyoo
amp = 5.0; freq = 2.0; decay = 4.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/100)*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
} else {
value;
}

También podría gustarte