diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-09-17 17:08:10 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-09-17 17:08:10 +0200 |
| commit | 95b209426dd7a9f844cf1aa093a2b1c4301f049b (patch) | |
| tree | d52a30d085147646071b6d6fe96a1aae411339a4 /main.c | |
| parent | 6f826d798eaaf01d2025de791985427faa0a6a6b (diff) | |
| download | mandelbrot_cpu-95b209426dd7a9f844cf1aa093a2b1c4301f049b.tar.gz mandelbrot_cpu-95b209426dd7a9f844cf1aa093a2b1c4301f049b.tar.bz2 mandelbrot_cpu-95b209426dd7a9f844cf1aa093a2b1c4301f049b.zip | |
Options
A Config struct and more getopt options for window size, real/imag
range, center position.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 59 |
1 files changed, 55 insertions, 4 deletions
@@ -1,25 +1,76 @@ #include <getopt.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> #include "header.h" +#define CHAR_SIZE sizeof(char) +#define DEFAULT_WINDOW_W 200 +#define DEFAULT_WINDOW_H 200 +#define DEFAULT_CENTER_X 0.0 +#define DEFAULT_CENTER_Y 0.0 +#define DEFAULT_REAL_RANGE 4.0 +#define DEFAULT_IMAG_RANGE 4.0 + +static void print_help(void); + int main(int argc, char **argv) { int opt; + Config config; + /* Image *image = NULL; */ - while ((opt = getopt(argc, argv, "c")) != -1) + config.window_w = DEFAULT_WINDOW_W; + config.window_h = DEFAULT_WINDOW_H; + config.center_x = DEFAULT_CENTER_X; + config.center_y = DEFAULT_CENTER_Y; + config.real_range = DEFAULT_REAL_RANGE; + config.imag_range = DEFAULT_IMAG_RANGE; + while ((opt = getopt(argc, argv, "hps:r:c:")) != -1) { switch (opt) { - case 'c': + case 'p': mandelbrot_print(); exit(EXIT_SUCCESS); break; + /* case 'i': */ + /* image = image_init(); */ + case 'h': + print_help(); + exit(EXIT_SUCCESS); + break; + case 's': + config.window_w = atoi(optarg); + config.window_h = atoi(strstr(optarg, ",") + CHAR_SIZE); + break; + case 'r': + config.real_range = atof(optarg); + config.imag_range = atof(strstr(optarg, ",") + CHAR_SIZE); + break; + case 'c': + config.center_x = atof(optarg); + config.center_y = atof(strstr(optarg, ",") + CHAR_SIZE); + break; + case '?': default: - fprintf(stderr, "Usage %s ...", argv[0]); + fprintf(stderr, "Usage %s [pwh]", argv[0]); + exit(EXIT_FAILURE); } } - GState *gstate = graphics_init(); + /* if (image != NULL) */ + /* { */ + /* */ + /* return EXIT_SUCCESS; */ + /* } */ + GState *gstate = graphics_init(&config); graphics_run(gstate); graphics_quit(gstate); return EXIT_SUCCESS; } + +static void print_help(void) +{ + printf("help"); +} |
