ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random Color Change at Layer Marker (with transition)?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rob Frese
Random Color Change at Layer Marker (with transition)?
on Jun 16, 2015 at 4:51:11 pm

Hey guys -- searched around but can't find an answer to this.

How can I create a random color change at each layer marker that transitions between the colors?

In other words, it doesn't just abruptly cut to a different color, it changes to that color over the course of a couple of frames? Like if you just keyframed a color property?

I have an expression yields a random color change at each layer marker, when applied to the HUE property of the Color Balance (HLS) effect (see below) but this just cuts to the new color, no transition.

I don't nearly have the intelligence to put together something like this, but it would be GREATLY appreciated.

Thanks,
Rob

markerLayer = thisComp.layer(1);
m = markerLayer.marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}

seedRandom(n,true);
random([n*81.79],[n*n*7.77])


Return to posts index

Dan Ebberts
Re: Random Color Change at Layer Marker (with transition)?
on Jun 16, 2015 at 5:28:15 pm

Try this:


tRamp = 3*thisComp.frameDuration;
markerLayer = thisComp.layer(1);
m = markerLayer.marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}

seedRandom(n,true);
c1 = random([n*81.79],[n*n*7.77]);

if (n > 0){
seedRandom(n-1,true);
c0 = random([(n-1)*81.79],[(n-1)*(n-1)*7.77]);
t = time - m.key(n).time;
linear(t,0,tRamp,c0,c1)
}else{
c1
}



Dan



Return to posts index

Rob Frese
Re: Random Color Change at Layer Marker (with transition)?
on Jun 16, 2015 at 8:59:10 pm

Dan! Yes! Perfect! Exactly what I needed.

Wow, I didn't know Dan Ebberts would be answering my question. That's pretty freaking cool.


Return to posts index


JuanLuis Vich
Re: Random Color Change at Layer Marker (with transition)?
on Aug 10, 2016 at 2:25:58 am

hi!
do you know if it's possible to take the color from a selection from a bunch of Color Control effect (maybe stored at the same layer) instead of a total random color? I've been trying to, but not lucky at all :-(

thanks!


Return to posts index

Santi Agustí
Re: Random Color Change at Layer Marker (with transition)?
on Aug 10, 2016 at 3:14:34 pm

it is not the cleanest, but you can apply this to a fill effect:

markerLayer = thisLayer
m = markerLayer.marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}

seedRandom(n,true);
color1=thisComp.layer("Colors").effect("Color Control")("Color");
color2=thisComp.layer("Colors").effect("Color Control 2")("Color");
color3=thisComp.layer("Colors").effect("Color Control 3")("Color");
color4=thisComp.layer("Colors").effect("Color Control 5")("Color");
//etc

colors = [color1,color2,color3,color4];

idx = Math.floor(random(colors.length));
colors[idx]


Return to posts index

ido shor
Re: Random Color Change at Layer Marker (with transition)?
on Jan 1, 2020 at 9:26:37 am

Hey Dan, and all the rest... :)))

I encountered an error while trying to use this expression:
"expression result must be of dimension 4, not 1"

any clues?

also... while you are at it, will be nice if you can send a version of the script that doesn't have a transition within.

thanks!!
Ido.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]