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
2
votes
2 answers

Dynamically changing saturation in css

I am creating a stacked bar chart using jQuery a bunch of DIVs. The segments of each stack are colored with different shades of gray. I would like to encode an additional global value onto the bar chart by changing the saturation of the divs to…
Gene Golovchinsky
  • 6,101
  • 7
  • 53
  • 81
1
vote
0 answers

Animate background color's saturation or lightness using JQuery

I did a search, and I found a function that randomly changes RGB values only, namely http://buildinternet.com/2009/09/its-a-rainbow-color-changing-text-and-backgrounds/ However, I simply want to change a header color's HSL value (either saturation…
1
vote
1 answer

Set different backgroundcolor on numbers from an array in DOM Javascript

Im stucked in how to create this below; 1.Create an array with 10 numbers from 0 to 360 2. write out in DOM in an element of choice 3.Set the background color of each number, by using the number of HUE in (hue, saturation, lightness) //1 let nummers…
tocajossan
  • 41
  • 9
1
vote
2 answers

Which color space does linear-gradient() uses?

Which color space does CSS's linear-gradient() function uses, RGB, HSL or HSV and why ? Can I change the color space of my own choice ?
entropyfeverone
  • 1,052
  • 2
  • 8
  • 20
1
vote
1 answer

Substract SVG HSLA colours on intersection

I'm trying to make a kind of "heatmap". When two svg elements with color and opacity intersect, they get darker or unexpected colour on the intersection, i would like to substract those colours in HSLA scale so for example if i had a green ellipse…
imvenx
  • 194
  • 3
  • 10
1
vote
2 answers

Why Microsoft rescaled their HSL ranges to [0-240]?

I'm studying digital image processing in university, and now we're doing a work where we have to convert RGB values to HSL, and it has to be equal to the Microsoft Paint. When I finished the implementation I saw that it was not equal to Paint, and…
Ellyzeul
  • 23
  • 1
  • 5
1
vote
1 answer

Passing variables into HSL color values in Three.JS

I currently have 2 HSL colors set in my code: scene.background = new THREE.Color("hsl(0, 100%, 50%)"); var light = new THREE.AmbientLight("hsl(180, 100%, 50%)"); I'm trying to pass a variable for 'hue' from my CSS in. When I run this code, I'm able…
1
vote
1 answer

OpenCV converts HSL to RGB

I am using OpenCV python to convert a single HSL value to RGB value. Since there is no HSL2RGB flag, so I used HLS2RGB flag. I assumed HSL and HLS refers to the same color space but just flipping the S and L values. Is that right? So here is my…
Katherine Chen
  • 502
  • 2
  • 5
  • 14
1
vote
2 answers

Incorrect rgb to hue convertion

I'm trying to convert a rgb color to hsl in Java, i have searched for many codes that explain how you convert rgb to hsl, i now have saturation and lightness working, but the hue value is incorrect I am now trying to convert rgb to hsl and then…
Jaron
  • 13
  • 3
1
vote
3 answers

Convert hsl to hsv color codes and vice versa in Python

I'm currently trying to convert hsl color codes to hsv and vice versa in Python, but can't find an easy way to do this. I tried converting the codes indirectly by converting hsl to rgb and rgb to hsv using the colorsys package. Unfortunately, this…
Merle
  • 125
  • 1
  • 14
1
vote
1 answer

why the r in rgb value is not correct when converting rgb to hsl in colorsys package

import colorsys print(colorsys.rgb_to_hls(92/255, 137/255, 78/255)) [0.29378531 0.42156863 0.2744186] Saturation (S),Lightness (L) is correct(according this website), but Hue should 106, I am not sure where is problem?
4daJKong
  • 1,825
  • 9
  • 21
1
vote
0 answers

Sorting Hex Color in decreasing order of darkness in Java

I am looking for a method to sort a list of hex colors from dark to light / light to dark i.e all shades of red must be sorted like Dark Red to lighter red to pink. There might be shades of other colors in the list as well. I want to first show…
Falcon
  • 372
  • 4
  • 20
1
vote
1 answer

How should I connect my sliders to the article element in JavaScript?

I need to create an HSL slider that will change the background color of the article element in my HTML. However, I can't figure out how to connect the slider to the background color. I've been messing with it all day and reading but haven't come up…
1
vote
0 answers

dart/flutter: assign saturation of HSLColor after creation

Goal I'd love to do the following Convert Color to HSLColor; Customize the saturation of the color; Finally convert the HSLColor back to Color. Problems But it turns out that the HSLColor's properties including saturation are final. Then how do I…
kakyo
  • 10,460
  • 14
  • 76
  • 140
1
vote
1 answer

CSS Variable with HSL not recalculating

Situation I have the following definitions (simplified) in my CSS file. :root { --app-color-hue: 30; --app-color: hsl(var(--app-color-hue), 80%, 60%); } body { --app-color-hue: 145; background: var(--app-color); } I was expecting to use…