Skip to content
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

use HCL color space (Rec.2020 for luma) instead of HSV #1235

Merged
merged 24 commits into from
Oct 13, 2022

Conversation

caiofreitaso
Copy link
Contributor

Description

HSV Gradient brought some unpleasant colors (either too bright or too saturated) with my conky config because of how the HSV color space works. I changed it to HCL (Hue-Chroma-Luma) so that colors blend with a better distribution of luminosity.

Using HCL color space:
image

Using HSV color space:
image

@github-actions github-actions bot added sources PR modifies project sources tests Issue or PR related to project tests labels Oct 4, 2022
@netlify
Copy link

netlify bot commented Oct 4, 2022

Deploy Preview for lambent-marshmallow-4057de canceled.

Name Link
🔨 Latest commit fae9aa5
🔍 Latest deploy log https://app.netlify.com/sites/lambent-marshmallow-4057de/deploys/633cc6c7495f7e0008970825

@netlify
Copy link

netlify bot commented Oct 4, 2022

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit 99709da
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/634743ee99df7e000846a3ef

@brndnmtthws
Copy link
Owner

First of all, thanks for doing this.

Is there a reason why you removed the HSV code? I think it would make sense to add HCL, which does indeed look better to me, and keep HSV so it doesn't break existing configs. It seems like it should be fairly straight forward to have both HSV and HCL. What do you think?

@caiofreitaso
Copy link
Contributor Author

It indeed is quite easy to have them both. My issue with the HSV code is that it has some wrong calculations.

  • H' is assigned as (diff + chroma/2)/chroma + offset, when this chroma/2 shouldn't be there.
  • Saturation has a similar problem: (chroma + value/2)/value. value/2 also shouldn't be there.
  • Chroma at scaled_hsv_to_scaled_rgb is calculated as value * saturation + 0.5, when it should have been value * saturation.
  • X is calculated with a Hue tilted 30°, and increased by 0.5: (chroma * (1 - abs((H-30)/60 % 2 - 1)) + 0.5, when it should have been chroma * abs((H/60) % 2 - 1)
  • The way increments are calculated also use (diff + divisor/2)/divisor instead of diff/divisor for some reason, and hues are rotated unnecessarily.

So my line of reasoning was that I could either correct the HSV code or scrap it to use a better color space (specially for HDR monitors that have really bright magentas).

PS: Found out conversions are also wrong. Decimal scale conversions add and subtract max_value - 1 and 0.5, for no apparent reason.

After correcting them, this is the result for the gradient:
image

Copy link
Owner

@brndnmtthws brndnmtthws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks for fixing HSV gradient.

Now we have 3 different ways to colour the graphs, so we should probably add a config setting and document the available methods. Something like graph_griadent_method = (rgb|hsv|hcl). Do you want to take a stab at that?

Also, please unstage tests/catch2/catch.hpp, that's a 3rd party library and I'd like to keep the original.

@caiofreitaso
Copy link
Contributor Author

That seems nice. I’ll try 😊

Can I fix those errors I mentioned on HSV or should I leave it as it is?

And I will unstage the header! Sorry!

@brndnmtthws
Copy link
Owner

Can I fix those errors I mentioned on HSV or should I leave it as it is?

Yeah, that would be great!

@caiofreitaso
Copy link
Contributor Author

Done! Now the config file can declare which mode with graph_gradient_mode = 'hcl', for example.

RGB:
image

HSL:
image

HCL:
image

Copy link
Owner

@brndnmtthws brndnmtthws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks much better. Thanks for combining all the code into one file, I think that's cleaner.

It looks like the tests were removed, I'm not sure if that was intentional or not, but we keep & update the tests so they work with this code. I don't generally require people include tests with submissions, but we shouldn't be removing tests.

- name: graph_gradient_mode
desc: |-
Changes the color space used for interpolation. Arguments are hcl, hsv,
and rgb (default).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add args here, like:

    args:
      - (rbg|hcl|hsv)

@@ -68,6 +68,8 @@ set(conky_sources
exec.h
fs.cc
fs.h
gradient.cc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're including the sources like this, we can remove all references to BUILD_HSV_GRADIENT from the CMake files and source. The build option is defined in ConkyBuildOptions.cmake.

@github-actions github-actions bot added the documentation Issue or PR that suggests documentation improvements label Oct 6, 2022
Copy link
Owner

@brndnmtthws brndnmtthws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, looks good! Thanks for your patience, and I think we're good to go once all the checks pass.

and rgb (default).
args:
- (rbg|hcl|hsv)
default: rgb
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, good catch. Thanks!

@@ -267,8 +267,6 @@ option(BUILD_PULSEAUDIO
option(BUILD_INTEL_BACKLIGHT
"Enable support for Intel backlight" false)

option(BUILD_HSV_GRADIENT "Enable gradient in HSV colour space" true)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@caiofreitaso
Copy link
Contributor Author

Hey, could you explain what is the ON and OFF that appear on those builds? I want to reproduce the errors here, but I can't understand what exactly those are. Is it a no GUI or no X11 flag? D:

@brndnmtthws
Copy link
Owner

Good question, in this case OFF is referring to the BUILD_X11 flag. I will update the build so it prints the build command.

The full command should be as follows:

           cmake ..                               \
             -DBUILD_AUDACIOUS=ON                 \
             -DBUILD_HTTP=ON                      \
             -DBUILD_ICAL=ON                      \
             -DBUILD_ICONV=ON                     \
             -DBUILD_IRC=ON                       \
             -DBUILD_IRC=ON                       \
             -DBUILD_JOURNAL=ON                   \
             -DBUILD_LUA_CAIRO=ON                 \
             -DBUILD_LUA_IMLIB2=ON                \
             -DBUILD_LUA_RSVG=ON                  \
             -DBUILD_MYSQL=ON                     \
             -DBUILD_NVIDIA=ON                    \
             -DBUILD_PULSEAUDIO=ON                \
             -DBUILD_RSS=ON                       \
             -DBUILD_TESTS=ON                     \
             -DBUILD_WLAN=ON                      \
             -DBUILD_X11=OFF                      \
             -DBUILD_XMMS2=ON                     \
             -DCMAKE_C_COMPILER=$CC               \
             -DCMAKE_CXX_COMPILER=$CXX            \
             -DMAINTAINER_MODE=ON

@brndnmtthws
Copy link
Owner

Oh I guess you can also expand the substituted commands if you click the Run ... log line at the top of the step.

@brndnmtthws
Copy link
Owner

Are you still working on this PR? I think we're very close to completing it.

@caiofreitaso
Copy link
Contributor Author

Are you still working on this PR? I think we're very close to completing it.

I was. Sorry for the delay! D:


void gradient_factory::setup_colour_depth() {
#ifdef BUILD_X11
if (state == nullptr) { // testing purposes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is okay for now, but it would be better to initialize the state with appropriate values as part of the setup for the tests.

@brndnmtthws brndnmtthws merged commit 43a1043 into brndnmtthws:main Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issue or PR that suggests documentation improvements sources PR modifies project sources tests Issue or PR related to project tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants