Skip to content

plugins/nightlight: Tidy temperature lerp code

Vlad Zahorodnii requested to merge work/zzag/night-light-lerp into master

This change simplifies the color temperature interpolation code by doing the following:

  • compute a progress value so 0 corresponds to target1, i.e. the beginning of the transition, and 1 corresponds to target2, the end of the transition, instead of vice versa
  • and use std::lerp() function

Rounding to a multiple of ten is not needed, it is for nicer digits in the applet, but if the applet really cares about it, it could perform such rounding on its own. In the night light manager, it's better to avoid rounding the interpolated values because that can result in the final temperature getting outside of the [target1, target2] interval.

Edited by Vlad Zahorodnii

Merge request reports