commit: b8fade2c9be9da04735ac311e152f1264e80a714
parent e3ad3e689537fe4ca38ae4fc78c71e745b74a37f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 5 Apr 2021 02:26:00 +0200
xcd: Fix wrong coloring because of signs
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/bin/xcd.c b/bin/xcd.c
@@ -1,4 +1,4 @@
-// Copyright 2018-2020 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+// Copyright 2018-2021 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
// Distributed under the terms of the CC-BY-SA-4.0 license
#define _POSIX_C_SOURCE 200809L
@@ -11,14 +11,14 @@
#define LANODAN_XCD_RESET printf("[0m[48;2;0;0;0m");
#define LANODAN_XCD_PRINT printf(" >%s<", line);
-void rainbow(double freq, char i) {
+void rainbow(double freq, unsigned char i) {
if(i == 0) {
printf("[38;2;64;64;64m");
} else {
uint8_t red, green, blue;
double pi = 3.14159;
- red = sin(freq*i + 0) * 127 + 128;
+ red = sin(freq*i + 0*pi/3) * 127 + 128;
green = sin(freq*i + 2*pi/3) * 127 + 128;
blue = sin(freq*i + 4*pi/3) * 127 + 128;
@@ -27,10 +27,12 @@ void rainbow(double freq, char i) {
}
int main(void) {
- int cols = 0, bytes = 0;
+ int cols = 0;
int line_width = 16;
- double freq = 0.2;
- char c, line[line_width];
+ double freq = 0.018;
+ char line[line_width];
+ unsigned char c;
+ unsigned int bytes = 0;
memset(&line, 0, line_width);