P. 1
A Collection of Expressions for Adobe After Effects

A Collection of Expressions for Adobe After Effects

|Views: 163|Likes:
Published by hexinfx
Expressions for Adobe After Effects
Expressions for Adobe After Effects

More info:

Published by: hexinfx on Jul 14, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/28/2014

pdf

text

original

A Minor Collection of Useful Expr essions

{  for use w ith adobe after effects  }
featur ing

michael natk in, fr ed lew is, dan ebberts, br ian maffitt & steve holmes

total tr aining, inc w w w.t o ta lt r a i n i n g . c o m

CI RC LE FU N
by Michael Natkin & Brian Maffitt
This generates perfect circular motion centered around the original position of the layer. I recommend that you map the radius and cycle inputs to Expression Control sliders, and the phase input to an Expression Control angle. Apply this expression to the position of the layer.
radius = 75; // the radius of the circle cycle = 1; // number of seconds to complete a circle; higher value = slower if(cycle ==0){cycle = 0.001;} //avoids a "divide by zero" error phase = 27; // initial angle in degrees from bottom reverse = 1; // 1 for ccw, -1 for cw x = Math.sin( reverse * degrees_to_radians(time * 360 / cycle + phase)); y = Math.cos(degrees_to_radians(time * 360 / cycle + phase)); add(mul(radius, [x, y]), position)

c = this_comp. Use the expression below on the position property that you wish to animate.anchor_point) . if you want to use write-on to track the position of a layer called “moon”. c.layer("child"). For instance. and change “child” to “moon”.to_comp(c. changing the name “Child” to match the name of the layer you wish to track.T R ACK A CH I LD by Michael Natkin This expression is designed to track the position of a layer that has been parented to one or more layers. apply this expression to the “brush position” property of the write-on filter.

wigdetail) . wigamt. //wiggle frequency wigamt = 30. //detail of noise wiggle(wigfreq. keyframeable Wiggler. The variable names in the first three lines can be named whatever you like. //wiggle amount wigdetail = 3. wigfreq = 3. but remember to change their corresponding use in the last line of the script.ADJUSTA BLE W IGGLE by Brian Maffitt Use this expression as an interactive. Apply it to the property of the layer you wish to wiggle.

