-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.c
61 lines (57 loc) · 1.21 KB
/
color.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include "color.h"
void setColor(Color c){
char escape[] = "\033";
char * col;
switch (c) {
case red:
col = "[0;31m";
break;
case boldRed:
col = "[1;31m";
break;
case green:
col = "[0;32m";
break;
case boldGreen:
col = "[1;32m";
break;
case yellow:
col = "[0;33m";
break;
case boldYellow:
col = "[1;33m";
break;
case blue:
col = "[0;34m";
break;
case boldBlue:
col = "[1;34m";
break;
case magenta:
col = "[0;35m";
break;
case boldMagenta:
col = "[1;35m";
break;
case cyan:
col = "[0;36m";
break;
case boldCyan:
col = "[1;36m";
break;
default:
col = "[0m";
break;
}
printf("%s%s",escape,col);
}
void resetColor(){
char escape[] = "\033";
char col[] = "[0m";
printf("%s%s",escape,col);
}
Color getRandomColorValue() {
return (Color)(rand() % 12);
}