From 744ba41ebf79be040aaa63ab54d8aa65d09c2253 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Fri, 30 Mar 2018 15:53:42 +0200 Subject: [PATCH] Logos color --- ascii.h | 14 ++++++------ printer.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- printer.h | 3 +++ 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/ascii.h b/ascii.h index 43490a3..5e857da 100644 --- a/ascii.h +++ b/ascii.h @@ -10,12 +10,12 @@ #define AMD4 " \0" #define AMD5 " \0" #define AMD6 " \0" -#define AMD7 " @@@@ @@@% @@@. @@@@@@@@( .############ \0" -#define AMD8 " @@@@@@ @@@@@ %@@@@. @@@ @@@@ .((((((#### \0" -#define AMD9 " @@@ @@@ @@@/@@@@@@&@@. @@@ %@@% # #### \0" -#define AMD10 " @@@, (@@# @@@ @@@/ @@@. @@@ .@@@ ### #### \0" -#define AMD11 " ,@@@@@@@@@@, @@@ @@@. @@@ @@@ #### #### \0" -#define AMD12 " @@@ @@@ @@@ @@@. @@@@@@@@@& #######/ .## \0" +#define AMD7 " @@@@ @@@ @@@ @@@@@@@@ ############ \0" +#define AMD8 " @@@@@@ @@@@@ @@@@ @@@ @@@@ ########## \0" +#define AMD9 " @@@ @@@ @@@@@@@@@@@@@ @@@ @@ # #### \0" +#define AMD10 " @@@ @@@ @@@ @@@ @@@ @@@ @@@ ### #### \0" +#define AMD11 " @@@@@@@@@@@@ @@@ @@@ @@@ @@@ #### ## ### \0" +#define AMD12 " @@@ @@@ @@@ @@@ @@@@@@@@@ ######## ## \0" #define AMD13 " \0" #define AMD14 " \0" #define AMD15 " \0" @@ -39,7 +39,7 @@ #define INTEL12 "## ### ### ### ### ### ### ##### \0" #define INTEL13 "## ## ### ### ##### ######### ## ### \0" #define INTEL14 "### \0" -#define INTEL15 "(### \0" +#define INTEL15 " ### \0" #define INTEL16 " #### #### \0" #define INTEL17 " ##### ########## \0" #define INTEL18 " ########## ################ \0" diff --git a/printer.c b/printer.c index aef7768..332a6f2 100644 --- a/printer.c +++ b/printer.c @@ -5,13 +5,26 @@ #include "printer.h" #include "ascii.h" +#define COL_INTEL_1 "\x1b[34;1m" +#define COL_INTEL_2 "\x1b[37;1m" +#define COL_AMD_1 "\x1b[30;1m" +#define COL_AMD_2 "\x1b[32;1m" +#define RESET "\x1b[0m" + struct ascii { char art[NUMBER_OF_LINES][LINE_SIZE]; + char color1[10]; + char color2[10]; + VENDOR vendor; }; struct ascii* set_ascii(VENDOR cpuVendor) { struct ascii* art = malloc(sizeof(struct ascii)); + art->vendor = cpuVendor; if(cpuVendor == VENDOR_INTEL) { + strcpy(art->color1,COL_INTEL_1); + strcpy(art->color2,COL_INTEL_2); + strcpy(art->art[0],INTEL1); strcpy(art->art[1],INTEL2); strcpy(art->art[2],INTEL3); @@ -34,6 +47,9 @@ struct ascii* set_ascii(VENDOR cpuVendor) { strcpy(art->art[19],INTEL20); } else { + strcpy(art->color1,COL_AMD_1); + strcpy(art->color2,COL_AMD_2); + strcpy(art->art[0],AMD1); strcpy(art->art[1],AMD2); strcpy(art->art[2],AMD3); @@ -59,5 +75,54 @@ struct ascii* set_ascii(VENDOR cpuVendor) { } void print_ascii(struct ascii* art, int n) { - printf("%s",art->art[n]); + int flag = BOOLEAN_FALSE; + + if(art->vendor == VENDOR_INTEL) { + /*** PRINT ASCII WITH SHADOW ***/ + for(int i=0;iart[n][i] == ' ') { + flag = BOOLEAN_FALSE; + printf("%c",art->art[n][i]); + } + else + printf("%s%c" RESET,art->color1,art->art[n][i]); + } + else { + if(art->art[n][i] != ' ') { + flag = BOOLEAN_TRUE; + printf("%s%c" RESET,art->color2,art->art[n][i]); + } + else + printf("%c",art->art[n][i]); + } + } + } + else { + /*** PRINT TEXT AND LOGO IN DIFFERENT COLOR ***/ + for(int i=0;iart[n][i] == '@') + printf("%s%c" RESET,art->color1,art->art[n][i]); + else if(art->art[n][i] == '#') + printf("%s%c" RESET,art->color2,art->art[n][i]); + else + printf("%c",art->art[n][i]); + } + } + } + +/*** PRINT ASCII SIMPLE ***/ +/* +void print_ascii(struct ascii* art, int n) { + int flag = BOOLEAN_FALSE; + + for(int i=0;iart[n][i] != ' ') + printf(BLUE "%c" RESET,art->art[n][i]); + else + printf("%c",art->art[n][i]); + } + +} +*/ diff --git a/printer.h b/printer.h index 41dc9ea..bbe4708 100644 --- a/printer.h +++ b/printer.h @@ -9,6 +9,9 @@ struct ascii; struct ascii* set_ascii(VENDOR cpuVendor); void print_ascii(struct ascii* art, int n); +#define BOOLEAN_TRUE 1 +#define BOOLEAN_FALSE 0 + #define TITLE_NAME "Name: " #define TITLE_ARCH "Arch: " #define TITLE_FREQUENCY "Frequency: "