AE | Build a Monuments Timeline with Shape Layers and Expressions


Hopefully this has had enough time to load

We'll look at how to build a never ending timeline (or scale) that you can move around to any amount without hitting the edges using Expressions and a built-in effect, how to create the counting time, fast and easy method to extract the monuments and some tips on positioning comps while animating.


First things first, there's plenty of methods that can create the same effect without even involving expressions, but I think it's a good opportunity to learn how expressions would work here.
Remember to grab the AE Expressions Basics ebook, it's free and makes following these tutorials a lot easier. I generally assume that you at least have some idea of what expressions are and how they work.


Build the Scale

We'll start off by building the base of the scale in a separate composition. Create a new one at 1920 x 200 pixels. This should be the same width as the box the scale needs to fit in. I'll go with comp size, as I can always scale it down if I need it in a specific space, but I don't need it to be as tall as the comp, that's useless and very mis-clickable space. 200 pixels will do.

We'll start off by adding a Shape Layer.
Layer > New > Shape Layer.

Shape Layers are vector layers that not only let you create shapes, but also modify them and you can make some pretty cool and funky stuff with. We'll experiment with them in a moment, for now, let's build the scale.

We need a tall rectangle to represent the 10s on the scale. We could use the shape tools to draw, but they tend to create groups that can be difficult to work with. I like to create everything step-by-step to avoid any unnecessary sifting and deleting and I can set parameters as I go along.

So, expand the shape layer's properties and click the little add button on the right side:


There's quite a few options here. Let's start by adding a rectangle.

This will add "Rectangle Path 1", which will be [100,100] in size. This won't do. It's far too wide. So, we can unlink the X and Y and set the size to something thinner and taller, [15,150].
We also need it to be at the very left edge of the composition. 

Notice that the shape is in the center and it's position is [0,0]. So, the very left edge would be [-960,0] which is 1920 divided by 2.



But this leaves half the shape on the outside of the comp, so we'll have to add that half back in (width of 15 divide by 2 = 7.5) so we now have a position of [-952.5,0].

For now we only have a path, it doesn't have any color inside. So click "Add" and choose "Fill". This will fill the box with a red color. Set what you like.

This is the first piece. We need these to span the entire comp to represent a scale of 10, so we'll need to make copies of it.

Click "Add" again and select "Repeater".



A repeater comes in with default value of 3 copies, each copy 100 pixels from the last. If you expand the "Transform" section, you can adjust the amount of transform applied to each copy. Copy 1 is at 0, copy 2 is at 100, copy 3 at 200 and so on. The same applies to rotation and scale values. It's also worth noting that the original copy is counted; Setting copies to 3 will make 3 shapes total.

ROTATION works with an anchorPoint at the center of the Shape Layer. You'll notice that stuff rotates OFF the comp, this is because it's using the center of the Shape Layer as the anchorPoint. Change the anchorPoint value to -960 (where the first shape is) and the rotations will be centered.

Play around with the settings until you get a good idea of how it works, then we can proceed.
Once you're done messing around, you can reset all controls, or delete that repeater and create a new one.
Now, for this case, we need 10 copies spanning the comp. So, set the copies to 10.
Next, we need to set the distance so they span the comp fairly. This will obviously be the width of the space we're filling divided by 10 which is 192.
So set, "Position" to 192. And we're good!


Cool.
Now we'll use the same method to add the smaller scales.

We could create another shape layer, or create a group. Groups are a little complicated and I'd rather not have everything in a single layer.

Duplicate the Shape layer. In the second one's settings try creating this yourself before continuing:



I've duplicated (Ctrl+D) the Shape Layer 1 and changed a few settings:
Rectangle is now [8,50] in size. I've kept the position as is since the smaller rectangles need to be centered to the larger ones.
I've set the copies to 100 as there needs to be 10 between each larger line and we've split our comp in 10. So 100 pieces. I've set the Transform in the repeater to [19.2,0], as in 1920 divide by 100.

For the last bit of fine tuning, I'll set some roundness to the rectangles and change their color to a darker grey.

Stuck? Leave a comment below.

TO INFINITY

Okay, our scale is ready, now we need to add it to a new comp and get to work.

Create another comp and call it "Main Comp". It will be 1920 x 1080.
Place the scale into this comp.

To make the scale loop as we drag it, we'll add the "Offset" effect.
Offset shifts all pixels to the left/right or up/down and any pixels that leave the boundaries of the layer will be sent to the opposite side.


Offset is essential when creating seamless loops and textures, and pretty useful for scrolling marquees or tickers. 
Grab the X on "Shift Center to" and you'll almost immediately lose track of which line was the first one on the left... If you can still tell where the edge is, some math probably went wrong somewhere in the precomp with the shape layers.

Okay, that's pretty cool, but the effect is not very useful. We're going to have other elements tied to this, for example Timeline and year markers and precomps of images, but this offset control isn't very accessible. You'd have to open the effect and make sure it moves the same as everything else. That just won't do!
So, we're going to use a Null and tie the Offset to it. From this point forward, we'll be parenting everything to this Null object.

