-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplay.c
62 lines (56 loc) · 1.98 KB
/
display.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* display.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: znichola <znichola@student.42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/28 08:25:27 by znichola #+# #+# */
/* Updated: 2022/12/01 18:32:04 by znichola ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
// int offset = (y * line_length + x * (bits_per_pixel / 8));
void my_mlx_pixel_put(t_data *data, int x, int y, int color)
{
char *dst;
if (x < 0 || y < 0 || x > WIDTH || y > HIGHT)
return ;
dst = data->addr + (y * data->line_length + x * (data->bits_per_pixel / 8));
*(unsigned int *)dst = color;
}
// fast aproximative algo from stackoverflow
void put_circle_fast(t_data *d, int r, t_ipoint center, int colour)
{
int y;
int x;
y = -r;
while (y <= r)
{
x = -r;
while (x <= r)
{
if (x * x + y * y <= r * r)
my_mlx_pixel_put(d, center.x + x, center.y + y, colour);
x++;
}
y++;
}
}
int render_next_frame(t_app *p)
{
if (p->render && p->cf.depth < MAXDEPTH)
{
p->cf.depth += 1;
}
generate_fractal(p);
if (p->fractal_select == JULIA)
put_circle_fast(&p->img, 3,
rworld_to_screen(p, p->world_mouse_right), BACKGROUND);
if (p->mouse_left_toggle)
display_itterations(p);
mlx_put_image_to_window(p->vars.mlx, p->vars.win, p->img.img, 0, 0);
return (0);
}
// if (p->cf.depth < p->start_depth + 20)
// printf("mouse_down put circle"); pi(p->mouse_down); printf("\n");