aboutsummaryrefslogtreecommitdiffstats
path: root/src/colour.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/colour.c')
-rw-r--r--src/colour.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/colour.c b/src/colour.c
index d77c6ab..0138980 100644
--- a/src/colour.c
+++ b/src/colour.c
@@ -18,6 +18,31 @@
*/
#include "common.h"
+
+void
+interpolate_colour_settings(const struct colour_setting *a, const struct colour_setting *b,
+ double t, struct colour_setting *result)
+{
+ int i;
+ t = CLAMP(0.0, t, 1.0);
+ result->temperature = (1.0 - t) * a->temperature + t * b->temperature;
+ result->brightness = (1.0 - t) * a->brightness + t * b->brightness;
+ for (i = 0; i < 3; i++)
+ result->gamma[i] = (1.0 - t) * a->gamma[i] + t * b->gamma[i];
+}
+
+
+int
+colour_setting_diff_is_major(const struct colour_setting *a, const struct colour_setting *b)
+{
+ return MAX(a->temperature, b->temperature) - MIN(a->temperature, b->temperature) > 25UL ||
+ fabs(a->brightness - b->brightness) > 0.1 ||
+ fabs(a->gamma[0] - b->gamma[0]) > 0.1 ||
+ fabs(a->gamma[1] - b->gamma[1]) > 0.1 ||
+ fabs(a->gamma[2] - b->gamma[2]) > 0.1;
+}
+
+
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wfloat-equal"
#endif