add version

This commit is contained in:
2025-06-04 15:04:37 +02:00
parent 216c2d4b00
commit 9903a0c6e5
3 changed files with 28 additions and 11 deletions
+7 -2
View File
@@ -1,4 +1,5 @@
#include "args.h" #include "args.h"
#include "const.h"
#include "rand.h" #include "rand.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -6,8 +7,9 @@
#include <time.h> #include <time.h>
void print_help(int status_code) { void print_help(int status_code) {
puts("usage: margen " puts("usage: " NAME " "
"[--help] " "[--help] "
"[-v] "
"[-q] " "[-q] "
"[-w=WIDTH] " "[-w=WIDTH] "
"[-h=HEIGHT] " "[-h=HEIGHT] "
@@ -16,7 +18,7 @@ void print_help(int status_code) {
"[-p=PIXEL_SIZE] " "[-p=PIXEL_SIZE] "
"[-s=SLOPE] " "[-s=SLOPE] "
"[-c=R,G,B] " "[-c=R,G,B] "
"[-v=R,G,B] " "[--var=R,G,B] "
"[-m]\n\n" "[-m]\n\n"
"generates a marble-like pattern bitmap image.\n\n" "generates a marble-like pattern bitmap image.\n\n"
"options:\n" "options:\n"
@@ -132,6 +134,9 @@ parameters parse_args(int argc, char **argv) {
print_help(0); print_help(0);
} else if (is_arg(arg, "-q") || is_arg(arg, "--quiet")) { } else if (is_arg(arg, "-q") || is_arg(arg, "--quiet")) {
params.quiet = true; params.quiet = true;
} else if (is_arg(arg, "-v") || is_arg(arg, "--version")) {
puts(NAME " " VERSION);
exit(0);
} else if (is_arg(arg, "-w") || is_arg(arg, "--width")) { } else if (is_arg(arg, "-w") || is_arg(arg, "--width")) {
params.width = parse_ushort(arg, value); params.width = parse_ushort(arg, value);
if (params.width == 0) { if (params.width == 0) {
+7
View File
@@ -0,0 +1,7 @@
#ifndef CONST_H
#define CONST_H
#define NAME "margen"
#define VERSION "v1.0.0"
#endif
+6 -1
View File
@@ -1,5 +1,6 @@
#include "args.h" #include "args.h"
#include "bmp.h" #include "bmp.h"
#include "const.h"
#include "rand.h" #include "rand.h"
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
@@ -63,7 +64,8 @@ void debug_parameters(parameters params) {
} else { } else {
printf(" color %u,%u,%u\n", params.start[0], params.start[1], printf(" color %u,%u,%u\n", params.start[0], params.start[1],
params.start[2]); params.start[2]);
printf("var. %u,%u,%u\n", params.var[0], params.var[1], params.var[2]); printf(" var. %u,%u,%u\n", params.var[0], params.var[1],
params.var[2]);
} }
} }
} }
@@ -90,6 +92,9 @@ void clean() {
} }
void generate(parameters params) { void generate(parameters params) {
if (!params.quiet) {
puts(NAME " " VERSION);
}
init(params); init(params);
bmp_generate(params.width, params.height, color_depth, params.file_path, bmp_generate(params.width, params.height, color_depth, params.file_path,
generate_bmp_line); generate_bmp_line);