-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjulia.c
52 lines (47 loc) · 1.6 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* julia.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fvieira <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/30 11:27:09 by fvieira #+# #+# */
/* Updated: 2022/11/30 11:27:13 by fvieira ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int my_mlx_pixel_put(t_fractal *fractal, int x, int y, int color)
{
char *dst;
dst = fractal->addr + (y * fractal->line_length + x
* (fractal->bits_per_pixel / 8));
*(unsigned int *)dst = color;
return (0);
}
void juliaset(t_fractal *julia)
{
int i;
t_complex z0;
t_complex z1;
julia->x = 0;
while (++julia->x <= julia->width)
{
julia->y = 0;
while (++julia->y <= julia->height)
{
z0 = mappoint(julia, julia->x, julia->y);
i = 1;
while (i++ <= julia->iterations)
{
z1 = add(sqr(z0), julia->c);
if (z1.x * z1.x + z1.y * z1.y > julia->radius * julia->radius)
{
my_mlx_pixel_put(julia, julia->x,
julia->y, julia->color * i);
break ;
}
z0 = z1;
}
}
}
}