add version
This commit is contained in:
+7
-2
@@ -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) {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef CONST_H
|
||||||
|
#define CONST_H
|
||||||
|
|
||||||
|
#define NAME "margen"
|
||||||
|
#define VERSION "v1.0.0"
|
||||||
|
|
||||||
|
#endif
|
||||||
+14
-9
@@ -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>
|
||||||
@@ -52,18 +53,19 @@ void generate_bmp_line(unsigned short y, unsigned char *data_buffer,
|
|||||||
|
|
||||||
void debug_parameters(parameters params) {
|
void debug_parameters(parameters params) {
|
||||||
if (!params.quiet) {
|
if (!params.quiet) {
|
||||||
printf("output %s\n", params.file_path);
|
printf(" output %s\n", params.file_path);
|
||||||
printf("seed %ld\n", params.seed);
|
printf(" seed %ld\n", params.seed);
|
||||||
printf("width %d\n", params.width);
|
printf(" width %d\n", params.width);
|
||||||
printf("height %d\n", params.height);
|
printf(" height %d\n", params.height);
|
||||||
printf("pixel %d\n", params.size);
|
printf(" pixel %d\n", params.size);
|
||||||
if (params.monochrome) {
|
if (params.monochrome) {
|
||||||
printf("color %u\n", params.start[0]);
|
printf(" color %u\n", params.start[0]);
|
||||||
printf("var. %u\n", params.var[0]);
|
printf(" var. %u\n", params.var[0]);
|
||||||
} 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user