58 lines
1.9 KiB
C
58 lines
1.9 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* utils.h :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/10/15 16:56:47 by mcolonna #+# #+# */
|
|
/* Updated: 2024/10/29 14:01:34 by mcolonna ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef UTILS_H
|
|
# define UTILS_H
|
|
|
|
# include <linux/types.h>
|
|
|
|
typedef struct s_point_double
|
|
{
|
|
double x;
|
|
double y;
|
|
} t_point_double;
|
|
|
|
typedef struct s_point_int
|
|
{
|
|
int x;
|
|
int y;
|
|
} t_point_int;
|
|
|
|
// TODO Must the transparency be 0 or 255?
|
|
/// @brief Represents an TRGB color in 0xTTRRGGBB format.
|
|
typedef __u32 t_color;
|
|
|
|
/// @brief Convert a color from each color value to a t_color.
|
|
///
|
|
/// @param red Level of red from 0 to 255.
|
|
/// @param green Level of green from 0 to 255.
|
|
/// @param blue Level of blue from 0 to 255.
|
|
/// @return The result.
|
|
t_color color_from_rgb(int red, int green, int blue);
|
|
|
|
void write_err(const char *str, ...);
|
|
|
|
/// @brief Call the function in loop.
|
|
/// If not enough time passed since the last call, returns without doing
|
|
/// anything.
|
|
///
|
|
/// @param f Function to call in loop.
|
|
void timedloop(void (*f)(void));
|
|
|
|
/// @brief Get an address to the image data, but only if
|
|
/// bpp == 32 and endian == 0.
|
|
///
|
|
/// @param img_ptr mlx image to use.
|
|
/// @return Address to the data, or NULL if error.
|
|
u_int32_t *get_data_addr(void *img_ptr);
|
|
|
|
#endif
|