-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjulia.c
More file actions
59 lines (53 loc) · 1.67 KB
/
julia.c
File metadata and controls
59 lines (53 loc) · 1.67 KB
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: dbreton <dbreton@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/12/21 12:40:34 by dbreton #+# #+# */
/* Updated: 2015/12/29 11:55:15 by dbreton ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int julia_color(const t_mlx *s, const int i)
{
if (s->color == 1)
return (0x40 + 0x000804 * i);
else
return (0x11 * i + 0x032500);
}
void julia_ite(t_mlx *s, int x, int y)
{
long long i;
double tmp;
i = 0;
while ((pow(s->z_r, 2) + pow(s->z_i, 2) < 4) && (i < s->max_ite))
{
tmp = s->z_r;
s->z_r = pow(s->z_r, 2) - pow(s->z_i, 2) + s->c_r;
s->z_i = 2 * s->z_i * tmp + s->c_i;
i += 1;
}
put_in_image(s, x, y, julia_color(s, i));
}
void julia_set(t_mlx *s)
{
int x;
int y;
y = 0;
while (y < WIN_MAX_Y + 1)
{
x = 0;
while (x < WIN_MAX_X + 1)
{
s->z_r = 1.5 * (x - s->x_start) /
(0.25 * (s->zoom / 100) * WIN_MAX_X) * 10;
s->z_i = (y - s->y_start) /
(0.25 * (s->zoom / 100) * WIN_MAX_Y) * 10;
julia_ite(s, x, y);
x++;
}
y++;
}
}