Giter Club home page Giter Club logo

Comments (3)

nex3 avatar nex3 commented on May 30, 2024

This also raises the question for when we should allow users to construct these values. It's clear per the CSS spec that lab(110% 0 0) should be clamped, and clear that color.to-space(color(xyz 1 1 1), lab) should not be clamped, but what about like color.change(lab(0% 0 0), $lightness: 110%)? If we don't allow that, what do we do with color.change(color.to-space(color(xyz 1 1 1), lab), $a: 50%), since it already has an out-of-gamut lightness and that's not being explicitly changed?

@mirisuzanne I'm interested in your design thoughts here. I think I'm leaning towards allowing color.change() et al to produce out-of-gamut colors—basically going with the design principle that we never clamp except where the CSS spec explicitly mandates clamping. But I'm not strongly convinced of that yet.

from sass.

mirisuzanne avatar mirisuzanne commented on May 30, 2024

That's my instinct as well - let it happen, and let CSS resolve the outcome if authors don't do ggamut-mapping. But I'm not sure that I've thought through all the implications of that.

from sass.

nex3 avatar nex3 commented on May 30, 2024

This issue actually also exists for other channels in the latest spec: in legacy RGB, all three channels are clamped at parsed-value time; and in LCH and OKLCH, the lower bound of chroma is clamped at parsed-value time. We also currently clamp HSL's saturation and lightness channels and HWB's whiteness and blackness channels, but these are not specified (anymore) as being clamped.

Following the principle above that we should allow out-of-gamut colors as much as possible while only clamping where the spec explicitly mandates, we should:

  • Update the rgb() and rgba() functions to clamp their inputs, but not clamp conversions to RGB.
  • Update the lch() and oklch() functions to clamp the lower bound of their chroma.
  • Remove all clamping for HSL and HWB.
  • Serialize out-of-gamut legacy RGB colors as hsl(), since this can represent those values without being clamped at parsed-value time while also being compatible with older browsers. (I'm double-checking with @tabatkins that this will work as expected.)
  • Serialize LCH and OKLCH colors with negative Chroma values using the same XYZ conversion trick we use for out-of-gamut lightness in #3741.

from sass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.