From f84a3ba77c61a351e1d7efb67bd40db23a435281 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 16 Mar 2025 22:36:46 +0100 Subject: Refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/colour.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/colour.c') 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 -- cgit v1.2.3-70-g09d2