Activity › Forums › Adobe After Effects Expressions › Expression for color control
-
Jarek Borzecki
January 29, 2013 at 11:52 pmit’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 pmThis 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 pmHello 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 pmAssuming 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 pmThis 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 pmHi, 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!
-
Will Mcmillian
September 6, 2016 at 12:32 amTo 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 amHey,
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;
}
Reply to this Discussion! Login or Sign Up