Expressions used at AVW

Expressions used at AVW 2015

Scale Matte layer based on size of text layer, add padding

Expression for Size parameter in Matte layer (a shape layer)

s=thisComp.layer("TEXT_LAYER_NAME");
padding=250;
y=120;
x=s.sourceRectAtTime(time-s.inPoint,true).width+padding;
[x,y]

 

Center the Anchor of Matte layer

Expression for Posistion parameter of Matte layer

content("Rectangle 1").content("Rectangle Path 1").size/2

 

Place the logo based on width of Matte layer

Expression for Posistion parameter of Logo layer

x=thisComp.layer("MATTE_LAYER_NAME").sourceRectAtTime(time,true).width;
gap=30;
y=956;
[x+gap, y]

 

Scale Layer height based on text input

Expression for Scale parameter of Solid layer.

// Expression by Kati Haapamäki, Valve Media Oy, Finland
y = parseFloat(thisComp.layer("SOLID_LAYER_NAME").text.sourceText);
[100, y]

 

Simple On/Off expression

Expression for Opacity parameter of layer.

// Expression by Kati Haapamäki, Valve Media Oy, Finland
input = thisComp.layer("TEXT_LAYER_NAME").text.sourceText;
if (input != "") value else 0;

 

Expressions from AVW Presentation 2016

Text in bold is what you type manually. Text not in bold is either copy/pasted or written by the Pickwhip.

Type-On duration

A template with a Type-On effect will need different timing with different text lengths. We can control this with the expression from Adam Hark.

// expression by Adam Hark
var Duration = parseFloat(thisComp.layer("Duration").text.sourceText);
var Typeon = linear(time, 0, Duration, 0, 100)
Typeon

Turn Layers on/off based on text

Logo on left or right side. Add logo two places. Add expressions to both layers.

// expression based on expression from Kati Haapamäki
input = thisComp.layer("Align(L/R)").text.sourceText.toLowerCase();
if (input == "r") {
value
}else {
0
}

On/off Example 2

Add four logos on same place, and let the user decide which one is visible. This is the expression to show the AE logo.

input = thisComp.layer("Logo").text.sourceText.toLowerCase();
if (input == "ae") value else 0;

 

Move keyframes with expressions

Make animation of text in and out using Position. Then add a text layer named Duration (sec).

Add expression for the Position and other parameters that animate out.

// expression by Dan Ebberts
// expects source text layer named Duration (sec)
keyOut = 3;
tOut = parseFloat(thisComp.layer("Duration (sec)").text.sourceText);
if (! isNaN(tOut)){
if (time < inPoint + tOut){
value;
}else{
t = time - (inPoint + tOut);
valueAtTime(key(keyOut).time + t);
}
}else
value

Make a new layer that animates out later. Add Extra keyframe to make it animate out at the correct time relative to the other layer.

Bars – as many as you need

Layer > New > Shape Layer
Name it Bar 1, Add Rectangle, 200 x 850 px
Add Gradient Fill, adjust to taste
Add Expression to Position of Rectangle:

[value[0],-content("Rectangle Path 1").size[1]/2]

This makes it scale from bottom
Add keyframes from 0 to 850 for Y scale.
Grab Expression from MotionScript.com and paste into Size for Rectangle

// Expression by Dan Ebberts
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

Add text layer, name it Value Bar 1
Add expression to Scale (the one we get by pressing S) by pointing Pickwhip to the Source Text parameter of the Text layer and add the type below.

temp = parseFloat(thisComp.layer("Value Bar 1").text.sourceText);
[100, temp]

Add new text layer, name it Number of Bars

Add expression to Opacity (O)

BarNumber = parseFloat(thisComp.layer("Number of Bars").text.sourceText);
if (BarNumber>=2) value else 0;

Add more layers and adjust expressions accordingly, so they take the input from the correct layers.

Adjust Color

We don’t have a color picker, but we can to link color to the Hue/Saturation effect. Turn on Colorize, and use text layers to drive Colorize Hue, Colorize Saturation and Colorize Lightness.

The Hue and Saturation ones are simple:

parseFloat(thisComp.layer("Hue (0-360)").text.sourceText)

parseFloat(thisComp.layer("Saturation (0-100)").text.sourceText)

Since Lightness goes from -100 to 100, it can get confusing. So Let’s change the range to 0-100.

input = parseFloat(thisComp.layer("Lightness (0-100)").text.sourceText);
Lightness = linear(input, 0, 100, -100, 100);
Lightness