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

  • Dan Ebberts

    April 7, 2017 at 2:13 pm

    Try changing this part:

    holdTime = .5;
    seed = Math.floor((time+preRun)/holdTime);

    to this:

    holdTime = .5;
    seedRandom(index,true);
    preRun = random(holdTime);
    seed = Math.floor((time+preRun)/holdTime);

    Dan

  • Dan Ebberts

    April 7, 2017 at 2:20 pm

    Oops, I meant change this part:

    holdTime = .5;
    seed = Math.floor(time/holdTime);

    Dan

  • Greta Senne

    April 7, 2017 at 2:44 pm

    same result as before… maybe is added something in the wrong place?

    l=thisComp.layer("Colors");

    // retrieve colors stored in the color controls
    i=1;
    colors=[];

    try {
    while(l.effect(i)) {
    // an effect exists, but is it a color control ?
    // We'll check if it's first parameter is called "Farbe"
    if (l.effect(i)(1).name=="Farbe") {
    colors.push(l.effect(i)(1).value); // store the color in a list
    }
    i++;
    }
    } catch (e) {}

    // Now if the list of colors contains any elements
    // we will get a random value from the list.

    if (colors.length) {
    holdTime = .5;
    seedRandom(index,true);

    preRun = random(holdTime);
    seed = Math.floor((time+preRun)/holdTime);

    seedRandom(seed,true);

    r=Math.floor(random(colors.length)) // a random integer
    colors[r]; // return the color

    } else {
    // the list of colors is empty, so we use the existing color value.
    value;
    }

  • Menno Wisselink

    October 18, 2017 at 8:44 pm

    Awesome, thanks!
    Question; how to – not let it change every frame but just being static?

  • Andy Teel

    July 18, 2019 at 5:27 pm

    How would I adjust this so that the color change duration is random and not every single frame?

    l=thisComp.layer("Colors");

    // retrieve colors stored in the color controls
    i=1;
    colors=[];

    try {
    while(l.effect(i)) {
    // an effect exists, but is it a color control ?
    // We'll check if it's first parameter is called "Color"
    if (l.effect(i)(1).name=="Color") {
    colors.push(l.effect(i)(1).value); // store the color in a list
    }
    i++;
    }
    } catch (e) {}

    // Now if the list of colors contains any elements
    // we will get a random value from the list.

    if (colors.length) {
    r=Math.floor(random(colors.length)); // a random integer
    colors[r]; // return the color

    } else {
    // the list of colors is empty, so we use the existing color value.
    value;
    }

Page 3 of 3

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