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

  • Jarek Borzecki

    January 29, 2013 at 11:40 pm

    thanks Dan, I’ll check again everything…

  • Jarek Borzecki

    January 29, 2013 at 11:52 pm

    it’s working fine now! my fault, dont ask what happened please

    thank you again for your help!
    J

  • Goran Milovanovic

    March 13, 2013 at 12:07 pm

    This is amazing script. Is it possible that instead of random color I use float values in range from example -25,453 to 25.453. -value is blue and +value would be red like gradient. I have around 700 float values that i want to change into colors per frame.

    I am new to scripting so I would appreciate any help
    Thanks in advance

  • Rob Mcdougall

    June 12, 2013 at 8:49 pm

    Hello all,

    I’m wanting to control a colour scheme using a slider.

    So, if slider = 1

    circle = red

    square = green

    triangle = blue

    when the slider value increased to 2 each fill layer would move on to the next object…

    circle = blue

    square = red

    triangle = green

    So, I understand that I need to make a range of colour controls, then I want to store them in a list. What I don’t understand is how to chose a specific colour (or member of the index) based on the slider value. Any suggestions?

  • Dan Ebberts

    June 12, 2013 at 9:02 pm

    Assuming your colors are stored in an array named “colors”, and your slider control value is ‘slider’, you could calculate an index for each layer like this:

    idx = ((index-1) + Math.floor(slider))%colors.length;
    colors[idx]

    You might have to modify the index-1 if your shape layers aren’t at the top of the layer stack.

    Dan

  • Brandt Weisman

    July 25, 2013 at 8:43 pm

    This works great. Is there anyway to control the duration of the color cycle. Every frame is a bit fast for my needs. Thanks.

  • Matthew Newcomb

    August 22, 2013 at 5:41 pm

    Hi, Not sure if you ever got an answer to your question, but if you did would you mind sharing it with me? I’m not very good at expressions yet!

  • Deepak Kumar

    October 4, 2013 at 9:34 am

    How to use this Scripts. Can you tell me what i have to do.

  • Will Mcmillian

    September 6, 2016 at 12:32 am

    To make this last longer than a single frame, this worked for me; pre-comp and enable time-remapping to your new layer. Then apply this expression to the time re-mapping:

    framesToTime(Math.floor(timeToFrames()/4));

  • Greta Senne

    April 7, 2017 at 10:06 am

    Hey,
    im using your code just added a little time-tweak. I have this Code on an Adjustment Layer because i have multiple layers that i want to change between the colors – but randomly in time. right know everything is changing together.. i hope you understand what i mean.

    i think it could work about the “index”?!

    — thank you —

    here the code again (just added this holdTime-lines)

    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;
    seed = Math.floor(time/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;
    }

Page 2 of 3

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