# After Effects expressions (ongoing)

Loop
To loop any key frames
loopOut(type = “cycle”)

Wiggle

Wiggle the position of a layer
position.wiggle(3,5,1)

Put this in the opacity of a layer

if (n<=0) 0 else 100;

From this website

## Object bouncing on a floor

This will make your layer/object bounce along an imaginary ‘floor’. Paste it into the ‘position’ attribute for your layer.

```Vy0 = 500; //initial y velocity (pixels/second)
Vx0 = 100; // initial x velocity (pixels/second)
g = 2500; // gravity (pixels/second/second)
floor = 400;
e = .85; //elasticity
b = floor - position;
h = b + Vy0*Vy0/(2*g);
T = Vy0/g + Math.sqrt(2*h/g);
if (time < T){
y = Vy0*time - g*time*time/2 + b;
}else{
Vy = -(Vy0 - g*T);
while (true){
Vy *= e;
t = T;
T += 2*Vy/g;
if (time < T){
t = time - t;
y = Vy*t - g*t*t/2;
break;
}else if (T - t < thisComp.frameDuration){
y = 0;
break;
}
}
}
[position + Vx0*time, floor - y]```

## Bouncy scale ‘IN’

Apply this expression to the ‘scale’ parameter of your layer.

```k=16; // final scale
a=5; // how quickly the bounce ends
b=20; // how many bounces it'll do (that is, the bounce speed)
x=k*(1-Math.exp(-a*time)*Math.cos(b*time));
[x,x]```

http://www.motionscript.com/design-guide/toc.html

http://www.colinbraley.com/repel_expressions_tutorial.html

Objects repel each other

Jitter

``````//applyTo: position
// 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]

From ```http://www.motion-graphics-exchange.com/search.php?pg=2&ipp=10&mgxq=blur+jitter&p=1&c=0```