Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Remapping array to slider with easing

  • Remapping array to slider with easing

    Posted by Mark Warner on January 22, 2019 at 3:48 pm

    Hi all

    I have what I thought was simple that really has me stumped!

    I’ve an array of y positions that I’d like to simply remap to a slider so the array[0] is 0 on a slider, array[1] is 1 on a slider, array[2] is 2 on slider….. so I can animate between positions with simple values on a slider.

    I think there’s some loop to do that I can’t figure out, any help would be much appreciate!

    Mark Warner replied 7 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 22, 2019 at 5:11 pm

    It might be like this (unless you need tweening, which would be a little more complicated):

    s = effect(“Slider Control”)(“Slider”);
    yPos = [100,200,300,400,500];
    idx = Math.round(clamp(s,0,yPos.length-1));
    y = yPos[idx];
    [value[0],y]

    Dan

  • Mark Warner

    January 22, 2019 at 6:00 pm

    Many thanks Dan.

    Apologies – I inadvertently pressed the Report Post button!!!

    That’s great, but yes – really want tweening. I’ll go the long way round for now as it sounds quite complicated. Many thanks for your time.

  • Dan Ebberts

    January 22, 2019 at 6:08 pm

    There are a number of ways to do it, but this should work:

    s = effect(“Slider Control”)(“Slider”);
    yPos = [100,200,300,400,500];
    idx = clamp(s,0,yPos.length-1);
    idx1 = Math.floor(idx);
    idx2 = Math.ceil(idx);
    y1 = yPos[idx1];
    y2 = yPos[idx2];
    y = ease(idx,idx1,idx2,y1,y2);
    [value[0],y]

    Dan

  • Mark Warner

    January 22, 2019 at 6:28 pm

    Ohhh, thanks, amazing!! Will try when I get back in the morning. It’ll save so much time on this project as I can pretty much automate everything 😀

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