browse browse contact us contact us

Our Expert Insights

Stop Animating, Start Giving Instructions: How 10 Lines of Code Beat AI Video

How a few lines of expression code kept 500 bricks in formation, plus why motion designers should learn the technical side even in the age of AI.

In the Basilica of San Vitale in Ravenna, the Emperor Justinian has been looking down from the wall for close to fifteen hundred years. He is made of thousands of little tiles, and in all that time he has not moved an inch. Empires fell around him. Ravenna lost its crown. The tourists arrived, first with guidebooks, now with their phones and iced coffees. Justinian held his post. When you get down to it, a mosaic isn’t really a picture. It’s an agreement, where every piece knows its place.

I thought about that analogy a lot lately, because I watched a machine break it in under a second. 

A client sent us two stills of a padlock, one open, one closed, both made of a few hundred small rounded bricks glowing violet. The brief was one line long: make it lock and unlock. So I did a very 2026 thing and fed both frames to an AI video generation tool, asking it for the in-between. An hour and several attempts later, I had a folder of clips I’d be embarrassed to show my peer, let alone a client. So I opened After Effects and built the thing by hand, and that afternoon taught me more about where motion design is right now than any trend report I’ve read this year.

What the generator can’t see

A video generation model has no idea the lock is made of bricks. In any meaningful sense, it doesn’t know there is a lock. It has watched millions of clips and learned what the next frame of something like this usually looks like. Then it just guesses, frame after frame, and each guess is a fresh image that only loosely agrees with the one before it.

Imagine a flipbook where every page is drawn by a different illustrator, and each of them has only seen the previous page. Everything is gorgeous, and nothing stays the same. Somewhere around page forty, the thing forgets what it was supposed to be.

That’s what I got. Bricks puffed up, melted into each other, floated off the grid. These tools are good at nouns (they’ll redraw your two stills just fine), but verbs are another story, because a verb means something keeps being itself while it changes. You can’t fake that without knowing what the thing is. And this lock is a system: a grid, a rule, a shape the grid follows. Most of what we design is some version of that.

Teaching the bricks to think

Ever seen a stadium card stunt? Thousands of fans each hold up a colored card, and each one follows one tiny instruction printed for their seat: on cue, hold up red. Nobody in the crowd can see the picture, and the picture appears anyway.

After Effects lets you do the same thing. Position, scale, color, pretty much any layer property can carry a bit of JavaScript called an expression, and it runs on every frame. Duplicate the layer five hundred times and every copy runs that same code from its own seat. So I stopped animating bricks and wrote their instruction cards instead.

Rule one: look down

First I made a hidden layer called “object,” a soft, blurry silhouette. Every brick looks at the pixel directly beneath it and asks how solid the object is at that spot:

mapLayer = thisComp.layer(“object”);
p = toWorld(anchorPoint);
sampledColor = mapLayer.sampleImage(p, [0.5, 0.5], true, time);
alphaValue = sampledColor[3];
s = linear(alphaValue, 0, 1, 0, 100);
[s, s];

In plain English:

  • toWorld(anchorPoint) finds where the brick’s center sits in the composition.
  • sampleImage() reads the object layer at that point and returns four numbers from 0 to 1: red, green, blue and alpha. A radius of [0.5, 0.5] means “just this one pixel, please.”
  • sampledColor[3] grabs the alpha, which is how opaque that spot is.
  • linear() translates opacity into size. A transparent pixel gives 0% scale, and a solid pixel gives 100%.

(A note for the pedants: this only works if the object layer sits untouched in the comp. If you move it, you’ll want fromComp(), which is exactly what rule two uses.)

The clever part is that brick size is now a readout, not a keyframe. Blur the object, and the edge of the lock dissolves into a gradient of shrinking bricks. My first test was simple yellow squares over a cyan glow, and I still love it. Watching the edge bricks shrink to specks as the glow faded was the moment the grid stopped being a picture and became a crowd.

