FORUMS: list search recent posts

coloring text based on numbers from an array (list)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
chris gulliford
coloring text based on numbers from an array (list)
on Sep 10, 2014 at 7:51:10 pm

So I have the following expression that takes a number from a list and puts it up on the screen every six frames (30 fps). Works great. Now i need compare each number from the list to the following and change the color of the test accordingly:

0-100 - Green
101-140 - Yellow
141 - 160 - Orange
161 - Up - Red

I've tried to use different animator descriptions and changing the hue/saturation, but to no avail.

Any ideas would be greatly appreciated.

Thanks.

// expression to take input of series of numerical values and display them five per second or every six frames
// get our source list
listText = thisComp.layer("heart").text.sourceText;

// now make an array, assuming a comma delimiter
list = listText.split(",");

// what's the biggest value? we'll use this as our denominator
maximum = Math.max.apply(Math, list);

// which number should we look at? one per six frames
wholeSeconds = Math.floor(time-inPoint);
milliSeconds = Math.floor(((time-inPoint) - wholeSeconds) * 1000);
indexModifier = Math.floor(milliSeconds/200);
target = (wholeSeconds*5) + indexModifier;

// make sure we don't try to find the value-as-a-percentage for an out-of-bounds array number, or try to divide by zero
if ((target >= 0) && (target &lt; list.length) && (maximum != 0)) {

// this will print to screen the array number or zero
speed = list[target];
} else speed= 0;


Return to posts index

Dan Ebberts
Re: coloring text based on numbers from an array (list)
on Sep 10, 2014 at 8:29:14 pm

Assuming that you're using an RGB fill animator and "n" represents your number, something like this for fill color should work:


if (n <= 100)
[0,1,0,1]
else if (n <= 140)
[1,1,0,1]
else if (n <= 160)
[1,.5,0,1]
else
[1,0,0,1];



Dan



Return to posts index

chris gulliford
Re: coloring text based on numbers from an array (list)
on Sep 10, 2014 at 8:59:44 pm

that works good, but returns whatever's between the square brackets... How do I get that number to return and change in the text's color?

Thanks again.


Return to posts index


Dan Ebberts
Re: coloring text based on numbers from an array (list)
on Sep 10, 2014 at 9:35:15 pm

I'm lost. I would only work as part of an expression for Fill Color.

Dan



Return to posts index

chris gulliford
Re: coloring text based on numbers from an array (list)
on Sep 11, 2014 at 4:12:16 pm

This was great! thanks.... It took me a bit to think to put the code in under "color" lol.


Return to posts index

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