Animates the Scale property by randomly changing its size every few frames, either on both axes, just X, or just Y.
frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
seedRandom(seed, true);
s = random(50, 150);
[s, s];
frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
seedRandom(seed, true);
s = random(50, 150);
[s, value[1]];
frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
seedRandom(seed, true);
s = random(50, 150);
[value[0], s];
frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
// Randomize X
seedRandom(seed + 1, true);
x = random(50,150);
// Randomize Y
seedRandom(seed + 2, true);
y = random(50,150);
// Apply separately
[x,y];
Apply these expressions to the Scale property of any layer. They also work for other two-value properties (like Size on a shape layer), and you can tweak them to work on three-value properties if needed by adding a third value.
// Get the current frame number
frame = Math.round(time/thisComp.frameDuration);
// Create a seed that changes every 3 frames
seed = Math.floor(frame/3);
// Lock the random behavior based on that seed
seedRandom(seed, true);
// Pick a random value between 50 and 150
s = random(50, 150);
// Apply the same random value to X and Y (or just X/Y individually depending on the version)
[s, s]; // or [value[0], s] or [s, value[1]]
frame = Math.round(time/thisComp.frameDuration);
It figures out the current frame number you're on.
(Frame numbers are easier to work with when timing randomness.)
seed = Math.floor(frame/3);
It groups frames into sets of 3. So every 3 frames, it will generate a new random value.
(You can change the /3
to a bigger number if you want slower changes.)
seedRandom(seed, true);
It locks the random generator to the seed we made, so you get consistent randomness that only updates when the seed changes.
s = random(50, 150);
It picks a random scale value between 50% and 150%.
Then depending which version:
[s, s];
Both X and Y get the same random size (keeps it proportional).
[value[0], s];
X stays locked to its current value, Y changes randomly.
[s, value[1]];
Y stays locked to its current value, X changes randomly.
Just copy the full expression code from the top of this page. Then Alt-click (or Option-click on Mac) the stopwatch on the property you want to animate. Paste the code into the editor and that's it. If you’re not sure which property to use, check the "Where to Apply" section above.
First, make sure your project is using the JavaScript engine (go to File > Project Settings > Expressions). Also double-check for missing characters, and see if the code requires parenting a layer. If so, there will be a comment in the code explaining what needs to be connected.
Take a look at the "How It Works" section on this page. It explains each part of the expression in plain language so you can understand how everything works together.
Yes, absolutely. Most expressions include easy-to-edit variables near the top and comments that guide you on what to change. You can also link sliders or checkboxes using Expression Controls if you want more control in the timeline.
Yes, you can use it on any property with a stopwatch. That includes Position, Scale, Opacity, and also effect settings like Blur or Tint.
In most cases, yes. These expressions are designed to adapt to your comp’s resolution and frame rate. If anything specific needs adjusting, it’ll be noted in the code or in the "How It Works" section.
Explore more expressions in this category