Activity › Forums › Adobe After Effects Expressions › Expression for color control
-
Dan Ebberts
April 7, 2017 at 2:13 pmTry 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 pmOops, I meant change this part:
holdTime = .5;
seed = Math.floor(time/holdTime);Dan
-
Greta Senne
April 7, 2017 at 2:44 pmsame 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 pmAwesome, thanks!
Question; how to – not let it change every frame but just being static? -
Andy Teel
July 18, 2019 at 5:27 pmHow 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;
}
Reply to this Discussion! Login or Sign Up