diff options
Diffstat (limited to 'src/mandelbrot.c')
| -rw-r--r-- | src/mandelbrot.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mandelbrot.c b/src/mandelbrot.c index a996b26..3c8ab98 100644 --- a/src/mandelbrot.c +++ b/src/mandelbrot.c @@ -1,19 +1,20 @@ #include "mandel.h" -int mandelbrot(double ca, double cb) +int mandelbrot(double ca, double cb, int iterations) { - double zr = ca; - double zi = cb; - double zr_square; - double zi_square; - int n; - for (n = 0; n < 20; n++) + double zr = ca; + double zi = cb; + double zr_square; + double zi_square; + int n; + + for (n = 0; n < iterations; n++) { zi_square = zi * zi; zr_square = zr * zr; - if (zr_square + zi_square > 4) + if (zr_square + zi_square > 4.0) return n; - zi = 2 * zr * zi; + zi = 2.0 * zr * zi; zr = zr_square - zi_square; zi += cb; zr += ca; |
