-
Notifications
You must be signed in to change notification settings - Fork 0
/
julia.c
61 lines (56 loc) · 1.74 KB
/
julia.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
56
57
58
59
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* julia.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahmaymou <ahmaymou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/17 18:14:41 by ahmaymou #+# #+# */
/* Updated: 2023/01/29 16:27:07 by ahmaymou ### ########.fr */
/* */
/* ************************************************************************** */
#include "fract_ol.h"
int count_iter_jul(t_cmp c, t_cmp fix, t_mlx_info *info)
{
t_cmp new_z;
double temp;
int iter;
iter = 0;
new_z = c;
while (iter < info->iter_max)
{
if (magnitude(new_z.real, new_z.imag) >= 2)
return (iter);
temp = new_z.real;
new_z.real = new_z.real * new_z.real
- new_z.imag * new_z.imag - fix.real;
new_z.imag = 2 * new_z.imag * temp + fix.imag;
iter++;
}
return (info->iter_max);
}
void draw_julia(t_mlx_info *info)
{
double i;
double j;
int iter;
int color;
t_cmp z;
i = -1;
while (++i < 800)
{
j = -1;
while (++j < HEIGHT)
{
z = convert(i, j, info);
if (iter == info->iter_max)
color = 0;
else
color = iter * info->p;
iter = count_iter_jul(z, info->fix, info);
my_mlx_pixel_put(&info->data, i, j, color);
}
}
mlx_put_image_to_window(info->mlx_ptr, info->window_ptr,
info->data.img, 0, 0);
}