bevyengine / bevyengine/bevy

Feathers oklch color widgets

Open
#24,118 2 comments 0 reactions 0 assignees View on GitHub
A-Color A-UI C-Feature D-Domain-Expert D-Modest S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

The feathers color widgets (color slider and color plane) currently support sRGB and HSL color spaces. Given the emphasis that we have put on supporting oklab and oklch color spaces, it would be nice if we had support for editing these color spaces as well.

Unfortunately, this is not easy to do. Unlike rgb or hsl spaces where the widget can display a simple color gradient, we have to deal with out-of-gamut colors: not all points within the gradient are valid oklch colors. You can see an example here: https://oklch.com/

## What solution would you like?

First, we'll need to decide what we want the out-of-gamut regions to look like.

For the color plane, the gradient uses a custom shader and has access to @ickshonpe 's general color conversion functions, so it probably would not be too difficult to render the out-of-gamut parts of the plan differently, possibly using a checkerboard texture.

The slider widget, on the other hand, uses Bevy's built-in gradient support, so this would require a complex gradient with the out-of-gamut areas being rendered transparent. Alternatively, we could reimplement the color slider to use a custom material similar to what the color plane does.

Alternatively, we could implement special widgets that only know about oklch colors, and then dynamically switch widgets when the user switches to a different color space.

## What alternative(s) have you considered?

* Not supporting ok color spaces
* Not doing anything special with out-of-gamut colors and then just clamping them during editing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.