Questions tagged [hsl]

HSV is cylindrical color model that determines colors by hue (0°-360°), saturation (color intensity) and lightness (from black over the color to white).

The HSL model describes colors in terms of hue, saturation, and lightness (also called luminance). (Note: the definition of saturation in HSL is substantially different from HSV) The model has two prominent properties:

  • The transition from black to a hue to white is symmetric and is controlled solely by increasing lightness

    • Shading and tinting are controlled by a single value, lightness
  • Decreasing saturation transitions to a shade of gray dependent on the lightness, thus keeping the overall intensity relatively constant

    • Tones are controlled by a single value, saturation

The properties mentioned above have led to the wide use of HSL, in particular, in the CSS3 color model. As in HSV, hue corresponds directly to the concept of hue in the Color Basics section. The advantages of using hue are

  • The relationship between tones around the color circle is easily identified
  • Shades, tints, and tones can be generated easily without affecting the hue

http://xahlee.info/js/i/HSL_color_model.png

Lightness combines the concepts of shading and tinting from the Color Basics section. Assuming full saturation, lightness is neutral at the midpoint value, for example 50%, and the hue displays unaltered. As lightness decreases below the midpoint, it has the effect of shading. Zero lightness produces black. As lightness increases above 50%, it has the effect of tinting, and full lightness produces white.

At zero saturation, lightness controls the resulting shade of gray. A value of zero still produces black, and full lightness still produces white. The midpoint value results in the "middle" shade of gray, with an RGB value of (128,128,128).

As saturation decreases, it produces tones of the reference hue that converge on a shade of gray that is determined by the lightness. This keeps the total intensity relatively constant.


Note that the physical nature of additive color prevents the scheme from working exactly except for hues halfway between the primary and secondary hues. However, the total intensity of the tones resulting from decreasing saturation are much closer than tinting alone, as in HSV.

265 questions
245
votes
25 answers

HSL to RGB color conversion

I am looking for an algorithm to convert between HSL color to RGB. It seems to me that HSL is not very widely used so I am not having much luck searching for a converter.
hhafez
  • 38,949
  • 39
  • 113
  • 143
70
votes
4 answers

RGB to HSL conversion

I'm creating a Color Picker tool and for the HSL slider, I need to be able to convert RGB to HSL. When I searched SO for a way to do the conversion, I found this question HSL to RGB color conversion. While it provides a function to do conversion…
akinuri
  • 10,690
  • 10
  • 65
  • 102
67
votes
7 answers

CSS: lighten an element on hover

Assuming an element is at 100% saturation, opacity, etc... how can I have its background become slightly lighter when it is hovered? The use case is that I'm allowing a user to hover over any element on a page. I don't want to go around determining…
Don P
  • 60,113
  • 114
  • 300
  • 432
64
votes
5 answers

HSB vs HSL vs HSV

I am making a Color class as a part of a very basic graphics API in c++. So I decided to take a look at Microsoft's .NET framework and noticed that their Color class has functions for HSB. Then I started a research to determine whether I should…
Giwrgos Tsopanoglou
  • 1,165
  • 2
  • 8
  • 15
28
votes
4 answers

CSS Filter as a color modifier for one image

Is it possible to change, with the CSS Filter methods like HueRotate, Saturation, and Brightness, the color of a PNG drawn totally white? Like Photoshop's color overlay effect, but in CSS. This would be a good solution to avoid creating lots of…
Mateus Leon
  • 1,381
  • 1
  • 14
  • 21
26
votes
9 answers

Color Theory: How to convert Munsell HVC to RGB/HSB/HSL

I'm looking at at document that describes the standard colors used in dentistry to describe the color of a tooth. They quote hue, value, chroma values, and indicate they are from the 1905 Munsell description of color: The system of colour notation …
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
22
votes
6 answers

How can I use the HSL colorspace in Java?

I've had a look at the ColorSpace class, and found the constant TYPE_HLS (which presumably is just HSL in a different order). Can I use this constant to create a Color from hue, saturation, and luminosity? If not, are there any Java classes for…
Eric
  • 95,302
  • 53
  • 242
  • 374
20
votes
4 answers

Why does greyscale work the way it does?

My original question I read that to convert a RGB pixel into greyscale RGB, one should use r_new = g_new = b_new = r_old * 0.3 + g_old * 0.59 + b_old * 0.11 I also read, and understand, that g has a higher weighting because the human eye is more…
Delan Azabani
  • 79,602
  • 28
  • 170
  • 210
19
votes
9 answers

Convert HSB/HSV color to HSL

How do I convert HSB color to HSL? Photoshop shows HSB color in its color picker. HSB color cannot be used in CSS, but HSL can. I tried this JS: function hsb2hsl(h, s, b) { return { h: h, s: s, l: b-s/2 } } But hsb2hsl(0, 100, 50).l…
NVI
  • 14,907
  • 16
  • 65
  • 104
19
votes
3 answers

Why doesn't hue rotation by +180deg and -180deg yield the original color?

By reading HSL/HSV color theory, I get the impression that hue component is a cyclical attribute that repeats every 360 degrees and can be changed independently of saturation and lightness/value. Correct me if I am wrong, but these statements…
Maros Urbanec
  • 443
  • 4
  • 11
18
votes
2 answers

What do the color() and l() function in a CSS value mean?

Today I encountered some code when digging in the Ghost code. I'm trying to create the same styling in my React app after extracting data from the API. I found this: :root { /* Colours */ --blue: #3eb0ef; --green: #a4d037; --purple:…
Robert Tirta
  • 2,593
  • 3
  • 18
  • 37
18
votes
4 answers

Why doesn't this Javascript RGB to HSL code work?

I found this RGB to HSL script over at http://www.mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript. I can't find any other small decent ones. The issue is that this code doesn't even really work. Would…
Kyle Hotchkiss
  • 10,754
  • 20
  • 56
  • 82
16
votes
1 answer

HEX to HSL convert javascript

Hello I'm trying to create HEX to HSL converter function. I know that at first I should convert HEX to RGB and then from RGB to HSL. I've done so using some script from StackOverflow. S and L is working correctly but H (hue) is not. I do not know…
BT101
  • 3,666
  • 10
  • 41
  • 90
16
votes
6 answers

Algorithm for Hue/Saturation Adjustment Layer from Photoshop

Does anyone know how adjustment layers work in Photoshop? I need to generate a result image having a source image and HSL values from Hue/Saturation adjustment layer. Conversion to RGB and then multiplication with the source color does not work. Or…
lechec
  • 839
  • 1
  • 8
  • 17
11
votes
3 answers

Why does the CSS filter hue-rotate produce wierd results?

I'm trying to emulate Photoshop's "Color Overlay" using CSS filters, and while doing so, found out the CSS filters operate on colors as consistently as an epileptic seizure. Consider the color #FF0000. If we rotate its hue by 120deg, we should get…
Camilo Martin
  • 37,236
  • 20
  • 111
  • 154
1
2 3
17 18