diff --git a/.gitignore b/.gitignore index 7fc71cc..75fb9b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /a.out +/pride-c diff --git a/basic.c b/basic.c index 63abdce..88b0fc6 100644 --- a/basic.c +++ b/basic.c @@ -2,25 +2,29 @@ #include +#include "draw.h" + void rainbow_8() { - printf( - RED STRIPE - L_RED STRIPE - L_YELLOW STRIPE - GREEN STRIPE - BLUE STRIPE - MAGENTA STRIPE - ); + color colors [] = { + RED, + L_RED, + L_YELLOW, + GREEN, + BLUE, + MAGENTA + }; + draw(6, colors); } void aroace_8() { - printf( - YELLOW STRIPE - L_YELLOW STRIPE - WHITE STRIPE - L_CYAN STRIPE - BLUE STRIPE - ); + color colors [] = { + YELLOW, + L_YELLOW, + WHITE, + L_CYAN, + BLUE + }; + draw(5, colors); } void bigender_8() { @@ -34,21 +38,25 @@ void bigender_8() { } void bisexual_8() { - printf( - RED STRIPE STRIPE - MAGENTA STRIPE - BLUE STRIPE STRIPE - ); + color colors [] = { + RED, + RED, + MAGENTA, + BLUE, + BLUE + }; + draw(5, colors); } void gay_8() { - printf( - CYAN STRIPE - L_CYAN STRIPE - WHITE STRIPE - L_BLUE STRIPE - BLUE STRIPE - ); + color colors [] = { + CYAN, + L_CYAN, + WHITE, + L_BLUE, + BLUE + }; + draw(5, colors); } void genderfluid_8() { @@ -62,39 +70,46 @@ void genderfluid_8() { } void lesbian_8() { - printf( - RED STRIPE - L_RED STRIPE - WHITE STRIPE - L_MAGENTA STRIPE - MAGENTA STRIPE - ); + color colors [] = { + RED, + L_RED, + WHITE, + L_MAGENTA, + MAGENTA + }; + draw(5, colors); } void nonbinary_8() { - printf( - L_YELLOW STRIPE - WHITE STRIPE - MAGENTA STRIPE - BLACK STRIPE - ); + color colors [] = { + L_YELLOW, + WHITE, + MAGENTA, + BLACK + }; + draw(4, colors); } void pansexual_8() { - printf( - MAGENTA STRIPE STRIPE - L_YELLOW STRIPE STRIPE - CYAN STRIPE STRIPE - ); + color colors [] = { + MAGENTA, + MAGENTA, + L_YELLOW, + L_YELLOW, + CYAN, + CYAN + }; + draw(6, colors); } void transgender_8() { - printf( - L_CYAN STRIPE - L_MAGENTA STRIPE - WHITE STRIPE - L_MAGENTA STRIPE - L_CYAN STRIPE - ); + color colors [] = { + L_CYAN, + L_MAGENTA, + WHITE, + L_MAGENTA, + L_CYAN + }; + draw(5, colors); } diff --git a/basic.h b/basic.h index 524d8f9..64c4496 100644 --- a/basic.h +++ b/basic.h @@ -1,23 +1,21 @@ #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) +#define BLACK 0 +#define RED 1 +#define GREEN 2 +#define YELLOW 3 +#define BLUE 4 +#define MAGENTA 5 +#define CYAN 6 +#define GRAY 7 +#define L_BLACK 8 +#define L_RED 9 +#define L_GREEN 10 +#define L_YELLOW 11 +#define L_BLUE 12 +#define L_MAGENTA 13 +#define L_CYAN 14 +#define WHITE 15 void rainbow_8(); void aroace_8(); diff --git a/color.h b/color.h deleted file mode 100644 index 92ef0a3..0000000 --- a/color.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define COLOR(n) "\x1b[38;5;" #n "m" -#define STRIPE "██████████████████\n" - diff --git a/draw.c b/draw.c new file mode 100644 index 0000000..da7f1e2 --- /dev/null +++ b/draw.c @@ -0,0 +1,10 @@ +#include "draw.h" + +#include + +void draw(unsigned short int len, color colors []) { + for(int i = 0; i < len; i++) { + printf(ANSI "%dm" STRIPE, colors[i]); + } +} + diff --git a/draw.h b/draw.h new file mode 100644 index 0000000..00cc7d4 --- /dev/null +++ b/draw.h @@ -0,0 +1,10 @@ +#pragma once + +#define ANSI "\x1b[38;5;" +#define COLOR(n) ANSI #n "m" +#define STRIPE "██████████████████\n" + +typedef unsigned short int color; + +void draw(unsigned short int len, color colors[]); + diff --git a/full.c b/full.c index ba45508..446ac96 100644 --- a/full.c +++ b/full.c @@ -2,27 +2,29 @@ #include -#include "color.h" +#include "draw.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 - ); + color colors [] = { + 196, // red + 208, // orange + 220, // yellow + 28, // green + 21, // blue + 90 // purple + }; + draw(6, colors); } void aroace_256() { - printf( - COLOR(172) STRIPE - COLOR(184) STRIPE - COLOR(255) STRIPE - COLOR(38) STRIPE - COLOR(17) STRIPE - ); + color colors [] = { + 172, // orange + 184, // yellow + 255, // white + 38, // blue + 17 // navy + }; + draw(5, colors); } void bigender_256() { @@ -36,23 +38,27 @@ void bigender_256() { } void bisexual_256() { - printf( - COLOR(161) STRIPE STRIPE - COLOR(91) STRIPE - COLOR(21) STRIPE STRIPE - ); + color colors [] = { + 161, // magenta + 161, + 91, // purple + 21, + 21 // blue + }; + draw(5, colors); } void gay_256() { - printf( - COLOR(29) STRIPE - COLOR(49) STRIPE - COLOR(123) STRIPE - COLOR(255) STRIPE - COLOR(75) STRIPE - COLOR(63) STRIPE - COLOR(56) STRIPE - ); + color colors [] = { + 29, + 49, // greens + 123, + 255, // white + 75, + 63, // blues + 56 + }; + draw(7, colors); } void genderfluid_256() { @@ -66,39 +72,43 @@ void genderfluid_256() { } void lesbian_256() { - printf( - COLOR(202) STRIPE - COLOR(209) STRIPE - COLOR(255) STRIPE - COLOR(134) STRIPE - COLOR(161) STRIPE - ); + color colors [] = { + 202, // orange + 209, // tangerine + 255, // white + 134, // pink + 161 // magenta + }; + draw(5, colors); } void nonbinary_256() { - printf( - COLOR(226) STRIPE - COLOR(255) STRIPE - COLOR(134) STRIPE - COLOR(16) STRIPE - ); + color colors [] = { + 226, // yellow + 255, // white + 134, // purple + 16 // black + }; + draw(4, colors); } void pansexual_256() { - printf( - COLOR(161) STRIPE STRIPE - COLOR(220) STRIPE STRIPE - COLOR(45) STRIPE STRIPE - ); + color colors [] = { + 161, 161, // magenta + 220, 220, // yellow + 45, 45 // cyan + }; + draw(6, colors); } void transgender_256() { - printf( - COLOR(45) STRIPE - COLOR(117) STRIPE - COLOR(255) STRIPE - COLOR(117) STRIPE - COLOR(45) STRIPE - ); + color colors [] = { + 45, // blue + 213, // pink + 255, // white + 213, // pink + 45 // blue + }; + draw(5, colors); } diff --git a/full.h b/full.h index 48039c3..0ba8d8c 100644 --- a/full.h +++ b/full.h @@ -1,6 +1,6 @@ #pragma once -#include "color.h" +#include "draw.h" void rainbow_256(); void aroace_256(); diff --git a/justfile b/justfile new file mode 100644 index 0000000..ee66722 --- /dev/null +++ b/justfile @@ -0,0 +1,4 @@ + +build: + gcc main.c draw.c basic.c full.c -o pride-c + diff --git a/main.c b/main.c index 794daf4..db2a8eb 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,8 @@ #include +#include #include -#include "color.h" +#include "draw.h" #include "basic.h" #include "full.h" @@ -58,8 +59,12 @@ int main(int argc, char **argv) { help(); return 0; } - + int color_mode = 0; + char * term = getenv("TERM"); + if(strcmp(term, "linux")) + color_mode = 1; + unsigned long flag_hash = djb_hash(flag); char *output; @@ -122,7 +127,7 @@ int main(int argc, char **argv) { case 249901996007388822lu: // 'pansexual' case 193502276lu: // 'pan' if(color_mode) pansexual_256(); - else nonbinary_8(); + else pansexual_8(); break; // - TRANSGENDER -