-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathburningship.c
52 lines (49 loc) · 2.11 KB
/
burningship.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* burningship.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vsivanat <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/08 14:43:32 by vsivanat #+# #+# */
/* Updated: 2024/04/11 18:00:46 by vsivanat ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void loop_img_buringship(t_master *master)
{
master->fract->x = -1;
while (++(master->fract->x) < WINDOW_X)
{
master->fract->y = -1;
while (++(master->fract->y) < WINDOW_Y)
buringship(master);
}
}
void buringship(t_master *master)
{
clear_px(master);
master->px->b = (((WINDOW_Y / -2) + master->fract->y) / master->scale)
+ master->fract->horizontal_shift - 0.5;
master->px->a = (((WINDOW_X / -2) + master->fract->x) / master->scale)
+ master->fract->vertical_shift - 0.5;
master->px->ca = master->px->a;
master->px->cb = master->px->b;
while (master->px->i++ < master->iterations)
{
master->px->aa = master->px->a * master->px->a - master->px->b
* master->px->b;
master->px->bb = 2 * fabs(master->px->a * master->px->b);
master->px->a = master->px->aa + master->px->ca;
master->px->b = master->px->bb + master->px->cb;
if ((master->px->a * master->px->a + master->px->b
* master->px->b) > 16)
break ;
}
if (master->px->i == (master->iterations + 1) || master->px->i == 0)
mlx_put_pixel(master->img, master->fract->x, master->fract->y,
get_grey(0, 255));
else if (master->px->i > 0)
mlx_put_pixel(master->img, master->fract->x, master->fract->y,
get_rgb_a(master->px->i, 255, master));
}