-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.c
64 lines (57 loc) · 1.89 KB
/
tools.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tools.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sel-hamr <sel-hamr@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/23 09:31:15 by sel-hamr #+# #+# */
/* Updated: 2019/12/25 10:23:26 by sel-hamr ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int str_cmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] == s2[i] && s1[i] && s2[i])
i++;
return (s1[i] - s2[i]);
}
void set_color(t_t *t, int color)
{
t->index = (4 * 1000 * t->y_y) + t->x_x * 4;
t->ch[t->index] = (t->itier * t->color + 680 + 179) * color;
t->ch[t->index + 1] = (t->itier * t->color + 42 + 84) * color;
t->ch[t->index + 2] = (t->itier * t->color + 936 + 45) * color;
t->ch[t->index + 3] = 0;
}
double ft_abs(double x)
{
if (x < 0)
return (-x);
return (x);
}
void map(t_t *t)
{
t->x = t->x_x / (WIDTH / (t->end_x - t->start_x)) + t->start_x;
t->y = t->y_y / (HIGHT / (t->end_y - t->start_y)) + t->start_y;
t->x_o = t->x;
t->y_o = t->y;
}
void itier_loop(t_t *t)
{
while (t->itier < t->max)
{
t->xtmp = t->x * t->x - t->y * t->y;
if (str_cmp(t->name, "Burningship") == 0)
t->ytmp = ft_abs(2 * t->x * t->y);
else
t->ytmp = 2 * t->x * t->y;
t->x = t->xtmp + t->x_o;
t->y = t->ytmp + t->y_o;
if (t->x * t->x + t->y * t->y > 4)
break ;
t->itier++;
}
}