aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-05-11 22:06:26 +0300
committerFred Sundvik <fsundvik@gmail.com>2016-05-11 22:06:26 +0300
commit25382cb6f21b6136b0f490a618ce8d494ca5cd38 (patch)
tree2c5ba60b98ffe3af4ab5b963ec703a5173784e67
parentf0c8e7c495af2aad476f4c428b700ed26188a8e5 (diff)
downloadqmk_firmware-25382cb6f21b6136b0f490a618ce8d494ca5cd38.tar.gz
qmk_firmware-25382cb6f21b6136b0f490a618ce8d494ca5cd38.zip
Fix compute_gradient_color
-rw-r--r--led_test.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/led_test.c b/led_test.c
index ed65a0baa..d358ef81e 100644
--- a/led_test.c
+++ b/led_test.c
@@ -86,10 +86,13 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
86static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; 86static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
87 87
88static uint8_t compute_gradient_color(float t, float index, float num) { 88static uint8_t compute_gradient_color(float t, float index, float num) {
89 float d = fabs(index - t); 89 const float target = t * (num - 1.0f);
90 if (d > num / 2.0f) { 90 const float half_num = num / 2.0f;
91 float d = fabs(index - target);
92 if (d > half_num) {
91 d = num - d; 93 d = num - d;
92 } 94 }
95 d = 1.0f - (d / half_num);
93 return (uint8_t)(255.0f * d); 96 return (uint8_t)(255.0f * d);
94} 97}
95 98