In CSS, can HSL values ​​float?

The CSS3 specification only states that:

The format of the HSLA color value in functional notation is: "hsla (followed by a hue in degrees, saturation and lightness as a percentage), and then").

I have to understand that these values ​​will not be interpreted as integers, but as a float? Example:

hsla(200.2, 90.5%, 10.2%, .2)

This would dramatically expand the smaller (compared to RGB) range of colors covered by HSL.

This seems to work fine in Chrome, although I don't know if they simply parse it as an INT value or what.

+6
source share
3 answers

HSL values ​​are converted to hexadecimal RGB values ​​before being transferred to the system. Before the device, you can copy any received RGB value that is outside the "device gamut" - the range of colors that can be displayed - up to the displayed value. RGB values ​​are indicated in hexadecimal. This is a specific algorithm for browsers to convert HSL values ​​to RGB values. Rounding behavior is not specified by the standard - and there are many ways to round it off, because there is no built-in rounding function in C or C ++.

 HOW TO RETURN hsl.to.rgb(h, s, l): SELECT: l<=0.5: PUT l*(s+1) IN m2 ELSE: PUT l+sl*s IN m2 PUT l*2-m2 IN m1 PUT hue.to.rgb(m1, m2, h+1/3) IN r PUT hue.to.rgb(m1, m2, h ) IN g PUT hue.to.rgb(m1, m2, h-1/3) IN b RETURN (r, g, b) 

Of the proposed recommendation

In other words, you should be able to represent the same range of colors in HSLA, as you can imagine in RGB using fractional values ​​for HSLA.

+3
source

I don’t know for sure, but it makes sense to just insert some floating numbers and see if this works? it takes two seconds to try with a decimal point and without ..

+1
source

AFAIK, each browser passes them to INT. May be. If I am mistaken, you still cannot tell the difference. If this is really important, why not just take screenshots, open them in Photoshop or use the on-screen color meter. No one here will have a final answer without checking it, and it takes 2 minutes to test ... so ...

+1
source

Source: https://habr.com/ru/post/886273/


All Articles