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
4
votes
1 answer

Using a Sass variable mapped to an hsl value doesn't work when trying to use it with hsla

I have a Sass variable which mapped to an hsl value. When I try to use it with hsla to add a little transparency, doesn't work. I'm doing this: $white:hsl(100, 100%, 100%); .thing{ color:hsla($white,.9); } Using gulp-sass to build my CSS, I get…
fstorr
  • 119
  • 2
  • 5
4
votes
3 answers

Convert RGB array to HSL

A disclaimer first, I'm not very skilled in Python, you guys have my admiration. My problem: I need to generate 10k+ images from templates (128px by 128px) with various hues and luminances. I load the images and turn them into arrays image =…
NodeNodeNode
  • 744
  • 5
  • 23
4
votes
2 answers

How to set hsl color on CSSStyleDeclaration object?

How to set hsl color on CSSStyleDeclaration object? //CSS background-color: hsl(155,100%,30%); //JavaScript divElement.style.backgroundColor = ?; I don't want to use HEX value or color name in javascript. Please suggest. W3C standard link would be…
P K
  • 9,972
  • 12
  • 53
  • 99
4
votes
1 answer

HSL python syntax (PIL)

I'm having a difficult time using hsl color values in my code here... My goal is to change the opacity of a pixel in an image based on how often the coordinate's index occurs in a data set. I'm pulling data from a csv file, and the only error I'm…
acfletch53
  • 43
  • 1
  • 3
4
votes
1 answer

Button background appears 3% darker than it should be

I'm adding CSS to a Bootstrap-based web app, to match a PDF from a designer. There's a button image, whose background color Seashore reports as rgb(0,186,158) aka hsl(171,100,36%). So I set the background colour of the button to match the…
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
4
votes
1 answer

hsl color problem in Firefox

I am trying to declare the border of a div using hsl() like this: border: 2px solid hsl(0,200,105); I am using Firefox 3.5 and there is no border being rendered at all. The same code works perfectly if hsl() is replaced with rgb() I read somewhere…
KJ Saxena
  • 21,452
  • 24
  • 81
  • 109
4
votes
1 answer

How to convert RGB to HSL in C?

How do I convert RGB to HSL in C/C++? (Note: This is a (short) self-answer -- I posted it here so people can find it quickly with a search.)
user541686
  • 205,094
  • 128
  • 528
  • 886
3
votes
1 answer

How to convert an image to gray scale?

I want to do exactly like the above image via code (android). But I'm confused about the algorithm to do that. All i know is: With every pixel: Convert RGB to HSL ??? Convert HSL back to RGB Can anyone explain for me what to do in Step 2? Thanks…
Wayne
  • 6,361
  • 10
  • 46
  • 69
3
votes
2 answers

Convert RGB bytes to HSL and back?

Is there an algorithm for converting a RGB byte array to an HSL float array and back again? I have tried the one found here but it seems to have bugs.
Papa John
  • 3,764
  • 3
  • 26
  • 23
3
votes
0 answers

How do I find the hue (or HSL)/RGB value from an input type text using javascript?

Backstory: I made a website where you add routines in a timetable style. You select the time amount etc but also the colour of the routine block in the timetable. I've looked online on ways to gather RGB values but I was only able to find it after…
lm16
  • 61
  • 5
3
votes
1 answer

How to colorize via HSL colors?

I have an complex problem, but it could be solved via this little problem. I would like to make a colorizer, which works per pixel. I have a defined base color for the picture (the picture has some pixels with this color and a lot of other pixels,…
Roland Soós
  • 3,125
  • 4
  • 36
  • 49
3
votes
2 answers

Change HSL values of a bitmap using c#

I would like to know how i can change the HSL values of a bitmap using C#. It must be possible to load a bitmap and change the HSL values of it on every pixel.
3
votes
1 answer

Java Script: How can i pull the HSL value when a colour is selected from input type = 'color'?

I am so blank on this idek where to start. I am trying to make functions that will manipulate the H S L values once I get them. Mainly the light value, which is why I need it in HSL format. So once I get it, i would idealy like to create var h =…
Ed.wado
  • 33
  • 3
3
votes
1 answer

Obtain 50% of a color hex value without using transparency

I need to obtain the color value of a 50% lighter version of an existing color hex. However it has to be 100% opaque, I cannot use opacity, rgba, hexa or hsla. The scenario: I draw routes on a map, each one with a different color, based on a…
Renato Rodrigues
  • 165
  • 1
  • 10
3
votes
1 answer

Converting RGB to HSL in C++

Currently trying to convert RGB to HSL. Can't figure out where I'm going wrong but my H & S values shows as 0 which is the problem. Here is what I have: #include #include #include float Min( float fR, float fG, float fB…
IFKCode
  • 43
  • 1
  • 5