Hue. Saturation. Lightness. Alpha.
The second most common way to describe color on digital devices are based on three controllers: hue, saturation and lightness. RGB colors have a few limitations mainly that there hardware oriented based on 16 million color assumption and its harder to use %u2013 easy to understand but really hard to figure out colors with this system. There are a few other color profilers out there but the second one that is supported that is very nattily logical is the HSL. HSL is far more intuitive making it easier to control colors in a human friendly way.
Keynotes:
- When 16 Million is just not enough
- RGB is easy to understand but very hard to implement
- HSL harder to understand easier to integrate.
- Creating colors with a Hue, Saturation, Lightness and Alpha
- How many colors can we create with HSL?
properties: rgba, rgb, css3, colors
Video Transcript
00:01(music)
00:06- So, we've been talking about RGB colors, those
00:0816 million color representations for quite a while.
00:11And, as we said, it's a big limitation
00:13in the modern world that we live in, where
00:15monitors can display 30 to a million colors,
00:17and even more.
00:18So, how do we kind of future-proof web designs
00:22to enable them to display an endless amount of colors?
00:25And, that's exactly where HSL comes into the picture.
00:29HSL stands for hue saturation lightness.
00:33It is incredibly easy to work with, harder,
00:36maybe, to understand initially, so that's why
00:38we have this lecture.
00:39But, it's a lot easier to work with than RGB,
00:42because is easy to understand, but how do you
00:45create all those color mixes between red, green,
00:48and blue to try to create the color that you want?
00:50How do you create velvet with that color?
00:52Most people would not know how to answer that question.
00:55Contrary to that, HSL is incredibly easy.
00:57All you have to do is remember the H channel, the hue,
01:00decide the color of the hue, and then the saturation
01:03and lightness is then controlled really easily.
01:06And, we're gonna see that in action in this lecture.
01:07And, we won't forget to also talk about the alpha channel.
01:11By the end this lecture you're really gonna be
01:13future-ready for how to work with colors.
01:16Not only in CSS, but in general.
01:18How to treat colors, in general, in a really logical
01:22way that by the end of this lecture, you're gonna
01:23know how to work with colors a lot better
01:25than you did before.
01:27So, and I want to hear from you,
01:28because I know there are some colors that just not
01:30in CSS yet.
01:31They might be in CSS4, future CSS.
01:34Well, they're not there yet.
01:35What color do you work with?
01:36There're some TV displays, for example,
01:39that represent colors in four channels.
01:42CY, I don't even remember,
01:44but it's like four color channels, making it even
01:46more color variations that are possible.
01:49So, let me ask you a question.
01:50How many color combinations are possible using HSL?
01:53I'm not gonna give that answer in this lecture.
01:55You can do a Google search if you want to,
01:57but go ahead and tell us what do you think intuitively,
01:59or through a search.
02:00Both are valid.
02:01I wanna know how many colors could HSL represent.
02:07We continue into a new world of colors.
02:10And, up until now, all the colors we said we
02:13had a limit of real clear border limit of
02:1716 million colors.
02:19Now, these 16 million colors, we had a really interesting
02:22way of creating them if it was those 16 millions with those
02:26six digits to two, each represented each color, red,
02:29green, and blue.
02:31We saw another way representing the same type of
02:34RGB values, only this time setting the values
02:37directly as zero to 255, literally setting them all
02:42from zero through 55, 255, that is, and we saw
02:46that extra channel in our RGBA that enabled us to
02:50then define if we wanted to be RGB or RGBA.
02:55Now, in this case, let me just set it so we could actually
02:58see the colors changing there and we would see that
03:00it would go down in color.
03:02All right, the next thing I wanna look at is hue
03:04saturation brightness, which you will find it right here,
03:07hue saturation brightness, it's our fifth element,
03:10fifth blackshire really, and in this fifth element,
03:13you'll see that it's a very interesting,
03:15very different, very interesting.
03:18Did I say that already?
03:19So, ignore these, I didn't clean it up yet, but I'll
03:22probably continuing cleaning it up later, after
03:24this lecture.
03:25But, there are three items in general.
03:27Let's start from the RGB.
03:29Well, not RGB, sorry, from the HSL.
03:32So, we're starting from the HSL, and then the
03:34HSL we have here the first value,
03:36which is quite interesting.
03:37It starts from zero and it goes all the way to 360 when
03:41zero equals 360, and, by the way, also,
03:46all the way to 360 equals red.
03:49Now, the way it works is very simple.
03:51At zero, and 360, because it's basically like a circle,
03:55the value is 360, is basically angles,
03:58and the angle of 120, right in here if I get to it,
04:02122, 120, is that perfect green.
04:06The value right after that, the 240, is gonna be
04:09the perfect blue.
04:11So, 240 would be the perfect blue.
04:13So, we have here basically this gap that goes from
04:15red, climbing its way up, going up, turning to
04:20orange, continuing onwards and moving into the yellow
04:23region, moving on, and you can see that every step,
04:26you know, getting greener, and every step we have your
04:29different flows of this color, different flows
04:34and different perspectives of this basic color.
04:37Really, really sharp green at this stage.
04:39And as we continue and we explore it, it's getting light
04:42to this light beautiful blue, and so on, and so forth.
04:45You explore it, and one of the things you wanna do is
04:47get familiar with this gamut, this color system.
04:51So, that's the first property, it's called the
04:53H, it stands for, basically, hue.
04:56And the hue defines that color, that range from red
04:59all the way through red, going through it, all the different
05:01colors in the rainbow.
05:03The more advanced a browser is, the more advanced your-
05:08I say this, the more differences you'll see between
05:10those hues that are coming in there.
05:12It's very hard for us to see a lot of the changes between
05:14four, five, and four, four,
05:16but you might be one of lucky people that could.
05:18Or, it could be that you're display doesn't even
05:19display colors in such a level.
05:22Just like when you look into the blue sky.
05:25Some people see a really large array of different blues,
05:28and others just see blue.
05:29Let's move on to the next item.
05:31The next item after the hue is saturation.
05:34The idea behind saturation is how much of that color
05:37is saturated.
05:38From none at all, basically, devoid of that blue,
05:41devoid of channel color, to all the way completely
05:45exposed to that channel.
05:47Now, you could see that I'm just, we're using a different
05:49color here, just to show, but this is not a color,
05:51this is really just this output, or this diplay
05:55of how much is the color being presented.
05:58From completely dark, without the color, to all
06:02the way to full richness of the color.
06:04So, that's about the saturation.
06:06So, if you wanted a shade of blue, and then you wanted
06:08to inject in this some gray, then you'd probably gray
06:11it out a bit.
06:12Or, if you wanted it to be really bright, then you would
06:14give it all the full depth of that color.
06:17Last, but not least, is lightness.
06:20Now, the lightness, again, accepts a value between zero
06:22and 100, where zero means there's no light, which basically
06:26means that you would be in completely black, or all the way
06:29light, which would basically mean white.
06:32And, in our case, if we set it to 50%, then it means that
06:35it's gonna be neutral.
06:36And, it's basically gonna show that color.
06:38So, if I have the full saturation in the color,
06:40the full saturation, and I set my lightness to be at
06:4450%, then I'm gonna see that color very vividly,
06:49very vividly, really.
06:50And, as the values go up, from 50% towards that 70,
06:5480%, the more white will be injected into the color,
06:57the more we go into from the 50 and go below it,
07:00we'll see the more black is gonna
07:02be injected into the color.
07:04So, really, your controllers here is on one, you have
07:08the lightness which controls the black through white
07:11injection of colors, where in the middle, there's no
07:13black or white injected inside, where it's exactly at 50%.
07:18And, for your saturation, what you have is completely
07:22the color there or devoid of the color, which would put you
07:25a shade of gray.
07:26So, if I go ahead here and change the different colors,
07:27you'll see that you're not really seeing much of that
07:29color there in the background.
07:31Now, the reason you're not seeing that color in the
07:33background is because all of that color has been
07:34saturated out.
07:35So, really, it's this full color to gray,
07:40and it's really a range of that full color to that
07:42gray, where you then can control, you know you
07:45want more darkness to make it even grayer,
07:47do you want more lightness to make it more light.
07:50And that's your game, that's how you're playing
07:52and creating the colors.
07:53It's a lot more intuitive as you can see than RGB.
07:56Not only is it a lot more intuitive,
07:58it has a lot more controls, a lot more color
08:00combinations you can create with it.
08:02It's really endless, cause you have your percentages,
08:04and you can even put your dots in the percentage,
08:07and dots in the-
08:08It creates a really huge variety of color possibilities,
08:11endless, really amount of color possibilities.
08:14Now, beyond that, we also have an alpha channel so
08:16H's cell would be for, as we've said, hue saturation,
08:21lightness, and we also add an alpha channel,
08:23then we'll add the A in the end of it,
08:25which will enable us to also define how
08:27much visibility would the item have in total.
08:29And, in this case, again, it's from zero to one.
08:32So, we see the first value, as we've said,
08:34just to wrap this up, is a value between zero and 360,
08:38where zero and 360 are equal to the red, or where 120
08:42is green, where 240 is blue.
08:45And, we saw that for the saturation where the value
08:49of no color at all would be zero, and complete
08:51saturation of the color would be 100.
08:54And, last, but not least, for our lightness,
08:57we said that for our lightness, we have completely
08:59black at zero, 50% there's no color extra added in,
09:03and it's just the color itself, or completely light,
09:06which is basically an injection of the white into
09:10our element.
09:10Now, before we wrap this up, and I'm not gonna show
09:12it in the HTML itself, I'm gonna let you practice
09:16because the color is here, we've seen it really
09:18in essence, I wanna show you Photoshop.
09:20It doesn't really matter if you have Photoshop or not,
09:22if you've ever seen this color picker,
09:24now it will make a lot more sense.
09:26For our saturation, for our hue itself,
09:28we see that we have here basically a slide,
09:30that controls our hue, where all the way in the bottom
09:34is completely red,
09:35all the way on the top is completely red.
09:37Zero for our hue.
09:40All the way up to 360, which equates to zero in this case.
09:44So if I put here 360, basically exact same
09:46thing will turn to zero.
09:47For our saturation, if we set it to be 100%,
09:50you'll see that it's full saturation.
09:52The element is all the way in the end, here, again.
09:54So, for the hue itself, if I go ahead here,
09:56all the way it's 360 or zero, that's red.
09:59If I go for the saturation of the color from all
10:01the way red to white, or all the way red to black,
10:05here in the corner.
10:06So, this is really the control of the lightness,
10:08where lower would be a lower value in the lightness,
10:12and higher would be a higher value in our lightness.
10:16Last, but not least, we talked about the grayness.
10:19And the grayness is really, we would go here in
10:21diagonal, really, and in that diagonal we'll see
10:24that we have here this gray region's going on
10:26here in the color itself, where we could find
10:28all these different combinations.
10:29It's really, in essence, the same thing, that's
10:32what I'm just practically trying to say.
10:34Although, when we're working in HTML, aka in CSS,
10:38our controllers are three controllers.
10:40Hue, saturation, lightness, and also that alpha channel,
10:42if we wanna put an alpha channel as well.
10:45By the way, in general, if you don't have to have
10:47an alpha channel, don't use an alpha channel,
10:50because they always add to the taxing on any system,
10:53no matter how advanced it is, because it has to
10:56also consider to draw things behind it.
10:59So, that's something that we wanna avoid,
11:00and we won't unless we have to.
11:02If we have to have a transference such as maybe
11:05this item, we want things to be able to go underneath it
11:07and to be able to see it, and that's the only case
11:08where we would use an alpha channel.
11:10That's it, for all the different color variations that
11:14we have here currently in CSS3.
11:16In the next lecture, we're not walking away from colors
11:18but will continue into another topic, not a very
11:21heavy one, we're getting close to wrapping up with a few
11:24interesting lectures.
