From 70b8aca498babc95b763df4a96f949b7b10214dc Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Wed, 14 Feb 2024 14:05:17 +0000 Subject: Uninvert lighting direction --- pineapple.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pineapple.c b/pineapple.c index 5137534..eeb112b 100644 --- a/pineapple.c +++ b/pineapple.c @@ -165,17 +165,14 @@ main(int argc, char *argv[]) float brightness = 0.0; if (shortest != INFINITY) { float light_angle = acosf(dot(shortest_norm, light) / magnitude(shortest_norm) / magnitude(light)); - brightness = 1 - light_angle / PI; + brightness = light_angle / PI; } if (mode == ASCII) { printf("%c", ASCII_CHARS[strlen(ASCII_CHARS) - 1 - (int)(brightness * strlen(ASCII_CHARS))]); } else if (mode == FARBFELD) { uint16_t x = htobe16((uint16_t)(brightness * 0xffff)); - uint16_t a = htobe16(0xffff); - fwrite(&x, 1, 2, stdout); - fwrite(&x, 1, 2, stdout); - fwrite(&x, 1, 2, stdout); - fwrite(&a, 1, 2, stdout); + uint16_t pixel[4] = { x, x, x, htobe16(0xffff) }; + fwrite(&pixel, 2, 4, stdout); } } if (mode == ASCII) printf("\n"); -- cgit v1.2.3