Layer > New > Null Object.

I'll rename the Null to "Mover".
We only want the X component from this, not Y. Y is going to spoil the scale if we move the null up or down. So, we'll let it remain at the value it is, but the X shifting will be controlled by the Null's X position.

Select the precomp and Alt+Click the stopwatch on "Shift Center to". We're going to apply an expression in the box that appears in the comp window:

[thisComp.layer("Mover").position[0],value[1]];

See the square brackets at the start and end. This means we're defining an array. This is explained in AE Expressions Basics, arrays define a value with more than one dimension.

[value for X, value for Y];

So, value for X is thisComp.layer("Mover").position[0], the [0] at the end means its referring to the X position of Mover only.
value[1] will let the offset control handle it's own Y. This way, we can offset it later if we need to. I think we will.

Adding more Elements



I mentioned earlier that we can tie stuff to the Null, let's put that to the test.

Create your monument. I've chosen the Eiffel tower so I'm going to use this Eiffel Tower image by 001099.


I've cut most of the background by adding a Luma Key to remove the brighter parts of the image. I've also added a Color Key to get rid of what was left of the sky after the Luma. Next, a square mask, feathered using the Feather Tool more at the bottom than the top.


I've also masked out the sides of the scale and feathered it greatly. Since Offset happens before masks, it still works properly.

To keep things neat, I'm going to pre-compose the title "Eiffel Tower" and the image, Leave the year there. We're going to use an expression to count up the years, so it's going to have to stay here when we transition.

Name the precomp "Monument - Eiffel".

Let's add another monument.
We can duplicate the pre-comp in the Project panel, rename it to "Monument - Liberty" and bring in this image of the Statue of Liberty by Freshleaf.
Select the eiffel image and alt+drag the image in. If it works, you'll have the statue isolated. Adjust the mask or use the Pan-Behind-Tool to move the image within the mask:

there's only the two layers in the pre-comp.
Let's see how it looks in the "Main Comp" with the scale we had setup. Switch off the Eiffel tower and drop in "Monument - Liberty".



Okay, now the Eiffel Tower was built in 1899, and the Statue of Liberty in 1886. Liberty came first, so we'll need to put it on the left side of the scale.

Parenting


We'll parent the layers to Mover, but we'll do it one-by-one as we get a feel for their positioning on the scale.
Select "Monument - Liberty". It's going to be on the left, so we're going to move it back, but we'll need an idea of how far back we're pushing it relative to our scale.
Select "Mover" and ensure it's at [960,540] before parenting Liberty to it. Don't parent the year indication, it's staying static.

In Mover, scrub the X control and move them out of the screen while watching the scale. We could accurately represent the 13 years between them, or we could make it flashy. I made a large scale, I'm gonna show off!
I've moved mine all the way out to [-1280,540]. Liberty is nowhere in sight.

Switch on the "Monument - Eiffel" and parent it to "Mover".
In this position, they're offset. If we now reset the position of "Mover" to [960,540] you'll have Liberty centered. At [-1280,540], you have Eiffel centered. So, add those keyframes at 2s and 3s.

Cool, but the year sucks! Let's animate it.

Slider Control Done Right



Effect > Expression Control > Slider Control

Create two keyframes on the Slider at the same times as the Mover's positioning, which is 2s and 3s. First being 1886 and the other 1899.
Before we create an expression, let's take a look around. Move the time in between the two keyframes and look at the values the Slider is showing:


AE is calculating per frame to interpolate the two keyframes. Number of frames between keyframes, values of keyframes, frames per second, do the math and you'll get a few decimals, especially if you ease the keyframes. These are going to deal hell to the indicator, since we don't want values with decimal points. We're going to have to round it off in the expression we'll apply.

Expand the layer's "Text" and "Effects". Make sure you can see the "Slider" property and the "Source Text".
Alt+Click the stopwatch on "Source Text" and type Math.floor( then pick-whip the Slider. Close the bracket and click away. You should have:

Math.floor(effect("Slider Control")("Slider"));

Math.floor rounds down numbers. So the 1879.20 value in the image above becomes 1879.00 when it shows in the text layer. AE ignores zeroes after a decimal, so it defaults to a nice round 1879.


Labelled the values of the keyframes. These are at 2s and 3s on the timeline.
Hopefully this has had enough time to load


The scale moves well, the year is ticking correctly. Excellent!

You can continue to work with moving the "Mover" Null and adding more monuments, remember to add the keyframes to the year as well. So we've looked at using offset to tie a never ending scale to a Null, creating the working years and figured out the workflow for a timeline like this!


This method has a problem! Do you know what it is? Comment below if you've noticed or figured out the limitation on the technique we've used on the timeline.



Thanks everyone for reading and for all the comments. It's great seeing my tutorials are helping others out there!