aboutsummaryrefslogtreecommitdiff
path: root/bship.c
diff options
context:
space:
mode:
Diffstat (limited to 'bship.c')
-rw-r--r--bship.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/bship.c b/bship.c
new file mode 100644
index 0000000..a9b7be2
--- /dev/null
+++ b/bship.c
@@ -0,0 +1,38 @@
+#include "fractal-gen.h"
+
+void *generate_bship_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( cabsf(crealf(z)) + I*cabsf(cimagf(z)) , d->power) + c;
+ }
+
+ d->data[idx++] = (255*i)/d->iterat;
+ }
+ }
+ return NULL;
+}