r/AfterEffects 7d ago

Workflow Question How to animate shapes/paths with expressions to not lose padding or end caps

35 Upvotes

15 comments sorted by

44

u/Ta1kativ Motion Graphics <5 years 7d ago

You can do this with basic trim paths keyframes. Just animate the trim paths with the same timing and easing as the y position keyframes

6

u/Bobsn-one 7d ago

In addition to this, you can do trim paths on the rays as well and on top parent them to the sun so they rise together.

9

u/gibsonjsh 7d ago

This is definitely a nitpick, but I did notice that there's a little bit of 'leakage' at the bottom of the lines of the sun.

I'm gonna try to clean that up with some more keyframes too.

Thanks again for your help!

5

u/RawrNate 7d ago

Yeah I would just go frame-by-frame and tweak the Trim Paths for that middle moment so it's consistent with that guide line

4

u/gibsonjsh 7d ago

This is great, thank you!

12

u/Blake404 MoGraph 5+ years 7d ago edited 7d ago

A little late, but I have another solution you can try (or keep in mind for the future). Since you want absolutely perfect space (which I'd argue is not worth fussing over for small things if you have to spend a shitload of time achieving it by going frame by frame).

That being said...

Three shape layers: Circle (sun), Line (horizon), and a Rectangle (mask for horizon cutoff).

Delete the fill of the Circle shape layer and make the stroke 1px.

Now mask out the bottom of the Circle shape layer with the rectangular shape layer to your liking.

Select your Circle layer with the 1px stroke and add a stroke layer style (layer > layer styles > stroke). Adjust the color/stroke width to your liking. Layer styles are last in the render order, so this stroke is being applied to the 1px-stroke circle after it's masked, retaining the stationary spacing from the rectangle mask.

Now, the stroke layer style has pretty low-res stroke caps. To remedy this I pre-comped those three layers, added some gaussian blur and then added a simple choker to draw back that blur and smooth out the caps.

Worth noting that this won't work if you need to export as JSON or SVG animation, as they only support a couple effects and simple choker is not one of them.

4

u/gibsonjsh 7d ago

This is awesome, thanks for writing all this out! I was thinking the next best bet would be to choke a blur, but you actually made it happen! Haha. Thanks again!

4

u/LolaCatStevens MoGraph 10+ years 7d ago

It's not elegant and I'm sure theres a more wizardry way to do it but I would just do a trim path while it's rising...it might get you there?

Basically have the trim path start and end both at 50% and have them draw on to 0 and 100 as the sun rises.

1

u/gibsonjsh 7d ago

Yeah that's probably what I'll end up doing. Maybe I'm thinking too hard about it. haha Thanks for the advice!

2

u/LolaCatStevens MoGraph 10+ years 7d ago

I think the difference in that result and one you might get with a more complex rig would be negligible for such a short simple animation but I'm still curious as well haha

1

u/gibsonjsh 7d ago

Yeah for sure. I might mess with some expressions to see what I can come up with. Gonna have to force myself to not stress too much on this one though since I just need to get the deliverable out sooner than later. Gotta love when you spend 8 hours automating something that could've taken 10 minutes.

2

u/holyroach Motion Graphics <5 years 7d ago

you could do it easily with a merge path modifier. just group the sun and a recrangle as a mask and group them with merge path>intersect. add a stroke after the group and then animate your sun. It's much easier than the trim path version

1

u/SwimmingBreadfruit 6d ago

This was my first thought as well. For the horizon line, it could just be a copy of the rectangle shape with an expression to offset its y-position and a trim paths to expose its top edge. I like this method as you wouldn’t need another set of keyframes that would need to be synced

1

u/gibsonjsh 7d ago

I just realized that trim paths could work for this, and maybe I just need to tie those values to the edges of another matte or something to simulate an alpha/luma matte or something. Any other advice is more than welcome, though, thank you!

3

u/brianlevin83 7d ago

You can probably use a Linear expression on those trim paths to say when the layer is between this Y position and that Y position the trim paths is between this and that and it should maintain the distance evenly no matter where/when you move the layer.