[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.52,0:00:02.94,Default,,0000,0000,0000,,We're back with Winston, Dialogue: 0,0:00:03.22,0:00:06.84,Default,,0000,0000,0000,,and now we have both \Nan {\i1}x{\i0} and a {\i1}y{\i0} variable Dialogue: 0,0:00:06.84,0:00:08.54,Default,,0000,0000,0000,,for Winston's position. Dialogue: 0,0:00:08.54,0:00:11.18,Default,,0000,0000,0000,,So, now we can make Winston \Nhop up and down Dialogue: 0,0:00:11.18,0:00:14.45,Default,,0000,0000,0000,,and have a little Winston party!\NWooo! Dialogue: 0,0:00:14.45,0:00:15.71,Default,,0000,0000,0000,,Very nice. Dialogue: 0,0:00:15.98,0:00:18.72,Default,,0000,0000,0000,,Let's review what this code does \Nbefore we keep going. Dialogue: 0,0:00:19.24,0:00:21.91,Default,,0000,0000,0000,,We have these {\i1}x{\i0} and {\i1}y{\i0} variables\Nat the top Dialogue: 0,0:00:21.91,0:00:24.73,Default,,0000,0000,0000,,that store the center position \Nof Winston's face, Dialogue: 0,0:00:25.25,0:00:28.58,Default,,0000,0000,0000,,which we use in this line here\Nwhen we make the ellipse for his face. Dialogue: 0,0:00:29.66,0:00:31.65,Default,,0000,0000,0000,,Then, we position the eyes \Nand the mouth Dialogue: 0,0:00:31.65,0:00:34.32,Default,,0000,0000,0000,,relative to the center of the face. Dialogue: 0,0:00:34.32,0:00:39.30,Default,,0000,0000,0000,,So, we subtract or add to {\i1}x{\i0} and {\i1}y{\i0} \Nin order to make sure that the eyes Dialogue: 0,0:00:39.30,0:00:42.70,Default,,0000,0000,0000,,are 50 pixels away and 100 pixels away. Dialogue: 0,0:00:43.50,0:00:45.12,Default,,0000,0000,0000,,For example, the mouth Dialogue: 0,0:00:45.13,0:00:49.23,Default,,0000,0000,0000,,is 50 pixels to the right \Nof the center of the face, Dialogue: 0,0:00:49.23,0:00:53.64,Default,,0000,0000,0000,,and 40 pixels below \Nthe center of the face. Dialogue: 0,0:00:55.75,0:01:00.13,Default,,0000,0000,0000,,So, let's go through and see \Nwhat else we can store as variables. Dialogue: 0,0:01:00.13,0:01:03.49,Default,,0000,0000,0000,,To do that, I'm going to go through \Neach line of code Dialogue: 0,0:01:03.49,0:01:07.41,Default,,0000,0000,0000,,and look for what we call \Nhard coded numbers. Dialogue: 0,0:01:07.92,0:01:10.78,Default,,0000,0000,0000,,Those are numbers \Nthat are just straight numbers, Dialogue: 0,0:01:11.20,0:01:14.26,Default,,0000,0000,0000,,not variables \Nor dependent on variables. Dialogue: 0,0:01:14.93,0:01:18.13,Default,,0000,0000,0000,,Let's see. \NIn our first ellipse call here, Dialogue: 0,0:01:18.27,0:01:22.26,Default,,0000,0000,0000,,we have 300 and 300 \Nfor the width and height. Dialogue: 0,0:01:22.75,0:01:26.59,Default,,0000,0000,0000,,So, we can make a variable \Nfor these instead, like {\i1}faceSize{\i0}. Dialogue: 0,0:01:26.60,0:01:32.74,Default,,0000,0000,0000,,So, {\i1}faceSize = 300{\i0},\Nand then we can pass {\i1}faceSize{\i0} in here, Dialogue: 0,0:01:32.74,0:01:36.14,Default,,0000,0000,0000,,and right now it would pass 300\Nas the value. Dialogue: 0,0:01:37.21,0:01:40.91,Default,,0000,0000,0000,,Cool. Now, let's keep going. Dialogue: 0,0:01:41.61,0:01:45.30,Default,,0000,0000,0000,,Everything in here \Nis using {\i1}x{\i0} or {\i1}y{\i0} or {\i1}eyeSize{\i0}, Dialogue: 0,0:01:45.30,0:01:48.79,Default,,0000,0000,0000,,but here for the mouth, \Nwe once again have 150 Dialogue: 0,0:01:48.79,0:01:51.17,Default,,0000,0000,0000,,and 150 for the width and height. Dialogue: 0,0:01:51.17,0:01:55.97,Default,,0000,0000,0000,,So, we can make a {\i1}mouthSize{\i0} variable,\Nsay {\i1}mouthSize = 150{\i0}, Dialogue: 0,0:01:56.66,0:01:59.57,Default,,0000,0000,0000,,and we'll go pass {\i1}mouthSize{\i0} here. Dialogue: 0,0:01:59.76,0:02:01.54,Default,,0000,0000,0000,,It'll just pass 150 right now, Dialogue: 0,0:02:01.54,0:02:03.54,Default,,0000,0000,0000,,because that's what\Nthe variable is equal to. Dialogue: 0,0:02:04.64,0:02:10.32,Default,,0000,0000,0000,,OK, so now that we've done that,\Nwe can easily change the {\i1}faceSize{\i0} here, Dialogue: 0,0:02:11.07,0:02:16.04,Default,,0000,0000,0000,,and we can easily change the {\i1}mouthSize{\i0},\Nand we can move it like that, Dialogue: 0,0:02:16.70,0:02:19.16,Default,,0000,0000,0000,,and we can change the {\i1}eyeSize{\i0} again. Dialogue: 0,0:02:19.16,0:02:20.61,Default,,0000,0000,0000,,OK, so that's cool. Dialogue: 0,0:02:20.61,0:02:24.23,Default,,0000,0000,0000,,But, there's something \NI don't really like about that, Dialogue: 0,0:02:24.74,0:02:27.39,Default,,0000,0000,0000,,and that's when I change the {\i1}faceSize{\i0}. Dialogue: 0,0:02:28.78,0:02:33.62,Default,,0000,0000,0000,,I actually want everything else to change\Nrelative to the {\i1}faceSize{\i0}, Dialogue: 0,0:02:33.76,0:02:37.30,Default,,0000,0000,0000,,so if I make the {\i1}faceSize{\i0} \Nreally small like this, Dialogue: 0,0:02:37.94,0:02:40.83,Default,,0000,0000,0000,,I want his eyes and his mouth \Nto be really small, too. Dialogue: 0,0:02:41.01,0:02:44.03,Default,,0000,0000,0000,,If I make the {\i1}faceSize{\i0} \Nhalf of its original size, Dialogue: 0,0:02:44.64,0:02:47.92,Default,,0000,0000,0000,,the eyes and the mouth \Nshould also be half of their size. Dialogue: 0,0:02:48.13,0:02:50.07,Default,,0000,0000,0000,,Otherwise he just looks really silly, Dialogue: 0,0:02:50.07,0:02:53.33,Default,,0000,0000,0000,,because his eyes and his mouth \Nare way too big for his face. Dialogue: 0,0:02:53.49,0:02:55.43,Default,,0000,0000,0000,,They're not even connected anymore. Dialogue: 0,0:02:55.94,0:02:59.47,Default,,0000,0000,0000,,So what we want to do \Nis somehow make these variables, Dialogue: 0,0:02:59.50,0:03:01.78,Default,,0000,0000,0000,,{\i1}mouthSize{\i0} and {\i1}eyeSize{\i0}, Dialogue: 0,0:03:01.78,0:03:04.70,Default,,0000,0000,0000,,be dependent on this variable,\N{\i1}faceSize{\i0}. Dialogue: 0,0:03:06.18,0:03:08.66,Default,,0000,0000,0000,,So, let's bring it back to what it was. Dialogue: 0,0:03:09.19,0:03:11.07,Default,,0000,0000,0000,,The way we can do this Dialogue: 0,0:03:11.07,0:03:16.59,Default,,0000,0000,0000,,is we can make these values \Nbe based off the {\i1}faceSize{\i0} values. Dialogue: 0,0:03:16.59,0:03:21.66,Default,,0000,0000,0000,,So, we can say\N{\i1}mouthSize = faceSize/2{\i0}. Dialogue: 0,0:03:22.02,0:03:24.02,Default,,0000,0000,0000,,We are using a fraction of the face; Dialogue: 0,0:03:24.02,0:03:27.100,Default,,0000,0000,0000,,we're saying take one half \Nof the face size. Dialogue: 0,0:03:27.100,0:03:29.96,Default,,0000,0000,0000,,If you're not familiar with fractions, Dialogue: 0,0:03:29.96,0:03:32.06,Default,,0000,0000,0000,,there's tons of videos on Khan Academy Dialogue: 0,0:03:32.06,0:03:35.51,Default,,0000,0000,0000,,that you can use \Nto review how fractions work. Dialogue: 0,0:03:36.24,0:03:40.77,Default,,0000,0000,0000,,All right. Now for {\i1}eyeSize{\i0}. \NIt's around {\i1}faceSize/4{\i0}. Dialogue: 0,0:03:40.77,0:03:43.57,Default,,0000,0000,0000,,It's not perfect, \Nbut it's pretty good. Dialogue: 0,0:03:43.57,0:03:46.87,Default,,0000,0000,0000,,Oh, 7.\NThere we go, that's better. Dialogue: 0,0:03:46.87,0:03:48.92,Default,,0000,0000,0000,,See, if you get the fraction \Nwrong at first, Dialogue: 0,0:03:48.92,0:03:50.85,Default,,0000,0000,0000,,you can always fix it later. Dialogue: 0,0:03:50.85,0:03:54.13,Default,,0000,0000,0000,,Just fiddle with that number \Nuntil something makes sense. Dialogue: 0,0:03:54.13,0:03:58.46,Default,,0000,0000,0000,,OK, so now if we resize the face again, Dialogue: 0,0:03:58.46,0:04:02.74,Default,,0000,0000,0000,,see how the eyes and the mouth \Nare actually resizing along with it? Dialogue: 0,0:04:02.74,0:04:04.27,Default,,0000,0000,0000,,It's pretty cool. Dialogue: 0,0:04:04.49,0:04:06.80,Default,,0000,0000,0000,,But, there's still something wrong. Dialogue: 0,0:04:06.80,0:04:09.31,Default,,0000,0000,0000,,The eyes and the mouth Dialogue: 0,0:04:09.87,0:04:12.71,Default,,0000,0000,0000,,are still going off the face \Nwhen we go really small. Dialogue: 0,0:04:12.94,0:04:16.47,Default,,0000,0000,0000,,The sizes are correct;\Nthe problem is the offset from the face. Dialogue: 0,0:04:18.12,0:04:20.84,Default,,0000,0000,0000,,What's happening here \Nis that down here, Dialogue: 0,0:04:21.31,0:04:24.27,Default,,0000,0000,0000,,when we position the ellipses, Dialogue: 0,0:04:24.71,0:04:31.14,Default,,0000,0000,0000,,we have {\i1}x - 50{\i0} and {\i1}y - 50{\i0},\Nand then {\i1}x + 100{\i0} and {\i1}y - 60{\i0}, Dialogue: 0,0:04:31.68,0:04:35.58,Default,,0000,0000,0000,,So even if our face size \Nis only 50 pixels, Dialogue: 0,0:04:35.93,0:04:40.87,Default,,0000,0000,0000,,we're still having the eye positioned \Nat -50 pixels to the center, Dialogue: 0,0:04:41.08,0:04:43.60,Default,,0000,0000,0000,,which is going to make it off the face. Dialogue: 0,0:04:43.74,0:04:47.77,Default,,0000,0000,0000,,So, we need for 50 and 100 \Nand all these numbers here Dialogue: 0,0:04:47.90,0:04:51.55,Default,,0000,0000,0000,,all of these should also be fractions\Nof the {\i1}faceSize{\i0}, Dialogue: 0,0:04:51.55,0:04:56.28,Default,,0000,0000,0000,,so that when the {\i1}faceSize{\i0} changes,\Nthe amount that the eyes are offset Dialogue: 0,0:04:56.28,0:04:57.77,Default,,0000,0000,0000,,and the mouth is offset, Dialogue: 0,0:04:57.77,0:05:00.64,Default,,0000,0000,0000,,those numbers should also change. Dialogue: 0,0:05:02.35,0:05:04.97,Default,,0000,0000,0000,,So, to show you what I mean, \Nlet's do the first eye. Dialogue: 0,0:05:05.21,0:05:08.37,Default,,0000,0000,0000,,{\i1}x - 50{\i0}. So, {\i1}x - 50{\i0} pixels. Dialogue: 0,0:05:08.37,0:05:12.40,Default,,0000,0000,0000,,This means it should be 50 pixels\Nto the left of the center of the face. Dialogue: 0,0:05:12.78,0:05:15.20,Default,,0000,0000,0000,,Well, what we actually want now\Nis to use the fraction, Dialogue: 0,0:05:15.20,0:05:19.69,Default,,0000,0000,0000,,so it's going to be {\i1}faceSize/6{\i0}. Dialogue: 0,0:05:19.89,0:05:22.37,Default,,0000,0000,0000,,So, one sixth the size of the face. Dialogue: 0,0:05:22.100,0:05:28.68,Default,,0000,0000,0000,,Cool. And then 50 \Nwill be also {\i1}faceSize/6{\i0}. Dialogue: 0,0:05:29.53,0:05:31.35,Default,,0000,0000,0000,,So, now if we resize, Dialogue: 0,0:05:31.93,0:05:35.47,Default,,0000,0000,0000,,notice how that eye \Nis perfectly positioned. Dialogue: 0,0:05:35.91,0:05:38.40,Default,,0000,0000,0000,,Good eye, Winston! Good eye. Dialogue: 0,0:05:38.90,0:05:41.08,Default,,0000,0000,0000,,The other eye still needs\Nsome help though. Dialogue: 0,0:05:41.32,0:05:47.93,Default,,0000,0000,0000,,So 100; that'll be {\i1}faceSize/3{\i0}, \Nso one third the size of the face, Dialogue: 0,0:05:48.29,0:05:53.32,Default,,0000,0000,0000,,and 60 is one fifth the size of the face,\Nso {\i1}faceSize/5{\i0}. Dialogue: 0,0:05:54.05,0:05:57.19,Default,,0000,0000,0000,,Great. Let's resize it, very nice. Dialogue: 0,0:05:57.19,0:06:00.32,Default,,0000,0000,0000,,We still have a problem with our mouth, Dialogue: 0,0:06:00.32,0:06:02.10,Default,,0000,0000,0000,,so we'll go down to the mouth. Dialogue: 0,0:06:02.30,0:06:06.54,Default,,0000,0000,0000,,This one is maybe {\i1}faceSize/6{\i0} again, Dialogue: 0,0:06:07.17,0:06:10.49,Default,,0000,0000,0000,,and this one is about {\i1}faceSize/7{\i0}. Dialogue: 0,0:06:11.32,0:06:15.56,Default,,0000,0000,0000,,All right, now everything is done \Nproportionally. Let's check it out. Dialogue: 0,0:06:15.56,0:06:18.66,Default,,0000,0000,0000,,Woo! Now we can make Winston really small, Dialogue: 0,0:06:19.15,0:06:22.49,Default,,0000,0000,0000,,and his eyes and mouth \Nare still inside his face! Dialogue: 0,0:06:23.13,0:06:26.69,Default,,0000,0000,0000,,I'm sure Winston \Nis really happy about that. Dialogue: 0,0:06:26.82,0:06:28.04,Default,,0000,0000,0000,,All right! Yay! Dialogue: 0,0:06:28.04,0:06:29.80,Default,,0000,0000,0000,,So, let's review what we're doing here. Dialogue: 0,0:06:31.38,0:06:33.24,Default,,0000,0000,0000,,At the top, we have our variables. Dialogue: 0,0:06:33.24,0:06:37.04,Default,,0000,0000,0000,,We start off with a variable \Nthat's just storing a number: 200. Dialogue: 0,0:06:37.24,0:06:39.100,Default,,0000,0000,0000,,Then, we make our {\i1}mouthSize{\i0} \Nand {\i1}eyeSize{\i0} variables Dialogue: 0,0:06:39.100,0:06:43.25,Default,,0000,0000,0000,,be dependent on that number\Nas fractions of that number, Dialogue: 0,0:06:43.35,0:06:45.85,Default,,0000,0000,0000,,so that if {\i1}faceSize{\i0} is currently 200, Dialogue: 0,0:06:45.91,0:06:47.81,Default,,0000,0000,0000,,then {\i1}mouthSize{\i0} will be 100. Dialogue: 0,0:06:47.84,0:06:50.43,Default,,0000,0000,0000,,But, if we change {\i1}faceSize{\i0} to 300, Dialogue: 0,0:06:50.43,0:06:53.43,Default,,0000,0000,0000,,then {\i1}mouthSize{\i0}\Nwould suddenly be 150, Dialogue: 0,0:06:53.73,0:06:55.60,Default,,0000,0000,0000,,so it's always changing in proportion. Dialogue: 0,0:06:56.65,0:06:59.62,Default,,0000,0000,0000,,Then, down here, \Nwhen we calculate our offsets, Dialogue: 0,0:06:59.62,0:07:01.27,Default,,0000,0000,0000,,we're also using fractions, Dialogue: 0,0:07:01.27,0:07:06.19,Default,,0000,0000,0000,,because we want the offsets \Nto also be changing Dialogue: 0,0:07:06.19,0:07:08.58,Default,,0000,0000,0000,,proportional to the {\i1}faceSize{\i0}. Dialogue: 0,0:07:08.58,0:07:10.45,Default,,0000,0000,0000,,We basically just want to make it Dialogue: 0,0:07:10.45,0:07:14.98,Default,,0000,0000,0000,,so we just have this one variable\Nthat affects everything. Dialogue: 0,0:07:14.98,0:07:18.07,Default,,0000,0000,0000,,We can do that with variables \Nand variable expressions. Dialogue: 0,0:07:19.89,0:07:21.24,Default,,0000,0000,0000,,So, now that we understand Dialogue: 0,0:07:21.24,0:07:24.16,Default,,0000,0000,0000,,how to make variables dependent\Non the values of other variables, Dialogue: 0,0:07:24.16,0:07:26.41,Default,,0000,0000,0000,,we can do way more with our programs. Dialogue: 0,0:07:26.43,0:07:30.47,Default,,0000,0000,0000,,Let's celebrate \Nby making Winston huge! Dialogue: 0,0:07:30.47,0:07:33.32,Default,,0000,0000,0000,,Go Winston, come on, \Nkeep going! Keep going! Dialogue: 0,0:07:33.93,0:07:39.41,Default,,0000,0000,0000,,Never stop!! \NKeep going! Naaaaaa!