wignoise). . FOR TWO DIMENSIONS wigfreq = 5. but constrained along a single axis. FOR THREE DIMENSIONS wigfreq = 5. Apply it to the position or anchor point of the layer you wish to wiggle. [position[0]. //wiggle amplitude wignoise = 3. just[1]] //will wiggle just on Y. wignoise). //wiggle frequency wigangle = 45. just[2]] //will wiggle just on Z. //octaves of noise just = wiggle(wigfreq. //wiggle amplitude wignoise = 3. position[1]. //wiggle frequency wigangle = 45. wigangle.ON E -DI MENSIONA L POSI T ION W IGGLE by Brian Maffitt Use this expression as an interactive. wigangle. keyframeable Wiggler. //octaves of noise just = wiggle(wigfreq. [position[0].

linear(t.t. and an Expression Control slider assigned to “period”. 90]. Change “linear” to “ease” for smoother interpolation. if (t > period) t = 2 * period . //one end of your oscillation to = [190. to) . Use an adjustment layer with Expression Control position points for “ from”. //the other end of your oscillation period = 1. period.5. 0. from.OSCI LLAT E POSI T ION by Michael Natkin & Brian Maffitt Creates an oscillating motion between two specified 2-dimensional positions over a specified period of time (in seconds). 30]. from = [50. “to”. //time between oscillation points (multiply by 2 for a round trip) t = time % (period * 2).

Use Expression Control angles or sliders for “ from”. //one end of your oscillation to = 45.5. from = -45. and an Expression Control slider assigned to “period” for fine control. if (t > period) t = 2 * period . 0. //time between oscillation points (multiply by 2 for a round trip) t = time % (period * 2).OSCI LLAT E ROTAT ION { OR A N Y SI NGLE VA LU E  } by Michael Natkin & Brian Maffitt Creates an oscillating motion between two specified values over a specified period of time (in seconds). “to”. from. You can apply these to any layer. to) . Change “linear” to “ease” for smoother interpolation.t. linear(t. period. //the other end of your oscillation period = 1.

BOU NCE by Michael Natkin & Brian Maffitt Creates a bouncing (sine wave) motion between two specified 2-dimensional positions over a specified period of time (in seconds). apogee) . 50]. Use Expression Control position points for “ from”.sin(t * Math.5. //the length of time from surface to apogee t = time % (period * 2). and an Expression Control slider assigned to “period” for fine control. You can apply these to any layer. surface = [320.t. 1. 0. linear(Math.PI / period). Useful for creating bouncing balls. //the position of the "bounce" surface apogee = [320. surface. 480]. “to”. //the "apogee" of the bounce period = 1. if (t > period) t = 2 * period .

Link Expression control sliders to lag (to interactively control how bunched together the layers are). . //wiggle frequency wigamt = 30.5. One works from the top down. the wiggle is based on the position of the leader. //wiggle frequency wigamt = 30. Change the word “Leader” to match the name of the leading layer.num_layers . .adj) //OR. Once applied to a single follower. wigamt. A follower will tag along after the leader.adj) . //wiggle amount adj = (index .layer("Leader"). wigfreq = 3. Only use one. this_comp.wiggle(wigfreq. wigfreq = 3. the other from the bottom up. deviating from the path according to the wiggle properties that are specified in the inputs. //USE THIS ONE IF THE LAYERS STACK UP FROM BOTTOM LEADER lagtime = .5.1) * lagtime.W IGGLE FROM LEADER by Michael Natkin & Brian Maffitt These two expressions create a “ follow the leader” effect. offset in time from the last and wiggling uniquely.layer("Leader"). Apply Expression control effects to the leader only... wigfreq (to control the frequency of the wiggle) and wigamp (to control the amplitude of the wiggle). this_comp.time .time . 2. 2. //wiggle amount adj = (this_comp. you can duplicate the layer as many times as you like and each subsequent copy will follow along.1. //USE THIS ONE IF THE LAYERS STACK DOWN FROM TOP LEADER lagtime = . wigamt.wiggle(wigfreq.index) * lagtime.1. In this expression.

.5. //wiggle frequency wigamt = 30. wigfreq (to control the frequency of the wiggle) and wigamp (to control the amplitude of the wiggle). //wiggle amount adj = (this_comp.layer(this_layer. //USE THIS ONE IF THE LAYERS STACK DOWN FROM TOP LEADER lagtime = .1.adj) //OR.1) * lagtime.1. 1). Link Expression Control sliders to lag (to interactively control how bunched together the layers are). offset from the last in time and wiggling uniquely..time . In this expression. A follower will tag along after the previous layer. wigfreq = 3.time . //wiggle amount adj = (index .wiggle(wigfreq. wigamt. 2. you can duplicate the layer as many times as you like and each subsequent copy will follow along.adj) . this_comp. 2. Once applied to a single follower.index) * lagtime. this_comp.W IGGLE FROM PR EV IOUS by Michael Natkin & Brian Maffitt This creates a “ follow the leader” effect that works from the bottom up. wigamt. deviating from the previous path according to the wiggle properties that are specified in the inputs. Apply Expression Control effects to the leader only. Change the word “Leader” to match the name of the leading layer.. .layer(this_layer. the wiggle is based on the position of the previous layer.5. -1). wigfreq = 3. //USE THIS ONE IF THE LAYERS STACK UP FROM BOTTOM LEADER lagtime = .wiggle(wigfreq. //wiggle frequency wigamt = 30.num_layers .

to the name of the layer you wish the layer to look at. below.layer(LookAt).this_comp.2D LOOK AT by Fred Lewis Apply this Expression to the Rotation channel of any layer you wish to control.position[1].layer(LookAt).abs(diffx))) * 90. below. diffy = position[1] . to adjust the direction it is looking. If the controlled layer is not initially pointing straight up.this_comp. Set LookAt.position[0]. if (diffx == 0) { diffx = 1 } sign = 1 + (-1 * (diffx / Math.atan(diffy/diffx)) + sign + offset . enter an offset amount in degrees. radians_to_degrees(Math. LookAt = “ball” offset = 0 diffx = position[0] .

adjust the layer offset by changing the X.3D LOOK AT by Fred Lewis Apply this expression to the orientation channel of the layer you wish to have look at another layer (the layer being controlled). Y and Z rotation values (not the orientation values) for the layer being controlled.layer(LookAt). If the layer being controlled does not correctly look at other layer. Enter the name of the layer to look at in LookAt below. [look[0]. LookAt = "ball" look = look_at(position. look[2]] .position). this_comp. look[1].

layer("angle_zoomer"). To use: Create a null called “angle_zoomer”. by scaling a null object on screen.A NGLE OF V I EW ZOOMER by Fred Lewis This allows you to control the angle of view of a camera interactively. this_comp. substitute = this_comp.width / (2 * Math. Animate the null’s scale to control viewing angle in degrees.tan(degrees_to_radians(substitute/2))) .scale[1].

layer("focal_zoomer"). 5. Create a null layer called “ focal_zoomer” and turn off its visibility switch in the timeline. 4. in millimeters. FocalLength = this_comp. Set the value of hFilmPlane in the expression to the size of your film. this_comp.FOCA L LENGT H ZOOMER by Fred Lewis This expression will allow you to zoom a camera in After Effects using real-world focal length values.scale[1]. 2.width * (FocalLength/hFilmPlane) . Animate the null’s scale to control the focal length of the camera. in millimeters hFilmPlane = 35. 3. Apply the expression below to the Zoom parameter of the camera. To use this expression: 1. Create a camera.

then change the name “Focus Layer” below. position).CA MER A AUTOFOCUS by Fred Lewis Apply this expression to the Focus Distance of your camera.layer(focuser). cam_to_layer = sub(this_comp. focuser = "Focus Layer". length(cam_to_layer) .position. to the name of the layer you wish to keep in focus.

[stretch.atan2(diff[1]. one for rotation and one for scale.layer(follow2).diff[0]) * 180/Math. // apply this Expression to the Connector layer’s Position parameter // set follow1 below to the name of the first layer to follow follow1 = "End 1" this_comp.layer(follow1).position).CON N ECTOR by Fred Lewis These Expressions can be used to make a connector that stretches like a rubber band between two layers. (Math. which by default are named “End 1” and “End 2”. The connector layer wants to be a horizontal rectangle. The Expressions are listed separately below. with the anchor point of the layer moved to the left center edge of the layer. The connector has 3 separate expressions applied to it: one for position.PI) + 180 // apply this Expression to Connector layer’s Scale parameter // set follow2 below to the name of second layer to follow follow2 = "End 2" stretch = length(position.this_comp.this_comp. . Obviously you can change these names to anything you like.position // apply this Expression to Connector layer’s Rotation parameter // set follow2 below to the name of second layer to follow follow2 = "End 2" diff = sub(position.layer(follow2).position).scale[1]].

GEA R S by Fred Lewis This Expression causes one gear to rotate at the proper speed when a second gear next to it is rotated. -1) . Ratio = 3/4 mul((this_comp. the ratio of the difference in size between the two gears must equal the ratio of the difference in the number of teeth between the two gears. to the name of the Leader gear. Then set the LayerToFollow. Once imported. so that the two gears stay meshed with each other. in the Expression. LayerToFollow = "Leader". relative to the Follower. In order for two gears to mesh properly. decide which gear will be the Leader and which will be the Follower.rotation) * Ratio. To use this expression. first create and import two gears that mesh together properly. Apply the Expression below to the Rotation parameter of the Follower gear. Set the Ratio in the expression to the size of the Leader.layer(LayerToFollow).

y]). 2. radius = 75. To use this Expression: 1. cycle = 1. without making it follow a path. reverse = 1. spacing and other features of Path Text with ordinary straight text. Use only Vertex 1 of the path to position the text.PAT H T EXT LEV ELER by Fred Lewis This Expression will automatically keep the text in Path Text level within the comp.cos(degrees_to_radians(time * 360 / cycle + phase)). Useful for when you simply want to make a straight line or paragraph of text in Path Text. Set the Shape Type to “Line” under Path Options in the effects window for Path Text. // // // // the radius of the number of seconds initial angle in 1 for ccw. higher value = slower degrees from bottom cw x = Math.sin( reverse * degrees_to_radians(time * 360 / cycle + phase)). It allows you to use the extra kerning. [x. -1 for circle to complete a circle. position) . add(mul(radius. 3. phase = 27. y = Math. Past the expression (below) into the “Vertex 2” parameter of Path Text in the Timeline.

this_comp. layertofollow = "eagle" ticker = Math. Set pickup and dropoff time values to times for pickup and dropoff. in seconds.0.0.layer(layertofollow). these two expressions can be used to parent one layer to another for only a portion of a longer animation.rotation. Set “layertofollow” to name of “eagle” layer.T EM POR A RY PA R EN T I NG by Fred Lewis Using the analogy of an eagle picking up a fish and dropping it in a nest. dropofftime = 5.min(Math. 2. Set pickup and dropoff time values to times for pickup and dropoff. this_comp. time).position. time). dropofftime).value_at_time(ticker) . Apply the first expression below to the position channel for a null.max(pickuptime. 1.53333.value_at_time(ticker) pickuptime = 1. layertofollow = "eagle" ticker = Math.max(pickuptime.min(Math.53333. Apply the second expression to the rotation channel for the null. in seconds. pickuptime = 1. Set “layertofollow” to name of “eagle” layer. dropofftime). dropofftime = 5.layer(layertofollow).

position. layposx = effectlayer.param(ParamToFollow).position[0]. layposy = effectlayer.5 * layheit))] .effect(EffectToFollow). EffectToFollow = "Corner Pin". effectposx = effectparam[0]. ParamToFollow = “Lower Right”. and use this expression to track another layer to the lower right corner of the effect. [(layposx + effectposx .layer(LayerToFollow) effectparam = effectlayer. For example. laywid = effectlayer. Set the ParamToFollow to the name of the parameter within the effect you want to follow The layer this is applied to will follow the effect parameter.T R ACK EFFEC T PA R A MET ER by Fred Lewis This expression will track any effect point on a layer. // // // // // // Apply this expression to the position parameter of any layer. Set the EffectToFollow to the name of the effect who’s parameter you want to follow.5 * laywid)). (layposy + effectposy . LayerToFollow = "Corner Pinned Layer". Set the LayerToFollow to the layer who’s effect parameter you want to follow. For example. you could have a small layer with corner pin applied. layheit = effectlayer. regardless of size.(. This expression will not take into account the scale or rotation of the source layer.width. effectlayer = this_comp.position[1]. regardless of how the layer is moved. or scale of the layer.height. effectposy = effectparam[1].(. and translate it to positional values that are relative to the comp.

y = amplitude*Math. create a small solid called “Control Layer” and hide it in the timeline. Paste the expression below into the Position property of the layer you wish to bounce.layer("Control Layer"). decay = thisComp.DECAY I NG BOU NC E by Dan Ebberts & Steve Holmes This expression allows you to “drop” a layer from the top of the screen and have it bounce in the center of the comp as if tied to a string. First. and be sure to set the layer’s anchor point to the correct location.effect("amplitude control")("Slider"). amplitude = thisComp.layer("Control Layer").y] . “amplitude control” and “decay control”. such as the bottom edge if dropping from the top.exp(decay*time).layer("Control Layer").effect("decay control")("Slider"). Add 3 Slider Control effects. naming them “velo control”. Suggested initial slider values for each are -200. veloc = thisComp.effect("velo control")("Slider"). value + [0. with a bounce decay control.cos(veloc*time)/Math. -200 and 4 respectively.

effect("spd control")("Slider").layer("squash control"). One frame before the final position keyframe. adjust the sliders to the level you desire. with a bounce decay control.layer("squash control"). Keyframe the position drop of your layer. naming them “maxDev control”. // max deviation in pixels spd = thisComp. Paste the expression below into the Position property of the layer you wish to bounce. making sure the anchor point is in the correct location you wish the bounce to occur from. maxDev = thisComp. Then one frame later.effect("maxDev control")("Slider").layer("squash control").effect("decay control")("Slider").y] . create a small solid called “squash control” and hide it in the timeline.SQU ISH Y SQUASH Y by Dan Ebberts & Steve Holmes This expression allows you to “drop” a layer from any position (defined by your own position keyframes) and have it bounce in the center of the comp as if tied to a string.sin(spd*(time -inPoint))/Math. //speed of oscillation decay = thisComp. both at 0. First.exp(decay*time). y = scale[0]*scale[1]/x. //how fast it slows down x = scale[0] + maxDev*Math. set keyframes for the maxDev control and spd control sliders. [x. “spd control” and “decay control”. Add 3 Slider Control effects. and adjust the decay to suit. Suggested initial slider value for decay control is 2.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->