diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-06-06 23:11:34 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-06-06 23:11:34 +1200 |
commit | 7b5eb54e54aad01383912d2e67b996402eb9a602 (patch) | |
tree | f26e094dc944fb13a9035ad7c3d77e62d36c0e44 /mbrot.c | |
parent | a157d1890add21eceddae2adee6213f302bc1bd2 (diff) | |
download | fractal-gen-7b5eb54e54aad01383912d2e67b996402eb9a602.tar.xz |
Updated Makefile, added missing files
Diffstat (limited to 'mbrot.c')
-rw-r--r-- | mbrot.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#include "fractal-gen.h" + +void *generate_mbrot_section(void *section) +{ + data_section *d = (data_section*)section; + unsigned int x,y,i; + int idx = 0; + double a,b; + double complex z,c; + + + d->data = malloc((d->size*d->size)/d->cores); + if (d->data == NULL) + { + perror("malloc"); + return NULL; + } + + + for (y = d->core, b = (d->core*(3.5f/d->size)-1.75f); y < d->size; b+=((d->cores*3.5f)/d->size), y+=d->cores) + { + for (x = 0, a = -2.5f; x < d->size; a+=(3.5f/d->size), x++) + { + z = 0; + c = a+I*b; + for (i = 0; i < d->iterat; i++) + { + if (cabsf(z) >= 2) + break; + + z = cpow(z, d->power)+c; + } + + d->data[idx++] = (255*i)/d->iterat; + } + } + return NULL; +} |