[csswg-drafts] [css-color-5] color-ramp functions (#6694)

tabatkins has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-5] color-ramp functions ==
Designing a good color ramp, where data is displayed in various colors along a spectrum to indicate their value, is very difficult. There's a lot of color theory, accessibility, and practical considerations that have be balanced with each other to get it right, and the vast majority of people do *not* get it right. Maps and diagrams are often a travesty of misleading or difficult-to-distinguish colors.

It might be worthwhile to include some pre-built ramps that *are* designed well. I've seen a few suggestions in the past, but most recently have come across [the "viridis" ramp](https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html), which looks promising, even giving good results when translated to b/w printing. However, my knowledge in this space is very limited, and I've got no particular attachment to anything in particular.

The primary use-case is being able to extract a spot color corresponding to some value; this probably means a function that takes a % between 0% and 100% and resolves to an appropriate color from the ramp: `viridis(50%)` or `color-ramp(viridis 50%)` for easier extensibility.

However, displaying the color scale itself is also important for legends, so offering this as some kind of built-in gradient would also probably be good. I think `linear-gradient(..., viridis)` would work, with the keyword subbing in for the entire color-stop list? Possibly something more complex that lets us stretch a specified fragment of the ramp between two specified positions in the gradient, so you don't have to do funky hacks just to get a fragment of the ramp to display.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6694 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 28 September 2021 21:21:57 UTC