This commit is contained in:
Emmanuel Srivastava
2024-12-09 11:56:59 +01:00
parent d8315cea20
commit c0da6de2c2
5 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include "lightness.h"
#define LIGHT 0
#define DARK 1
#define RED 1
#define GREEN 2
#define BLUE 4
#define DARK_RED 124
#define DARK_GREEN 34
#define DARK_BLUE 19
int hue(void) {
int choice = rand()%3;
if (choice == 0) {
return RED;
} else if (choice == 1) {
return GREEN;
} else /* if (choice == 2) */ {
return BLUE;
}
}
int main(void) {
int l, c, v;
srand(time(NULL));
l = lightness();
c = hue();
if (c == RED) {
v = (l == LIGHT) ? LIGHT_RED : DARK_RED;
} else if (c == GREEN) {
v = (l == LIGHT) ? LIGHT_GREEN : DARK_GREEN;
} else /* if (c == BLUE) */ {
v = (l == LIGHT) ? LIGHT_BLUE : DARK_BLUE;
}
printf("┏━━━━┓\n");
printf("\33[48;5;%dm \33[m┃\n", v);
printf("\33[48;5;%dm \33[m┃\n", v);
printf("┗━━━━┛\n");
return EXIT_SUCCESS;
}