Last active
October 25, 2017 11:51
-
-
Save yone80/90e1afe3970fbcdd06a34dbde85d230a to your computer and use it in GitHub Desktop.
Shape on path - 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
dist = effect("Offset")("Slider"); // Position on path. | |
w = effect("Width")("Slider"); // Normal direction width. | |
restpath = thisProperty; | |
targetpath = thisComp.layer("Path").content("Shape 1").content("Path 1").path; // Target Path | |
refpt = restpath.points(); | |
refintan = restpath.inTangents(); | |
refouttan = restpath.outTangents(); | |
points =[]; | |
intangents = []; | |
outtangents = []; | |
for(i=0; i<refpt.length; i++){ | |
rest = refpt[i]; | |
f = dist + rest[0] / thisComp.width; | |
pathpoint = targetpath.pointOnPath(f); | |
pathnormal = targetpath.normalOnPath(f); | |
angle = Math.atan2(-pathnormal[0], pathnormal[1]); | |
intanx = refintan[i][0] * Math.cos(angle) - refintan[i][1] * Math.sin(angle); | |
intany = refintan[i][0] * Math.sin(angle) + refintan[i][1] * Math.cos(angle); | |
outtanx = refouttan[i][0] * Math.cos(angle) - refouttan[i][1] * Math.sin(angle); | |
outtany = refouttan[i][0] * Math.sin(angle) + refouttan[i][1] * Math.cos(angle); | |
points.push( pathpoint + pathnormal * rest[1] *w); | |
intangents.push( [intanx, intany * w] ); | |
outtangents.push( [ outtanx, outtany * w] ); | |
} | |
createPath(points, intangents, outtangents); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment