ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Re: Color changes on velocity

COW Forums : Adobe After Effects Expressions

Respond to this post   •   Return to posts index   •   Read entire thread

Darby Edelen
Re: Color changes on velocity
on May 28, 2012 at 11:20:21 pm

[Alain Lores] "
factor =5;

This is only sampling the X component of the velocity of your layer. Is that what you're after? You probably noticed that velocity has 2 or 3 components, these correspond to the rate of change on the X and Y (and Z on a 3D layer) axes. If you want to work with a single value, and you don't want to split the velocity into separate axes, then you probably want to use the "speed" property:

factor = 5;

The Math.abs() function is not necessary for the position speed.

[Alain Lores] "1. The object that samples the colors to the left over shoots in height sampling black color. This object moves higher in height the faster the dot moves. How can i clamp the vales so that the object doesn't go past a certain height value?"

There are a couple of ways to accomplish this. One would be to use the Math.min() function:

max = 500;
factor = 5;
s = thisComp.layer("G").position.speed/factor;
Math.min(max, s);

Math.min() will return the smaller of the two values passed to it, so whenever "s" is greater than "max" it will return "max" effectively clamping the highest value returned to "max."

[Alain Lores] "2. Notice how the colors on the band of particles do not fade. Instead it's solid from one color to the next. This is the result of the object moving way too quickly from fast to slow. Is there a way to control the speed in which the object moves? For example, how can the values be "smoothed" so that as the object samples the color it's slow enough to gradient correctly on the band of particles."

There is a smooth() function you could use that may help in this case. You'll want to smooth() the position property of the sampler, but it may be more complicated than that depending on how you've set up the expressions.

Darby Edelen

Posts IndexRead Thread 

Current Message Thread:

© 2018 All Rights Reserved