Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scale width generated by position x

  • Scale width generated by position x

    Posted by Brad Pickford on August 9, 2011 at 8:57 pm

    Hi Everyone was hoping someone might be able to help.

    I am creating a character rig and I need to create some expressions to control it. The first problem I have is this…

    I have a flat 2d character. I have a null that controls the position of the mouth eyes and nose. when i drag it from side to side it emulates the character looking from side to side (from left 3/4 to front on to right 3/4). The character is wearing some spectacles and I want the left and right lenses of the spectacles to scale in width dimension only depending on the x position of the null controller. I only want the scale to be constrained from 70% to 120%.

    Hope this makes sense?

    Thanks in advance!

    Cheers,
    Brad

    Caleb Power replied 12 years, 7 months ago 3 Members · 14 Replies
  • 14 Replies
  • Dan Ebberts

    August 10, 2011 at 12:08 am

    It’s probably going to look something like this:


    centerX = 400;
    d = Math.abs(thisComp.layer("Null 1").toComp([0,0,0])[0] - centerX);
    s = linear(d,0,100,120,70);
    [s,value[1]]

    The exact expression will depend on information you didn’t provide, like what’s the reference point? I mean the glasses scale as the null moves relative to what? What’s the range of movement? Which movement distance corresponds to which scale factor? Details like that.

    Dan

  • Brad Pickford

    August 10, 2011 at 12:31 am

    Hi Dan, Thanks for your reply! I have attached an image to show you what I am trying to achieve. I have tried a basic expression of connecting the lense scale[0] property to the position[0] of the “null”. As you can see in the attached image it scales it too far. So basically I need the scaling of the left and right lenses to be in relation to the “null” position x of the centre line.

    Am I explaining it right?

    Cheers,
    Brad

  • Brad Pickford

    August 10, 2011 at 12:39 am

    not too sure if image attached properly so I have an external link here…

    https://bradpickford.com/cc/example.jpg

  • Brad Pickford

    August 10, 2011 at 12:52 am

    Sorry about all the small replies Dan, this is my first post. I have applied your expression and it is working well except for the part where the “null” transitions onto the other side of the center line. So basically, when the null is on the far left hand side I need the scale to be 70%; at the center of the line I need it to be 100%; and on the far right of the center line I need it to be 120%. I am thinking I would need to use an if/else statement to achieve this. I am not too sure how to assemble all of these elements into the expression though?

    Thanks Dan

  • Dan Ebberts

    August 10, 2011 at 2:01 am

    More like this then, probably:


    centerX = 400;
    d = thisComp.layer("Null 1").toComp([0,0,0])[0] - centerX;
    s = d < 0 ? linear(d,-100,0,70,100) : linear(d,0,100,100,120);
    [s,value[1]]

    Dan

  • Brad Pickford

    August 10, 2011 at 2:12 am

    Perfect! Your a true genius Dan! Thank you for being so generous with you time and skills

  • Caleb Power

    October 8, 2013 at 9:27 pm

    Hi Dan,

    What would this expression be to make the scale grow with X and Y, not just X?

  • Dan Ebberts

    October 8, 2013 at 10:51 pm

    I’m not sure what you’re asking. Do you want it to uniformly scale in response to how far it is from a specific point, or ???

    Dan

  • Caleb Power

    October 9, 2013 at 5:26 pm

    What I have are the numbers 1 through 7. There’s a dot that moves from left to right above them. When the dot stops for example over the number 4, I’d like the number 4’s scale to grow uniformly to 140% and also the opacity to go from 40% to 100%.

    So whatever the dot is over, that numbers opacity grows from 40% to 100% and the scale would grow uniformly from 100% to 140%. Anything not under the dot, opacity would be 40% and the scale would be 100%.

    Sliding the dot from left the right, each number would act accordingly. Does this make sense?

  • Dan Ebberts

    October 9, 2013 at 5:50 pm

    Something like this should work for scale:

    minRange = 100;
    maxRange = 500;
    minVal = [100,100];
    maxVal = [140,140];

    dot = thisComp.layer(“dot”);
    p1 = dot.toComp(dot.anchorPoint);
    p2 = toComp(anchorPoint);
    d = length(p1,p2);
    linear(d,minRange,maxRange,maxVal,minVal)

    and this for opacity:

    minRange = 100;
    maxRange = 500;
    minVal = 40;
    maxVal = 100;

    dot = thisComp.layer(“dot”);
    p1 = dot.toComp(dot.anchorPoint);
    p2 = toComp(anchorPoint);
    d = length(p1,p2);
    linear(d,minRange,maxRange,maxVal,minVal)

    You’ll probably have to adjust the minRange and maxRange values.

    Dan

Page 1 of 2

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