Activity › Forums › Adobe After Effects Expressions › Need assistance with expression
-
Need assistance with expression
Posted by Yair Katznelson on January 19, 2011 at 3:50 pmhi all,
I need to randomize a color of a solid, but, the random colors should be picked from 4 specific colors i need.
can anyone help with an expression?Dan Ebberts replied 15 years, 4 months ago 3 Members · 6 Replies -
6 Replies
-
Dan Ebberts
January 19, 2011 at 6:33 pmTry this on the Fill effect’s Color parameter:
colors = [
[1,0,0,1], // red
[0,1,0,1], // green
[0,0,1,1], // blue
[1,.5,0,1]]; // orangeseedRandom(index,true);
colors[Math.floor(random(colors.length))]Dan
-
Yair Katznelson
January 19, 2011 at 7:43 pm10x very much!!
can you explain what the numbers represent? / how do i represent specific colors i need with those numbers?I guess this is not RGB…
-
Dan Ebberts
January 19, 2011 at 8:10 pmThe numbers are rgba. It’s just that the values go from 0 to 1. So, 50% gray would be [.5,.5,.5,1], white would be [1,1,1,1], etc.
You can set them up this way if it makes you more comfortable:
[255,0,0,255]/255 (red)
Dan
-
Kevin Camp
January 19, 2011 at 11:10 pmi’m sure yo’re done with this by now, but if you didn’t like figuring out the numerical values for rgba colors, you could add keyframes for the color change (and use the picker to set the colors), the use a slight modification of dan’s expression to randomize the keyframed value that the expression will choose…
this way you wouldn’t need to build the array of rgb values.
seedRandom(index, true);
key(Math.floor(random(numKeys)+1)).valueKevin Camp
Senior Designer
KCPQ, KMYQ & KRCW
Reply to this Discussion! Login or Sign Up