-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.c
55 lines (47 loc) · 1.77 KB
/
helpers.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* helpers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmouhiid <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/20 03:42:54 by mmouhiid #+# #+# */
/* Updated: 2024/01/03 17:04:24 by mmouhiid ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0')
i++;
return (s1[i] - s2[i]);
}
long double scale(long double number, long double inMax,
long double outMin, long double outMax)
{
long double scaled_value;
scaled_value = (number - 0) * (outMax - outMin);
scaled_value = scaled_value / (inMax - 0);
scaled_value = scaled_value + outMin;
return (scaled_value);
}
int exit_handler(t_program *program)
{
if (program->img)
mlx_destroy_image(program->mlx, program->img->img);
if (program->win && program->mlx)
mlx_destroy_window(program->mlx, program->win);
if (program)
free(program);
if (program->img)
free(program->img);
exit(0);
}
void opt_mlx_pixel_put(t_image *img, int x, int y, int color)
{
char *dst;
dst = img->addr + (y * img->line_length + x * (img->bits_per_pixel / 8));
*(unsigned int *)dst = color;
}