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

Converting hsl to hex in python3

I have the following string taken from the atom one-dark syntax: one_dark_syn = """ @hue-1: hsl(187, 47%, 55%); // <-cyan @hue-2: hsl(207, 82%, 66%); // <-blue @hue-3: hsl(286, 60%, 67%); // <-purple @hue-4: hsl( 95, 38%, 62%); //…
James Draper
  • 5,110
  • 5
  • 40
  • 59
3
votes
3 answers

How to Optimize execution time for RGB to HSL conversion function?

I've created this function to convert RGB color to HSL color. It works perfect. But I need to make it run faster, because it's used to replace colors on a canvas, and I need to reduce the time of replacement. Since the image contains 360k pixels…
Elias Soares
  • 9,884
  • 4
  • 29
  • 59
3
votes
1 answer

Calculation (algorithm) to mix 3 hsl colors

I am building a free real color mixer for 3 colors. To feel real I first convert hex or rgb to hsl and calculate with h, s, l values. I figured out to mix 2 colors: function hslMixer2c(hsl10,hsl11,hsl12,hsl20,hsl21,hsl22,amount1,amount2) { // read…
Harry
  • 786
  • 1
  • 8
  • 27
3
votes
2 answers

Trying to use variables in HSL function (color functions take numbers as parameters)

I'm getting this error while trying to compile a HSL function: http://codepen.io/anon/pen/GJVbzB?editors=010 @baseColor: #003459; @randomVar: `Math.floor(Math.random()*10 + 90).toString()`; @color: ~"@{randomVar}%"; @new: hsl(hue(@baseColor),…
Chriss
  • 323
  • 1
  • 2
  • 10
3
votes
2 answers

Tinting Towards or Away from a Hue By a Certain Percentage

I'm trying emulate the Tint Effect of Open XML. What it does is change the hue of pixels in an image by shifting the hue. It takes 2 parameters: 1) the hue (in degrees) and 2) the amt (the amount, a percentage). It is #2 that I'm having issues with.…
Todd Main
  • 28,951
  • 11
  • 82
  • 146
3
votes
2 answers

seaborn husl or hsl color palette is not working: remains default black and white colors

I am in need of a circular colormap, and came across this answer which describes using seaborn to import the husl system. I am trying to replicate the simple usage the example demonstrates, but I can't get my image to show up in color. It always…
S E Clark
  • 423
  • 4
  • 15
3
votes
1 answer

HSL Colors to Pigmentation

I have recently been working on a color picker application which allows an user to pick a hue, a saturation and the lightness of a color. After the user has decided on a color I give the user different color schemes that go with the chosen color.…
lomas09
  • 1,114
  • 4
  • 12
  • 28
3
votes
2 answers

Generate a saturation/brightness mask using gradients

I would like to know if it's possible to generate a mask of saturation+brightness that are used in color pickers for instance (something like http://johndyer.name/lab/colorpicker/refresh_web/colorpicker/images/map-hue.png) but using only…
Stéphane. D.
  • 181
  • 2
  • 9
3
votes
4 answers

linearRGB conversion to/from HSL

Does anyone know of a way to get HSL from an linearRGB color (not an sRGB color)? I've seen a lot of sRGB<->HSL conversions, but nothing for linearRGB<->HSL. Not sure if it is fundementally the same conversion with minor tweaks, but I'd appreciate…
Todd Main
  • 28,951
  • 11
  • 82
  • 146
3
votes
2 answers

Faster algorithm to change Hue/Saturation/Lightness in a bitmap

I am trying to filter a Bitmap image to increase or decrease Hue, Saturation, and Lightness values. My code is working perfectly, but it is slow. I am locking two bitmaps in memory, the original source and the current destination. The user can move…
Trevor Elliott
  • 11,292
  • 11
  • 63
  • 102
3
votes
3 answers

HSL Interpolation

If the hue component of my HSL color is in degrees, how can I correctly interpolate between two hues? Using (h1 + h2) / 2 does not seem to produce desirable results in all cases. Here are two examples that illustrate why: Let: red = 0° yellow =…
Scott
3
votes
2 answers

RGB color to HSL bytes

I've seen some implementations for converting RGB to HSL. Most are accurate and work in both directions. To me its not important that it will work in 2 directions (no need to put back to RGB) But i want code that returns values from 0 to 255 max,…
user613326
  • 2,140
  • 9
  • 34
  • 63
3
votes
1 answer

Is HSL conversion exact?

I have yet to find an algorithm/implementation that can convert rgb(0, 96, 255) to HSL and back, without ending up with a slightly different value (rgb(0, 98, 255)). This means everyone's algorithms are broken (including Wolfram|Alpha)—or that HSL…
Teddy Cross
  • 321
  • 2
  • 12
2
votes
1 answer

howto use imagemagick in powershell

I'm trying to convert a bat file into a powershell script. But I cannot solve the imagemagick command to determine if the photo is blackwhite. Can you assist me ? w. batfile : for %%f in (*.jpg) do ( %%f for /f %%i in ('magick "%%f" -colorspace HSL…
woef
  • 57
  • 2
  • 7
2
votes
1 answer

CSS filter: use hue rotation to change certain colors only (like Photoshop Hue/Saturation)

I was wondering if it is possible to perform a hue/saturation color transformation, using css/svg filters, in the same way that Photoshop Hue/Saturation works. Essentially, from what I've read, Photoshop internally converts all pixels from an RGB…
Marco Couto
  • 317
  • 5
  • 12