|
|
|
@ -35,8 +35,24 @@ char help_text[] = "\nUsage: colcat [args] [--] [FILES] \n"
@@ -35,8 +35,24 @@ char help_text[] = "\nUsage: colcat [args] [--] [FILES] \n"
|
|
|
|
|
|
|
|
|
|
/* Print the nth colour of the <rainbow_len> chars long rainbow */ |
|
|
|
|
void print_next_colour(int current) { |
|
|
|
|
static bool reverse = false; |
|
|
|
|
|
|
|
|
|
if (current % rainbow_len == 0) { |
|
|
|
|
reverse = !reverse; |
|
|
|
|
} |
|
|
|
|
if (current == 0) { |
|
|
|
|
reverse = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int index = 0; |
|
|
|
|
if (!reverse) { |
|
|
|
|
index = (current % num_colours) / col_dist; |
|
|
|
|
} else { |
|
|
|
|
index = num_colours -1- (current % num_colours) / col_dist; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (current % col_dist == 0) { |
|
|
|
|
struct colour c = colours[(current % num_colours) / col_dist]; |
|
|
|
|
struct colour c = colours[index]; |
|
|
|
|
printf("\x1b[38;2;%d;%d;%dm", c.r, c.g, c.b); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|