-
Notifications
You must be signed in to change notification settings - Fork 0
/
mandle3.c
52 lines (48 loc) · 1.7 KB
/
mandle3.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mandle3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmack <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/04 09:58:33 by tmack #+# #+# */
/* Updated: 2016/10/05 07:12:57 by tmack ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void calc_img_n(t_frac *m, double x)
{
m->w_x = (m->s_x_max / m->s_y_max) * (m->s_x - m->s_x_max / 2) /
x + m->pan_x;
m->zx = 0.00;
m->zy = 0.00;
m->zx2 = 0.00;
m->zy2 = 0.00;
m->iterate = -1;
while (++m->iterate < m->iterate_max && ((m->zx2 + m->zy2) < 4))
{
m->zx = m->zx2 * m->zx - 3 * m->zx * m->zy2 + m->w_x;
m->zy = 3 * m->zx2 * m->zy - m->zy2 * m->zy + m->w_y;
m->zx2 = m->zx * m->zx;
m->zy2 = m->zy * m->zy;
}
}
void mandelbrot_three(t_frac *m)
{
double x;
double y;
x = 0.5 * m->zoom * m->s_x_max;
y = 0.5 * m->zoom * m->s_y_max;
set_img(m);
while (++m->s_y < m->s_y_max)
{
m->w_y = (m->s_y - m->s_x_max / 2) / y + m->pan_y;
m->s_x = -1;
while (++m->s_x < m->s_x_max)
{
calc_img_n(m, x);
set_colour(m);
}
}
mlx_put_image_to_window(m->init, m->win, m->img, 0, 0);
}