Skip to content

Instantly share code, notes, and snippets.

@thatsmadden
thatsmadden / convex-hull-expression
Created September 14, 2020 01:42
An After Effects expression to calculate a minimum enclosing path shape (the convex hull) around a set of points.
// 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 September 5, 2022 01:14
Send an After Effects layer 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 September 5, 2022 01:14
Place an After Effects Null between two other Nulls and drive that placement with a slider. Goes in the Position property of a layer.
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