fractol/inc/fractol.h
2017-03-20 21:08:13 +02:00

120 lines
2.8 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/16 20:59:04 by gtertysh #+# #+# */
/* Updated: 2017/03/20 15:32:52 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRACTOL_H
# define FRACTOL_H
# include "libft.h"
# include "mlx.h"
# include <math.h>
# include <fcntl.h>
#include <stdio.h>
# define HEIGHT 1200
# define WIDTH 2500
# define COLOR1 0
# define COLOR2 16777215
# define INIT_X 30
# define INIT_Y -20
# define INIT_Z -45
# define INIT_X_SCALE 0.9
# define INIT_Y_SCALE 0.9
# define INIT_Z_SCALE 0.1
# define RED 16711680
# define ORANGE 16744448
# define YELLOW 16776960
# define GREEN 65280
# define BLUE 255
# define INDIGO 4915330
# define VIOLET 8323327
# define BLACK 0
# define JUL_MAX_ITER 100
typedef struct s_complex
{
double rl;
double im;
} t_complex;
typedef struct s_color
{
int red;
int green;
int blue;
} t_color;
typedef struct s_mw
{
void *mlx;
void *win;
} t_mw;
typedef struct s_move
{
int x;
int y;
double z;
} t_move;
typedef struct s_julia
{
t_complex jul_const;
t_color color;
int max_iterations;
t_move mov;
} t_julia;
typedef struct s_fractals
{
t_julia *jul;
} t_fractals;
typedef struct s_fractol
{
t_mw *mw;
t_fractals *fractals;
int w_height;
int w_width;
int bpp;
int line_size;
void *image;
char *image_data;
int endian;
} t_fractol;
int tab_length(char **tab);
void free_tab(char **tab);
void quit(t_fractol *fractol);
void print_help(void);
t_color color_init(int red, int green, int blue);
t_color color_lerp(t_color c1, t_color c2, double step);
int rainbow(int step, int max_step);
t_color int_to_color(int c);
int color_to_int(t_color c);
t_fractol *fractol_init(void);
int key_hook(int keycode, void *m);
int mouse_move_hook( int x, int y, void *fr);
int mouse_button_hook(int btn, int x, int y, void *fr);
void put_pixel_to_image(int x, int y, t_color *col, t_fractol *fr);
void new_and_clear_image(t_fractol *fr);
void complex_equal(double real, double imag, t_complex *c);
void draw_julia(t_fractol *fr);
#endif