Code Monkey home page Code Monkey logo

coloraide-extras's People

Contributors

facelessuser avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

coloraide-extras's Issues

Hunter Lab ka kb wrong

I can't recall where we came up with our ka kb calculation, but it's not correct. I've figured out what it should be, and we now match locally the ka kb values as dictated by the Hunter Lab spec. We weren't super far off, but still noticably so.

Color Space: RYB

I was considering implementing RYB, but I'm currently unsure.

  1. The most popular algorithm that is used at times is the one laid out by Gosset and Chen, which highly favors more paint-like colors. It doesn't actually have a true black, but kind of a very dark reddish color. It also doesn't contain the entire sRGB spectrum.

    It also isn't reversible. Well, I say isn't reversible, but with some extensive calculations, you could probably reverse it, there just aren't any that are readily available or at least none that cleanly round trip, and even if they did, they do not contain the full sRGB gamut. But I guess they are not attempting to, so 🤷🏻 .

  2. Another attempt that can be found is this one, which can only be found using the Wayback machine, though there are implementations using it here and there. This seems to do an okay job and is reversible. I'm not 100% sure about its accuracy, but there is no formal spec, so 🤷🏻.

  3. Another attempt is found in some scientific papers. It advertises the approach as being reversible and is similar to option (2.).

  4. There are numerous other attempts out there that are less common where people take on of the above approaches and try to "fix" them to meet the requirements they think they should meet.

Without an official spec, it makes it hard to really settle. Its main advantage is its ability to match (or more closely match) people's preference for it to mix color in a more paint-like manner. It's a funny little color space. I mocked up option (3.):

ryb

I'm not sure if I'm adding this, some other approach, or skipping it altogether.

Add an HCT gamut mapping solution

We've implemented HCT, the space as described in https://material.io/blog/science-of-color-design. The actual implementation that Material uses, does some "clever things" though.

  1. Lightness is clamped between 0 - 100. This makes sense as the conversion back to an SDR color space is easy-ish as the L* range of 0 - 100 maps to the J range of CAM16 of 0 - 100, not exactly mind you, but the range is the same. This means you can set your low and high to 0 and 100 and bisect to convert L* back to a suitable J. HDR range is more unpredictable as the J value can exceed the current L*. Limiting to SDR isn't that bad.
  2. Chroma gets clamped when it exceeds the sRGB gamut. This means that for every set of hue, chroma, or lightness, Material is recalculating the color and reduces lightness and chroma. We do not as we do not want to limit the color space to sRGB only. We live in the modern world, and modern color spaces are wide gamut. We also don't really have those kinds of hooks. We can do a simple range clamp, but not dynamic at this time. Also, dynamic range clamping that requires us to calculate what the actual max chroma can be for a given lightness and hue would be expensive to do on every set.

What this means is that if you take the color red in HCT, and adjust its tone, the chroma may not be in gamut for sRGB, Display P3, or whatever color space you plan to convert back to. You will not get the same result that the Material library would give you for tones. But there is a way to allow us to get those values.

In order to match what the Material library does, we'd need to reduce chroma in HCT until the color is within some other gamut, in the case of Material, sRGB. This is exactly what we already do with the default gamut mapping algorithm that uses LCh and the CSS proposed algorithm that uses OkLCh.

We should create a variant gamut mapping algorithm that can reduce chroma while in HCT. This would only work for SDR colors and would clip anything above SDR. I'm not sure if it is less expensive to use ∆E 2000 or use CAM16 which is designed for CAM16-based color spaces (which HCT basically is). Either way, doing this would preserve chroma and lightness and allow us to give the same or nearly the same results.

Obviously, this way is expensive to calculate, but so is HCT in general, so I see no issues. People should be able to generate very similar colors and palettes.

Color Space: ACEScc

Colorjs.io implemented it. I guess maybe considering it for HDR maybe. They have an implementation, but I'd like to dig up the spec somewhere and take a look (as long as it's not behind a paywall 🙃).

Color Space: HPLuv

It's technically already implemented, might as well throw it in here as well 🙂. It's a pretty limited color space, but no sense throwing away work.

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.