Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression for color control – frame hold – slider number?

  • expression for color control – frame hold – slider number?

    Posted by Bart Stevens on May 19, 2013 at 5:20 pm

    I’m using a great expression from created by Filip Vandueren
    to create a random fill effect via color control expressions.

    Currently the colors change every frame, what I would like to have a is a slider that determines how many frames the colors hold. 1 would be like it currently is (updating every frame), 2 it would hold for 2 frames, etc…

    Not exactly sure how to go about this,

    Here is the expression I’m using for the random fill:

    l=thisComp.layer(“Colors”);
    i=1;
    colors=[];
    try {
    while(l.effect(i)) {
    if (l.effect(i)(1).name==”Color”) {
    colors.push(l.effect(i)(1).value);
    }
    i++;
    }
    } catch (e) {}
    if (colors.length) {
    r=Math.floor(random(colors.length));
    colors[r];
    } else {
    value;
    }

    Thanks for the help

    Bart Stevens replied 12 years, 12 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 19, 2013 at 6:44 pm

    Adding this to the beginning or your expression should work:

    s=Math.max(Math.round(effect(“Slider Control”)(“Slider”)),1);
    f=timeToFrames(time);
    seed = Math.floor(f/s);
    seedRandom(seed,true);

    Dan

  • Bart Stevens

    May 20, 2013 at 4:17 pm

    Thanks Dan,
    This works great if my slider is on the same layer, but I have my slider on another layer called “Colors”.
    I tried modifying your expression, but the language is still off.
    Any ideas why it’s not seeing the slider on the master layer?

    s = thisComp.layer("Colors").effect("Slider Control")("Slider").value;
    s=Math.max(Math.round(effect("Slider Control")("Slider")),1);
    f=timeToFrames(time);
    seed = Math.floor(f/s);
    seedRandom(seed,true);

  • Dan Ebberts

    May 20, 2013 at 4:28 pm

    Try it this way:

    slider = thisComp.layer(“Colors”).effect(“Slider Control”)(“Slider”).value;
    s=Math.max(Math.round(slider),1);
    f=timeToFrames(time);
    seed = Math.floor(f/s);
    seedRandom(seed,true);

    Dan

  • Bart Stevens

    May 20, 2013 at 5:23 pm

    Great, thanks again Dan

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