Skip to content

Instantly share code, notes, and snippets.

View animoplex's full-sized avatar
🎯
Animating!

Animoplex animoplex

🎯
Animating!
View GitHub Profile
@animoplex
animoplex / Value.jsx
Created March 6, 2019 02:27
Value Expression
// Value Expression
value / 2
// Current property value divided by 2
@animoplex
animoplex / LinearCounterbalance.jsx
Created March 6, 2019 05:09
Linear Counterbalance
// Linear Counterbalance
s = thisComp.layer("Control").effect("Slider Control")("Slider");
a = transform.position;
b = thisComp.layer("Null").toWorld([0,0,0]);
linear(s, 0, 100, a, b)
// Adjust a Slider Control (from 0 to 100) to balance between two values (a and b)
@animoplex
animoplex / LinearEase.jsx
Last active March 14, 2019 01:09
Linear & Ease Expressions
// Linear & Ease Expressions
linear(time, outPoint - 2, outPoint, 100, 0)
ease(transform.opacity, 0, 100, 25, 75)
// Linear fade from 100 to 0 for the last 2 seconds of a layer’s duration
// Ease from 25 to 75 as the Opacity input animates from 0 to 100
@animoplex
animoplex / Loops.jsx
Created March 6, 2019 06:49
Loop Expressions
// Loop Expressions
loopOut("cycle", 0) // Repeat from start to finish, default loop mode
loopOut("pingpong", 2) // Loops last three keyframes back and forth
loopOut("offset", 0) // Repeats animation using last keyframe as new start point
loopOut("continue") // Does not loop, but continues onwards with current velocity
// loopOut evaluates from the first keyframe towards the layer outPoint
// loopIn can be substituted to evaluate from layer inPoint towards last keyframe
@animoplex
animoplex / WhileLoopExample.jsx
Created December 25, 2018 02:32
While Loop Example - After Effects Expression by Animoplex
// JavaScript While Loop Example - Created by Animoplex: www.animoplex.com
// The JavaScript While Loop and how it can be used in After Effects.
// Full Tutorial: https://www.youtube.com/watch?v=SG3NyHmfc0s&t=225s
src = thisComp.layer("Control").effect("Acceleration")("Slider");
dur = thisComp.frameDuration;
dist = 0;
t = 0;
while (t < time) {
dist += src.valueAtTime(t) * dur;
@animoplex
animoplex / MathMethods.jsx
Created September 4, 2018 02:13
Math Methods - After Effects Expression by Animoplex
// Math Methods - Created by Animoplex: www.animoplex.com
// Use these methods to manipulate properties and numerical values in After Effects.
// Full Tutorial: https://www.youtube.com/watch?v=aIxnJBOhdBw
// Math Method Examples
// Note: You must capitalize the M in Math for these methods to work properly.
Math.abs(-2) // Returns 2
Math.ceil(1.01) // Returns 2
Math.floor(1.99) // Returns 1
Math.min(1, 2, 3) // Returns 1
@animoplex
animoplex / AfterEffectsStringMethods.jsx
Last active June 29, 2020 17:10
After Effects String Methods - After Effects Expression by Animoplex
// After Effects String Methods - Created by Animoplex: www.animoplex.com
// List of compatible string methods in After Effects expressions and what they do.
// Full Tutorial: https://www.youtube.com/watch?v=l7Xd8mkqWfc&t=268s
// Outputs 2 characters, starting after the first character.
myString.substr(1, 2)
// Outputs everything after the first character, through the second character.
myString.substring()
@animoplex
animoplex / AddLightness.jsx
Created September 5, 2018 14:15
Add Lightness - After Effects Expression by Animoplex
// Add Lightness - Created by Animoplex: www.animoplex.com
// Adds lightness percentage to a color value.
// Full Tutorial: https://www.youtube.com/watch?v=QkqiaPZJa1Y
// Lightness Example
moreLight = effect("Color Brightness")("Slider") / 100;
hsl = rgbToHsl(value);
assemble = [hsl[0], hsl[1], hsl[2] + moreLight, hsl[3]];
hslToRgb(assemble)
@animoplex
animoplex / ForLoopExample.jsx
Created December 25, 2018 02:22
For Loop Example - After Effects Expression by Animoplex
// JavaScript For Loop Example - Created by Animoplex: www.animoplex.com
// The JavaScript For Loop and how it can be used in After Effects.
// Full Tutorial: https://www.youtube.com/watch?v=SG3NyHmfc0s&t=91s
myArray = [];
for (i = 0; i < thisComp.numLayers; i++) {
myArray[i] = thisComp.layer(i+1).name;
}
myArray.slice(0, thisComp.numLayers).join("\r")
@animoplex
animoplex / ToFixedExpression.jsx
Created September 4, 2018 02:23
Trim Decimals - After Effects Expression by Animoplex
// Trim Decimals with toFixed() - Created by Animoplex: www.animoplex.com
// Trim to a specific number of decimal places and add zeros if the value is a whole number.
// Full Tutorial: https://www.youtube.com/watch?v=aIxnJBOhdBw
// Trim Decimals Example
value.toFixed(2) // Outputs a value of, for example, 1 as 1.00 and 1.667 as 1.66
// Text String Trim Decimals Example
parseInt(text.sourceText).toFixed(2) // Converts text to string and trims decimals