merge changes from 256-color

This commit is contained in:
Valerie Wolfe 2024-03-23 00:39:06 -04:00
commit 3d7383fb0c
10 changed files with 182 additions and 134 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/a.out /a.out
/pride-c

119
basic.c
View file

@ -2,25 +2,29 @@
#include <stdio.h> #include <stdio.h>
#include "draw.h"
void rainbow_8() { void rainbow_8() {
printf( color colors [] = {
RED STRIPE RED,
L_RED STRIPE L_RED,
L_YELLOW STRIPE L_YELLOW,
GREEN STRIPE GREEN,
BLUE STRIPE BLUE,
MAGENTA STRIPE MAGENTA
); };
draw(6, colors);
} }
void aroace_8() { void aroace_8() {
printf( color colors [] = {
YELLOW STRIPE YELLOW,
L_YELLOW STRIPE L_YELLOW,
WHITE STRIPE WHITE,
L_CYAN STRIPE L_CYAN,
BLUE STRIPE BLUE
); };
draw(5, colors);
} }
void bigender_8() { void bigender_8() {
@ -34,21 +38,25 @@ void bigender_8() {
} }
void bisexual_8() { void bisexual_8() {
printf( color colors [] = {
RED STRIPE STRIPE RED,
MAGENTA STRIPE RED,
BLUE STRIPE STRIPE MAGENTA,
); BLUE,
BLUE
};
draw(5, colors);
} }
void gay_8() { void gay_8() {
printf( color colors [] = {
CYAN STRIPE CYAN,
L_CYAN STRIPE L_CYAN,
WHITE STRIPE WHITE,
L_BLUE STRIPE L_BLUE,
BLUE STRIPE BLUE
); };
draw(5, colors);
} }
void genderfluid_8() { void genderfluid_8() {
@ -62,39 +70,46 @@ void genderfluid_8() {
} }
void lesbian_8() { void lesbian_8() {
printf( color colors [] = {
RED STRIPE RED,
L_RED STRIPE L_RED,
WHITE STRIPE WHITE,
L_MAGENTA STRIPE L_MAGENTA,
MAGENTA STRIPE MAGENTA
); };
draw(5, colors);
} }
void nonbinary_8() { void nonbinary_8() {
printf( color colors [] = {
L_YELLOW STRIPE L_YELLOW,
WHITE STRIPE WHITE,
MAGENTA STRIPE MAGENTA,
BLACK STRIPE BLACK
); };
draw(4, colors);
} }
void pansexual_8() { void pansexual_8() {
printf( color colors [] = {
MAGENTA STRIPE STRIPE MAGENTA,
L_YELLOW STRIPE STRIPE MAGENTA,
CYAN STRIPE STRIPE L_YELLOW,
); L_YELLOW,
CYAN,
CYAN
};
draw(6, colors);
} }
void transgender_8() { void transgender_8() {
printf( color colors [] = {
L_CYAN STRIPE L_CYAN,
L_MAGENTA STRIPE L_MAGENTA,
WHITE STRIPE WHITE,
L_MAGENTA STRIPE L_MAGENTA,
L_CYAN STRIPE L_CYAN
); };
draw(5, colors);
} }

34
basic.h
View file

@ -1,23 +1,21 @@
#pragma once #pragma once
#include "color.h" #define BLACK 0
#define RED 1
#define BLACK COLOR(0) #define GREEN 2
#define RED COLOR(1) #define YELLOW 3
#define GREEN COLOR(2) #define BLUE 4
#define YELLOW COLOR(3) #define MAGENTA 5
#define BLUE COLOR(4) #define CYAN 6
#define MAGENTA COLOR(5) #define GRAY 7
#define CYAN COLOR(6) #define L_BLACK 8
#define GRAY COLOR(7) #define L_RED 9
#define L_BLACK COLOR(8) #define L_GREEN 10
#define L_RED COLOR(9) #define L_YELLOW 11
#define L_GREEN COLOR(10) #define L_BLUE 12
#define L_YELLOW COLOR(11) #define L_MAGENTA 13
#define L_BLUE COLOR(12) #define L_CYAN 14
#define L_MAGENTA COLOR(13) #define WHITE 15
#define L_CYAN COLOR(14)
#define WHITE COLOR(15)
void rainbow_8(); void rainbow_8();
void aroace_8(); void aroace_8();

View file

@ -1,5 +0,0 @@
#pragma once
#define COLOR(n) "\x1b[38;5;" #n "m"
#define STRIPE "██████████████████\n"

10
draw.c Normal file
View file

@ -0,0 +1,10 @@
#include "draw.h"
#include <stdio.h>
void draw(unsigned short int len, color colors []) {
for(int i = 0; i < len; i++) {
printf(ANSI "%dm" STRIPE, colors[i]);
}
}

10
draw.h Normal file
View file

@ -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[]);

120
full.c
View file

@ -2,27 +2,29 @@
#include <stdio.h> #include <stdio.h>
#include "color.h" #include "draw.h"
void rainbow_256() { void rainbow_256() {
printf( color colors [] = {
COLOR(196) STRIPE // red 196, // red
COLOR(208) STRIPE // orange 208, // orange
COLOR(220) STRIPE // yellow 220, // yellow
COLOR(28) STRIPE // green 28, // green
COLOR(21) STRIPE // blue 21, // blue
COLOR(90) STRIPE // purple 90 // purple
); };
draw(6, colors);
} }
void aroace_256() { void aroace_256() {
printf( color colors [] = {
COLOR(172) STRIPE 172, // orange
COLOR(184) STRIPE 184, // yellow
COLOR(255) STRIPE 255, // white
COLOR(38) STRIPE 38, // blue
COLOR(17) STRIPE 17 // navy
); };
draw(5, colors);
} }
void bigender_256() { void bigender_256() {
@ -36,23 +38,27 @@ void bigender_256() {
} }
void bisexual_256() { void bisexual_256() {
printf( color colors [] = {
COLOR(161) STRIPE STRIPE 161, // magenta
COLOR(91) STRIPE 161,
COLOR(21) STRIPE STRIPE 91, // purple
); 21,
21 // blue
};
draw(5, colors);
} }
void gay_256() { void gay_256() {
printf( color colors [] = {
COLOR(29) STRIPE 29,
COLOR(49) STRIPE 49, // greens
COLOR(123) STRIPE 123,
COLOR(255) STRIPE 255, // white
COLOR(75) STRIPE 75,
COLOR(63) STRIPE 63, // blues
COLOR(56) STRIPE 56
); };
draw(7, colors);
} }
void genderfluid_256() { void genderfluid_256() {
@ -66,39 +72,43 @@ void genderfluid_256() {
} }
void lesbian_256() { void lesbian_256() {
printf( color colors [] = {
COLOR(202) STRIPE 202, // orange
COLOR(209) STRIPE 209, // tangerine
COLOR(255) STRIPE 255, // white
COLOR(134) STRIPE 134, // pink
COLOR(161) STRIPE 161 // magenta
); };
draw(5, colors);
} }
void nonbinary_256() { void nonbinary_256() {
printf( color colors [] = {
COLOR(226) STRIPE 226, // yellow
COLOR(255) STRIPE 255, // white
COLOR(134) STRIPE 134, // purple
COLOR(16) STRIPE 16 // black
); };
draw(4, colors);
} }
void pansexual_256() { void pansexual_256() {
printf( color colors [] = {
COLOR(161) STRIPE STRIPE 161, 161, // magenta
COLOR(220) STRIPE STRIPE 220, 220, // yellow
COLOR(45) STRIPE STRIPE 45, 45 // cyan
); };
draw(6, colors);
} }
void transgender_256() { void transgender_256() {
printf( color colors [] = {
COLOR(45) STRIPE 45, // blue
COLOR(117) STRIPE 213, // pink
COLOR(255) STRIPE 255, // white
COLOR(117) STRIPE 213, // pink
COLOR(45) STRIPE 45 // blue
); };
draw(5, colors);
} }

2
full.h
View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "color.h" #include "draw.h"
void rainbow_256(); void rainbow_256();
void aroace_256(); void aroace_256();

4
justfile Normal file
View file

@ -0,0 +1,4 @@
build:
gcc main.c draw.c basic.c full.c -o pride-c

11
main.c
View file

@ -1,7 +1,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "color.h" #include "draw.h"
#include "basic.h" #include "basic.h"
#include "full.h" #include "full.h"
@ -58,8 +59,12 @@ int main(int argc, char **argv) {
help(); help();
return 0; return 0;
} }
int color_mode = 0; int color_mode = 0;
char * term = getenv("TERM");
if(strcmp(term, "linux"))
color_mode = 1;
unsigned long flag_hash = djb_hash(flag); unsigned long flag_hash = djb_hash(flag);
char *output; char *output;
@ -122,7 +127,7 @@ int main(int argc, char **argv) {
case 249901996007388822lu: // 'pansexual' case 249901996007388822lu: // 'pansexual'
case 193502276lu: // 'pan' case 193502276lu: // 'pan'
if(color_mode) pansexual_256(); if(color_mode) pansexual_256();
else nonbinary_8(); else pansexual_8();
break; break;
// - TRANSGENDER - // - TRANSGENDER -