Check out this sample project:
12475_scalepath.aep.zip
You need Ae CC 2018 v15.0 or higher to have expression access to paths. This project is set up to work on masks on solids, but it could be adapted to shape layers.
Here are the setup instructions if you want to build it from scratch:
1. Create a solid named PATH_SOURCE, and add a mask to it named Mask 1.
2. Create a solid named PATH_SCALE, and add as mask to it. Also, add two Slider Control effects to PATH_SCALE, and rename them xScale and yScale in the Effects Control Panel or on the Timeline. Alt+click the Mask Path property stopwatch on the PATH_SCALE layer’s mask and paste the following code:
originalPath = thisComp.layer("PATH_SOURCE").mask("Mask 1").maskPath;
var newPoints= [];
var newInTangents = [];
var newOutTangents = [];
var totalX = 0;
var totalY = 0;
xScale = thisComp.layer("PATH_SCALE").effect("xScale")("Slider")/100;
yScale = thisComp.layer("PATH_SCALE").effect("yScale")("Slider")/100;
for (i = 0; i < originalPath.points(time).length; i++) {
totalX += originalPath.points(time)[i][0];
totalY += originalPath.points(time)[i][1];
}
var centroid = [totalX, totalY] / originalPath.points(time).length;
for (var i = 0; i < originalPath.points(time).length; i++) {
var point = originalPath.points(time)[i];
var delta = point - centroid;
var scaledPoint = [delta[0] * xScale, delta[1] * yScale];
var scaledCentroid = [centroid[0] * xScale, centroid[1] * yScale];
newPoints.push(scaledPoint + centroid);
}
for (var i = 0; i < originalPath.inTangents(time).length; i++) {
var point = originalPath.inTangents(time)[i];
var scaledInTangent = [point[0] * xScale, point[1] * yScale];
newInTangents.push(scaledInTangent);
}
for (var i = 0; i < originalPath.outTangents(time).length; i++) {
var point = originalPath.outTangents(time)[i];
var scaledOutTangent = [point[0] * xScale, point[1] * yScale];
newOutTangents.push(scaledOutTangent);
}
createPath(newPoints, newInTangents, newOutTangents, thisComp.layer("PATH_SOURCE").mask("Mask 1").maskPath.isClosed());
I’d be happy to try to answer any questions you might have about what exactly the code is doing.
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn]