Repository navigation
[NOSQUASH] Editor: Replace the OKLab color picker by a 2D color picker - #2895
Conversation
|
There's various compiler errors: |
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? |
c6fc201 to
ac66973
Compare
4ce2e46 to
39f69d4
Compare
provigz
left a comment
There was a problem hiding this comment.
The picker seems to work well, and is definitely way simpler than the OKLab one.
Left some code-related comments only.
39f69d4 to
243163b
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.
243163b to
d7e6703
Compare
|
I just wanna ask if there are any plans on adding a saturation slider underneath the color picker. It's been almost 2 years since we can only select 100% saturated colors in the editor unless we paste the colors from an external source or edit the RGB value numbers or hex code manually. I'm starting worry, as I'm seeing consequences of this limitation on new levels made by players, where every color in gradients, light sources and etc is 100% saturated. I know there's PR #3251 trying to fix it, but it seems to be abandoned right now, probably because the person who made it isn't part of the team or a regular contributor, and did it just as a school project and didn't appear again to handle the requested changes. The saturation setting is an indispensable feature for level design, a feature that we lost when this color picker was added, and I'm still surprised that nobody is talking about this. How haven't anybody noticed that you can't make anything gray!? |
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.