diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2016-01-04 21:16:45 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2016-01-04 21:16:45 +0100 |
commit | 9e0e2e77fd659dc45ff55592da52ff439a6227f0 (patch) | |
tree | 7558d030d3414178c7328a5967ff185224ff8629 /src | |
parent | misc (diff) | |
download | libred-9e0e2e77fd659dc45ff55592da52ff439a6227f0.tar.gz libred-9e0e2e77fd659dc45ff55592da52ff439a6227f0.tar.bz2 libred-9e0e2e77fd659dc45ff55592da52ff439a6227f0.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/blackbody.c | 10 | ||||
-rw-r--r-- | src/libred.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/blackbody.c b/src/blackbody.c index f45ead4..7884f2f 100644 --- a/src/blackbody.c +++ b/src/blackbody.c @@ -103,7 +103,7 @@ static void ciexyy_to_srgb(double x, double y, double Y, double *r, double *g, d */ static void interpolate(double x1, double y1, double x2, double y2, double temp, double *r, double *g, double *b) { - double weight = fmod(temp, (double)DELTA_TEMPERATURE) / (double)DELTA_TEMPERATURE; + double weight = fmod(temp, (double)LIBRED_DELTA_TEMPERATURE) / (double)LIBRED_DELTA_TEMPERATURE; double x = x1 * (1 - weight) + x2 * weight; double y = y1 * (1 - weight) + y2 * weight; ciexyy_to_srgb(x, y, 1.0, r, g, b); @@ -132,17 +132,17 @@ int libred_get_colour(long int temp, double *r, double *g, double *b) /* We do not have any values for above 40 000 K, but * the differences will be unnoticeable, perhaps even * unencodeable. */ - if (temp > HIGHEST_TEMPERATURE) temp = HIGHEST_TEMPERATURE; + if (temp > LIBRED_HIGHEST_TEMPERATURE) temp = LIBRED_HIGHEST_TEMPERATURE; /* Things do not glow below 1000 K. Yes, fire is hot! */ - if (temp < LOWEST_TEMPERATURE) t ((errno = EDOM)); + if (temp < LIBRED_LOWEST_TEMPERATURE) t ((errno = EDOM)); /* Read table. */ - offset = ((off_t)temp - LOWEST_TEMPERATURE) / DELTA_TEMPERATURE; + offset = ((off_t)temp - LIBRED_LOWEST_TEMPERATURE) / LIBRED_DELTA_TEMPERATURE; offset *= (off_t)(sizeof(values) / 2); errno = 0; xpread(fd, values, sizeof(values), offset); /* Get colour. */ - if (temp % DELTA_TEMPERATURE) + if (temp % LIBRED_DELTA_TEMPERATURE) interpolate(values[0], values[1], values[6], values[7], (double)temp, r, g, b); else *r = values[2], *g = values[3], *b = values[4]; diff --git a/src/libred.h b/src/libred.h index 615ed04..98011cb 100644 --- a/src/libred.h +++ b/src/libred.h @@ -122,6 +122,8 @@ int libred_check_timetravel(void); /** * The temperature difference between the colours in the table. + * Note, `libred_get_colour` will make interpolation for colours + * that are not in the table. */ #define LIBRED_DELTA_TEMPERATURE 100 |