buddhabrot/src/main.c

34 lines
679 B
C
Raw Permalink Normal View History

2020-11-10 16:40:06 +01:00
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include "buddhabrot.h"
2020-11-10 16:31:32 +01:00
#include "image.h"
#include "mandelbrot.h"
2020-11-10 17:25:43 +01:00
#include "options.h"
2020-11-10 16:31:32 +01:00
#include "ppm.h"
2020-11-10 17:25:43 +01:00
int main(int argc, char *argv[]) {
struct options opt = parse_options(&argc, &argv);
struct image *image = create_image(opt.w, opt.h);
2020-11-10 16:40:06 +01:00
if (!image)
err(EXIT_FAILURE, "could not allocate image");
switch (opt.render) {
case BUDDHABROT:
buddhabrot(image, opt.max_iter);
break;
case MANDELBROT:
mandelbrot(image, opt.max_iter);
break;
}
2020-11-10 17:25:43 +01:00
print_ppm(image, opt.output);
fclose(opt.output);
2020-11-10 16:40:06 +01:00
destroy_image(image);
return EXIT_SUCCESS;
2020-11-10 16:23:02 +01:00
}