-
Notifications
You must be signed in to change notification settings - Fork 0
/
julia.c
59 lines (56 loc) · 1.7 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* julia.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yagnaou <yagnaou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/02 16:18:49 by yagnaou #+# #+# */
/* Updated: 2022/03/09 17:23:37 by yagnaou ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int iterate_julia(char *av, t_p *p)
{
if (!ft_strcmp(av, "first_julia"))
{
p->c_re = -0.2321;
p->c_im = -0.835;
}
else if (!ft_strcmp(av, "second_julia"))
{
p->c_re = -0.3842;
p->c_im = -0.70176;
}
else
{
p->c_re = 0.01;
p->c_im = 0.285;
}
while (p->n < 100 && p->re * p->re + p->im * p->im < 4)
{
p->temp = p->re * p->re - p->im * p->im;
p->im = 2 * p->re * p->im + p->c_re;
p->re = p->temp + p->c_im;
p->n++;
}
return (p->n);
}
void julia(char *av, t_p *p)
{
p->i = 0;
while (p->i < WIN_SIZE)
{
p->j = 0;
while (p->j < WIN_SIZE)
{
p->n = 0;
p->re = (p->i - WIN_SIZE / 2) * (p->zoom / WIN_SIZE) + p->x;
p->im = (p->j - WIN_SIZE / 2) * (p->zoom / WIN_SIZE) + p->y;
if (p->n < 100)
my_putpixel(p, p->i, p->j, iterate_julia(av, p) * 0x000f0f);
p->j++;
}
p->i++;
}
}