Created
October 23, 2017 14:10
-
-
Save yone80/7724875996b69ee0ae7e2c6d46948b78 to your computer and use it in GitHub Desktop.
Circle shape - Aftereffects Expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seg = Math.floor( Math.max(effect("Segments")("Slider"), 2) ); | |
radius = effect("Radius")("Slider"); | |
angle_param = clamp(effect("Angle Control")("Angle"), -360, 360); | |
close = effect("Close")("Checkbox") > 0; | |
angle = degreesToRadians(angle_param) * 1 / seg; | |
tangent = [0, 4 / 3 * Math.tan(angle/4) ] * radius; | |
firsttangent = [0,0]; | |
numiterations = seg + 1; | |
if( close && (angle_param >= 360 || angle_param <= -360) ) | |
{ | |
firsttangent = -tangent; | |
numiterations -= 1; | |
} | |
points = []; | |
intan = []; | |
outtan = []; | |
points.push( [radius, 0] ); | |
intan.push(firsttangent); | |
outtan.push(tangent); | |
for(var i = 1; i < numiterations; i++){ | |
points.push( [Math.cos(angle * i), Math.sin(angle * i)] * radius); | |
tanx = tangent[0] * Math.cos(angle) - tangent[1] * Math.sin(angle); | |
tany = tangent[0] * Math.sin(angle) + tangent[1] * Math.cos(angle); | |
tangent = [tanx, tany]; | |
intan.push(-tangent); | |
if( close && i == numiterations-1 && angle_param < 360 && angle_param > -360 ) | |
outtan.push( [0,0] ); | |
else | |
outtan.push(tangent); | |
} | |
if( close && angle_param < 360 && angle_param > -360 ) | |
{ | |
points.push( [0, 0] ); | |
intan.push( [0,0] ); | |
outtan.push( [0,0] ); | |
} | |
createPath(points, intan, outtan, close); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment