Activity › Forums › Adobe After Effects › simple expression help
-
simple expression help
Posted by Randy Cates on June 15, 2006 at 9:16 pmI want to generate an animation bed for a retro looking fashion show open (translucent circles of varying sizes floting randomly around a blue background and circular elements pop in and out at random. I know how to do this this the traditional way but am sure it’s better done with expressions. Since I’m expressionally challenged (but trying) can anyone tell me how to write the expression to:
(1.) position these circles at random, with random sizes (within a small, med, lrg size range) and pop in (3frames) and fade out (5 frms)
and
(2.) makes various size circles (same size range as above)just float around randomly
Should be a snap just don’t have it yet.
Colin Braley replied 19 years, 10 months ago 2 Members · 6 Replies -
6 Replies
-
Colin Braley
June 16, 2006 at 2:35 amFor the random sized circles that have 3 size ranges and pop in and fade out try this:
-First create a solid of any size and add a circular mask to it (double click the circular mask tool)
-Then add the following expressions
-Go into the scale expression and adjust the variables smallScaleAmt, medScaleAmt, and largeScaleAmt
-Next, you can go to the opacity expression and change the lifeSpan of the circles and how long the fades in and out take
-Press Ctrl + D and duplicate your circle a bunch of times//expression for position
seedRandom(index, true);
x = random(0, thisComp.width);
y = random(0, thisComp.height);
[x,y]
//end expression for position//expression for scale
smallScaleAmt = 50;//Adjust this to taste
medScaleAmt = 100;//Adjust this to taste
largeScaleAmt = 150;//Adjust this to taste
//–
seedRandom(index, true);
arr = [smallScaleAmt, medScaleAmt, largeScaleAmt];
ind =Math.round( random(0, 2) ) ;
[arr[ind], arr[ind]]
//end expression for scale//expression for opacity
fadeIn = 3;//frames
fadeOut = 5;//frames
minLife = 30;//frames
maxLife = 50;//frames
//–
seedRandom(index, true);
lifeBegin = random(0, timeToFrames(thisComp.duration) );
lifeEnd = lifeBegin + random(minLife, maxLife);
if(time > framesToTime(lifeEnd) || time < framesToTime(lifeBegin) ) 0 else{ if(time < framesToTime(lifeBegin + fadeIn) ) linear(time, framesToTime(lifeBegin + fadeIn), framesToTime(lifeBegin), 0, 100 ); else if(time > framesToTime(lifeEnd – fadeOut) )
linear(time, framesToTime(lifeEnd – fadeOut), framesToTime(lifeEnd), 100, 0);
else
100
}
//end expression for opacityThese expressions aren’t too hard to understand, allthough the last 2 are a bit long.
By the way, I didnt understand what you meant when you said the circles should “pop in.” I’m assuming this means the same as fade in.Now for the random moving circles.
For these create a new circle like above and add the same scale expression. Don’t add an opacity expression. Then add this expression for position://begin position expression
seedRandom(index, true);
bPos = [random(0, thisComp.width), random(0, thisComp.height)];
ePos = [random(0, thisComp.width), random(0, thisComp.height)];
ease(time,0, thisComp.duration,bPos, ePos)
//–Expressions aren’t well suited to making things float around randomly like you said. Maybe you can find something better for the floating circles on http://www.motionscript.com. Hope this helped.
~Colin//end position expression
-
Randy Cates
June 16, 2006 at 4:15 pmWow what a response. Thanks Colin. As for the create a solid and use a mask to create the circle. I opted to just import a PICT file with a soft circular alpha channel. Am I correct in assuming this doesn’t change anything in the expressions?
Also yes “pop in” was the 3 frm in 5 frm out “soft cut.” If you study a flashing light it is in the range of 3 in 5 out but visually appears to cut in and out. I’m trying to “graphically” suggest a bunch of flash bulbs but not realistic, graphic. Kind of a retro thing going on.
Thanks again. Gotta get going with this.
-
Randy Cates
June 16, 2006 at 5:39 pmColin,
Everything is working like a charm (thanks). After seeing this work (exactly as I’d hoped) I started thinking it would be cool to create an octagon (simulating a camera shutter), put it in a 8 frame comp, make it animate from 0% to 100% in 3 frms, 100% to 0% in 5 and then swap this comp with the circular layer and get the same effect but with a scale up and down during the 8 frames that each cirlce is visible.What I’m getting (obviously) is an 8 frame layer (comp) that clearly can’t go random through the duration of a 30 sec animation bed. I’ve played around with some expression settings but don’t understand them enough (yet) to have much success. I’d like to get the start of the octagonal comp to coinside with the start of each randomly placed, scaled and “poped” circular layer.
I thought it would just be a matter of adjusting the scale values but I want to maintain the sm, med, lrg values that exist while having each octagon play it’s little 8 frame animation when they are visible. If you have time is this something that isn’t too diificult (for a seasoned expressionist)?
-
Colin Braley
June 16, 2006 at 8:43 pmI’m not quite sure if I understand what you are asking. So you have a comp of an octagon that is 8 frames long with a fade in and a fade out? And you want the octagons to appear in a few random places while scaling up and down? If this is the case, use the same position expression that I gave you for the circles. Then, use this expression for scale:
//Begin expression for scale
scaleMax = 100;//scale will peak at this value
//–
dur = outPoint – inPoint;
midPoint = inPoint + dur/2;
if(time < midPoint) linear(time, inPoint, midPoint, [0,0], [scaleMax, scaleMax] ); else linear(time, midPoint, outPoint, [scaleMax, scaleMax], [0,0] ); //End expression for scale Have fun. ~Colin -
Randy Cates
June 21, 2006 at 4:12 pmActually I just wanted the octagons to scale up and down instead of the circles that fade in and out. I “think” I can figure this out based on what you gave me.
If I’m correct I’ll just dupe the circle project, swap out the cricles for octagons, dump the expression for opacity and use the expression for scale. Sound about right?
Reply to this Discussion! Login or Sign Up