Skip to content

[css-color] hsl values - integer or number? #506

Description

@MSP-Greg

I believe the current wd does a good job of explaining hsl vs rgb. See 6. HSL Colors: hsl() and hsla() functions, and the following section (6.1) on conversion.

What it does not address is how an algorithm for hsl to rgb conversion should handle numbers, as opposed to 'integer' values. I believe the spec refers to hsl using 'numbers', and numbers are not restricted to being integers, see CSS Values and Units Module Level 3 - 4.2 Real Numbers: the type.

I checked four browsers for conversion from hsl to rgb (using s = 100%, l = 50%). In this restricted 'color space', rgb (1,530) has 4.25 times the resolution of hsl (360) when hsl is computed using integer values.

So I checked the browsers using a hue (h) value that varied from 0 to 6.9 by tenths.

I found three different algorithms being used, three displayed only a green value that was a 'rounded multiple' of 4.25 (0, 4, 8, 12, 17, 21, 25). Of the three, two truncated, one rounded. Only one browser had all green integer values.

See https://msp-greg.github.io/ct-hue-sat.html for the test I used.

I did check that the painted rgb color matched the reported color.

Given that monitor technology has changed quite a bit since hsl was introduced in 2003 or so, I think it would be helpful for hsl to have the same color range as rgb. Hence, can the spec reflect that?

Thanks for your work...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions