From 8bc82bc93dee326e72c411dd42f93d5c4da79f06 Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sat, 3 Sep 2022 15:55:16 +0200 Subject: [PATCH] colors update ! --- polynome.c | 39 +++++++++++++++++++++++++++++++++------ polynome.h | 1 + 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/polynome.c b/polynome.c index c4f5a78..96dac1c 100644 --- a/polynome.c +++ b/polynome.c @@ -2,6 +2,8 @@ #include #include #include +#include + #include "polynome.h" enum STATUS Calcul_Delta(Poly* poly) { @@ -121,22 +123,43 @@ enum STATUS Dessiner_Graph(Poly* poly) { if (Calcul_Derivee(poly, i, &y2) == FAIL) { return FAIL; } - + + //wow, much colors ! https://www.codeproject.com/Tips/5255355/How-to-Put-Color-on-Windows-Console if (roundf(y) == j) { if (j == 0) { - printf("-o--"); + if (use_colors) { + printf("-\033[36m\033[1mo\033[0m--"); + } + else { + printf("-o--"); + } } else { - printf(" o "); + if (use_colors) { + printf("\033[36m\033[1m o \033[0m"); + } + else { + printf(" o "); + } } continue; } if (roundf(y2) == j) { if (j == 0) { - printf("-u--"); + if (use_colors) { + printf("-\033[92m\033[1mu\033[0m--"); + } + else { + printf("-u--"); + } } else { - printf(" u "); + if (use_colors) { + printf("\033[92m\033[1m u \033[0m"); + } + else { + printf(" u "); + } } continue; } @@ -178,7 +201,7 @@ enum STATUS Dessiner_Graph(Poly* poly) { int main(int argc, char* argv[]) { if (argc < 4) { - fprintf(stderr, "%s", "[-] usage : poly.exe a b c\n"); + fprintf(stderr, "%s", "[-] usage : poly.exe a b c [--colors]\n"); return 1; } @@ -186,6 +209,10 @@ int main(int argc, char* argv[]) { float b = atof(argv[2]); float c = atof(argv[3]); + if (argc > 4) { + use_colors = true; + } + printf("[+] Processing %.3fx^2%.3fx%.3f\n", a, b, c); Poly* poly = malloc(sizeof(Poly)); diff --git a/polynome.h b/polynome.h index 9723a7c..371e2e4 100644 --- a/polynome.h +++ b/polynome.h @@ -28,5 +28,6 @@ enum STATUS Calcul_Derivee(Poly* poly, float x, float *out); #define LONGUEUR_X 20 #define LONGUEUR_Y 20 void Dessiner_Separateur(); +bool use_colors = false; enum STATUS Dessiner_Graph(Poly* poly); int main(); \ No newline at end of file