Rule two: report what you see

The second rule paints every brick with the average color of the image patch behind it:

let target = thisComp.layer(“Video.png”);
let b = sourceRectAtTime(time, false);
let localCenter = [b.left + b.width/2, b.top + b.height/2];
let compPos = toComp(localCenter);        // brick space → composition space
let targetPos = target.fromComp(compPos); // composition space → color layer space
let radius = [20, 20];
target.sampleImage(targetPos, radius, true, time);

sourceRectAtTime() returns the brick’s bounding box, which the next line uses to find its center. toComp() converts that point into composition coordinates, and fromComp() converts it into the color layer’s coordinates. Finally, a radius of [20, 20] samples a 40×40-pixel patch and returns the average, giving each brick a small patch of the image to sample.

Drop a swirl of acid-bright paint behind the grid and you get neat little chips of teal, orange and cobalt. None of the bricks make anything up; each one just reports what’s behind it, which is pretty much the opposite of what the generator does, inventing every pixel on every frame.

Two animations, one lock

The finished animation came down to two layers. The first is the object map: the lock closing, with a blur that resolves as the shackle drops, which the grid turns into bricks swelling from dots into a solid padlock. The second is a shimmering, iridescent background that the color rule samples, so violet and pink light keeps rolling through the bricks.

If the client wants a snappier close, I retime one layer, and five hundred bricks follow in formation with no drift. Ask AI for “the same clip, 20% faster,” and it will hand you a different lock that’s barely even a cousin of the one you fed it.

That’s really what it comes down to for me. The generator gives you a result. Rules give you something you can keep directing.

Why I keep working this way

Every few years someone announces that a craft is dead. Templates were going to kill hand animation. Then stock motion packs were. Now it’s generative video’s turn. And every time, what lasted was the work where somebody made a decision a tool couldn’t make for them.

I’m not some Luddite hugging a Wacom, by the way. I use AI all the time and I’m happy to let it paint mood frames for our next pitch. It just can’t hold an idea steady over time yet, and that’s kind of the whole job in motion design.

My guess is we’re heading for a split. Generated clips keep getting cheaper, and they keep looking more alike, since they’re all averaged from the same huge pile of footage. People will learn to spot it the way they learned to spot stock photos. Same weird woman laughing alone with a salad, just in 4K and moving now. Once that happens, the work people pay for will be the stuff that clearly came from one particular person’s way of solving a problem.

My advice: learn the plumbing

My recommendation to younger designers is blunt: learn the boring machinery. Learn what sampleImage() actually returns, how coordinate spaces interact, and how a few lines of code can control hundreds of layers. A prompt gets you a clip anyone could have made. Knowing what’s under the hood gets you something nobody could have prompted.

AI can generate a convincing starting point in seconds. The harder part is making every element behave as intended, then changing one parameter without breaking the rest. That’s where technical understanding pays off.

The padlock started as two still images and a one-line brief: make it lock and unlock. AI gave me the images. Expressions gave me control over how the lock came together, how its bricks changed size, and how light moved across its surface.

The machine drew the lock. A human made it work.

Recommended Reading

Liked this one? We’ve got more: unpopular opinions, design hot takes, and industry reflections. Dive in:

The Discipline Loop: How Training Rewired My Design Brain

Old Rules, Bad Advice: 10 Design Myths Everyone Still Believes

The Glass Is Half Empty: How Apple’s Boldest Redesign Missed the Point

Drawing Attention: The Real Power of Illustrations in UI Design

The Anatomy of a Good Design Review

Welcome to check designs by Tubik on Dribbble and Behance; explore the gallery of 2D and 3D art by Tubik Arts on Dribbble

Don't want to miss anything?

Get weekly updates on the newest design stories, case studies and tips right in your mailbox.

    More articles

    Let’s collaborate

    Want to work on the project together? Contact us and let’s discuss it.

    contact us