The HSL colour space (and the closely related HSV space) store colours as 3 values:
- The Hue (H) indicates the basic colour, essentially the position of the colour on the colour wheel that goes from red to green to blue then back to red.
- The Saturation (S) controls how saturated the colour is. A value of 100% indicates a pure colour, 50% represents the same colour but mixed with grey, and at 0% the colour is pure grey.
- The Lightness (L) controls how light or dark the colour is. Lightness of 50% shows the basic colour at a medium level of lightness. If the L component increases towards 100%, the colour gets lighter and lighter until it eventually becomes white. If the L component decreases towards 0%. the colour gets darker and darker until it eventually becomes black.
This diagram shows the colour wheel of hue values. The hue can be expressed as an angle between 0 and 360 degrees, where 0 degrees is red, 120 degrees is green, and 240 degrees is blue:
Here is the effect of changing the saturation between 0% and 100% (with a hue of green and lightness of 50%). Notice that the basic colour remains the same:
Finally, here is the effect of changing the lightness between 0% and 100% (with a hue of green and saturation of 50%). Again, the basic colour remains the same:
HSL colours are useful in art and design applications, because they allow sets of related colours to be created very easily.
The HSB (hue, saturation, brightness) colour space uses the same definition of hue as HSL. Saturation and brightness behave differently, but can achieve the same range of colours as HSL.
The HSL model works well with the additive model (as used by RGB). HSB is based on a subtractive colour model, but generally CMYK is more useful for subtractive colours. HSB tends not to be used as often as HSL, so we will not cover it in detail.
You may also see the term HSV (hue, saturation, value). This is an alternative name for HSB.
2d arrays abstract data type alignment and angle animation arc array arrays bar chart bar style behavioural pattern bezier curve built-in function callable object chain circle classes clipping close closure cmyk colour combinations comparison operator comprehension context context manager conversion count creational pattern data science data types decorator design pattern device space dictionary drawing duck typing efficiency ellipse else encryption enumerate fill filter font font style for loop formula function function composition function plot functools game development generativepy tutorial generator geometry gif global variable gradient greyscale higher order function hsl html image image processing imagesurface immutable object in operator index inner function input installing iter iterable iterator itertools join l system lambda function len lerp line line plot line style linear gradient linspace list list comprehension logical operator lru_cache magic method mandelbrot mandelbrot set map marker style matplotlib monad mutability named parameter numeric python numpy object open operator optimisation optional parameter or pandas partial application path pattern permutations pie chart polygon positional parameter print product programming paradigms programming techniques pure function python standard library radial gradient range recipes rectangle recursion reduce regular polygon repeat rgb rotation roundrect scaling scatter plot scipy sector segment sequence setup shape singleton slice slicing sound spirograph sprite square str stream string stroke structural pattern subpath symmetric encryption template text text metrics tinkerbell fractal transform translation transparency triangle truthy value tuple turtle unpacking user space vectorisation webserver website while loop zip zip_longest