colors update !

This commit is contained in:
ALittlePatate
2022-09-03 15:55:16 +02:00
parent e624b56624
commit 8bc82bc93d
2 changed files with 34 additions and 6 deletions

View File

@@ -2,6 +2,8 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include "polynome.h"
enum STATUS Calcul_Delta(Poly* poly) {
@@ -122,22 +124,43 @@ enum STATUS Dessiner_Graph(Poly* poly) {
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) {
if (use_colors) {
printf("-\033[36m\033[1mo\033[0m--");
}
else {
printf("-o--");
}
}
else {
if (use_colors) {
printf("\033[36m\033[1m o \033[0m");
}
else {
printf(" o ");
}
}
continue;
}
if (roundf(y2) == j) {
if (j == 0) {
if (use_colors) {
printf("-\033[92m\033[1mu\033[0m--");
}
else {
printf("-u--");
}
}
else {
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));

View File

@@ -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();