Bug 457861 - Wallpaper accent color sometimes has bad contrast on Breeze Dark
Summary: Wallpaper accent color sometimes has bad contrast on Breeze Dark
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_colors (show other bugs)
Version: 5.25.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-14 04:22 UTC by Lemuel Simon
Modified: 2022-09-12 16:40 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.26
Sentry Crash Report:


Attachments
Poor contrast on the highlighed items. (816.67 KB, image/png)
2022-08-14 04:22 UTC, Lemuel Simon
Details
Sample wallpaper for bad contrast. (778.64 KB, image/jpeg)
2022-08-14 04:41 UTC, Lemuel Simon
Details
Another sample. (3.13 MB, image/jpeg)
2022-08-14 04:43 UTC, Lemuel Simon
Details
The worst one. (927.90 KB, image/jpeg)
2022-08-14 04:45 UTC, Lemuel Simon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lemuel Simon 2022-08-14 04:22:48 UTC
Created attachment 151309 [details]
Poor contrast on the highlighed items.

SUMMARY
The current implementation of the wallpaper-generated accent color does not account for dark color schemes. Depending on the wallpaper, the automatically-chosen accent color may appear to dark to see. It would blend-into the background of the color theme, so highlighted/selected buttons/sliders are not legible in Plasma. The 'hyperlink text' that one would find in Spectacle, when you save a screenshot, would also be completely illegible.


STEPS TO REPRODUCE
1. Select the default, unmodified Breeze Dark color theme or Global Theme.
2. Select the 'From Wallpaper' option in the Colors KCM.
3. Cycle to a dark wallpaper.
4. Open the Application Launcher (Kick-off)

OBSERVED RESULT
With the wallpaper's accent color applied on Breeze Dark, highlighted/selected buttons/sliders are not legible in Plasma, and "Hyperlink Text" is either too dark or invisible due to poor contrast. 

EXPECTED RESULT
The accent colors are bright enough to stand-out, when using Breeze Dark or another similarly dark color-scheme. 

SOFTWARE/OS VERSIONS
Operating System: openSUSE Leap 15.4
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Kernel Version: 5.14.21-150400.24.18-default (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-3320M CPU @ 2.60GHz
Memory: 7.6 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4000
Manufacturer: LENOVO
Product Name: 2347G2U
System Version: ThinkPad T430

ADDITIONAL INFORMATION
I would submit a screenshot of the bug in action, as well as some of the offending wallpapers that trigger this behavior. Unfortunately, I couldn't get a screenshot of Spectacle, it hides before the shot.
I have seen these two bug reports, but I don't believe they are the same to the current one.
https://bugs.kde.org/show_bug.cgi?id=442820
https://bugs.kde.org/show_bug.cgi?id=445040
Comment 1 Lemuel Simon 2022-08-14 04:41:10 UTC
Created attachment 151310 [details]
Sample wallpaper for bad contrast.
Comment 2 Lemuel Simon 2022-08-14 04:43:46 UTC
Created attachment 151311 [details]
Another sample.
Comment 3 Lemuel Simon 2022-08-14 04:45:27 UTC
Created attachment 151312 [details]
The worst one.
Comment 4 Nate Graham 2022-08-15 19:13:06 UTC
Heh yeah this happens as well with light-colored wallpapers when using a light color scheme.

Probably when you're using a dark color scheme, we should apply a small amount of lightening to wallpaper-derived accent colors that are calculated to be too dark, and darken light ones when using a light color scheme.
Comment 5 Fushan Wen 2022-08-16 13:44:02 UTC
This doesn't seem to be fixable by judging the system color scheme, as one can choose Breeze Twilight, and Plasma components will still use the dark color scheme but the color scheme is still light.
Comment 6 Nate Graham 2022-08-16 13:46:09 UTC
Hmm, that's true.

Perhaps we could just unconditionally lighten very dark calculated colors and darken very light calculated colors. That's probably the best we can do, and beyond that, users will just need to live with poor contrast when they choose to use this combination of features.
Comment 7 Bug Janitor Service 2022-08-16 15:21:17 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1095
Comment 8 Bug Janitor Service 2022-08-18 19:46:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1104
Comment 9 Karsten.Fleischer 2022-08-22 14:53:21 UTC
First of all I absolutely love the wallpaper based accent colour, brilliant work/idea. 

Unfortunately  I also like dark wallpapers and the dark theme, so 50% of my backgrounds lead to very poor contrast for the highlight colour. 

Would it be possible to modify the process to keep the selected hue H/saturation S of the accent colour but always increase/decrease the value V of the HSV tuple of the accent colour to be always lets say 25% higher/lower than the panel from the dark/light themes respectively. That way there should always be enough contrast.

Ciao Karsten
Comment 10 Bug Janitor Service 2022-08-25 09:19:32 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2046
Comment 11 Nate Graham 2022-08-25 18:39:00 UTC
Git commit 95766459f3c7de96c79f4fc1bb220b7e77f1140d by Nate Graham.
Committed on 25/08/2022 at 18:21.
Pushed by ngraham into branch 'master'.

Adjust wallpaper accent calculation to increase contrast and vibrancy

Right now, the calculation prefers the image's dominant color, which is
likely to be a color from the background. As a result, it often returns
a color that is very dark or muted, especially with wallpapers based on
night landscaped or space. The darkness is especially problematic when
using a dark color scheme, where it causes contrast issues. It also has
the effect of making the selection highlight on the desktop hard to see
since by definition, its color will be very similar to the most common
color in the wallpaper.

This commit adjusts the wallpaper accent color calculation as follows:

1. Consider a narrower range of lightness values acceptable; now the
   lightness has to be at least 0.4, and it can't be darker than 0.75.
   This fixes most of the contrast issues.
2. Try the wallpaper's highlight color before the dominant color. This
   tends to pick the color in the wallpaper that is most likely to draw
   the user's attention, even if it's not the most common color. It also
   tends to be a richer and brighter color compared to the dominant
   color, so the extracted accent color is more likly to be bright and
   pretty rather than dark and muted.
3. If the highlight color or dominant color isn't within the specified
   lightness range, lighten or darken it and try again. This makes the
   algorithm work harder to try to give you a color based on the
   highlight color or the dominant color and avoid falling back to the
   average color, which is highly likely to return a drab, muted color.
FIXED-IN: 5.26

M  +23   -11   desktoppackage/contents/views/Desktop.qml

https://invent.kde.org/plasma/plasma-desktop/commit/95766459f3c7de96c79f4fc1bb220b7e77f1140d
Comment 12 Bug Janitor Service 2022-08-26 15:42:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/731
Comment 13 Fushan Wen 2022-09-12 16:40:11 UTC
Git commit 6da378a1d764fb73bbcea7339b7ed01394642463 by Fushan Wen.
Committed on 12/09/2022 at 16:39.
Pushed by fusionfuture into branch 'master'.

imagecolors: make extracted colors follow WCAG contrast criterion

Filter the pixels by chroma, and adjust the lightness of extracted colors
to follow WCAG Non-text Contrast (dark theme) orContrast (Minimum) (light theme).

M  +65   -3    src/imagecolors.cpp
M  +5    -2    src/imagecolors.h

https://invent.kde.org/frameworks/kirigami/commit/6da378a1d764fb73bbcea7339b7ed01394642463