-
Notifications
You must be signed in to change notification settings - Fork 0
/
mandelbar.c
55 lines (50 loc) · 1.61 KB
/
mandelbar.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
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mandelbar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlechapt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/13 19:19:57 by rlechapt #+# #+# */
/* Updated: 2015/03/03 09:38:26 by rlechapt ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void calcul_mandelbar(t_env *e, int x, int y)
{
double tmp;
int i;
e->cr = e->x1 + (x - e->width / 2) /
(e->zoom * e->width / 2) + e->movex;
e->ci = e->y1 + (y - e->height / 2) /
(e->zoom * e->height / 2) + e->movey;
e->zr = (double)e->x;
e->zi = (double)e->y;
i = 0;
while (e->zr * e->zr + e->zi * e->zi < 4 && i < e->iter_max)
{
tmp = e->zr;
e->zr = e->zr * e->zr - e->zi * e->zi + e->cr;
e->zi = -(2 * e->zi * tmp + e->ci);
i++;
}
get_color_julia(e, x, y, i);
}
void mandelbar(t_env *e)
{
int x;
int y;
ft_clear_image(e);
x = 0;
while (x < e->width)
{
y = 0;
while (y < e->height)
{
calcul_mandelbar(e, x, y);
y++;
}
x++;
}
mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
}