From da8e51f6616be3215a82276f9d2540e8620b3959 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 21 Mar 2024 17:01:09 -0400 Subject: [PATCH] major project restructure; new 256-color implementation --- basic.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ basic.h | 29 +++++++++++++++++++++++ color.h | 5 ++++ full.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ full.h | 12 ++++++++++ main.c | 73 +++++++++++++++++++++++++++------------------------------ 6 files changed, 222 insertions(+), 39 deletions(-) create mode 100644 basic.c create mode 100644 basic.h create mode 100644 color.h create mode 100644 full.c create mode 100644 full.h diff --git a/basic.c b/basic.c new file mode 100644 index 0000000..2377ed9 --- /dev/null +++ b/basic.c @@ -0,0 +1,70 @@ +#include "basic.h" + +#include + +void rainbow_8() { + printf( + RED STRIPE + L_RED STRIPE + L_YELLOW STRIPE + GREEN STRIPE + BLUE STRIPE + MAGENTA STRIPE + ); +} + +void aroace_8() { + printf( + YELLOW STRIPE + L_YELLOW STRIPE + WHITE STRIPE + L_CYAN STRIPE + BLUE STRIPE + ); +} + +void bisexual_8() { + printf( + RED STRIPE STRIPE + MAGENTA STRIPE + BLUE STRIPE STRIPE + ); +} + +void lesbian_8() { + printf( + RED STRIPE + L_RED STRIPE + WHITE STRIPE + L_MAGENTA STRIPE + MAGENTA STRIPE + ); +} + +void nonbinary_8() { + printf( + L_YELLOW STRIPE + WHITE STRIPE + MAGENTA STRIPE + BLACK STRIPE + ); +} + +void pansexual_8() { + printf( + MAGENTA STRIPE STRIPE + L_YELLOW STRIPE STRIPE + CYAN STRIPE STRIPE + ); +} + +void transgender_8() { + printf( + L_CYAN STRIPE + L_MAGENTA STRIPE + WHITE STRIPE + L_MAGENTA STRIPE + L_CYAN STRIPE + ); +} + diff --git a/basic.h b/basic.h new file mode 100644 index 0000000..6f58c5b --- /dev/null +++ b/basic.h @@ -0,0 +1,29 @@ +#pragma once + +#include "color.h" + +#define BLACK COLOR(0) +#define RED COLOR(1) +#define GREEN COLOR(2) +#define YELLOW COLOR(3) +#define BLUE COLOR(4) +#define MAGENTA COLOR(5) +#define CYAN COLOR(6) +#define GRAY COLOR(7) +#define L_BLACK COLOR(8) +#define L_RED COLOR(9) +#define L_GREEN COLOR(10) +#define L_YELLOW COLOR(11) +#define L_BLUE COLOR(12) +#define L_MAGENTA COLOR(13) +#define L_CYAN COLOR(14) +#define WHITE COLOR(15) + +void rainbow_8(); +void aroace_8(); +void bisexual_8(); +void lesbian_8(); +void nonbinary_8(); +void pansexual_8(); +void transgender_8(); + diff --git a/color.h b/color.h new file mode 100644 index 0000000..92ef0a3 --- /dev/null +++ b/color.h @@ -0,0 +1,5 @@ +#pragma once + +#define COLOR(n) "\x1b[38;5;" #n "m" +#define STRIPE "██████████████████\n" + diff --git a/full.c b/full.c new file mode 100644 index 0000000..8615037 --- /dev/null +++ b/full.c @@ -0,0 +1,72 @@ +#include "full.h" + +#include + +#include "color.h" + +void rainbow_256() { + printf( + COLOR(196) STRIPE // red + COLOR(208) STRIPE // orange + COLOR(220) STRIPE // yellow + COLOR(28) STRIPE // green + COLOR(21) STRIPE // blue + COLOR(90) STRIPE // purple + ); +} + +void aroace_256() { + printf( + COLOR(172) STRIPE + COLOR(184) STRIPE + COLOR(255) STRIPE + COLOR(38) STRIPE + COLOR(17) STRIPE + ); +} + +void bisexual_256() { + printf( + COLOR(161) STRIPE STRIPE + COLOR(91) STRIPE + COLOR(21) STRIPE STRIPE + ); +} + +void lesbian_256() { + printf( + COLOR(202) STRIPE + COLOR(209) STRIPE + COLOR(255) STRIPE + COLOR(134) STRIPE + COLOR(161) STRIPE + ); +} + +void nonbinary_256() { + printf( + COLOR(226) STRIPE + COLOR(255) STRIPE + COLOR(134) STRIPE + COLOR(16) STRIPE + ); +} + +void pansexual_256() { + printf( + COLOR(161) STRIPE STRIPE + COLOR(220) STRIPE STRIPE + COLOR(45) STRIPE STRIPE + ); +} + +void transgender_256() { + printf( + COLOR(45) STRIPE + COLOR(117) STRIPE + COLOR(255) STRIPE + COLOR(117) STRIPE + COLOR(45) STRIPE + ); +} + diff --git a/full.h b/full.h new file mode 100644 index 0000000..1317dd0 --- /dev/null +++ b/full.h @@ -0,0 +1,12 @@ +#pragma once + +#include "color.h" + +void rainbow_256(); +void aroace_256(); +void bisexual_256(); +void lesbian_256(); +void nonbinary_256(); +void pansexual_256(); +void transgender_256(); + diff --git a/main.c b/main.c index a1c84db..819cbf8 100644 --- a/main.c +++ b/main.c @@ -1,17 +1,15 @@ #include #include +#include "color.h" +#include "basic.h" +#include "full.h" + #define VERSION "0.0.1" #define INDENT " " #define RESET "\x1b[0m" -#define COLOR(n) "\x1b[38;5;" #n "m" -#define BLACK "\x1b[38;5;0m" -#define WHITE "\x1b[38;5;255m" - -#define STRIPE "██████████████████\n" - #define RAINBOW "rainbow" #define AROACE "aroace" #define BISEXUAL "bisexual" @@ -49,6 +47,8 @@ int main(int argc, char **argv) { if(argc > 1) { flag = argv[1]; } else { flag = RAINBOW; } + int color_mode = 0; + // handle flags if(strcmp(flag, "--version") == 0) { version(); @@ -59,57 +59,52 @@ int main(int argc, char **argv) { } if(strcmp(flag, RAINBOW) == 0) { // - RAINBOW - - printf(COLOR(196) STRIPE); // red - printf(COLOR(208) STRIPE); // orange - printf(COLOR(220) STRIPE); // yellow - printf(COLOR(28) STRIPE); // green - printf(COLOR(21) STRIPE); // blue - printf(COLOR(90) STRIPE); // purple + if(color_mode) + rainbow_256(); + else + rainbow_8(); } else if(strcmp(flag, AROACE) == 0) { // - ARO/ACE - - printf(COLOR(172) STRIPE); // orange - printf(COLOR(184) STRIPE); // yellow - printf(WHITE STRIPE); // white - printf(COLOR(38) STRIPE); // blue - printf(COLOR(17) STRIPE); // navy + if(color_mode) + aroace_256(); + else + aroace_8(); } else if(strcmp(flag, BISEXUAL) == 0) { // - BISEXUAL - - printf(COLOR(161) STRIPE STRIPE); // maroon - printf(COLOR(91) STRIPE); // purple - printf(COLOR(21) STRIPE STRIPE); // blue + if(color_mode) + aroace_256(); + else + bisexual_8(); } else if(strcmp(flag, LESBIAN) == 0) { // - LESBIAN - - printf(COLOR(202) STRIPE); // orange - printf(COLOR(209) STRIPE); // tangerine - printf(WHITE STRIPE); // white - printf(COLOR(205) STRIPE); // pink - printf(COLOR(161) STRIPE); // magenta + if(color_mode) + lesbian_256(); + else + lesbian_8(); } else if(strcmp(flag, NONBINARY) == 0) { // - NONBINARY - - printf(COLOR(226) STRIPE); // yellow - printf(WHITE STRIPE); // white - printf(COLOR(134) STRIPE); // purple - printf(BLACK STRIPE); // black + if(color_mode) + nonbinary_256(); + else + nonbinary_8(); } else if(strcmp(flag, PANSEXUAL) == 0) { // - PANSEXUAL - - printf(COLOR(161) STRIPE STRIPE); // magenta - printf(COLOR(220) STRIPE STRIPE); // yellow - printf(COLOR(45) STRIPE STRIPE); // cyan + if(color_mode) + pansexual_256(); + else + pansexual_8(); } else if(strcmp(flag, TRANSGENDER) == 0) { // - TRANSGENDER - - char *blue = COLOR(45) STRIPE; - char *pink = COLOR(177) STRIPE; - printf(blue); - printf(pink); - printf(WHITE STRIPE); - printf(pink); - printf(blue); + if(color_mode) + transgender_256(); + else + transgender_8(); }