Skip to content

Instantly share code, notes, and snippets.

@yone80
Last active August 21, 2018 10:21
Show Gist options
  • Save yone80/a71e2031b8290fa90b7be117e1b9a402 to your computer and use it in GitHub Desktop.
Save yone80/a71e2031b8290fa90b7be117e1b9a402 to your computer and use it in GitHub Desktop.
Roll - Aftereffects Expression
numsegments = Math.max(2, Math.floor(effect("Segments")("Slider")));
totallength = Math.max(0.001, effect("Line Length")("Slider"));
seglength = totallength / numsegments;
sepdist = Math.max(0.001, effect("Seperation Distance")("Slider") * 0.5) / (Math.PI * 2);
roll = clamp(effect("Roll")("Slider"), 0, 1);
pos = [0, 0];
cv = [];
firsttheta = Math.sqrt(numsegments * seglength / sepdist);
f = numsegments;
for(i=0; i<numsegments; i++)
{
u = (i - 1) / numsegments;
u = linear(u, roll, 1, 0, numsegments);
f -= clamp(u, 0, 1);
theta = Math.sqrt(f * seglength / sepdist);
theta -= firsttheta;
if(i != 0)
{
x = Math.cos(theta) * seglength;
y = Math.sin(theta) * seglength;
pos += [x, y];
}
cv.push(pos);
}
createPath(cv, [], [], false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment