Skip to content

Lightness out of range #106

@waywardmonkeys

Description

@waywardmonkeys

There is a test in svgtypes for when HSL values are out of range from parse time.

It expects hsl(800, 150%, -50%) to result in rgba(0, 0, 0, 255) as the lightness is clamped to 0, and so the value is a black color.

While the CSS Color Module 4 spec says that, when parsing HSL, saturation is clamped, it does not say it about lightness.

  • Section 4.2 does say to clamp alpha.
  • Section 5.1 does say to clamp r, g, and b when parsing rgb().
  • Section 7 says to clamp saturation for HSL.
  • Section 9.3 says to clamp L for Lab and Lch.
  • Section 9.4 says to clamp L for OkLab and OkLch.
  • Section 13.2 says that when gamut mapping to ran rgb destination, the out of range lightness values should be handled by resulting in either black or white colors.

Even if we clamp at parse time, we'd have to think also about what to do when the lightness has been modified (like via map_lightness) and is now out of range due to calculations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions