[gnome-settings-daemon/benzea/fix-nightlight-interpolation: 8/8] color: Correct temperature interpolation corner cases



commit 74783ae8db12f386b661bb44f397b0d9b4bea619
Author: Benjamin Berg <bberg redhat com>
Date:   Fri Sep 28 12:22:27 2018 +0200

    color: Correct temperature interpolation corner cases
    
    The linear interpolation done for the color temperature would fail if
    the value is exactly 0 or 1. Such values can be hit, so the we need to
    accept them in normal operations.
    
    Fixes #92

 plugins/color/gsd-night-light.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/plugins/color/gsd-night-light.c b/plugins/color/gsd-night-light.c
index 2a19241d..1becb1b5 100644
--- a/plugins/color/gsd-night-light.c
+++ b/plugins/color/gsd-night-light.c
@@ -121,8 +121,8 @@ gsd_night_light_set_smooth_enabled (GsdNightLight *self,
 static gdouble
 linear_interpolate (gdouble val1, gdouble val2, gdouble factor)
 {
-        g_return_val_if_fail (factor > 0.f, -1.f);
-        g_return_val_if_fail (factor < 1.f, -1.f);
+        g_return_val_if_fail (factor >= 0.f, -1.f);
+        g_return_val_if_fail (factor <= 1.f, -1.f);
         return ((val1 - val2) * factor) + val2;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]