-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjulia.c
64 lines (60 loc) · 1.91 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
62
63
64
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* julia.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jfortin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/11 14:51:47 by jfortin #+# #+# */
/* Updated: 2016/03/17 18:30:52 by jfortin ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void ft_ini_val_julia(t_env *e)
{
e->x1 = -1.6;
e->x2 = 1;
e->y1 = -1.2;
e->y2 = 1.2;
e->zoom = 250;
e->im_x = (e->x2 - e->x1) * e->zoom + 150;
e->im_y = (e->y2 - e->y1) * e->zoom;
e->iter_max = 90;
e->c_r = 0.285;
e->c_i = 0.01;
}
void ft_print_julia(t_env *e)
{
e->x = -1;
while (++e->x < e->im_x)
{
e->y = -1;
while (++e->y < e->im_y)
{
e->z_r = e->x / e->zoom + e->x1;
e->z_i = e->y / e->zoom + e->y1;
e->i = 0;
while (e->z_r * e->z_r + e->z_i * e->z_i < 4 && e->i < e->iter_max)
{
e->tmp = e->z_r;
e->z_r = e->z_r * e->z_r - e->z_i * e->z_i + e->c_r;
e->z_i = 2 * e->z_i * e->tmp + e->c_i;
e->i++;
}
if (e->i == e->iter_max)
ft_put_pixel(e, e->x, e->y, 0xFFFFFF);
else
ft_put_pixel(e, e->x, e->y, e->i * 1899750);
}
}
}
int ft_julia_hook(int x, int y, t_env *e)
{
if (!(ft_strcmp(e->av, "julia")) &&
x <= IM_X && y <= WIN_Y && x > 0 && y > 0 && e->bj == 0)
{
e->c_r = (float)(x + 400 - IM_X) / 300;
e->c_i = (float)(y + 320 - WIN_Y) / 300;
}
return (0);
}