-
Notifications
You must be signed in to change notification settings - Fork 0
/
zoomfix.c
69 lines (62 loc) · 2.1 KB
/
zoomfix.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* zoomfix.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ggiannit <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/07 10:54:33 by ggiannit #+# #+# */
/* Updated: 2023/02/07 10:56:19 by ggiannit ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void ft_set_zoom_td(t_map *map)
{
int diff_y;
map->zoom = (WIN_WIDE - (WIN_WIDE / 10)) / (map->x);
ft_set_dot(map, ft_isometric);
while (map->min_x < map->minmax[MINX] || map->max_x > map->minmax[MAXX])
{
map->zoom -= 1;
ft_set_dot(map, ft_isometric);
}
while (map->min_y < map->minmax[MINY])
{
diff_y = abs(map->min_y - map->minmax[MINY]);
if (diff_y + map->max_y < map->minmax[MAXY])
map->zy += diff_y;
else
map->zoom -= 1;
ft_set_dot(map, ft_isometric);
}
}
void ft_orto_zoomfix(t_map *map)
{
int zoom_x;
int zoom_y;
int new_wide;
new_wide = WIN_WIDE - (WIN_WIDE / 6);
zoom_x = ((new_wide >> 1) - ((new_wide >> 1) / 10)) / map->x;
zoom_y = ((WIN_HEIGHT >> 1) - ((WIN_HEIGHT >> 1) / 10)) / map->y;
if (zoom_x > zoom_y)
map->zoom = zoom_y;
else
map->zoom = zoom_x;
if (!map->zoom)
map->zoom = 1;
}
int check_zoomfit_down(t_map *map, int new_zx, int new_zy, int k)
{
int diff_y;
ft_set_orto(map, new_zx, new_zy + k, ft_ytoz);
while (map->min_y < new_zy + 15 || map->max_y > WIN_HEIGHT - 15)
{
diff_y = abs(map->min_y - new_zy - 15);
if (diff_y + map->max_y < WIN_HEIGHT - 15)
k += diff_y;
else
map->zoom -= 1;
ft_set_orto(map, new_zx, new_zy + k, ft_ytoz);
}
return (k);
}