From cdf84a50abd343ff9e72ddeb0e79e118cc6769de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20R=C3=B3=C5=BCewski?= Date: Tue, 27 Aug 2024 00:52:16 +0200 Subject: [PATCH] fix: background color first in lib This change is for swapping color in function on library. The background color in `cprint` function is first and then the foreground color. I think is more intuitive. --- lib/mdsanima.c | 4 ++-- lib/mdsanima.h | 4 ++-- project/mdsanima-amarooke/main.c | 4 ++-- project/mdsanima-blizzard/main.c | 4 ++-- project/mdsanima-conquest/main.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/mdsanima.c b/lib/mdsanima.c index 7b92cfd..82a6ed9 100644 --- a/lib/mdsanima.c +++ b/lib/mdsanima.c @@ -6,7 +6,7 @@ #include #include -void cprint(const char *text, int foreground, int background) +void cprint(const char *text, int background, int foreground) { - printf("\e[38;5;%dm\e[48;5;%dm\e[1m%s\e[0m\n", foreground, background, text); + printf("\e[48;5;%dm\e[38;5;%dm\e[1m%s\e[0m\n", background, foreground, text); } diff --git a/lib/mdsanima.h b/lib/mdsanima.h index 78f2483..5724a1f 100644 --- a/lib/mdsanima.h +++ b/lib/mdsanima.h @@ -12,9 +12,9 @@ * @note Wrapper for the ANSI escape sequence, where 0 is black and 255 is white. * * @param text The bold text message to stdout print in the color on the terminal. - * @param foreground The foreground color of the text message. A number from 0 to 255. * @param background The background color of the text message. A number from 0 to 255. + * @param foreground The foreground color of the text message. A number from 0 to 255. */ -void cprint(const char *text, int foreground, int background); +void cprint(const char *text, int background, int foreground); #endif diff --git a/project/mdsanima-amarooke/main.c b/project/mdsanima-amarooke/main.c index 9054ec2..ccef6d8 100644 --- a/project/mdsanima-amarooke/main.c +++ b/project/mdsanima-amarooke/main.c @@ -8,10 +8,10 @@ int main(void) { const char *message = " MDSANIMA AMAROOKE "; - const int fgColor = 38; // Text color const int bgColor = 26; // Background color + const int fgColor = 38; // Text color - cprint(message, fgColor, bgColor); + cprint(message, bgColor, fgColor); return 0; } diff --git a/project/mdsanima-blizzard/main.c b/project/mdsanima-blizzard/main.c index 982a90a..20b9797 100644 --- a/project/mdsanima-blizzard/main.c +++ b/project/mdsanima-blizzard/main.c @@ -8,10 +8,10 @@ int main(void) { const char *message = " MDSANIMA BLIZZARD "; - const int fgColor = 48; // Text color const int bgColor = 36; // Background color + const int fgColor = 48; // Text color - cprint(message, fgColor, bgColor); + cprint(message, bgColor, fgColor); return 0; } diff --git a/project/mdsanima-conquest/main.c b/project/mdsanima-conquest/main.c index 0fdae1e..c515a4f 100644 --- a/project/mdsanima-conquest/main.c +++ b/project/mdsanima-conquest/main.c @@ -8,10 +8,10 @@ int main(void) { const char *message = " MDSANIMA CONQUEST "; - const int fgColor = 74; // Text color const int bgColor = 62; // Background color + const int fgColor = 74; // Text color - cprint(message, fgColor, bgColor); + cprint(message, bgColor, fgColor); return 0; }