8000 [css-color-4] Percentage reference ranges for `lab()`/`oklab()`/`lch()`/`oklch`/`color()` · Issue #7064 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-color-4] Percentage reference ranges for lab()/oklab()/lch()/oklch/color() #7064

@svgeesus

Description

@svgeesus

For the call, to see the full proposal in one place, the percentages would be explicitly defined so that 0% to 100% maps as follows::

  • lab.L: [0, 100]
  • lab.a: [-125, 125]
  • lab.b: [-125, 125] (a and b have the same range, for simplicity)
  • lch.c: [0, 150]
  • oklab.L: [0, 1.0]
  • oklab.a: [-0.4, 0.4]
  • oklab.b: [-0.4, 0.4] (see above re: a and b)
  • oklch.c: [0, 0.4]
  • xyz, xyz-d50, xyz-d65: [0, 1.0]
  • predefined RGB: [0, 1.0] (not a change, but a clarification)

No-one mentioned hue as a percentage so it remains an angle, in degrees by default if no unit is given.

This gives useful ranges for percentages on all colors, roughly covering the display-p3 gamut plus a bit, and should minimize the errors in implementations where something was either not divided by 100, or was and shouldn't be, etc (Safari and color.js and PostCSS all had this type of error at various points).

It also means people can paste in lab/lch/oklab/oklch values from other software (which does not use percents) without getting an error and without having to remember if L is [0..1] or [0..100].

lch(29% 66.5 327) == lch(29% 44.33% 327) == lch(29 66.5 327)
oklch(58% 0.11 110) == oklch(58% 27.5% 110) == oklch(0.58 0.11 110)
color(xyz-d65 0.9504 1.0000 1.0888) == color(xyz-d65 95.04% 100.00% 108.88%)

Originally posted by @svgeesus in #6741 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0