-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractol_bounds.c
69 lines (63 loc) · 1.75 KB
/
fractol_bounds.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
65
66
67
68
69
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol_bounds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpeters <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/06 22:24:17 by tpeters #+# #+# */
/* Updated: 2022/11/06 22:31:52 by tpeters ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void set_bounds(t_vars *vars, t_bounds in)
{
vars->xmin = in.a;
vars->xmax = in.b;
vars->ymin = in.c;
vars->ymax = in.d;
calc_len(vars);
}
void calc_len(t_vars *vars)
{
vars->x_len = (vars->xmax - vars->xmin);
vars->y_len = (vars->ymax - vars->ymin);
}
void inc_max_dep(t_vars *vars)
{
int c;
int d;
c = 0;
if (vars->show_rects)
init_depth_array(vars->depths);
else
{
while (c < WIDTH)
{
d = 0;
while (d < HEIGHT)
{
if (vars->depths[c][d] == vars->max_depth)
vars->depths[c][d] = -1;
d++;
}
c++;
}
}
if (vars->max_depth < 50)
vars->max_depth += 5 - 4 * (vars->max_depth < 10);
else
vars->max_depth += 10;
}
void dec_max_dep(t_vars *vars)
{
if (vars->max_depth > 0)
{
if (vars->max_depth <= 10)
vars->max_depth -= 1;
else if (vars->max_depth <= 50)
vars->max_depth -= 5;
else
vars->max_depth -= 10;
}
}