Working with interactive Radial Gradient
In the last lecture we created our first gradient %u2013 the linear gradient. In this lecture we move to a more complex type of gradient- a radial gradient. In this lecture we will learn how to create with it and understand how to control the two anchor points and radius of the gradient.
Keynotes:
- Two center points.
- Two circles %u2013 a sphere.
- Controlling and manipulating them.
Video Transcript
00:00Just like quadratic and bezier curves, the big difference between them is that there was more control points.
00:06That is true also with the radial gradient.
00:09While the radial gradient had two control points, or really from this color to that color,
00:15a radial has two center points instead, and you're talking about two circles instead of two points,
00:23which makes a lot more richness to colors.
00:26So we're going to see how to control and manipulate these circles to create radial gradients,
00:31a really interesting topic.
00:34Everything looks incredibly similar, but it's not.
00:37I changed the colors a bit, and I also duplicated our method.
00:40So our old method is right here already, and I'm calling it radial gradient, create radial gradient.
00:47If you look at it, you'll see a complete duplication of create linear gradient.
00:52I've just done that in between lectures and created the create radial gradient.
00:56Nothing changed beyond the fact that I changed the color here. Really small change.
01:00What I want to do is I want to actually create the radial gradient instead of creating the linear gradient.
01:05And as our name create radial gradient applies, the name of the creation process is also create radial gradient.
01:14Now, the same logic applies where you have two points, but besides those two points,
01:18between each point, we also need to send a radius.
01:22In our case, let me show you. So if I have a radius of 10 for the first point,
01:26and a radius of 40 for the next point, it's kind of important that the second radius will be larger in general.
01:33Let's take a look at it, because literally what we're talking about is the internal radial,
01:38the circle that defines position zero, the circle that defines position one.
01:42So by nature, you probably wouldn't want to put your 100 and then 40 because you're going to get a very odd outcome.
01:48So if I go ahead here and click it refresh and try to create this, it's not that I'm not allowed to do this.
01:54I totally could, but I'm going to be creating something completely different, something completely interesting,
02:00something not necessarily expected. So this is what happens when I'm creating a very interesting kind of layout.
02:09Now, I want to kind of walk through the steps here.
02:13So in general, I'm just going to go ahead here and set here, I'm going to go ahead and set here a radius of 10.
02:18And then I'm going to go to my larger radius, and I really want to make sure that no matter where I'm drawing,
02:23it's going to take the complete spectrum of our area.
02:27So to do that, I'm going to put my full width, so it's going to be for our radius, which is really big,
02:31making sure that we're going to flow out of our design in general, no matter what.
02:37Now, if I go ahead here and save this, and no matter if our points are closer, by the way,
02:41because if my points are closer here, it really doesn't matter, because our points just define the center point of these elements.
02:49So again, if I have here a circle, and this is the small one, its center point is right here.
02:54The larger circle in this area, its center point is right here.
02:58And the reason was because we drew the line and went from one side to the other.
03:01Now, in this case, when I'm going to go through and actually send here the whole width,
03:05it's going to be very hard for me to see the center point,
03:08and usually I'm going to be creating elements that are going to be a lot more natural and kind of like blending,
03:14like you could see in this scenario where we don't see the end of each point necessarily.
03:18Now, I want to go through O2 and continue this.
03:21I'm going to go ahead here and make it again small.
03:23So I'll have your 10, and I'm going to have your maybe 30, and let's go ahead and just show this point again.
03:28Now, if I go ahead here and save this and I create my radial,
03:32again, it's very, very weird constructs that I would be getting out of these type of manipulations
03:38when I'm working with smaller sizes, and it makes a lot of sense.
03:42The logic that applies here is that we're really working with, if it's out of the bound,
03:47then okay, so we're not drawing it at all.
03:49We're creating these conuses that are relatively small.
03:52So if I go ahead here and save this and flip it around,
03:54then my original circle that was supposed to be small would be larger.
03:58But again, I'm creating a conus because I'm creating an ending point in sight.
04:03Now, even before we resize this, because I want us to be able to look at these circles
04:07that have different center points,
04:09if instead of putting different center points, I stick to the same point,
04:13and I just said, hey, I want you to always be in point one,
04:16literally saying that the center point of circle one and circle two will be in the same place.
04:20What will happen is very interesting.
04:22So if I go ahead here and just run that for a second,
04:25you can see that I'm going to have a very clear and defined center point,
04:28and it's going to be overlapping each other accurately,
04:31exactly center point of each of the items,
04:33which is definitely a style that you might want to do
04:36when you're creating a radial gradient.
04:42Now, I urge you and encourage you to not just watch videos,
04:45but if this is not 100% clear,
04:47start playing with these values with point one and point two.
04:50I'm going to go ahead and end this with just changing here a little bit of stuff.
04:54I'm going to use the point one and point two and using the width,
04:57but instead I have a radius that is hard-coded and defined.
05:00What I want to do is I'm going to take my point one dot x
05:06and I'm going to subtract from it point two dot x,
05:08and I'm just going to make sure, because it has to be a positive value,
05:11I'm going to go to math abs.
05:13So that way, based on the drawing of the distance between the points,
05:17that's going to be also the size of our radial,
05:20of our internal smallest circle, the line that we drew.
05:23So if I go ahead here and save this and go back and click here on refresh,
05:27then I'll be able to see that if I draw this out,
05:30our inner circle is going to be, its radius is going to be the size of our length.
05:34And by the way, maybe we should even take this whole thing and divide it by two.
05:40So we're going to have a radius that will be the radius of the line that we drew
05:44or half of the line that we drew.
05:46So basically, what I'm saying here, in this case,
05:49if I drew this out from here to here,
05:51then our circle will be half of the size of our drawing,
05:53which will make it easier for us to see it in depth in its naturalness
05:57and it's all of its glory.
05:59So that's it.
06:00We've created gradients, both linear and radial,
06:03and now you could also throw in gradients inside of things that you create.
06:10In this lesson, we really completed everything to do with control points
06:14as we explored radial gradients.
06:16The next section, our last section in this title,
06:19is going to be dedicated to manipulating the whole canvas.
06:23See you in the next section.
