Tapering A Stroke with Expressions in After Effects Part 1

  • Share
 

Similar lessons

Tapering A Stroke with Expressions in After Effects Part 1

We all know After Effects is PACKED with features, but sometimes After Effects just doesn’t have the feature we want built into the program; for example the ability to taper a stroke with ease and control. Well, After Effects still has us covered in that department, it just takes a little more know-how to do it.

We just need to roll up our sleeves and get our hands dirty with some fancy expressions.

Expressions can seem a tiny bit overwhelming at first, but once you learn how they work you can do some really amazing stuff. In this lesson our resident Expressions Wizard, Jake Bartlett, will take you through the first part of how he built this powerful tapered stroke rig. It’s a lot to digest if you’re new to expressions, but Jake will guide you through and break down everything into easy to handle nuggets of knowledge.

In this lesson Jake will be using a really great tool for writing expressions in After Effects called Expressionist. Go ahead and grab that here if you're ready to really dive deep into the world of code.

If you have any questions, click over to the Q&A tab to post them. Other students can answer you, and we'll put our team on the case to try and get you a solution ASAP.

Download Project File
    • Download isn't working

    • I'm sorry to hear that Katie! Could you please write us at [email protected] so we can help you troubleshoot?

    00:00:00,246(ethereal electronic music)
    00:00:15,086(uptempo electronic beat)
    00:00:23,395- [Jake] Hey, this is Jake Bartlett
    00:00:24,874for School of Motion,
    00:00:25,904and I am going to be teaching you
    00:00:27,276how to make a tapered stroke rig
    00:00:29,530in After Effects using expressions.
    00:00:32,270Now, expressions are a very intimidating topic,
    00:00:35,155let's face it.
    00:00:36,219Code is just not a language
    00:00:37,494that most motion designers speak.
    00:00:39,358But if you can understand some very basic principles
    00:00:43,590of how to use expressions
    00:00:45,560as a problem solving tool,
    00:00:47,457the possibilities that they open up
    00:00:49,257are pretty incredible.
    00:00:51,413You can create entire setups inside of After Effects
    00:00:53,787that allow you to do things
    00:00:55,403that natively After Effects can't even do.
    00:00:58,275They're an extremely powerful tool to have in your toolbox.
    00:01:01,450And hopefully after this lesson,
    00:01:02,631you will have a very good grasp
    00:01:04,121on how to use them to your advantage.
    00:01:06,250So let me start with my big, fat disclaimer up front.
    00:01:08,829We are going to be writing a lot of code in this lesson.
    00:01:12,346And it's gonna get pretty geeky,
    00:01:14,087but it's not gonna get too complex.
    00:01:16,594Really, we're gonna be more clever with our expressions.
    00:01:19,826So you should have no problem following along.
    00:01:21,685I'll go step by step.
    00:01:23,104And at the end, we'll have a tapered stroke rig
    00:01:24,962that you can reuse over and over in any project.
    00:01:27,856Alright, let's get straight to it.
    00:01:29,280I'm gonna make a new composition.
    00:01:31,670And framerate doesn't really matter.
    00:01:33,839Resolution, I'll do 1920 by 1080.
    00:01:35,978And I'll set the background color to white,
    00:01:37,771just so it's easy to see.
    00:01:39,786And I'm going to start by drawing a line.
    00:01:42,920Now, natively, shape layers do not allow you
    00:01:45,413to taper a stroke in After Effects.
    00:01:47,469It's a single width all the way along your line.
    00:01:49,955There's no control for that.
    00:01:51,756The only real solution that I know of that exists
    00:01:54,456is Trapcode's 3D Stroke.
    00:01:56,411And the reason I don't really wanna use that
    00:01:58,440is 'cause one, it's not free,
    00:02:00,373and two, it works with mask paths.
    00:02:02,907So I don't have all of the controls
    00:02:04,791and special operators that shape layers allow me to have.
    00:02:07,959So when I approached this problem originally,
    00:02:09,759my goal was to have a line
    00:02:12,135behave exactly the same way that I'm used to
    00:02:14,119on a shape layer that I could control with Trim Paths,
    00:02:16,367and use all kind of operators on,
    00:02:18,423exactly the way that I was used to,
    00:02:21,050with the additional control of
    00:02:22,123being able to control the width of the line
    00:02:24,654from one end to the other.
    00:02:26,350So let me show you what my original concept
    00:02:28,462for that even being a possibility was.
    00:02:31,667I will go into my Contents
    00:02:33,570and add a Trim Paths on the shape group.
    00:02:37,063I don't need that fill.
    00:02:39,031And I'll make my stroke round caps and round joins.
    00:02:43,816Then I'll take my Trim Paths
    00:02:45,331and set the End value to 10.
    00:02:48,322And I'm gonna make a bunch of duplicates of this group.
    00:02:51,528So let's say 10.
    00:02:52,935And then I will bring up all of the start
    00:02:56,935and End values.
    00:02:59,618And I want to offset each one of these by 10%,
    00:03:02,769so that I have 10 different segments.
    00:03:03,722So I'm just gonna do that really quick.
    00:03:07,620Not a very fun process to have to do this.
    00:03:10,915Alright, there we go, so we got 10 segments, all offset
    00:03:14,439by 10% on the Trim Paths.
    00:03:16,020So then I will open up the Stroke Width
    00:03:19,387and offset each one of these by 10 pixels.
    00:03:22,421So 100, then 90.
    00:03:24,969All the way down the line.
    00:03:29,945Alright, there we go.
    00:03:30,970So, if you take a look at this line, it's totally crude,
    00:03:34,525but you can kind of see the concept working.
    00:03:37,620Basically, if you segment this line,
    00:03:39,732and offset the Trim Paths of each one of them,
    00:03:42,755as well as the Stroke Width, you kind of get a taper.
    00:03:45,863Now, obviously, you would need a lot more segments
    00:03:48,675to make this not noticeable.
    00:03:51,304And doing it by hand is pretty much out of the question.
    00:03:54,187That takes way too much time.
    00:03:56,068And I have all these Duplicate Groups
    00:03:58,377that each have a copy of the same path.
    00:04:00,735So if I were to go in and try and modify this path,
    00:04:03,983that's only controlling this segment,
    00:04:05,654and I've got another path,
    00:04:07,327another path.
    00:04:08,399Really, I would want one path
    00:04:10,427to control all of the segments.
    00:04:12,675So I wanted to figure out a way to get expressions
    00:04:15,491to do all this complicated work or me
    00:04:17,868so I didn't even have to think about it
    00:04:19,638and I'd be left with a tapered stroke.
    00:04:21,647So now I'm gonna walk you through
    00:04:22,817how I used expressions to solve that problem.
    00:04:26,574I'll start by deleting all of the Duplicate Groups.
    00:04:29,748And I will rename this Master Group.
    00:04:33,176And I'll duplicate that group
    00:04:34,668and rename it Taper 01.
    00:04:38,052And I'll regroup that group
    00:04:40,210and name it Duplicate Groups.
    00:04:44,076Now, setting up this structure is pretty important
    00:04:45,998because we're gonna be referencing
    00:04:47,468a lot of different properties
    00:04:48,868in groups within this layer structure.
    00:04:51,005So naming is super important.
    00:04:53,596So let's continue this structure
    00:04:55,279and rename the contents of the Master Group
    00:04:57,514Master Path,
    00:05:00,333Master Trim Paths,
    00:05:03,131and Master Stroke.
    00:05:05,763Alright, in the Duplicate Groups,
    00:05:08,078I will go into Taper 01,
    00:05:10,255and that is all fine just the way it is.
    00:05:12,608So I want these expressions to be based
    00:05:14,324off of the Master Group.
    00:05:15,856I want all the duplicates
    00:05:17,650to be following the Master Group,
    00:05:19,259and then the expressions that we use
    00:05:21,313will automatically divide this line up into segments
    00:05:24,714and offset the stroke incrementally.
    00:05:26,970So the first thing I wanna do
    00:05:28,111is link the duplicate path to the Master Path.
    00:05:30,891So this is what we're gonna use our first expression for.
    00:05:33,977If you've never use expressions before,
    00:05:35,704you just go to any property
    00:05:37,095that has a stopwatch for the keyframes,
    00:05:39,166and hold down Option, or Alt on a PC,
    00:05:41,268and click on that stopwatch.
    00:05:43,213That will open up the expression dialog box
    00:05:46,158and give us a few extra controls.
    00:05:48,394And it automatically fills in the code
    00:05:50,204that references the property that
    00:05:52,092you are putting that expression on.
    00:05:54,486Now, I don't need this line of code.
    00:05:56,436I actually need the code that references the Master Path.
    00:06:00,255But I don't actually have to know how to type that out,
    00:06:02,446or what that code to reference that is.
    00:06:04,581There's this little expression pick whip
    00:06:06,649that behaves just like the parenting pick whip.
    00:06:08,777I can click and drag it
    00:06:10,364and then come down to the Master Path
    00:06:12,297and let go.
    00:06:13,246And then After Effects will automatically
    00:06:15,078fill in that code for me,
    00:06:16,560so I don't have to do any coding.
    00:06:18,135It's as simple as that.
    00:06:19,345I just click off to apply it,
    00:06:20,596and now that duplicate path
    00:06:22,959follows the Master Path.
    00:06:24,707And if I offset the Trim Paths for this group,
    00:06:28,082just so we can see the two different groups,
    00:06:31,172grabbing this path and moving it around,
    00:06:33,186you see that it looks like
    00:06:34,364there's only one copy of that path
    00:06:36,297because this path will always follow it
    00:06:39,092now that we have that expression.
    00:06:40,809So, awesome, we're already using expressions
    00:06:42,925to make stuff work!
    00:06:44,125Let's keep going!
    00:06:46,247Next I want to add some expression controls.
    00:06:49,334So I'm gonna come up to Effect,
    00:06:50,724and go to Expression Controls,
    00:06:52,200and you'll see this whole list of controls that we can add.
    00:06:54,896Now on their own, expression controls do absolutely nothing.
    00:06:58,755They're basically there just to give you values
    00:07:01,300that you can use to control expressions.
    00:07:04,017So, the first one we'll start with is Slider Control.
    00:07:06,789So go to Expression Controls, Slider Control.
    00:07:09,559And by default, a slider,
    00:07:11,275if I twirl this open,
    00:07:12,273has a range of zero to 100.
    00:07:15,434You can grab this number and go past
    00:07:16,940that range in either direction,
    00:07:18,972and you can also right-click on the slider
    00:07:20,288and say Edit Value to adjust that range.
    00:07:23,539We're not gonna need to do that,
    00:07:24,847but just so you're aware,
    00:07:26,479if you ever have to have a different range of numbers.
    00:07:28,993Zero to 100 is gonna work just fine
    00:07:30,838for what we're using it for, though.
    00:07:32,618So I'm gonna rename this slider Stroke Width.
    00:07:36,207And then I want to link the Master Stroke Width
    00:07:41,276to that slider.
    00:07:42,821To do that, I'll just hit Option
    00:07:44,513and click on that stopwatch to add the expression,
    00:07:47,074grab this expression pick whip,
    00:07:48,778and I can actually come up to the Effects Controls panel
    00:07:51,858and let go.
    00:07:52,965And there we go.
    00:07:54,044After Effects fills in that line of code for me.
    00:07:57,242I click off of it
    00:07:58,482and that number turns red.
    00:08:00,197Now that means
    00:08:01,030that there's an expression driving this value.
    00:08:04,565I can click and drag on this number
    00:08:06,157and you see it's changing,
    00:08:07,151but as soon as I let go,
    00:08:08,662it switches back to zero.
    00:08:10,868The reason why it's zero is because
    00:08:13,001our Stroke Width slider is set to zero.
    00:08:15,251If I adjust this, you see that now
    00:08:18,056the Stroke Width of my Master Path
    00:08:19,727is being controlled by that.
    00:08:22,129And just like I said before,
    00:08:23,163I can increase that to a higher number if I need to.
    00:08:25,659But I seriously doubt I'll ever need a Stroke Width
    00:08:27,902higher than 100,
    00:08:29,390so I'm gonna leave the range right where it is.
    00:08:32,374Next, I'm gonna duplicate this slider,
    00:08:34,254and I'll rename it End.
    00:08:36,170And I wanna tie the Master Trim Path's End value
    00:08:39,578to that slider.
    00:08:40,711So, I will add an expression again
    00:08:43,228and pick whip that slider,
    00:08:45,211and click off.
    00:08:46,403Now if I move this slider around,
    00:08:48,695it controls the End value.
    00:08:50,229And because the End value is a percentage of zero to 100,
    00:08:53,917the range of zero to 100 is perfect for that value.
    00:08:57,609So, no need to change that.
    00:09:00,440Next we need to add another type of expression control.
    00:09:03,105I'll come down to Angle Control.
    00:09:05,661And this is gonna be a value measured in degrees.
    00:09:07,939So the offset control is measured in degrees as well.
    00:09:11,087So that's the type of controller I want to use
    00:09:13,714to drive that property.
    00:09:15,789So I will add my expression,
    00:09:17,612grab the pick whip,
    00:09:18,445select the angle control,
    00:09:20,298and click off.
    00:09:22,087Now that angle is controlling the offset of the Trim Paths.
    00:09:27,949Now if you take a look at the way
    00:09:28,782that After Effects wrote this expression,
    00:09:31,033it's referencing the effect Angle Control
    00:09:34,356and the value of Angle.
    00:09:35,588But the more important part that I wanna point out
    00:09:37,070is that the name of this effect is Angle Control,
    00:09:41,208which you can see up here.
    00:09:42,866If I change the name of this angle to Offset,
    00:09:46,940the expression just updated based on what I named it.
    00:09:49,589So After Effects is pretty intelligent in that sense.
    00:09:53,143Which is a really nice feature.
    00:09:55,447Alright, so we've already got
    00:09:56,280three controls driving our rig.
    00:09:58,566But there's a lot more you can do with expressions
    00:10:00,535than just linking properties to expression controllers
    00:10:03,463or to other properties.
    00:10:05,251You can have complex equations,
    00:10:06,781you can base stuff on time, offset keyframes.
    00:10:09,311There's all kinds of possibilities.
    00:10:11,589Again, we're not gonna get too complex.
    00:10:13,477But we are gonna start writing some code of our own.
    00:10:16,225So this is where I wanna introduce
    00:10:17,818an extension for After Effects called Expressionist.
    00:10:21,075So, I'm gonna switch over to my Expressionist layout
    00:10:24,924and make this window bigger over here.
    00:10:26,725Now, Expressionist
    00:10:28,304is an expression editor
    00:10:30,546that is much easier to work with
    00:10:33,175than the expression editor built into After Effects.
    00:10:37,314As you can see down here, I am confined to this window.
    00:10:40,571I can't change the size of the font,
    00:10:42,820and it can get pretty complex
    00:10:44,766if you have a lot of lines of code
    00:10:47,172with not a lot of room to work with.
    00:10:49,914Expressionist behaves a lot more like
    00:10:52,105an actual coding program
    00:10:54,245inside of After Effects,
    00:10:55,455and it has a ton of great features.
    00:10:57,662If you're serious about learning how to write expressions,
    00:11:00,858and making your own things with expressions,
    00:11:03,175I highly recommend that you purchase Expressionist.
    00:11:06,331It is totally worth the money,
    00:11:07,930and we have a link for it on this page
    00:11:09,886so you can go check it out.
    00:11:11,684If you think you're gonna get it,
    00:11:12,517I would even recommend that you pause the video,
    00:11:14,570go buy it, install it, and then come back
    00:11:16,588so you can follow along with me inside of Expressionist.
    00:11:19,662It's fine if you don't use Expressionist.
    00:11:21,314Everything I do in here is completely doable
    00:11:22,852inside of After Effects.
    00:11:24,595Expressionist just makes it a lot more easy to look at.
    00:11:28,054Alright, so the first thing I wanna do
    00:11:29,563is work on the Start value
    00:11:31,270of the Master Trim Paths.
    00:11:33,058So, I'm just gonna clean up my layer a little bit
    00:11:35,188so I can just focus
    00:11:36,277on what's important.
    00:11:39,503I want the Start value to be based on the End value
    00:11:42,593and the total number of groups in my layer.
    00:11:45,662So the number of duplicates we have in this group here.
    00:11:48,557Right now, there are two groups total,
    00:11:51,367the Master Group and Taper 01.
    00:11:53,888So, I want the Start value to be the End value
    00:11:57,062divided by the number of groups, which is two.
    00:11:59,535So it should be 50.
    00:12:01,831So what does the expression look like
    00:12:03,721that would get that to happen?
    00:12:05,482Well, let's write that code.
    00:12:06,860I'll come over to Expressionist.
    00:12:08,759And I will select the End value.
    00:12:11,003And down here, I have this pick whip.
    00:12:13,187I will click it once
    00:12:14,450and Expressionist fills in the code exactly the same way
    00:12:17,902as if I was writing the expression down here
    00:12:20,279and using the expression pick whip.
    00:12:22,792Now, the syntax that Expressionist uses
    00:12:25,255is slightly different than the syntax After Effects uses.
    00:12:28,685And syntax is just the structure
    00:12:30,845and the naming conventions
    00:12:32,384that coding languages use.
    00:12:34,219So things like putting names in quotes
    00:12:36,114and putting groups in parentheses.
    00:12:38,024The thing is, After Effects natively uses
    00:12:39,974one naming convention for its syntax
    00:12:42,875and Expressionist just uses another one
    00:12:45,026that's a little bit more consistent.
    00:12:46,884Expressions are based on the JavaScript language,
    00:12:49,286and it's pretty flexible in the way
    00:12:50,749that you can write things.
    00:12:52,255If you look down here, After Effects puts Content,
    00:12:55,519Master Group dot Content Master Trim Paths,
    00:12:58,708and Expressionist uses parentheses and double-quotes
    00:13:03,123for each one of those groups instead.
    00:13:05,193So you see Contents, instead of being separated by periods,
    00:13:08,833is just in the exact same format as the other groups.
    00:13:11,315The end result is exactly the same,
    00:13:13,242it's just a little bit different way of writing the code.
    00:13:15,796So if you're not using Expressionist,
    00:13:17,463just know that any time I click on a pick whip,
    00:13:19,473my code's probably gonna look different than yours,
    00:13:22,059but the end result is gonna be exactly the same,
    00:13:23,897so don't worry about it.
    00:13:25,284Alright, so that code references the End value.
    00:13:28,783And then, again, there are two Total Groups,
    00:13:30,466Master Group and the Taper 01.
    00:13:32,455So, I want to take this End value
    00:13:35,850and divide it by two.
    00:13:39,681Then I'll apply that to the Start value
    00:13:42,456by having my Start value selected
    00:13:44,610and then inside of Expressionist pressing Command-Enter.
    00:13:48,418That applies the expression and look at that.
    00:13:50,356Our Start value is now 50%.
    00:13:52,637Because it is 100, the End value,
    00:13:55,952divided by two.
    00:13:57,616So that's great.
    00:13:58,452If I go into my Effects Control,
    00:14:00,461and I adjust this slider, you see
    00:14:02,286that the Start value of the Master Group
    00:14:04,523is moving in proportion to the End value.
    00:14:07,506So if this was set to 50,
    00:14:09,224then the Start value is 25%
    00:14:11,109because it is half of the End value.
    00:14:13,313Great!
    00:14:14,513The problem is, that hard coded number
    00:14:16,756is not going to update with the number of groups.
    00:14:19,120So if I were to duplicate these groups,
    00:14:21,768this value doesn't change at all.
    00:14:24,246So instead of using a two,
    00:14:26,240we need to tell After Effects
    00:14:28,234how to count the number of groups
    00:14:30,624and automatically fill that in,
    00:14:33,007instead of a hard-coded number.
    00:14:35,294So I'll delete these Duplicate Groups.
    00:14:37,956And now I'm gonna show you really quickly
    00:14:39,459how to get a group's index.
    00:14:42,161So I'm just gonna make a new
    00:14:42,994composition really quick for a demo.
    00:14:44,651You don't have to follow along with this.
    00:14:46,818I'm gonna make a new solid.
    00:14:48,779And you probably already know that this number over here
    00:14:51,878in this column is the index value of the layer.
    00:14:54,765That's what After Effects calls its number.
    00:14:57,039It's an index value.
    00:14:59,165What you might not know is that inside any layer,
    00:15:02,652every group, every effect and every property
    00:15:06,280has an index value.
    00:15:07,996There's just no number next to it.
    00:15:10,264So inside of this layer is a Transform group.
    00:15:13,099Right now, that's an index value of one.
    00:15:15,534If I add, say, a Fast Blur
    00:15:18,423to that layer,
    00:15:19,473now there's an Effects group.
    00:15:21,030So in this hierarchy,
    00:15:22,831the index value of Effects is one and Transform is two.
    00:15:26,866If I open up the Effects,
    00:15:28,403and I duplicate this Fast Blur five times,
    00:15:31,962now there's a hierarchy inside of the Effects group.
    00:15:34,894Fast Blur one, two, three, four, five.
    00:15:37,885So I'll open up the fifth Fast Blur,
    00:15:40,067and I'll add an expression on the blur value.
    00:15:43,045And I'm just gonna type in a simple expression,
    00:15:45,338ThisProperty.
    00:15:47,002So, the property I'm writing the expression on,
    00:15:49,472dot
    00:15:51,214PropertyGroup,
    00:15:53,197parentheses,
    00:15:54,902one, close parentheses,
    00:15:57,576dot
    00:15:58,876PropertyIndex.
    00:16:03,807I'll apply that.
    00:16:05,769And now we have a value of five.
    00:16:07,583So this expression is saying ThisProperty, the blurriness,
    00:16:11,390PropertyGroup one,
    00:16:13,592which means the property group one level higher
    00:16:17,510than ThisProperty,
    00:16:19,976give me the property index for that value.
    00:16:22,505So, one level higher is Fast Blur five
    00:16:25,585from the value that I'm writing the expression on.
    00:16:28,771If I change the order of this
    00:16:30,412Fast Blur to the third position,
    00:16:32,423that value updates to three.
    00:16:34,587And if I copy this expression to all the Fast Blurs,
    00:16:38,566and double-tap the E to bring up all the expressions,
    00:16:41,193you see that the index value is reflected
    00:16:44,104in the Fast Blurs' blurriness,
    00:16:47,789and it updates based on the order of the effects.
    00:16:51,053So that's how we can find the property index of any value.
    00:16:54,723So I'll go back to this main comp,
    00:16:56,791and things get a little bit more tricky
    00:16:58,519when it comes to shape layers.
    00:17:00,040To show you what I mean, I'm just gonna go into
    00:17:02,124the stroke of this Taper 01,
    00:17:05,442and I'll add an expression onto the Stroke Width.
    00:17:08,336So if I type that same expression,
    00:17:09,956ThisProperty,
    00:17:11,853dot
    00:17:12,686PropertyGroup
    00:17:15,444one, dot
    00:17:17,110PropertyIndex,
    00:17:20,320and I capitalize ThisProperty.
    00:17:22,466That is not the proper syntax,
    00:17:24,014so that would have broken the expression.
    00:17:25,845So that is something that is very important to take note of.
    00:17:29,225It's very common for commands and expressions
    00:17:31,206to start with lowercase,
    00:17:32,609but then the second word of the command to be uppercase,
    00:17:35,395and every word after that uppercase as well.
    00:17:37,630And if you don't follow that syntax,
    00:17:39,305the expression will break.
    00:17:40,981So anyway, we've got ThisProperty,
    00:17:42,459ProperyGroup1, PropertyIndex,
    00:17:44,352so the index of Stroke One.
    00:17:47,292So it says it's got a value of three.
    00:17:49,614If I move it up, it goes to two.
    00:17:51,217So we know it's working.
    00:17:53,352Here's where it gets interesting.
    00:17:54,756The next level up is Taper 01.
    00:17:56,705So you would think, if I change this to Group Two,
    00:18:00,379we should get the index value of Taper 01.
    00:18:02,764But this is returning a value of two.
    00:18:05,154And there's only one group inside of Duplicate Groups.
    00:18:09,117If I duplicate this taper, the value doesn't change.
    00:18:12,309I can do it as many times as I want.
    00:18:13,746It's always going to be two.
    00:18:15,981So the reason this is happening
    00:18:17,938is because there's actually an invisible layer
    00:18:19,981of the hierarchy that we're not seeing.
    00:18:22,606To show you what I mean, I will grab the Stroke Width.
    00:18:25,346And let's get rid of this; I will clear it out.
    00:18:29,136And I'm going to pick whip that Stroke Width.
    00:18:34,445So let's look at this layer structure that it gave us.
    00:18:38,166Starting at this layer, Contents,
    00:18:42,054Duplicate Groups,
    00:18:44,435Contents, which we don't see,
    00:18:47,774Taper 01,
    00:18:50,252Contents again,
    00:18:52,953then Stroke One, the Stroke Width.
    00:18:55,969So the reason this is happening is because
    00:18:58,012there is an invisible layer of Contents
    00:19:01,150inside every shape group.
    00:19:03,091It's a unique thing to shape layers,
    00:19:05,182but it's very important to be aware of
    00:19:07,012because when we're using this Property Group command,
    00:19:10,503we need to account for those levels of the hierarchy
    00:19:13,071even though we can't see them.
    00:19:15,323Alright, so let's get rid of that expression,
    00:19:17,392and we can actually start doing some coding.
    00:19:19,324So let's go back to the Start value.
    00:19:21,665I will load that back in.
    00:19:24,142And I'm gonna get rid of this divided by two.
    00:19:26,271Now obviously this line of code is not that easy to look at.
    00:19:29,135It's pretty long and it would take you a little bit
    00:19:32,173to figure out what exactly it's saying.
    00:19:34,551It's not very clear.
    00:19:35,824But expressions allow you to create
    00:19:37,820what are called variables.
    00:19:39,619And a variable is basically a way
    00:19:41,395for you to create your own shorthand
    00:19:43,785so that your code is easier to look at.
    00:19:46,650So I'm actually gonna clear out this entire line of code.
    00:19:49,689And I'm gonna start over by writing a new variable.
    00:19:52,859So, to write a variable, you start
    00:19:54,890by typing V-A-R for variable,
    00:19:57,711and then you need to give it a name.
    00:19:59,140So I'm going to name this End,
    00:20:01,466and then an equals sign,
    00:20:03,581and then the line of code that you want End to contain.
    00:20:07,072So, I want to go to the Effects
    00:20:09,321and to the End slider.
    00:20:11,561And Expressionist can't pick whip anything
    00:20:13,491from the Effects Controls,
    00:20:14,785so that's why it went down to the Effect.
    00:20:16,916But then with that selected, I will click on the pick whip,
    00:20:20,153and end that variable with a semicolon.
    00:20:21,813It's every important that you end it with a semicolon,
    00:20:24,625or else After Effects will not know
    00:20:26,531when that variable is supposed to end.
    00:20:29,550But there you go.
    00:20:30,383Now I can use End
    00:20:32,105anywhere in my expression
    00:20:34,544after that line,
    00:20:35,837and it will automatically interpret it
    00:20:37,466as this line of code.
    00:20:39,722Cool.
    00:20:40,555So the next variable that I need
    00:20:42,629is the Total Groups.
    00:20:44,117So I'll make another variable
    00:20:45,779and name it Total Groups.
    00:20:49,186And then I need to write the expression
    00:20:50,986that will give me the Total Groups.
    00:20:53,065So I'm going to pick any property within this Taper 01.
    00:20:57,035So, we'll just say the opacity,
    00:20:59,872pick whip it,
    00:21:01,518and then I can get rid of everything
    00:21:03,162on this line of code that I don't need.
    00:21:06,154Remember, I want to count the number of groups
    00:21:07,932within Duplicate Groups.
    00:21:09,319So, I need to go to this layer,
    00:21:11,366Contents, Duplicate Group, Contents,
    00:21:13,984that invisible layer of contents,
    00:21:16,779and I can get rid of everything else.
    00:21:19,267Then I'll type in a new expression.
    00:21:20,861It's very simple:
    00:21:21,943dot NumProperties.
    00:21:25,027And what that's saying is take the number of properties
    00:21:27,941that are within the contents of that group.
    00:21:33,493So now, I can write my equation.
    00:21:37,022So I'll drop down two lines and I'll say End
    00:21:40,707divided by Total Groups.
    00:21:43,492And I'll end that with a semicolon.
    00:21:45,500Now After Effects is pretty forgiving
    00:21:47,244and will generally still carry out a command
    00:21:49,185even if you don't end a line with a semicolon.
    00:21:51,224But it's just a good practice to get into
    00:21:53,605to make sure that there are no mistakes in your code
    00:21:56,761and no errors pop up.
    00:21:58,549So, just get into the habit
    00:22:00,114of ending every line with a semicolon.
    00:22:02,332Alright, now that I've got that written,
    00:22:03,853I will apply it to the Start value.
    00:22:07,609And the value goes to 90.7,
    00:22:09,187which is exactly the End value.
    00:22:11,444So let me just make this 100% to make it more clear.
    00:22:15,441Why is the End value, 100,
    00:22:18,717divided by the Total Groups also 100?
    00:22:21,539They're two different groups, so it should be 50, right?
    00:22:24,200Well, the problem is, we defined Total Groups
    00:22:27,264to be the number of properties within Duplicate Groups,
    00:22:30,609and the Master Group is not contained within that.
    00:22:33,201So the expression is actually working
    00:22:34,691exactly the way it's supposed to,
    00:22:36,638it's just not what we want.
    00:22:38,433So we need to account for this Master Group
    00:22:41,148within our variable for the Total Groups.
    00:22:43,874And it's very simple to do that.
    00:22:45,397All I have to do is add a plus one
    00:22:48,892after NumProperties, and that will automatically
    00:22:51,811increase the number of properties by one
    00:22:54,297anytime it references it.
    00:22:55,828So let me reapply that to the start.
    00:22:58,178And there we go, we're back to 50%.
    00:23:02,060And now, if I duplicate this group,
    00:23:04,821you see that the End value updates as well.
    00:23:08,228Now, it's not updating the way that I need it to,
    00:23:10,356but it is being based on that total number of groups,
    00:23:13,550which is progress.
    00:23:14,918So we're doing great.
    00:23:16,614Let's delete those Duplicate Groups,
    00:23:18,500and then we need to add another factor into this,
    00:23:22,021which is the Segment Length.
    00:23:23,915So I actually need to duplicate my End slider,
    00:23:26,821and I'll rename it Segment Length.
    00:23:33,805And I need to define a variable for that slider.
    00:23:36,816So I will drop down here
    00:23:38,647and type in V-A-R, SegLength, just for short.
    00:23:42,712And then open up the Segment Length,
    00:23:47,240pick whip it,
    00:23:49,297and finish off that variable.
    00:23:52,529Now, I want to update my equation
    00:23:54,840to be End minus the Segment Length,
    00:23:59,014divided by the total of groups.
    00:24:00,993And if you remember back to your algebra days,
    00:24:03,599the order of operations applies here.
    00:24:06,470And by that, I just mean multiplication and division
    00:24:09,706is going to happen before addition and subtraction.
    00:24:13,130So this equation is going to play out like this.
    00:24:14,904It's gonna take the Segment Length, 100,
    00:24:17,760divided by the Total Groups, two,
    00:24:20,461so that becomes 50.
    00:24:24,283Then it's gonna take the End value, which is 100,
    00:24:26,826and subtract 50 from it.
    00:24:29,658And it'll do it in that order.
    00:24:31,642So, let's apply that to our Start value.
    00:24:35,124And now when I duplicate this group,
    00:24:38,148you see this number is getting bigger, closer to 100,
    00:24:41,427making the Segment Length smaller with every duplicate.
    00:24:45,355That's working exactly the way it needs to.
    00:24:48,120And that's actually all we have to do for the Start value.
    00:24:51,571Now we can move on to the Duplicate Groups.
    00:24:53,742Alright, hopefully you're following along with no problems.
    00:24:56,287I know this is a lot to take in,
    00:24:58,157but hang in there, we're making really great progress.
    00:25:00,982Let's get into the Trim Paths of the Taper 01
    00:25:04,347and start with the End value.
    00:25:07,340Now, really, I want the End value of the first duplicate
    00:25:10,417to be in the exact same place as the Start value
    00:25:13,852of the Master Trim Paths.
    00:25:15,652Or another way to think about it
    00:25:17,367is I want the End value to be the same as the master end
    00:25:20,957minus one Segment Length.
    00:25:23,822Now, that might sound a little bit confusing,
    00:25:25,434so instead of talking about, I'm just gonna show you.
    00:25:27,825Let's write the expression for the End value.
    00:25:29,659I'm gonna load that up into Expressionist
    00:25:31,484by Shift-clicking into the editor.
    00:25:34,475And let's define some variables.
    00:25:35,997So, V-A-R, End, equals,
    00:25:39,584and again, we'll grab that End slider.
    00:25:45,396Then we'll add a variable for the Group Index.
    00:25:50,116And I'll write the same expression we used before.
    00:25:52,443ThisProperty
    00:25:54,491dot
    00:25:56,140PropertyGroup3
    00:25:59,515dot PropertyIndex.
    00:26:02,539And the reason I chose three is because
    00:26:04,359one level up is the Trim Paths,
    00:26:06,822two levels up is that invisible layer of contents,
    00:26:10,243and then three levels up is Taper 01,
    00:26:12,213which is the index value that I need.
    00:26:14,165So ThisProperty, PropertyGroup3, PropertyIndex.
    00:26:19,504Then I'm gonna define one more variable,
    00:26:21,089and I'll put this on the second line.
    00:26:23,791And I'll name this Master Start.
    00:26:26,642And this is going to be the Master Trim Path's Start value.
    00:26:33,281And then one last variable for the Segment Length.
    00:26:36,895Now this Segment Length is gonna be different
    00:26:38,713than the actual Master Path's Segment Length.
    00:26:41,123I don't want it to be base exactly on this slider.
    00:26:43,631Instead, I want it to be based
    00:26:45,545on the trimmed portion of the Master Path,
    00:26:48,456so whatever the length that segment is.
    00:26:51,894To find that, all I have to do
    00:26:53,680is subtract the Start value of the Master Path
    00:26:56,622from the End value, which is the same
    00:26:58,629as the End value of the slider.
    00:27:00,466Which is why I pick whipped the end slider
    00:27:02,232instead of the master end.
    00:27:04,083So, for the Segment Length, very simply,
    00:27:06,543I just want to write End minus masterStart.
    00:27:12,520So within this variable, I'm already referencing
    00:27:15,220variables that I defined up here.
    00:27:17,553That's an extremely powerful feature of variables.
    00:27:21,057As long as the variable was defined before this line,
    00:27:24,176I can already use it.
    00:27:26,172Alright, so now that all my variables are defined,
    00:27:27,733I'll actually write the equation.
    00:27:29,675I want this End value to be the End value
    00:27:34,417minus the Segment Length
    00:27:37,097times
    00:27:38,780the Group Index.
    00:27:41,046So, let me walk you through this.
    00:27:42,508The End value, master end, set here,
    00:27:45,514minus the Segment Length times the Group Index.
    00:27:48,373And again, order of operations, it's gonna do that
    00:27:51,743multiplication before the subtraction.
    00:27:54,604The Segment Length is this segment,
    00:27:56,740the Master Path's Segment Length,
    00:27:58,820times the Group Index; in this case, it's one.
    00:28:01,549So, end minus one Segment Length.
    00:28:04,611Let's apply that to the End value.
    00:28:08,236And it's set to 50,
    00:28:09,894which is exactly the same as the Start value
    00:28:11,903of the Master Trim Paths.
    00:28:14,131I'll set this Taper 01 to Multiply
    00:28:15,587just so you can see this is perfectly overlapping.
    00:28:18,802So there's no gap between the two lines.
    00:28:21,645And if I adjust the Segment Length,
    00:28:23,675you see that that updates with it.
    00:28:25,834And the End value also controls that.
    00:28:28,726So what happens if I duplicate this group?
    00:28:31,009Well, it offsets, and this is segmented evenly.
    00:28:34,050I can duplicate this a bunch and you see
    00:28:35,842that all of these End values are spread out evenly,
    00:28:38,763and the Segment Length
    00:28:40,366proportionately spaces everything out.
    00:28:42,361So I hope you're getting excited.
    00:28:43,774This is actually working.
    00:28:45,548Let's delete the tapered groups.
    00:28:48,339And now we need to do the same thing for the Start value.
    00:28:53,030And the variables can actually stay the same.
    00:28:54,986So I'm actually gonna reuse this instance of Expressionist.
    00:28:57,796The equation just needs to change slightly.
    00:29:00,458Instead of the Start value being based on the End value
    00:29:03,544of the Master Trim Paths,
    00:29:05,093it needs to be based on the Start value.
    00:29:07,657So instead of End, I'm gonna type in Master Start.
    00:29:13,602And I'll apply that to the Start value.
    00:29:15,273Everything else is the same.
    00:29:18,693Now when I adjust the Segment Length,
    00:29:21,074look at that, the End value of the duplicate
    00:29:22,509and the Start value of the master stays
    00:29:24,464directly in the center there,
    00:29:26,492and everything else gets spaced out proportionately.
    00:29:29,262I can duplicate this a whole bunch.
    00:29:32,510And just like that, everything is perfectly spaced out,
    00:29:35,401and I'm able to adjust the length of that line
    00:29:37,764and animate it exactly the way that you would expect
    00:29:40,895a shape layer to behave.
    00:29:42,875If I move the offset angle,
    00:29:44,548now there's something I forgot to do.
    00:29:46,374I did not set up the offset of any of the duplicates
    00:29:49,612to be based on that, but that is an easy fix.
    00:29:52,634I'll just delete all of my duplicates,
    00:29:55,675Option-click on that offset,
    00:29:57,387expression pick whip the offset value.
    00:29:59,720Now that it's all linked up,
    00:30:00,930I'll reduplicate this a bunch of times,
    00:30:03,873and now I can use that offset control
    00:30:06,337exactly as you would expect it to be used.
    00:30:09,577So, that's really awesome.
    00:30:10,845We've already solved the first part of the problem,
    00:30:13,604which was automatically dividing up that segment
    00:30:15,819based on the number of groups.
    00:30:17,859Now obviously if I take off this Multiply,
    00:30:20,764this line looks exactly the same as it did when we started.
    00:30:23,933So we need to solve the other half of the problem now,
    00:30:26,431which is offsetting the Stroke Width.
    00:30:28,544So, take a deep breath,
    00:30:29,988(breathes in, exhales)
    00:30:31,976and let's keep going!
    00:30:33,809I'm gonna delete all these duplicates again.
    00:30:38,121I'll set this back to Multiply
    00:30:39,183just so we can see where the two lines are segmented.
    00:30:43,041And I'll collapse the Trim Paths for both groups,
    00:30:47,377and I will open up the Stroke One.
    00:30:49,462This is where we're gonna be working.
    00:30:51,974And before I forget, I'm actually going to
    00:30:53,739link some of these properties up.
    00:30:55,273I want the color of all the duplicates
    00:30:57,243to be driven by the color of the Master Stroke.
    00:30:59,754So I will directly link that.
    00:31:04,252I don't think I'll need to mess with the opacity,
    00:31:06,011so I'm gonna leave that the way it is.
    00:31:07,811But let's start writing the Stroke Width expressions.
    00:31:09,886So I will select that
    00:31:11,359and then Shift-click into Expressionist
    00:31:13,372to load that property up.
    00:31:14,764And we'll start by defining more variables.
    00:31:16,668So let's start with the Stroke Width.
    00:31:20,276And pick whip the Stroke Width slider.
    00:31:28,150Then we're gonna need to know the Group Index,
    00:31:29,774which we can actually pull from the Trim Paths.
    00:31:32,879That variable's gonna be exactly the same.
    00:31:36,104We find that, Group Index.
    00:31:40,734Copy and paste that in.
    00:31:42,279And we're also gonna need to know the Total Groups.
    00:31:44,411So, I'll define that variable,
    00:31:46,196TotalGroups
    00:31:47,945equals.
    00:31:49,207And I'll just pick whip the Stroke Width.
    00:31:53,087And, again, delete everything I don't need.
    00:31:55,457So, I need to know the Duplicate Groups' contents,
    00:31:59,148the number of properties in there.
    00:32:00,516So I'll delete everything after that
    00:32:01,895and type dot NumProperties.
    00:32:06,579And there's my Total Groups.
    00:32:08,710So, let's write the equation.
    00:32:12,717I want the Stroke Width
    00:32:13,942to be based on the slider's Stroke Width.
    00:32:15,994So I'll type in strokeWidth
    00:32:20,273divided by the Total Groups
    00:32:23,685times the Group Index.
    00:32:27,119So let's apply that expression to the Stroke Width.
    00:32:30,322And it stays at 100.
    00:32:32,206Now, again, that is because we did not account
    00:32:34,545for the Master Group in our Total Groups.
    00:32:37,260So I need to come back up to that variable,
    00:32:39,098add plus one at the end,
    00:32:41,402and update that expression.
    00:32:43,228And now it is half the width.
    00:32:45,972Let's duplicate this group a bunch of times.
    00:32:48,710And it seems to be working, kind of?
    00:32:52,388It's not doing exactly what I expected.
    00:32:55,162This taper is going in reverse.
    00:32:57,760And the Master Group is on the wrong end.
    00:33:00,704So the reason why this is happening is because
    00:33:03,681even though this counts Taper 01 all the way up to Taper 10,
    00:33:07,512the index structure starts at the top and goes down.
    00:33:11,720So every new duplicate is actually the index value of one.
    00:33:15,074So Taper 10 is now one, nine is two,
    00:33:17,827all the way down the line.
    00:33:19,318Taper One, which is here at the end,
    00:33:21,694has the Group Index of 10.
    00:33:24,128So what I need After Effects to do
    00:33:26,038is reverse that index order.
    00:33:28,363And it's actually pretty simple.
    00:33:30,088All I have to do is type in
    00:33:31,971Total Groups minus the Group Index.
    00:33:36,187And I need this to be calculated before it's multiplied
    00:33:39,684by the rest of the equation.
    00:33:40,907So to make that happen,
    00:33:42,658I just have to put this within parentheses.
    00:33:47,664So, what's happening here is
    00:33:49,252it's gonna take the total number of groups,
    00:33:50,885so right now there are 10,
    00:33:52,983actually 11, because of the extra,
    00:33:55,386and then subtract the Group Index from it.
    00:33:58,413So if Taper 01 has an index value of 10,
    00:34:03,007I'm gonna take the total number of groups, 11,
    00:34:05,027and subtract 10 from it,
    00:34:06,490and it's going to become Group One.
    00:34:09,625And, say, Group Seven...
    00:34:11,929we'll take the Total Groups again,
    00:34:13,20211 minus seven is four.
    00:34:16,217So that's essentially reversing my index order.
    00:34:19,185So I'll delete all these duplicates,
    00:34:21,616go to my Stroke Width,
    00:34:25,670and then reapply this expression.
    00:34:28,929Now if I make some duplicates,
    00:34:31,208look at that, our stroke is tapering in the correct order.
    00:34:34,351And if I have enough of these,
    00:34:36,063I'll turn off the Multiply.
    00:34:40,613That segmentation gets less and less noticeable.
    00:34:43,780Now this is great, except that I have no way to control
    00:34:46,812how thick or thin this taper is.
    00:34:49,927So we need to add one more piece of the equation
    00:34:52,456into our expression.
    00:34:54,066And I'll start by adding a new slider.
    00:34:56,767I'll just duplicate the end
    00:34:58,219and rename this Taper Out.
    00:35:01,462Then I'll delete all these Duplicate Groups.
    00:35:05,591And this last part of the equation
    00:35:07,020is a function within expressions
    00:35:08,296called linear interpolation.
    00:35:10,534And that sounds complicated, but once you understand it,
    00:35:12,838it is an incredibly powerful tool.
    00:35:15,083So, again, I'm gonna jump into a new composition.
    00:35:17,529You don't have to follow along with this.
    00:35:19,151It's just for a demo.
    00:35:20,260But feel free if you want to.
    00:35:23,255I'm going to make a square again,
    00:35:25,673and I'm gonna add a slider control to it.
    00:35:30,606And this slider by default goes from zero to 100.
    00:35:34,278Now let's say I wanted to change the rotation of this layer,
    00:35:38,962so I'll bring that up.
    00:35:40,606And rotation is measured in a value of degrees,
    00:35:43,550while the slider control is just a hard number.
    00:35:49,353If I wanted this slider to control
    00:35:51,200the rotation of this square,
    00:35:53,446where zero was zero degrees,
    00:35:56,336but 100
    00:35:59,331was one entire rotation,
    00:36:02,576that wouldn't work if I directly linked them together.
    00:36:05,191And I'll show you.
    00:36:06,024If I just link this to the slider,
    00:36:07,928the slider's set to 100,
    00:36:09,814the angle of the rotation goes to 100.
    00:36:12,302It doesn't go to one revolution because
    00:36:14,491one revolution is actually a value of 360 degrees.
    00:36:18,557Now linear interpolation allows me to remap
    00:36:22,113any range of values to another range of values.
    00:36:26,258And I'll show you what I mean by that.
    00:36:28,562Let's load this expression up,
    00:36:30,675and I'll define this as a variable.
    00:36:32,332So, V-A-R,
    00:36:34,804Slider, equals,
    00:36:37,446and then this code for the expression.
    00:36:40,723End it with a semicolon.
    00:36:42,555And I'll come down and say
    00:36:44,662linear
    00:36:47,052parentheses,
    00:36:49,290and then I need to tell the linear expression
    00:36:52,034what values to look at.
    00:36:53,701So, I'm going to type Slider.
    00:36:58,168So I target the slider control,
    00:37:00,840and then I need four numbers.
    00:37:02,386So I'm just gonna put a comma zero,
    00:37:05,472comma zero, comma zero, comma zero.
    00:37:07,214So we have four numbers.
    00:37:08,651This is completely arbitrary right now,
    00:37:10,851but I'll tell you what these mean.
    00:37:12,551The first number is the input minimum value,
    00:37:15,890and the second number is the input maximum value,
    00:37:19,257so the range of numbers of that slider
    00:37:21,865that we want to pay attention to.
    00:37:24,874So I want the range to go from zero to 100.
    00:37:27,687So zero is fine, and the second number will be 100.
    00:37:32,990The second set of numbers is the output range.
    00:37:36,826So, the minimum output and the maximum output.
    00:37:40,774So when the slider is set to zero,
    00:37:43,692which is the input,
    00:37:45,685I want to interpret that number
    00:37:47,679as this number, the output.
    00:37:51,856So zero is actually fine.
    00:37:53,433When the slider is at zero, it should be at zero degrees.
    00:37:56,975But when the output slider is at 100,
    00:37:59,864I want the rotation to be 360 degrees.
    00:38:04,056So I'll type 360 degrees there.
    00:38:06,893And then I'll finish this off with a semicolon.
    00:38:09,492And, just one more time, I'm gonna run through this again,
    00:38:11,728just so it's crystal clear.
    00:38:13,697We're targeting the slider values
    00:38:18,101and taking the range of zero to 100
    00:38:21,729and remapping that range
    00:38:24,286from zero to 360.
    00:38:26,551Let's apply that expression to the rotation.
    00:38:30,024And now this is set to 100,
    00:38:31,849and you see that we have one full revolution.
    00:38:34,596And if I adjust this slider,
    00:38:35,890you see that it makes an entire rotation
    00:38:38,714from zero to 100.
    00:38:41,270So that's an example of what linear interpolation can do.
    00:38:44,560Now you can do a lot more than hard-coded numbers
    00:38:47,274in the linear interpolation.
    00:38:49,087You can use variables, you can do equations,
    00:38:51,873and you don't even have to use a full range of numbers.
    00:38:54,908I could have said from a minimum input of 25
    00:39:00,896to, say, 75.
    00:39:04,206And then if I reapply that to the rotation,
    00:39:07,561now, until this value reaches 25,
    00:39:11,632nothing happens.
    00:39:12,690But you see that as soon as it hits 25, it starts rotating.
    00:39:16,087And then once it gets to 75
    00:39:18,239is when that rotation finishes its entire revolution,
    00:39:22,259and then from 75 to 100, nothing happens.
    00:39:26,116So it's an extremely powerful function,
    00:39:28,490and it's a key factor in getting our tapered stroke to work
    00:39:31,634the way that we want it to.
    00:39:33,337So let's go back out to our tapered stroke,
    00:39:35,503and you can jump back in to following along.
    00:39:39,288I'll load up the Stroke Width again.
    00:39:42,175And now that we have this Taper Out slider,
    00:39:43,905let's put that into our variable list.
    00:39:46,808So, V-A-R, and we'll call it TaperOut,
    00:39:50,904equals,
    00:39:52,624pick whip the Taper Out.
    00:39:57,470Semicolon.
    00:39:59,456And then I'm actually gonna take this equation
    00:40:02,257and make it a variable.
    00:40:04,214So I'm gonna type V-A-R,
    00:40:06,482and name this StrokeTaper
    00:40:10,322equals
    00:40:12,038and then this equation.
    00:40:13,456So now, anytime I type out StrokeTaper,
    00:40:15,618it's just gonna interpret that as this entire equation.
    00:40:21,053Now, our new equation is going to be a linear expression.
    00:40:23,948So, we start by typing...
    00:40:26,158Whoops, I had my layer selected.
    00:40:28,677let's get back to the Stroke Width.
    00:40:33,372Alright, there we go.
    00:40:34,283So, linear,
    00:40:36,880parentheses.
    00:40:39,566And I wanna look at the Taper Out slider.
    00:40:42,174So, TaperOut,
    00:40:44,947comma,
    00:40:46,467zero to 100,
    00:40:48,920comma,
    00:40:50,212StrokeWidth,
    00:40:53,090comma,
    00:40:55,179StrokeTaper.
    00:40:57,884And then end it with a semicolon.
    00:40:59,512Now, what does this expression say?
    00:41:01,399It's saying take the range of zero to 100,
    00:41:04,857and in this case, I'm treating this
    00:41:06,160kind of like a percentage.
    00:41:07,752When the Taper Out is set to 0%, I want no taper,
    00:41:11,157and when it's at 100%, I want the maximum taper.
    00:41:14,601So, the range of zero to 100% is remapped
    00:41:18,396to the Stroke Width, which makes sense
    00:41:21,180because when there's no taper,
    00:41:23,318the Duplicate Groups should match
    00:41:25,472the Stroke Width of the master.
    00:41:27,975And when it's at 100%,
    00:41:30,857I want it to be the stroke taper,
    00:41:32,299which is our equation that makes the taper work.
    00:41:36,282Anything in between is automatically interpolated
    00:41:40,895between those two values.
    00:41:43,174So this is making the expression extremely flexible,
    00:41:46,224allowing us to control things with variables
    00:41:49,104instead of fixed, hard-coded numbers.
    00:41:52,672Let's apply this to the Stroke Width
    00:41:56,758and duplicate the group a bunch.
    00:41:58,768So now we have 10 Total Groups.
    00:42:00,612And now, watch what happens
    00:42:01,694when I adjust this Taper Out slider.
    00:42:03,453(gasps)
    00:42:05,238I hope I just blew your mind
    00:42:06,729because that is a working tapered stroke
    00:42:09,816with full control of the taper.
    00:42:13,365And if I duplicate this group a whole bunch,
    00:42:15,293and then maybe lower the Stroke Width to, say, 50,
    00:42:18,157it's starting to become really difficult to see
    00:42:20,007that there are any segments in there.
    00:42:23,066And I can go ahead and modify this path
    00:42:26,009to, say, be a curve like this.
    00:42:32,289And then maybe change the Segment Length
    00:42:33,888so it doesn't take up the entire line.
    00:42:36,213And this is a completely working tapered stroke.
    00:42:39,094If I set some keyframes...
    00:42:41,039Let's zoom in here.
    00:42:44,229You know, just something really simple.
    00:42:45,621We'll go from zero to 100 on the End value.
    00:42:50,366And then I will
    00:42:52,237just easy ease these keyframes really quickly.
    00:42:55,248And let's RAM Preview.
    00:42:58,852This layer animates exactly the same way
    00:43:01,180that a single path would on a shape layer,
    00:43:05,022but we have these added controls
    00:43:06,664of being able to taper the stroke,
    00:43:08,490control the Segment Lengths,
    00:43:12,893and the Stroke Width.
    00:43:14,902All right here
    00:43:16,184with lots of calculations taking place behind the scenes
    00:43:19,420so that we don't even have to think about it.
    00:43:21,470All we're left with are the animation controls
    00:43:23,669that we're already used to using.
    00:43:25,814And if I closed this path,
    00:43:28,879and maybe made this like a figure eight,
    00:43:34,821then instead of animating the End value,
    00:43:37,090I could animate the offset.
    00:43:41,105And I'll just put it at one.
    00:43:47,479And then I will RAM Preview that.
    00:43:50,036And we now have a looping tapered stroke
    00:43:52,692going around this figure eight.
    00:43:54,789So, it's time to place your head between your knees,
    00:43:57,220take some deep breaths.
    00:43:58,895We just built a freaking taper stroke rig
    00:44:01,901inside of After Effects
    00:44:03,422on a single shape layer
    00:44:05,429using expressions.
    00:44:07,444That is pretty incredible.
    00:44:09,640Now the way that I like to animate with this
    00:44:11,973is usually with a low number of groups,
    00:44:14,348usually around 10.
    00:44:15,773And then once I'm ready to render,
    00:44:17,642I'll really crank up the duplicates.
    00:44:19,514Now if I go ahead and do that, say there's 40 groups,
    00:44:23,069you might notice that After Effects
    00:44:24,613is starting to slow down a little bit
    00:44:27,535as I'm working with this.
    00:44:29,072And it's just because with every group duplicate,
    00:44:32,615After Effects has to recalculate
    00:44:35,010all of these expressions that we wrote
    00:44:37,055for every frame.
    00:44:39,025So typically, like I said, I'll work with, say, 10 groups,
    00:44:42,276and that's generally quick enough.
    00:44:44,749And then once I'm ready to render,
    00:44:46,314I'll just increase the duplicate count
    00:44:47,844until that taper is no longer noticeable,
    00:44:50,635and then you're ready to roll.
    00:44:52,553Holy crap, that was a lot to take in!
    00:44:55,078We just covered
    00:44:56,007linking properties directly with expressions,
    00:44:58,512defining variables, writing equations,
    00:45:01,265determining index values of groups,
    00:45:03,629and counting the number of groups within a group,
    00:45:06,200and linear interpolation.
    00:45:08,352I know that that was a lot to take in,
    00:45:10,488and if you're anything like me,
    00:45:11,554you're probably pretty overwhelmed right now.
    00:45:13,698But if you were able to follow along,
    00:45:15,527and you can grasp all the concepts that I covered,
    00:45:18,660you are well onto your way
    00:45:20,342to harnessing the power of expressions
    00:45:22,473to allow you to build things
    00:45:24,284to make animation the priority,
    00:45:26,392and make really complex, intricate processes
    00:45:29,366happen in the background so you don't
    00:45:30,568have to think about it.
    00:45:32,510Now, we can actually build a lot
    00:45:34,291more functionality into this rig,
    00:45:36,558but we're gonna save that for the next lesson.
    00:45:38,498For now, give yourself a hand.
    00:45:40,511Pat yourself on the back.
    00:45:41,590That was an incredible amount of coding,
    00:45:43,514especially if you're new to expressions.
    00:45:45,962Now, if you got lost at any point,
    00:45:47,389and you really don't feel like going back
    00:45:48,567and figuring out what went wrong,
    00:45:50,579you can always sign up to be a VIP member
    00:45:53,214of School of Motion
    00:45:54,391and download my project file for free.
    00:45:56,941Then you could just use my project
    00:45:58,151and take that tapered stroke rig that I just built
    00:46:00,615and reuse it in any of your own projects.
    00:46:03,150And again, I can't say enough good things
    00:46:04,848about Expressionist.
    00:46:06,267We didn't even cover all of the amazing features
    00:46:08,320that it allows, but I'm sure you noticed that
    00:46:10,554seeing this color-coded syntax
    00:46:12,859makes looking at these expressions much easier
    00:46:15,775than working in these tiny little boxes
    00:46:17,302with no highlighting at all.
    00:46:19,189It'd be much more difficult
    00:46:21,211to catch mistakes inside of this box.
    00:46:23,884So, again, check out the link to Expressionist on this page,
    00:46:27,402if you're serious about getting into
    00:46:28,712writing your own expressions.
    00:46:30,324Alight, that's enough.
    00:46:31,526Thank you so much for sticking with me through that
    00:46:33,870very long process.
    00:46:35,610Now get out there and start making
    00:46:36,696some tapered stroke animations,
    00:46:38,605and post your work online.
    00:46:40,242Let us know what you make with this rig.
    00:46:42,362Thanks again and stay tuned for the next lesson
    00:46:44,434where we're gonna add more features to this rig
    00:46:46,658using some more types of expression controllers.
    00:46:52,886(uptempo electronic beat)

    Similar lessons