MaxVerevkin / wl-gammarelay-rs

A simple program that provides DBus interface to control display temperature and brightness under wayland without flickering
GNU General Public License v3.0
119 stars 2 forks source link

Adjust color temperature of inverted colormap: flip gamma ramp left-to-right (rather than upside-down) #4

Closed piater closed 2 years ago

piater commented 2 years ago

My use case: I like to adjust the color temperature of my display (redhift style). I also frequently invert the colors of my display (by keystroke) because I visually prefer light-on-dark but have to look a lot at black-on-white documents.

However, currently, adjusting the color temperature and inverting the display do not properly combine, as effectively the temperature-adjusted gamma ramp is inverted. This is because the gamma ramp is inverted upside-down:

r[i] = u16::MAX - (v * white_r) as u16;

To properly temperature-adjust the inverted gamma ramp, one should instead flip the gamma ramp left-to-right:

r[ramp_size - 1 - i] = (v * white_r) as u16;

With a linear gamma ramp and full brightness, both methods of course have the same effect. With a linear gamma ramp and reduced brightness setting, the original increases brightness due to the inversion (turning black into gray), while my proposed method reduces brightness even under inversion.

Changing the behavior as I propose would probably destroy other users' use cases. But would you accept a patch that adds this behavior as a new option?

MaxVerevkin commented 2 years ago

Changing the behavior as I propose would probably destroy other users' use cases. But would you accept a patch that adds this behavior as a new option?

I think your proposed behavior makes more sense than the current one. I rarely use both settings at once, so I didn't notice it. I would accept a patch that changes the current behavior, and if someone will show interest in the old one, we can add an option :)

piater commented 2 years ago

If you just replace the existing functionality then you'll be just as fast simply replacing the three lines of code in colorramp_fill() in color.rs as shown for r above, saving me the hassle of forking, cloning, pushing, pull requesting, ... but I'll do it if you prefer.

piater commented 2 years ago

Wait, I have a patch that adds setting Gamma, in a way that combines sensibly with setting color temperature, brightness, and inversion. If you're interested I'll generate a pull request.

MaxVerevkin commented 2 years ago

I have a patch that adds setting Gamma, in a way that combines sensibly with setting color temperature, brightness, and inversion.

You mean something different from r[ramp_size - 1 - i] = (v * white_r) as u16;?

If you're interested I'll generate a pull request.

Sure :)

MaxVerevkin commented 2 years ago

You mean something different from r[ramp_size - 1 - i] = (v * white_r) as u16;?

Oh, sorry, I confused "gamma" with "temperature".