-
Notifications
You must be signed in to change notification settings - Fork 0
/
mandelbrotJuliaSet_v1_1_0.h
71 lines (65 loc) · 1.59 KB
/
mandelbrotJuliaSet_v1_1_0.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _MANDELBROTJULIASET_H
#define _MANDELBROTJULIASET_H 0x010100
#define _BMP_GRADIENT
#define _BMP_TRANSFORM
#include "bmpEncoder.h"
#if _BMPENCODER_H < 0x010201
#error bmpEncoder.h lower than v1.2.1
#endif
#ifdef __cplusplus
extern "C" {
#endif
int mandelbrotSet(const char *filename, _ulong width, _ulong height, TRANSFORMATION transX, TRANSFORMATION transY, _ulong (*gradient)(_ulong)) {
BITMAP *bitmap=BitmapHeaderInit(filename, 0, width, height);
_ulong i, j, cnt;
double x, y, m, n, p, q;
for(i=0; i<height; ++i) {
for(j=0; j<width; ++j) {
x = Transform(transX, j);
y = Transform(transY, i);
m = 0;
n = 0;
for(cnt=0; cnt<137; cnt++) {
p = m*m - n*n + x;
q = 2*m*n + y;
m = p;
n = q;
if(m*m + n*n > 4.0) break;
}
BitmapSetThrough(bitmap, (*gradient)(cnt));
}
BitmapWritePad(bitmap);
BitmapFlush(bitmap);
}
BitmapClose(bitmap);
return 0;
}
int juliaSet(const char *filename, _ulong width, _ulong height, TRANSFORMATION transX, TRANSFORMATION transY, double initX, double initY, _ulong (*gradient)(_ulong)) {
BITMAP *bitmap=BitmapHeaderInit(filename, 0, width, height);
_ulong i, j, cnt;
double x, y, m, n, p, q;
for(i=0; i<height; ++i) {
for(j=0; j<width; ++j) {
x = initX;
y = initY;
m = Transform(transX, j);
n = Transform(transY, i);
for(cnt=0; cnt<137; cnt++) {
p = m*m - n*n + x;
q = 2*m*n + y;
m = p;
n = q;
if(m*m + n*n > 4.0) break;
}
BitmapSetThrough(bitmap, (*gradient)(cnt));
}
BitmapWritePad(bitmap);
BitmapFlush(bitmap);
}
BitmapClose(bitmap);
return 0;
}
#ifdef __cplusplus
}
#endif
#endif