New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NOSQUASH] Editor: Replace the OKLab color picker by a 2D color picker #2895
Open
HybridDog
wants to merge
2
commits into
SuperTux:master
Choose a base branch
from
HybridDog:m_colour_chooser_2d
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There's various compiler errors:
|
MatusGuy
added
category:code
status:needs-review
Work needs to be reviewed by other people
labels
Apr 7, 2024
HybridDog
force-pushed
the
m_colour_chooser_2d
branch
from
April 7, 2024 09:50
fa1bfb5
to
8d982c9
Compare
A two-dimensional image can enable a more convenient selection of colors than a one-dimensional slider. Under the assumption that users typically want to select a color with the highest saturation, a two-dimensional color picker where any RGB color with the highest saturation can be slected with one click could be suitable. For an independent adjustment of lightness and hue, which is considered a good property of a color picker, the two-dimensional color picker should use a perceptual color space such as OKLab. As a side effect for choosing a perceptual color space, a marker showing the lightness and hue of the current color can visualize how a change in RGB values affects the perceived color. Changes: * For the color selection in the editor, add the ItemColorPicker2D menu item, which displays an image and enables picking a color from it by clicking. The image contains the highest-saturation sRGB colors, so for the color picker we only need OKLab code to determine marker positions and no color clipping code since we can sample pixels from the image. * Add a method drawing a hexagon to Canvas * Add a helper method to ColorOKLCh which calculates a modified lightness * Add a missing include guard and constness to the code for ColorOKLCh
There are reports that the one-dimensional OKLab color selection is unpopular and difficult to use, so we can remove it to simplify the code and GUI. This commit removes ItemColorChannelOKLab and most of the OKLab color space code. Since the two-dimensional color picker uses some of the OKLab code, it is not removed completely.
HybridDog
force-pushed
the
m_colour_chooser_2d
branch
from
April 7, 2024 10:18
ba10857
to
c6fc201
Compare
I've fixed the compiler errors; the MacOS checks also fail in the master branch. |
Looks good, I guess. The drawing methods I didn't look at in detail because urgh, code but from what I can tell this is good to merge. |
This good to merge? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
There are reports that the one-dimensional OKLab color selection is unpopular and difficult to use (see this Discussion),
so we can remove it to simplify the code and GUI.
A two-dimensional image can enable a more convenient selection of colors than a one-dimensional slider.
Under the assumption that users typically want to select a color with the highest saturation,
a two-dimensional color picker where any RGB color with the highest saturation can be slected with one click could be suitable.
For an independent adjustment of lightness and hue, which is considered a good property of a color picker,
the two-dimensional color picker should use a perceptual color space such as OKLab.
As a side effect for choosing a perceptual color space,
a marker showing the lightness and hue of the current color can visualize how a change in RGB values affects the perceived color.
Proposed changes
which displays an image and enables picking a color from it by clicking.
The image contains the highest-saturation sRGB colors,
so for the color picker we only need OKLab code to determine marker positions
and no color clipping code since we can sample pixels from the image.
Since the two-dimensional color picker uses some of the OKLab code,
it is not removed completely.
Additional information
The author of OKLab has a webpage about a color picker, which uses a modified lightness.
I have also used the modified lightness since it leads to smaller dark regions in the color picker image and in SuperTux it is, I assume, uncommon to select dark colors (correct me if I'm wrong).
Color picker image with unmodified lightness:
Color picker image with modified lightness:
The new color picker with default language and 800x600 window size:
The color picker stretches horizontally; since the language affects the width of the menu title, the color picker's aspect ratio depends on the language. I don't think this is a problem, so I haven't implemented it differently.
I couldn't find a way to get a pixel from a Surface, so the color picker image is loaded twice: one time for the drawing and one time to sample pixel values from it.
Please test the new color picker.