Utilities
Accessing sub-objects
Get layer's pixel size
function getSize(layer){
var src = layer.sourceRectAtTime();
var s = layer.transform.scale
var size = [src.width*s[0],src.height*s[1]]/100;
return size;
}Get layer's top left coordinates
function getSrcRectTopLeft(layer){
s = layer.sourceRectAtTime();
localPos = [s.left,s.top];
worldPos = layer.toWorld(localPos);
return worldPos;
}Get effect index number
Get number of effects applied to a layer
Working with Array
https://dmitripavlutin.com/operations-on-arrays-javascript/
Check how many array is empty
Finding minimum or maximum element
In ES6, you can use the ... operator to spread an array and take the minimum or maximum element.
Get length of each element
Comparing a value to elements, filtering conditions
Increment by Index
Usage: tiling, valueAtTime offset
Checking selected layer
Shape Layer
This snippet returns if the layer is a shape layer by checking if there is "Contents" property group.
Loops
Through every frame
Unsorted
Explanation
Using simple trigonometry:
Imagine you have the point [960, 540];
Those 2 values, 960 and 540, represent two adjacent sides of a triangle.
Now, if you recall back to 9th Grade, you may remember that there is a simple equation to get the third side of that triangle. A² + B² = C². So, we can find the third side (the magnitude) by using an equation like:
var mag = Math.sqrt(Math.exp(position[0], 2) + Math.exp(position[1], 2)); Essentially saying take the square root of X² + Y².
Fortunately, AE gives us the handy little ‘length’ operator, which simply does all of these computations for us.
—
Another similar equation can be used to find the angle of a triangle when you know two other sides, you may remember SOH CAH TOA.
Imagine the angle at the top left of your comp, now notice that you have the opposite side (the Y coord) and the adjacent side (the X coord). Since TOA uses both opposite and adjacent sides, we can get that angle using an equation like this:
Null / Camera Rigs
Add sliders with specific affix names to property
Autonomous agents
Auto-capture ball by Aaron Cobb
Compounding ease() interpolation (source)
You can't control the influence directly, but you can compound the ease such as below.
Interactive app for easing: http://gizma.com/easing/
Highly useful for learning about speed graph & math
Last updated
Was this helpful?