Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expressions, wiggle and dimensions

  • Expressions, wiggle and dimensions

    Posted by Olly Lawer on April 2, 2012 at 12:08 pm

    Hi,

    I’m currently learning expressions and trying to get my head around dimensions and expressions.

    In the book i’m reading by Marcus Geduld, he tends to write expressions like this:

    var bothDimensions = wiggle(1,200);
    var widthDimension = transform.scale[0];
    var heightDimension = bothDimensions[1];
    [widthDimension, heightDimension]

    But I understand you can write the same expression like this:

    transform.position[0], wiggle(1,200)[1]

    Which for me is easier to grasp and use.

    My question is when it comes to this:

    [transform.position[1], wiggle(1,200)[1]]

    I thought it meant that on the Y axis, you are saying to use both the keyframes AND add an wiggle, while the X axis, although you haven’t stated it in the expression, remains as transform.position[0]?

    Although this doesn’t compute when it comes to trying that theory out. Any keyframes are cancelled out by the expression.

    [wiggle(1,200)[0], transform.position[1]]

    Results in the wiggle on the X axis as planned, but you cannot keyframe the Y axis. Fine. But what does this mean then?

    [wiggle(1,200)[1], transform.position[1]]

    Now it is still wiggling along the X axis but I though the X axis was 0?

    I get even more confused when it comes to scale, that only has one dimension.

    So what is the difference between:

    [wiggle(1,200)[1], transform.scale[0]]

    And

    [wiggle(1,200)[1], transform.scale[1]]

    ?

    I will get my head around it!

    Olly Lawer

    Darby Edelen replied 14 years, 5 months ago 3 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 2, 2012 at 2:51 pm

    For expressions that refer to their own keyframed value, I like to use “value” rather than “transform.position” because it works for whatever property you’re talking about. So all of the following applies to both position and scale.

    This expression essentially does nothing–just gives you the keyframed value:

    value

    This does the same:

    [value[0],value[1]]

    This would swap the x and y keyframed values (if you needed to do that for some reason):

    [value[1],value[0]]

    So, whatever you specify as the first element in the array becomes the x value and the second element of the array is the y value. This gives you x wiggle and the y keyframed value:

    [wiggle(1,200)[0],value[1]]

    There’s nothing stopping you from using the y component of the wiggle as your x output value. (You could do it, but offhand I can’t think of a reason that you would want to):

    [wiggle(1,200)[1],value[1]]

    Finally, to wiggle only y:

    [value[0],wiggle(1,200)[1]]

    I hope that helps.

  • Darby Edelen

    April 3, 2012 at 10:20 pm

    To expand on Dan’s comments, the position and scale properties are both vector properties with 2 elements. That is to say that they have an X and a Y component. You access these elements by calling the variable with the index of the element you want in brackets:

    value[0]

    The above returns the first (numbering starts from 0) element in the vector (the X value for scale and position).

    value[1]

    The above returns the second element in the vector (this is the Y value for scale and position).

    When you call the wiggle() function it returns a vector of the same size as the property that its being called from:

    wiggle(1,5);

    So the above returns a vector with 2 elements (X = [0] and Y = [1]) for position and scale, while it returns a scalar value for rotation and other scalar properties.

    Darby Edelen

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