Random Scale

Animates the Scale property by randomly changing its size every few frames, either on both axes, just X, or just Y.

Author:
Dan Ebberts
Source:
https://creativecow.net/forums/thread/random-scale-expression-2/
Category:
Time, Wiggle, Random

Expression

frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
seedRandom(seed, true);
s = random(50, 150);
[s, s];
javascript

Expression (X Axis Only)

frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
seedRandom(seed, true);
s = random(50, 150);
[s, value[1]];
javascript

Expression (Y Axis Only)

frame = Math.round(time/thisComp.frameDuration);
seed = Math.floor(frame/3);
seedRandom(seed, true);
s = random(50, 150);
[value[0], s];
javascript

Expression (X and Y Axis Randomly)

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];
javascript

Where to Apply

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.


How It Works

// 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]]
javascript
  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.)

  2. 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.)

  3. 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.

  4. s = random(50, 150);
    It picks a random scale value between 50% and 150%.

  5. 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.

Frequently asked questions

How do I use the expression on this page?

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.

The expression isn’t working. What should I check?

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.

I’m not sure what the expression does. Where can I learn more?

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.

Can I customize how the expression behaves?

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.

Can I apply this to other properties too?

Yes, you can use it on any property with a stopwatch. That includes Position, Scale, Opacity, and also effect settings like Blur or Tint.

Will it work in comps with different frame rates or sizes?

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.

Related Expressions

Explore more expressions in this category