FORUMS: list search recent posts

expression for color control - frame hold - slider number?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
bart stevens
expression for color control - frame hold - slider number?
on May 19, 2013 at 5:20:40 pm

I'm using a great expression from created by Filip Vandueren
to create a random fill effect via color control expressions.

Currently the colors change every frame, what I would like to have a is a slider that determines how many frames the colors hold. 1 would be like it currently is (updating every frame), 2 it would hold for 2 frames, etc...

Not exactly sure how to go about this,

Here is the expression I'm using for the random fill:

l=thisComp.layer("Colors");
i=1;
colors=[];
try {
while(l.effect(i)) {
if (l.effect(i)(1).name=="Color") {
colors.push(l.effect(i)(1).value);
}
i++;
}
} catch (e) {}
if (colors.length) {
r=Math.floor(random(colors.length));
colors[r];
} else {
value;
}

Thanks for the help


Return to posts index

Dan Ebberts
Re: expression for color control - frame hold - slider number?
on May 19, 2013 at 6:44:03 pm

Adding this to the beginning or your expression should work:

s=Math.max(Math.round(effect("Slider Control")("Slider")),1);
f=timeToFrames(time);
seed = Math.floor(f/s);
seedRandom(seed,true);


Dan



Return to posts index

bart stevens
Re: expression for color control - frame hold - slider number?
on May 20, 2013 at 4:17:12 pm

Thanks Dan,
This works great if my slider is on the same layer, but I have my slider on another layer called "Colors".
I tried modifying your expression, but the language is still off.
Any ideas why it's not seeing the slider on the master layer?

s = thisComp.layer("Colors").effect("Slider Control")("Slider").value;
s=Math.max(Math.round(effect("Slider Control")("Slider")),1);
f=timeToFrames(time);
seed = Math.floor(f/s);
seedRandom(seed,true);


Return to posts index


Dan Ebberts
Re: expression for color control - frame hold - slider number?
on May 20, 2013 at 4:28:41 pm

Try it this way:

slider = thisComp.layer("Colors").effect("Slider Control")("Slider").value;
s=Math.max(Math.round(slider),1);
f=timeToFrames(time);
seed = Math.floor(f/s);
seedRandom(seed,true);


Dan



Return to posts index

bart stevens
Re: expression for color control - frame hold - slider number?
on May 20, 2013 at 5:23:05 pm

Great, thanks again Dan


Return to posts index

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