Page 1 of 1

Controlling color based on a random, cycling value

Posted: August 18th, 2007, 6:18 pm
by redforty
Ok, here's the effect I'm trying to achieve:

A set of numbers that fluctuates randomly, changing color depending on the number going up or down (green and red, respectively).

I started by creating a text layer with the source text pik-whipped to the X value of a null. I put a wiggle on the null with a low frequency to give the number a 'soft' fluctuation. It rises and falls just fine.

What I want to do now is change to color of the text layer green when the number is rising and red when it's falling (no grad between. It can be a binary switch).

I thought maybe I could get an expression to read the value of X (on the normal) on the last frame and compare it to the current frame, then color based on an If-then statement. But I can't figure out how to do that.

valueAtTime(time-1) didnt work. I know I'm not doing it right.

Any help would be greatly appreciated. Thanks!

-Daniel

Posted: August 18th, 2007, 10:18 pm
by Dan Ebberts
Something like this should do the trick:

Code: Select all

red = [1,0,0,1];
green = [0,1,0,1];
if ( thisComp.layer("Null 1").transform.position.velocity[0] >0 ) green else red

Dan