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

Any bug with hsla(0, 0%, 0%, 0), becoming hsla(0, 0, 0, 0)? (missing percent sign)

I set up a text color as hsla(0, 0%, 0%, 0) to hide it. But sometimes it became hsla(0, 0, 0, 0), which can't be executed by browser. I can fix this if I go the site with incognito mode. I have no idea if it's a bug in Chrome, from the server or…
chenghuayang
  • 1,424
  • 1
  • 17
  • 35
2
votes
1 answer

C# - Setting Custom Colors in a Color Dialog using RGB Values

I would think that using RGB to set the custom colors would be the default method, but that does not seem to be the case. This stackoverflow answer was very helpful in using named colors (such as red or blue) or hexadecimal values to set custom…
AARRGGHHH
  • 127
  • 4
  • 9
2
votes
1 answer

Coloursquare Algorithm

I'm writing a colourpicker in Javascript and having some degree of progress. However, I've noticed that the algorithm I am using to generate the colour space could be improved in order to fill the space more efficiently. I'm using HSL to generate…
Dan Prince
  • 29,491
  • 13
  • 89
  • 120
2
votes
2 answers

convert HSL or HSV to RGB via jquery

I'm looking to generate random "similar" colors using jquery. It is my understanding that the best way to approach this is using HSL or HSV, according to this question. The issue is I can't seem to figure out how to either… Use HSL or HSV with…
Derek Adair
  • 21,846
  • 31
  • 97
  • 134
2
votes
1 answer

How to apply HSB color filters to UIImage

I've been struggling for a few days for a project on UIImage colorization. The idea is that the app will embark a set of images that I will have to colorize with values retrieved from a webservice. Some sort of themes if you wish. The designer I…
Yonic Surny
  • 451
  • 6
  • 15
2
votes
2 answers

Given hue and saturation of a color, how to generate colors in evenly spaced relative luminance level?

Given hue and saturation of a color (H & S of HSL), how to generate colors in evenly spaced relative luminance level? E.g. Source: http://www.workwithcolor.com/hsl-color-schemer-01.htm If I give it a pure Red @ 50 relative luminance, how can I…
Henry
  • 32,689
  • 19
  • 120
  • 221
2
votes
1 answer

Problems converting HSL to RGB

I am trying to convert HSL values to RGB but I am getting strange results, if the hue value is about 180 then the resulting RGB is negative dependent on the lightness value. My implementation: public class HSLtoRGB { private static float…
Lerp
  • 2,957
  • 3
  • 24
  • 43
2
votes
1 answer

Why are the HSL values not what one would expect?

As the HSL vals presumably cycle through the rainbow, and there are 7 cardinal colors in that proverbial array of hues (ROYGBIV), the distance between each one, from 0 to 360, should be 51 or 52. So why do the colors here not correspond to what one…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
2
votes
2 answers

Turning RGB values into HSL values in a random Javascript

I have a random color overlay on the media-boxes of this site. http://www.reportageborsen.se/reportageborsen/wordpress/ I had some really good help from the mates here at stackoverflow wich resulted in this script: var getRandomInRange =…
fortes
  • 81
  • 1
  • 10
2
votes
1 answer

Replace colour tones with HSL + GD?

We are working with a base image that has three tones of blue (#645591, #6B90CA and #7BC8EF) with one user-chosen colour that will replace the first blue value (the base) and it will generate two tones for the extra two colours to be replaced. I've…
metrobalderas
  • 5,180
  • 7
  • 40
  • 47
2
votes
2 answers

OpenCV C++: Convert RGBA to HSL and then split channels

For some image segmentation work I'd like to use the lightness channel of an image in HSL color space. To accomplish this I convert a RGBA image to RGB and then so HSL. After the color conversion I split the image into it's color planes using…
dom
  • 11,894
  • 10
  • 51
  • 74
2
votes
4 answers

Can't convert from HSL to RGB

I have a problem with converting a color from HSL to RGB. I've written the following function: struct RGB { float r, g, b; }; RGB hslToRgb( float hue, float saturation, float lightness ) { RGB rgb1, rgbResult; float chroma = ( 1.0 -…
JavaRunner
  • 2,455
  • 5
  • 38
  • 52
2
votes
1 answer

HSL to RGB color conversion problems

I am fond of random generation - and random colors - so I decided to combine them both and made a simple 2d landscape generator. What my idea was is to, depending on how high a block is, (yes, the terrain is made of blocks) make it lighter or…
user1533320
2
votes
2 answers

Sorting list by color (Java)

I am looking to sort a list by "color distance." I am using the following function to calculate the distance between two colors: double colorDistance(Color c1, Color c2) { double rmean = (c1.getRed() + c2.getRed()) / 2; int r = c1.getRed() -…
Marty
  • 2,104
  • 2
  • 23
  • 42
2
votes
1 answer

How to calculate Hue, Saturation and Lightness values from a chosen color by input distance

Given a starting hex code, I would like to know the maths to calculate the linear values of lightness in ascending and descending order. Same for Hue and Saturation. It's kinda difficult for me to describe exactly what i want, forutnately i've found…
Renexandro
  • 464
  • 5
  • 13