Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Defining Min and Max

  • Defining Min and Max

    Posted by Al Johnson on September 23, 2008 at 12:25 am

    Alright, so, as I said before, I’m trying to get into writing expressions for myself when I need them, so I’ll probably be on here asking things as questions crop up.

    I understand how to basically define an expression (position = thisComp.layer(“Null 6”).transform.opacity) that makes sense to me. However, say I wanted to say the position of a given thing is equal to the opacity of a given layer but between two numbers. I’m trying to think of the most concise way to say this. But if I wanted the position between 2500 and 3500 as the opacity went from 0 to 100. How do I get that going?

    Thanks as always.

    Mike Clasby replied 17 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Mike Clasby

    September 23, 2008 at 2:39 am

    Interpolation. Click that little triangle next to the pickwhip, then select Interpolation, and you’ll see the forms (or see Help Files).

    Anyway, if you trying to have the Z position (depth) to range from 2500 to 3500 as the opacity varies from 0 to 100 (I’m guessing that’s what you want) then this would be an expression that works (on position):

    x = position[0];
    y = position[1];
    z = linear(opacity, 0, 100, 2500, 3500);
    [x, y, z]

    So that third line is saying as the opacity varies from 0 to 100, then interpolate the z to be from 2500 to 3500. Linear is straigh proportional, and there are Ease form if that’s what you want.

    Is that what you want?

  • Mike Clasby

    September 23, 2008 at 2:46 am

    OK, after re-reading your question I see you asked for min and max values for input into your expression, so this is probably a better way to write it so you can see what min and max are for the various things you could change.

    minZ = 2500;
    maxZ = 3500;

    minOp = 0;
    maxOp = 100;

    x = position[0];
    y = position[1];
    z = linear(opacity, minOp, maxOp, minZ, maxZ);
    [x, y, z]

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