Adobe After Effects Expressions Forum
Replicating "Marching Ants" Photoshop selection effect in After Effects
Replicating "Marching Ants" Photoshop selection effect in After Effects
by Mikey Zoppo on Oct 22, 2018 at 9:07:54 pm

Marching ants, the dashed lines that slowly travel over any selection you make in Photoshop. I'm trying to recreate those in AE.

It's pretty simple right? Well, I'm a big dumb dumb.

I've got a square, it is stroked with dashes. If I animate the "offset" parameter, the dashed stroke will travel across my shape much like the Marching ants travel across a selection in photoshop. THE ONLY DIFFERENCE! The Marching ants move in small intervals, as opposed to one continuous smooth motion. Much like a clock hands ticks from one second to the next, it's not smooth.

I can easily get what I want by just animating the offset and applying posterize time with a super low number.

But this seems like a really useful thing to know how to do with an expression. I'm assuming it's kind of like a blink expression, except instead of oscillating between two values, we just want our value to continue growing/shrinking in those stuttering intervals.

Basically an expression that is a counter, that counts up/down at a rate you define, and will pause at an interval you define, how long the pause is would also be a value you define.


Re: Replicating "Marching Ants" Photoshop selection effect in After Effects
by Kalleheikki Kannisto on Oct 23, 2018 at 8:16:35 am

It would be a Math.round() expression on the time remapping, if you want to emulate posterize time.

Math.round(time) would give you a change once per second
Math.round(time*5)/5would give you a change 5 times per second
etc.

Or a similar expression on the offset, using time, but making the output 2-dimensional, for example

my_offset = 5*Math.round(time*5);
[my_offset, my_offset]


That would move 5 pixels over and down 5 times a second.

Adjust values to taste.

Kalleheikki Kannisto
Senior Graphic Designer


Re: Replicating "Marching Ants" Photoshop selection effect in After Effects
by Filip Vandueren on Oct 23, 2018 at 1:24:42 pm

Hey Mikey,

If you look closely at Marching Ants, you'll notice that they're not actually doing the same as the offset on a dashed line.
A dashed line turns around corners, and continuous along the path until it's back where it started,
whereas the marching ants are a 45° slanted zebra pattern that is masked within a 1px stroke.
The easiest way to get the effect is to use an animated pattern, and use your shape as a track matte.

Alternatively, if you want to keep it in 1 layer I have a solution using Gradients and Colorama effect.
(see attached FFX)
12828_marchingants.ffx.zip







© CreativeCOW.net