diff --git a/mandelbrot.c b/mandelbrot.c index 5932c04..0ea47ea 100644 --- a/mandelbrot.c +++ b/mandelbrot.c @@ -18,17 +18,13 @@ int main(int argc, char *argv[]) { int y = i / screen->w; int x = i % screen->w; - if (x == 0) { - printf("y = %d\n", y); - } - - float complex c = ((3.0 * x / screen->w) - 2.0) - + I * ((2.0 * y / screen->h) - 1.0); + float complex c = ((3.0 * x / screen->w) - 2.0) + + I * ((2.0 * y / screen->h) - 1.0); bool diverges = false; float complex z = 0; int it; - for (it=1; it<256; it++) { + for (it = 1; it < 256; it++) { z = cpowf(z, 2) + c; if (cabs(z) > 100) { diverges = true; @@ -47,6 +43,13 @@ int main(int argc, char *argv[]) { if (y % 10 == 0) SDL_Flip(screen); } + + /* Save BMP */ + char *file = "mandelbrot.bmp"; + if (SDL_SaveBMP(screen, file) != 0) { + fprintf(stderr, "Could not write %s!\n", file); + } + if (SDL_MUSTLOCK(screen)) { SDL_UnlockSurface(screen); }