Increasing and decreasing interpolation paths in cylindrical colour spaces for UI gradients
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 4d 8m
- Merged PRs (30d)
- 147
Description
## What problem does this solve or what need does it fill?
We only support the shortest and longest path interpolation methods. For completeness, I'd like us to also support increasing and decreasing paths, as CSS does.
[Explanation of the CSS API here](https://developer.mozilla.org/en-US/docs/Web/CSS/hue-interpolation-method)
## What solution would you like?
Assuming the changes from #19992 are merged, the `InterpolationColorSpace` enum is:
```
pub enum InterpolationColorSpace {
/// Interpolates in `OKLab` space.
#[default]
OkLab,
/// Interpolates in OKLCH space, taking the shortest hue path.
OkLch,
/// Interpolates in OKLCH space, taking the longest hue path.
OkLchLong,
/// Interpolates in sRGB space.
Srgb,
/// Interpolates in linear sRGB space.
LinearRgb,
/// Interpolates in HSL space, taking the shortest hue path.
Hsl,
/// Interpolates in HSL space, taking the longest hue path.
HslLong,
/// Interpolates in HSV space, taking the shortest hue path.
Hsv,
/// Interpolates in HSV space, taking the longest hue path.
HsvLong,
}
```
I kept the plain names `OkLch`, `Hsl` or `Hsl` for the shortest path variants, instead of adding a `Short` suffix, to signal that these are the default recommended choices.
We could either add extra variants with `Increasing`/`Decreasing` suffixes for each cylindrical colour space or we could add a separate enum:
```
pub enum HuePath {
Shortest,
Longest,
Decreasing,
Increasing,
}
```
I'm not too bothered, either API would be fine.
The implementation will need changes to the `gradients.wgsl` shader but it would just be some simple logic to choose the correct path and wouldn't require any technical knowledge of rendering or wgsl.
## Additional context
The HSL and HSV interpolation PR is here: #19992
Contributor guide
Assessment
This issue has not been assessed yet.