diff --git a/color_math.c b/color_math.c index 831e216..af561ee 100644 --- a/color_math.c +++ b/color_math.c @@ -133,7 +133,7 @@ static double srgb_gamma(double value, double gamma) { } } -double clamp(double value) { +static double clamp(double value) { if (value > 1.0) { return 1.0; } else if (value < 0.0) { diff --git a/color_math.h b/color_math.h index 83bdfc8..c7739ce 100644 --- a/color_math.h +++ b/color_math.h @@ -24,6 +24,5 @@ struct sun { enum sun_condition calc_sun(struct tm *tm, double longitude, double latitude, struct sun *sun); void calc_whitepoint(int temp, double *rw, double *gw, double *bw); -double clamp(double value); #endif diff --git a/main.c b/main.c index 37e1dde..c4fcd60 100644 --- a/main.c +++ b/main.c @@ -397,7 +397,12 @@ static int interpolate_temperature(time_t now, time_t start, time_t stop, int te if (start == stop) { return stop; } - double time_pos = clamp((double)(now - start) / (double)(stop - start)); + double time_pos = (double)(now - start) / (double)(stop - start); + if (time_pos > 1.0) { + time_pos = 1.0; + } else if (time_pos < 0.0) { + time_pos = 0.0; + } int temp_pos = (double)(temp_stop - temp_start) * time_pos; return temp_start + temp_pos; }