*styles

Design + Motion Portfolio of Sanjai Davé

  • Home
  • Reel
  • About
  • Clients
  • Contact

After Effects Scripts

March 16, 2015 by Sanjai (0)

Inertial Bounce

Intertial Bounce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Inertial Bounce (moves settle into place after bouncing around a little)
 
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){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
amp = 0.1;
freq = 2.0;
decay = 7.0;
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
 
}else{
 
value;
 
}

Throw

Throw
1
2
3
4
5
// Throw (move at a constant speed without keyframes)
veloc = -10; //horizontal velocity (pixels per second)
x = position[0] + (time - inPoint) *veloc;
y = position[1];
[x,y]

Rotation

Rotation
1
2
3
4
// Spin (rotate at a constant speed without keyframes)
veloc = 360; //rotational velocity (degrees per second)
r = rotation + (time - inPoint) *veloc;
[r]

Wiggle in one direction

Wiggle only in x (horizontal)
1
2
3
4
5
6
7
org=value; temp=wiggle (5,50); [temp[0],org[1]];
Shorthand:
 
[wiggle(5,50)[0],position[1]]
wiggle only in y (vertical):
 
org=value; temp=wiggle (5,50); [org[0],temp[1]];

Looping Wiggle
1
2
3
4
5
6
7
freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)

Random Frame
1
2
3
4
5
6
7
8
fr = 12; // frame rate;
numFrames = 8;
seedRandom(index,true);
seg = Math.floor(time*fr);
f = Math.floor(random(numFrames));
for (i = 0; i < seg; i++)
  f = (f + Math.floor(random(1,numFrames)))%numFrames;
framesToTime(f);

 

Loop Cycle not working?

Activate the collapse transformations (asterisk like symbol on the left of the layermodes) and this works for me in conjunction with time remap and the previously mentioned loopOut expression (loopOut(type = “cycle”, numKeyframes = 0)

My Top 5 After Effects Expressions

Color Conversion methods (expression reference)

Harry Frank provides a video tutorial on his graymachine website that shows how to use these color conversion methods to change the color of the waves produced by the Radio Waves effect.

rgbToHsl(rgbaArray)
Return type: Array [4].Argument type: rgbaArray is an Array [4].

Converts a color in RGBA space to HSLA space. The input is an Array of normalized red, green, blue, and alpha channel values, all in the range of 0.0 to 1.0. The resulting value is an Array of hue, saturation, lightness, and alpha channel values, also in the range of 0.0 to 1.0. Example:

1
  rgbToHsl.effect("Change Color")("Color To Change")

hslToRgb(hslaArray)
Return type: Array [4].Argument type: hslaArray is an Array [4].

Converts a color in HSLA space to RGBA space. This conversion is the opposite of the conversion performed by the rgbToHsl method.

 

wiggle(freq, amp, octaves=1, amp_mult=.5, t=time)
Return type: Number or Array.Argument type: freq, amp, octaves, amp_mult, and t are Numbers.Randomly shakes (wiggles) the value of the property.freq value is the frequency in wiggles per second.amp value is the amplitude in units of the property to which it is applied.octaves is the number of octaves of noise to add together. This value controls how much detail is in the wiggle. Make this value higher than the default of 1 to include higher frequencies or lower to include amplitude harmonics in the wiggle.amp_mult is the amount that amp is multiplied by for each octave. This value controls how fast the harmonics drop off. The default is 0.5; make it closer to 1 to have the harmonics added at the same amplitude as the base frequency, or closer to 0 to add in less detail.t is the base start time. This value defaults to the current time. Use this parameter if you want the output to be a wiggle of the property value sampled at a different time.

Example: position.wiggle(5, 20, 3, .5) produces about 5 wiggles per second with an average size of about 20 pixels. In addition to the main wiggle, two more levels of detailed wiggles occur with a frequency of 10 and 20 wiggles per second, and sizes of 10 and 5 pixels, respectively.

This example, on a two-dimensional property such as Scale, wiggles both dimensions by the same amount:

1
2
  v = wiggle(5, 10);
  [v[0], v[0]]

This example, on a two-dimensional property, wiggles only along the y axis:

1
2
3
4
  freq = 3;
  amp = 50;
  w = wiggle(freq,amp);
  [value[0],w[1]];

Paul Tuersley provides a script on the AE Enhancers forum that automatically adds wiggle, smooth, and loop expressions to selected properties.

Dan Ebberts provides an example expression and a detailed explanation on his MotionScript website that shows how to use the time parameter of the wiggle method to create a looping animation.

https://motionarray.com/blog/6-common-after-effects-expressions-you-should-be-using

Keyboard shortcuts:

AA – Material options
/ – Sets the composition preview magnification to 100% (on main keyboard)
Option+Command+f – Scales footage in timeline to fit the composition window
Option+Command+Shift+h – for width
Option+Command+Shift+g – for height
u – Reveals all properties with keyframes on a selected layer in the timeline
uu – Reveals all changed properties on a selected layer in the timeline
e – Reveals the effects on a selected layer in the timeline
ee – Reveals all properties with expression on a selected layer in the timeline
Command+k – Opens the Compositions Settings Window
‘ (Apostrophe) – Turns Title/Action Safe on and off
Home – Moves the current time indicator to the start of the timeline (0:00:00:00)
End – Moves the current time indicator to the end of the timeline

Simple Postion Random Expression

seedRandom(index,true);
x = random(0,1500);
z = random(0,1500);
[x,value[1],z]

Try using a constant for the seed rather than the layer index, like this:
seedRandom(1,true);

Fade opacity of a 3D layer based on distance from camera

startFade = 500; // Start fade 500 pixels from camera. endFade = 1500; // End fade 1500 pixels from camera. try { // Check whether there’s a camera C = thisComp.activeCamera.toWorld([0,0,0]); } catch(err) { // No camera, so assume 50mm w = thisComp.width * thisComp.pixelAspect; z = (w/2)/Math.tan(degreesToRadians(19.799)); C = [0,0,-z]; } P = toWorld(anchorPoint); d = length(C,P); linear(d,startFade,endFade,100,0)

Motion, Tutorial

Related Work

  • Premier Shortcuts

Instagram

Instagram did not return a 200.

Search

More

  • Blog
  • Tumblr
  • Log in
*styles is the trading name of Starstyles Design Ltd.