Copy link to clipboard
Copied
Hello, i have error when copying the path to the layer i want him to go to the path:
content("Forme 1").content("Tracé 1").path
temp = thisComp.layer("Calque de forme 1").content("Forme 1").content("Tracé 1").path;
[temp, temp]
temp,temp = seem to be correct ? this function is write by After
thanks to help me
Copy link to clipboard
Copied
Hello, i get this code:
var temp = thisComp.layer("Calque de forme 1").content("Forme 1").content("Tracé 1").path;
var points = temp.points();
var numPoints = points.length;
// Calculer la longueur totale du tracé
var totalLength = 0;
var lengths = [];
for (var i = 0; i < numPoints; i++) {
var nextIndex = (i + 1) % numPoints;
var segmentLength = length(points[i], points[nextIndex]);
lengths.push(segmentLength);
totalLength += segmentLength;
}
// Définir la durée totale en fonction de la longueur du tracé
var totalDuration = totalLength / 100; // Ajustez ce facteur pour changer la vitesse
// Calculer la position sur le tracé en fonction du temps
var t = (time % totalDuration) / totalDuration * totalLength;
var currentLength = 0;
var index = 0;
// Trouver les points actuels et suivants en fonction de la longueur parcourue
while (currentLength + lengths[index] < t) {
currentLength += lengths[index];
index++;
}
var nextIndex = (index + 1) % numPoints;
var segmentLength = lengths[index];
var progress = (t - currentLength) / segmentLength;
var currentPoint = points[index];
var nextPoint = points[nextIndex];
var x = linear(progress, 0, 1, currentPoint[0], nextPoint[0]);
var y = linear(progress, 0, 1, currentPoint[1], nextPoint[1]);
// Ajuster les coordonnées pour qu'elles restent dans le cadre
var compWidth = thisComp.width;
var compHeight = thisComp.height;
x = linear(x, -compWidth / 2, compWidth / 2, 0, compWidth);
y = linear(y, -compHeight / 2, compHeight / 2, 0, compHeight);
// S'assurer que les coordonnées sont dans le cadre
x = Math.max(0, Math.min(compWidth, x));
y = Math.max(0, Math.min(compHeight, y));
[x, y];
Copy link to clipboard
Copied
it's go to 3/4 of the path, don't go to the end