Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Map range of values to multiple other values

  • Map range of values to multiple other values

    Posted by Noel Powell on October 16, 2014 at 3:06 pm

    Hi,

    I’ve been trying to figure out a simple way to map a range of values of one parameter to multiple values in another parameter, like a basic interpolation expression, except that I have more than two values that need to be mapped. I’ve used if/else statements, which works, but if there are many values to map, it requires many if/else statements and I’m wondering if there’s a better way?

    For example, let’s say the rotation of layer1 goes from 0 to 50 to 60. if I want to make layer 2’s opacity go from 100 to 80 to 20, using layer1’s rotation values as the prompt, is there a single line of code to do this?
    something like:

    t = thisComp.layer(“layer1”).transform.rotation;
    linear(t, 0, 50, 60, 100, 80, 20)

    Thanks.

    After Effects templates – lens flares, light leaks, old film effects, digital glitches, VHS glitches, and more: https://CreationEffects.com

    Noel Powell replied 11 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 16, 2014 at 3:59 pm

    There’s no way that I know of to do it all in one statement. If you only have a few range segments, you can do it fairly compactly, like this (I added another range to your example):

    t = thisComp.layer(“layer1”).transform.rotation;
    if (t < 50) linear(t, 0, 50, 100, 80)
    else if (t < 60) linear(t,50,60,80,20)
    else linear(t,60,100,20,0)

    If you have a lot of ranges, I would probably set it up as arrays, but that code gets a little more complicated.

    Dan

  • Noel Powell

    October 16, 2014 at 4:57 pm

    Ok, thank you Dan. BTW, your article on Random Motion Expressions has been a huge help to me. Thanks.

    After Effects templates – lens flares, light leaks, old film effects, digital glitches, VHS glitches, and more: https://CreationEffects.com

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