• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

error when copy path

Explorer ,
Sep 02, 2024 Sep 02, 2024

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

TOPICS
Crash , Expressions , Scripting

Views

60

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 02, 2024 Sep 02, 2024

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];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 02, 2024 Sep 02, 2024

Copy link to clipboard

Copied

LATEST

it's go to 3/4 of the path, don't go to the end

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines