Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/colorramp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <stdint.h>
#include <math.h>

#define min(x,y) ((x) < (y) ? (x) : (y))


/* Whitepoint values for temperatures at 100K intervals.
These will be interpolated for the actual temperature.
Expand Down Expand Up @@ -292,11 +294,11 @@ colorramp_fill(uint16_t *gamma_r, uint16_t *gamma_g, uint16_t *gamma_b,
&blackbody_color[temp_index+3], white_point);

for (int i = 0; i < size; i++) {
gamma_r[i] = pow((float)i/size, 1.0/gamma[0]) *
(UINT16_MAX+1) * brightness * white_point[0];
gamma_g[i] = pow((float)i/size, 1.0/gamma[1]) *
(UINT16_MAX+1) * brightness * white_point[1];
gamma_b[i] = pow((float)i/size, 1.0/gamma[2]) *
(UINT16_MAX+1) * brightness * white_point[2];
gamma_r[i] = min(pow((float)i/size, 1.0/gamma[0]) *
(UINT16_MAX+1) * brightness * white_point[0], UINT16_MAX);
gamma_g[i] = min(pow((float)i/size, 1.0/gamma[1]) *
(UINT16_MAX+1) * brightness * white_point[1], UINT16_MAX);
gamma_b[i] = min(pow((float)i/size, 1.0/gamma[2]) *
(UINT16_MAX+1) * brightness * white_point[2], UINT16_MAX);
}
}
2 changes: 1 addition & 1 deletion src/redshift.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static const location_provider_t location_providers[] = {
#define MIN_TEMP 1000
#define MAX_TEMP 25000
#define MIN_BRIGHTNESS 0.1
#define MAX_BRIGHTNESS 1.0
#define MAX_BRIGHTNESS 1.5
#define MIN_GAMMA 0.1
#define MAX_GAMMA 10.0

Expand Down