Forum Replies Created

Page 11 of 32
  • You can use the linear function, this way:

    ypos=thisComp.layer("A").transform.position[1];
    x = linear(ypos, 600, 300, 20, 100);
    [x,x];

    Xavier

  • Xavier Gomez

    February 12, 2016 at 6:20 pm in reply to: Reference property value in layer above

    I tried your code and it works.
    I get rotations values 0,1.5, 3, 4.5, 6, etc

    Another possibility is to defined rotation based on first in the stack:

    leader = thisComp.layer(“LEADER”);
    leader.rotation + (index-leader.index)*1.5;

    Xavier.

  • Xavier Gomez

    February 9, 2016 at 3:44 pm in reply to: looping text Array

    What is wrong with the third example (‘A’, ‘B’, ‘C’) ?
    Can you post the error, if any, or tell which misbehaviour you observe ?

  • Xavier Gomez

    January 29, 2016 at 1:07 am in reply to: Getting layers real bounds using sampleImage()

    If you are on a Text layer or Shape layer, you can use the sourceRectAtTime method, which is way easier to manipulate and also faster.

    For a layer with source (like a solid with a mask etc), to find the left most pixel, you should scan the layer with a verical band that is as high as the layer (ie radius[1] = layer.height). Otherwise with a radius of 0.5 you will need ages to finish.

    Method 1 is to roll that a thin vertical band by increments of 1 until you hit something.

    Method 2 is to start with a sample as big as the layer (so it is not really vertical).
    If you hit, then:

    step0 : you divide the width (radius x) by 2,
    step1 : sample the left part of the image.
    step2 : if you hit, go to step 0 again, with left part of the image,
    else go to step 2, but with the right part.
    And so forth until the radius x becomes smaller than 0.5 (or more if you dont need pixel accuracy);

  • Xavier Gomez

    January 28, 2016 at 11:22 pm in reply to: Progressive, always positive wiggle?

    Here is a possibility, not optimal since it calculates the whole every frame.
    If your keys are not far apart and the param averageChangesPerSec isnt too big, it should be fine

    startVal = 0;
    endVal = 100; // max copies
    t1 = numKeys>0 ? key(1).time : inPoint;
    t2 = numKeys>1 ? key(2).time : outPoint;
    averageChangesPerSec = 1.5;
    seed1 = index+1000;
    seed2 = index+2000;
    a = 3; // controls time variations (close to 1 = small, bigger=more disparity)
    b = 10; // controls value variations (same)

    if (time<=t1){startVal;}
    else if (t2<=time) {endVal;}
    else{
    numSteps =Math.ceil((t2-t1)*averageChangesPerSec);
    t=0; times = [0];
    v=0; values = [0];
    for (n=1; n<=numSteps; n++){seedRandom(t+seed1, true);t+=random(1,a); times[n]=t; seedRandom(t+seed2, true);v+=random(1,b); values[n]=v;};

    t = (time-t1)/(t2-t1) * t;
    x = (endVal-startVal) / v;

    a=0; b=numSteps; while(b-a>1){j=Math.floor((a+b)*0.5); if (times[j]<=t){a=j;} else{b=j;};};

    startVal + x*linear(t, times[a], times[b], values[a], values[b]);
    };

    Xavier

  • Xavier Gomez

    January 28, 2016 at 7:53 pm in reply to: Progressive, always positive wiggle?

    This should work:

    startVal = 0;
    endVal = 100; // max copies
    DTmin = 0.2; // DTmin/max : time interval min/max between changes
    DTmax = 0.8;
    DNmin = 2; // DNmin/max : change amount min/max
    DNmax = 5;

    s=t=inPoint;
    m=n=startVal;
    while (n

    Xavier

  • Xavier Gomez

    January 25, 2016 at 11:37 am in reply to: Ternary diagram / ternary plot calculations

    Yes, if the A,B,C points are somewhere deep inside a shape layer and the point M is sommewhere else, you are stuck as i think it is not possible to convert A, B, C in that case. At least i dont know how to do it.
    It should be fine otherwise.

    Side note: i just noticed that the variable called BC is not even used, so you can erase the corresponding line even in the “slimmed” version.

    Xavier

  • Xavier Gomez

    January 22, 2016 at 8:31 pm in reply to: Ternary diagram / ternary plot calculations

    I can’t tell.
    The expression i gave assumes that all point coordinates A, B, C and M are in the same system. Depending on your set up you might have to use one of the space transform functions (toComp/fromComp etc).

    Also, that expression is unnecessarily heavy. If you have lots of points you can change it to this one, which does the same thing without extra stuff:

    A = thisComp.layer("A").transform.position.value;
    B = thisComp.layer("B").transform.position.value;
    C = thisComp.layer("C").transform.position.value;
    M = thisComp.layer("Point").transform.position.value;
    AB = sub(B,A);
    BC = sub(C,B);
    CA = sub(A,C);
    AM = sub(M,A);
    u = AB[0]*CA[1]-AB[1]*CA[0];

    c = 100 * (AM[0]*AB[1]-AM[1]*AB[0]) / u;
    b = 100 * (AM[0]*CA[1]-AM[1]*CA[0]) / u;
    a = 100-(b+c);

    letters= ["a", "b", "c"];
    values = [a,b,c];
    for (k=0; k<3; k++) letters[k] += " : " + (values[k]<10 ? " " : "") + values[k].toFixed(1) + "%";
    letters.join("\n");

    Xavier

  • Xavier Gomez

    January 22, 2016 at 6:01 pm in reply to: Expression Disabled after Expression pick whip

    Have you renamed something after that ?

    It is kind of weird that your expression uses single quotes, as normally AE uses double ones.

    One thing to know is that AE recognises single quotes, but, when renaming layers/properties, comps etc, the expression engine only converts expressions that use double quotes.

  • Xavier Gomez

    January 22, 2016 at 5:25 pm in reply to: Ternary diagram / ternary plot calculations

    The expression below is for a text layer (display all 3 coordinates in 1 single text) :

    A = thisComp.layer("A").transform.position.value;
    B = thisComp.layer("B").transform.position.value;
    C = thisComp.layer("C").transform.position.value;
    M = thisComp.layer("Point").transform.position.value;
    AB = sub(B,A); if (AB.length<3) AB.push(0);
    BC = sub(C,B); if (BC.length<3) BC.push(0);
    CA = sub(A,C); if (CA.length<3) CA.push(0);
    AM = sub(M,A); if (AM.length<3) AM.push(0);
    u = cross(AB, CA);
    U = dot(u,u);

    c = dot(u, cross(AM, AB))/U*100;
    b = dot(u, cross(AM, CA))/U*100;
    a = 100-(b+c);

    letters= ["a", "b", "c"];
    values = [a,b,c];
    for (k=0; k<3; k++) letters[k] += " : " + (values[k]<10 ? " " : "") + values[k].toFixed(1) + "%";
    letters.join("\n");

    It’s not optimal as it does unnecessary calculations, but trying to optimize would make it less compact.

    Xavier

Page 11 of 32

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy