Skip to content

Instantly share code, notes, and snippets.

@thatsmadden
thatsmadden / convex-hull-expression
Created Sep 14, 2020
An After Effects expression to calculate a minimum enclosing path shape (the convex hull) around a set of points.
View convex-hull-expression
// This is a messy way to calculate a minimum enclosing shape given a set of 2D points. Just replace the "points[0]=.... ;" section with your own selection of points.
// The expression uses a Graham scan to find the points on the outer edge of the shape-- utilizing a cross product to find the point with the greatest "left-turn" for the next vertex on the hull.
// It's meant to go on a path shape-- either a mask path or a Shape Layer path.
function indexOfMin(arr) { // find index of point that has the lowest x-position.
if (arr.length === 0) {
return -1;
}
@thatsmadden
thatsmadden / around-a-circle
Last active May 27, 2017
Send an After Effects layer around a circle.
View around-a-circle
s=effect("size")("Slider");
d=degreesToRadians(effect("driver")("Angle"));
h=Math.sin(d);
v=-Math.cos(d);
([h,v]*s)+value
@thatsmadden
thatsmadden / null-between-nulls
Last active May 27, 2017
Place an After Effects Null between two other Nulls and drive that placement with a slider. Goes in the Position property of a layer.
View null-between-nulls
a=thisComp.layer("NullA").toWorld([0,0,0]);
b=thisComp.layer("NullB").toWorld([0,0,0]);
wh=thisLayer.effect("weight")("Slider");
aW=a*wh;
bW=b*(1-wh);
aW+bW