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

Making a dynamic gradient with HSL or RGB

I have a standard 50-state map built with d3 in which I'm dynamically coloring states according to various datasets. Whatever the dataset, the values are normalized on a scale of 0 to 1, where 1 corresponds to the state with the highest value. I'm…
Chris Wilson
  • 6,599
  • 8
  • 35
  • 71
1
vote
1 answer

OpenCL RGB->HSL and back

Ive been through every resource and cant fix my problem. My host code calls the rgb2hsl kernel, then calls the hsl2rgb kernel. I should end up with the same image that I started with, but I do not. My new image hue is off in certain areas. The red…
user84564
  • 31
  • 3
1
vote
1 answer

How to use HSLA colors with RMagick?

How to set an arbitrary HSLA color instead of gray20? draw = Magick::Draw.new draw.font_family = 'arial' draw.pointsize = 12 draw.gravity = Magick::CenterGravity draw.annotate(@canvas, size,size, x,y, text) { self.fill = 'gray20' } Also, using…
B Seven
  • 44,484
  • 66
  • 240
  • 385
1
vote
3 answers

Converting RGBA, HSL and HSLA colors to RGB (or in a java.awt.Color object)

I'm looking for a description of algorithms for converting RGBA, HSL and HSLA colors to RGB color, or a library for converting them in an java.awt.Color object. Can you help me?
1
vote
1 answer

Converting between RGB and HSL/HSV: What to do with overflows?

I've implemented some functions according to the HSL->RGB and HSV->RGB algorithms. They mostly work fine, but I'm not sure what is the right thing to do then a color component overflows as a result of the conversion. E.g., the red component ends up…
GSerg
  • 76,472
  • 17
  • 159
  • 346
1
vote
1 answer

why isn't this HSL to RGB conversion function working?

Okay, I have written a function that should convert HSL color value to RGB. I have rewritten it in PHP according to this script: http://www.easyrgb.com/index.php?X=MATH&H=19#text19 This is what I have: function HSL2RGB($h, $s, $l){ function…
nkcmr
  • 10,690
  • 25
  • 63
  • 84
1
vote
0 answers

How to create lut for rgb to hsl conversion

I need to do a rgb to hsl and vice versa conversion using shaders.. I tried to do all programmatically but it is too slow... So i read about lookup table for conversion, LUT, but i don't know how to create it and what it has to contain... I need…
Esses77
  • 86
  • 2
  • 7
1
vote
1 answer

Changing bitmap color/hue efficiently in Android

I am using the following method to change the hue of a bitmap: public Bitmap changeHue( Bitmap source, double hue ) { Bitmap result = Bitmap.createBitmap( screenWidth, screenHeight, source.getConfig() ); float[] hsv = new float[3]; …
Mikko P.
  • 41
  • 1
  • 8
0
votes
1 answer

How to animate scroll progress bar color with framer motion useScroll?

I successfully implemented a scaling scroll progress bar using framer motion, but I also want the color to change as the bar fills up. So it would start at hsl(216, 100%, 50%), empty/small bar, and end at hsl(156, 100%, 50%), full bar. Below is how…
0
votes
1 answer

How can I accurately reverse this HSL formula using JavaScript?

This formula works perfectly for obtaining Lightness and Saturation from an X/Y position within a rectangle. (Thanks to Collin Henderson.) let hsv_value = 1 - (posy / 100); let hsv_saturation = posx / 100; let lightness = (hsv_value / 2) * (2 -…
atat
  • 19
  • 4
0
votes
0 answers

How to compute Color Schemes on the RYB model?

On the RGB/CMY model it's easy, as they use the same color wheel as the HSL model. Therefore, given the Hue value on the HSL model, you just need to increase it by 180 (modulo 360) to obtain the complementary color, or increase and decrease by 120…
0
votes
0 answers

How to find-out the ratio between the HSL based darken (Sass) function and the RGB based darken function

I have an RGB based darken function that equally reduces the individual color channels by the given amount in percentage. /** * Darkens the given RGB color by the specified amount. * * **NOTE:** The algorithm used to darken the given color is…
Alex Pappas
  • 2,377
  • 3
  • 24
  • 48
0
votes
1 answer

How to change alpha of an HSL color if the color comes from a CSS custom property?

I have a list of HSL colors coded as CSS custom properties and I want to manipulate their alpha channel. What I have tried: :root { --color: hsl(25, 33%, 93%); } .test { box-shadow: ... hsla(var(--color), 1); } In the web browser debugger,…
Ferit
  • 8,692
  • 8
  • 34
  • 59
0
votes
0 answers

How to Synchronize both ways Input Values - h, s, l sliders & hsl code?

I have a hsl color tool that I need to improve with a missing functionality The tool has 4 parts sliders (range inputs for h, s, l) text boxes (text inputs = show/set h, s, l range values from/for each slider) text box for the output hsl…
Chris
  • 1
  • 3
0
votes
0 answers

Convert RGB QColor to HSL

code: QColor color = "#f0f0f0"; qDebug() << color; qDebug() << color.toHsl(); qDebug() << color.convertTo(QColor::Hsl); output: QColor(ARGB 1, 0.941176, 0.941176, 0.941176) QColor(AHSL 1, -1, 0, 0.941176) // hue == -1 here QColor(AHSL 1, -1, 0,…
Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51