Compare commits
No commits in common. "02fe8897ee4c5bf496feef57af2749e3b9ef9edf" and "b399898721b8b748cda35f7548a5fc085ca80443" have entirely different histories.
02fe8897ee
...
b399898721
11 changed files with 135 additions and 215 deletions
29
CMakeLists.txt
Normal file
29
CMakeLists.txt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
cmake_minimum_required(VERSION 3.6)
|
||||||
|
project(fractol)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wextra")
|
||||||
|
|
||||||
|
include_directories(inc libft/includes minilibx) # headers
|
||||||
|
link_directories(libft minilibx) # libraries
|
||||||
|
|
||||||
|
set(SOURCE_FILES
|
||||||
|
src/main.c
|
||||||
|
src/help_func.c
|
||||||
|
src/color.c
|
||||||
|
src/fractol_init.c
|
||||||
|
src/hooks.c
|
||||||
|
src/image_routine.c
|
||||||
|
src/complex.c
|
||||||
|
src/julia.c
|
||||||
|
src/threads_routine.c
|
||||||
|
src/mandelbrot.c
|
||||||
|
src/burning_ship.c
|
||||||
|
src/fractal_routine.c
|
||||||
|
src/hooks_funcs.c
|
||||||
|
src/parse_input.c
|
||||||
|
src/hooks_funcs_1.c
|
||||||
|
src/hooks_funcs_2.c) # sources
|
||||||
|
|
||||||
|
add_executable(fractol ${SOURCE_FILES}) # compilation
|
||||||
|
|
||||||
|
target_link_libraries(fractol -lft -lmlx "-framework OpenGL" "-framework AppKit") # linkage
|
4
Makefile
4
Makefile
|
@ -6,7 +6,7 @@
|
||||||
# By: gtertysh <marvin@42.fr> +#+ +:+ +#+ #
|
# By: gtertysh <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2016/12/14 16:54:48 by gtertysh #+# #+# #
|
# Created: 2016/12/14 16:54:48 by gtertysh #+# #+# #
|
||||||
# Updated: 2017/03/25 17:59:43 by gtertysh ### ########.fr #
|
# Updated: 2017/03/24 13:59:39 by gtertysh ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ libclean:
|
||||||
@make clean -s -C $(LIBFT_DIR)
|
@make clean -s -C $(LIBFT_DIR)
|
||||||
@make clean -s -C $(MLX_DIR)
|
@make clean -s -C $(MLX_DIR)
|
||||||
|
|
||||||
libfclean: libclean
|
libfclean:
|
||||||
@make fclean -s -C $(LIBFT_DIR)
|
@make fclean -s -C $(LIBFT_DIR)
|
||||||
|
|
||||||
re: fclean libfclean all
|
re: fclean libfclean all
|
||||||
|
|
1
author
1
author
|
@ -1 +0,0 @@
|
||||||
gtertysh
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/16 20:59:04 by gtertysh #+# #+# */
|
/* Created: 2017/03/16 20:59:04 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/25 17:36:38 by gtertysh ### ########.fr */
|
/* Updated: 2017/03/24 14:00:01 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -16,8 +16,10 @@
|
||||||
# include "libft.h"
|
# include "libft.h"
|
||||||
# include "mlx.h"
|
# include "mlx.h"
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
|
# include <fcntl.h>
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
|
||||||
# define HEIGHT 700
|
# define HEIGHT 700
|
||||||
# define WIDTH 1300
|
# define WIDTH 1300
|
||||||
|
@ -38,84 +40,85 @@
|
||||||
|
|
||||||
# define NUM_THREADS 24
|
# define NUM_THREADS 24
|
||||||
|
|
||||||
typedef struct s_complex
|
|
||||||
|
typedef struct s_complex
|
||||||
{
|
{
|
||||||
long double rl;
|
long double rl;
|
||||||
long double im;
|
long double im;
|
||||||
} t_complex;
|
} t_complex;
|
||||||
|
|
||||||
typedef struct s_move
|
typedef struct s_move
|
||||||
{
|
{
|
||||||
long double x;
|
long double x;
|
||||||
long double y;
|
long double y;
|
||||||
long double z;
|
long double z;
|
||||||
} t_move;
|
} t_move;
|
||||||
|
|
||||||
typedef struct s_color
|
typedef struct s_color
|
||||||
{
|
{
|
||||||
int red;
|
int red;
|
||||||
int grn;
|
int grn;
|
||||||
int blu;
|
int blu;
|
||||||
} t_color;
|
} t_color;
|
||||||
|
|
||||||
typedef struct s_gradient
|
typedef struct s_gradient
|
||||||
{
|
{
|
||||||
t_color grd[NUM_COLORS];
|
t_color grd[NUM_COLORS];
|
||||||
} t_gradient;
|
} t_gradient;
|
||||||
|
|
||||||
typedef struct s_frac_data
|
typedef struct s_frac_data
|
||||||
{
|
{
|
||||||
t_complex com_const;
|
t_complex com_const;
|
||||||
t_gradient grd;
|
t_gradient grd;
|
||||||
t_move mov;
|
t_move mov;
|
||||||
int max_itr;
|
int max_itr;
|
||||||
int com_rl_im_change;
|
int com_rl_im_change;
|
||||||
int allow_mouse_change;
|
int allow_mouse_change;
|
||||||
int frac_type;
|
int frac_type;
|
||||||
} t_frac_data;
|
} t_frac_data;
|
||||||
|
|
||||||
typedef struct s_image
|
typedef struct s_image
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
char *data;
|
char *data;
|
||||||
int l_size;
|
int l_size;
|
||||||
int end;
|
int end;
|
||||||
int bpp;
|
int bpp;
|
||||||
} t_image;
|
} t_image;
|
||||||
|
|
||||||
typedef t_color (*t_frac_func)(t_frac_data *data, int x, int y);
|
typedef t_color (*frac_func)(t_frac_data *data, int x, int y);
|
||||||
|
|
||||||
typedef struct s_fractol
|
typedef struct s_fractol
|
||||||
{
|
{
|
||||||
void *mlx;
|
void *mlx;
|
||||||
void *win;
|
void *win;
|
||||||
t_frac_data *frac;
|
t_frac_data *frac;
|
||||||
t_frac_func fr_funcs[3];
|
frac_func fr_funcs[3];
|
||||||
int w_height;
|
int w_height;
|
||||||
int w_width;
|
int w_width;
|
||||||
t_image *img;
|
t_image *img;
|
||||||
} t_fractol;
|
} t_fractol;
|
||||||
|
|
||||||
typedef struct s_thread_data
|
typedef struct s_thread_data
|
||||||
{
|
{
|
||||||
t_fractol fr;
|
t_fractol fr;
|
||||||
int y_start;
|
int y_start;
|
||||||
int y_end;
|
int y_end;
|
||||||
t_frac_func fractal_func;
|
frac_func fractal_func;
|
||||||
} t_thread_data;
|
} t_thread_data;
|
||||||
|
|
||||||
void quit(t_fractol *fractol);
|
void quit(t_fractol *fractol);
|
||||||
void print_help(void);
|
void print_help(void);
|
||||||
void parse_input(int ac, char **av);
|
void parse_input(int ac, char **av);
|
||||||
|
|
||||||
t_color gradient(float value, t_gradient gradient);
|
t_color gradient(float value, t_gradient gradient);
|
||||||
t_gradient default_gradient(void);
|
t_gradient default_gradient(void);
|
||||||
t_gradient random_gradient(void);
|
t_gradient random_gradient(void);
|
||||||
|
|
||||||
t_fractol *fractol_init(void *mlx, int frac_type);
|
t_fractol *fractol_init(void *mlx, int frac_type);
|
||||||
|
|
||||||
int key_hook(int keycode, void *m);
|
int key_hook(int keycode, void *m);
|
||||||
int mouse_move_hook(int x, int y, void *fr);
|
int mouse_move_hook( int x, int y, void *fr);
|
||||||
int mouse_button_hook(int btn, 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 put_pixel_to_image(int x, int y, t_color col, t_fractol *fr);
|
||||||
|
@ -134,8 +137,6 @@ void parallel_fractal(t_fractol *fr);
|
||||||
|
|
||||||
void zoom_in(t_fractol *frm, int x, int y);
|
void zoom_in(t_fractol *frm, int x, int y);
|
||||||
void zoom_out(t_fractol *fr);
|
void zoom_out(t_fractol *fr);
|
||||||
void zoom_in_key(t_fractol *fr);
|
|
||||||
void zoom_out_key(t_fractol *fr);
|
|
||||||
void move_left(t_fractol *fr);
|
void move_left(t_fractol *fr);
|
||||||
void move_right(t_fractol *fr);
|
void move_right(t_fractol *fr);
|
||||||
void move_up(t_fractol *fr);
|
void move_up(t_fractol *fr);
|
||||||
|
@ -143,11 +144,8 @@ void move_down(t_fractol *fr);
|
||||||
void reset(t_fractol *fr);
|
void reset(t_fractol *fr);
|
||||||
void change_limit_down(t_fractol *fr);
|
void change_limit_down(t_fractol *fr);
|
||||||
void change_limit_up(t_fractol *fr);
|
void change_limit_up(t_fractol *fr);
|
||||||
int change_real(t_fractol *fr, int x, int *start_x);
|
int change_real(t_fractol *fr, int x, int *start_x);
|
||||||
int change_imagianry(t_fractol *fr, int x, int *start_x);
|
int change_imagianry(t_fractol *fr, int x, int *start_x);
|
||||||
void gradient_hook(t_fractol *fr);
|
void gradient_hook(t_fractol *fr);
|
||||||
|
|
||||||
void julia_samples(t_fractol *fr, double real, double img);
|
|
||||||
void mandelbrot_samples(t_fractol *fr, double x, double y);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/04 19:13:25 by gtertysh #+# #+# */
|
/* Created: 2016/12/04 19:13:25 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/24 20:06:06 by gtertysh ### ########.fr */
|
/* Updated: 2016/12/06 19:47:50 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -23,4 +23,4 @@ int ft_lst_len(t_list *lst)
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
return (len);
|
return (len);
|
||||||
}
|
}
|
|
@ -5,109 +5,72 @@
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/28 18:15:15 by gtertysh #+# #+# */
|
/* Created: 2016/12/04 15:59:21 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/24 20:41:17 by gtertysh ### ########.fr */
|
/* Updated: 2016/12/06 19:45:44 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
t_fd *new_node(int fd)
|
static t_fd *new_node(int fd)
|
||||||
{
|
{
|
||||||
t_fd *new;
|
t_fd *new;
|
||||||
|
|
||||||
new = NULL;
|
new = NULL;
|
||||||
if ((new = (t_fd *)malloc(sizeof(t_fd))))
|
if ((new = (t_fd *)malloc(sizeof(t_fd))))
|
||||||
{
|
{
|
||||||
new->fd = fd;
|
new->fd = fd;
|
||||||
new->n = NULL;
|
new->n = NULL;
|
||||||
new->next = NULL;
|
new->next = NULL;
|
||||||
new->t = 0;
|
new->t = 0;
|
||||||
}
|
}
|
||||||
return (new);
|
return (new);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_fd *find_fd(int fd, t_fd **cur_fd)
|
static t_fd *find_fd(int fd, t_fd **cur_fd)
|
||||||
{
|
{
|
||||||
if (!*cur_fd)
|
if (!*cur_fd)
|
||||||
return ((*cur_fd = new_node(fd)));
|
return ((*cur_fd = new_node(fd)));
|
||||||
while ((*cur_fd))
|
while ((*cur_fd))
|
||||||
{
|
{
|
||||||
if ((*cur_fd)->fd == fd)
|
if ((*cur_fd)->fd == fd)
|
||||||
return (*cur_fd);
|
return (*cur_fd);
|
||||||
cur_fd = &((*cur_fd)->next);
|
cur_fd = &((*cur_fd)->next);
|
||||||
}
|
}
|
||||||
return ((*cur_fd = new_node(fd)));
|
return ((*cur_fd = new_node(fd)));
|
||||||
}
|
|
||||||
|
|
||||||
int check_reminder(t_fd *c, char **line)
|
|
||||||
{
|
|
||||||
char *substr;
|
|
||||||
char *old_line;
|
|
||||||
|
|
||||||
old_line = *line;
|
|
||||||
if (c->n)
|
|
||||||
{
|
|
||||||
if ((c->t = ft_strchr(c->n, '\n')))
|
|
||||||
{
|
|
||||||
substr = ft_strsub(c->n, 0, c->t - c->n);
|
|
||||||
*line = ft_strjoin(*line, substr);
|
|
||||||
free(substr);
|
|
||||||
c->n = ++(c->t);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*line = ft_strjoin(*line, c->n);
|
|
||||||
c->n = 0;
|
|
||||||
}
|
|
||||||
free(old_line);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int check_buf(t_fd *c, char **line)
|
|
||||||
{
|
|
||||||
char *substr;
|
|
||||||
char *old_line;
|
|
||||||
|
|
||||||
old_line = *line;
|
|
||||||
while ((c->readed = read(c->fd, c->b, BUFF_SIZE)))
|
|
||||||
{
|
|
||||||
if (c->readed == -1)
|
|
||||||
return (-1);
|
|
||||||
c->b[c->readed] = 0;
|
|
||||||
if ((c->n = ft_strchr(c->b, '\n')))
|
|
||||||
{
|
|
||||||
substr = ft_strsub(c->b, 0, c->n++ - c->b);
|
|
||||||
old_line = *line;
|
|
||||||
*line = ft_strjoin(*line, substr);
|
|
||||||
free(substr);
|
|
||||||
free(old_line);
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
old_line = *line;
|
|
||||||
*line = ft_strjoin(*line, c->b);
|
|
||||||
free(old_line);
|
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_next_line(const int fd, char **line)
|
int get_next_line(const int fd, char **line)
|
||||||
{
|
{
|
||||||
static t_fd *head_fd;
|
static t_fd *head_fd;
|
||||||
t_fd *c;
|
t_fd *c;
|
||||||
|
|
||||||
if (fd < 0 || !line)
|
if (fd < 0 || !line)
|
||||||
return (-1);
|
return (-1);
|
||||||
*line = ft_strnew(0);
|
*line = ft_strnew(0);
|
||||||
c = find_fd(fd, &head_fd);
|
c = find_fd(fd, &head_fd);
|
||||||
c->readed = 0;
|
c->readed = 0;
|
||||||
if (check_reminder(c, line))
|
if (c->n) {
|
||||||
return (1);
|
if ((c->t = strchr(c->n, '\n')) &&
|
||||||
if (check_buf(c, line) == -1)
|
(*line = ft_strjoin(*line, ft_strsub(c->n, 0, (c->t - c->n)))) &&
|
||||||
return (-1);
|
(c->n = ++(c->t)))
|
||||||
if ((c->readed == 0) && !ft_strlen(*line))
|
{
|
||||||
return (0);
|
return (1);
|
||||||
return (1);
|
}
|
||||||
}
|
else if ((*line = ft_strjoin(*line, c->n)))
|
||||||
|
{
|
||||||
|
c->n = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while ((c->readed = read(c->fd, c->b, BUFF_SIZE)))
|
||||||
|
{
|
||||||
|
c->b[c->readed] = 0;
|
||||||
|
if ((c->n = strchr(c->b, '\n')) &&
|
||||||
|
(*line = ft_strjoin(*line, ft_strsub(c->b, 0, (c->n++ - c->b)))))
|
||||||
|
break;
|
||||||
|
*line = ft_strjoin(*line, c->b);
|
||||||
|
}
|
||||||
|
if (!c->readed && !ft_strlen(*line))
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 12:21:43 by gtertysh #+# #+# */
|
/* Created: 2016/11/28 12:21:43 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/24 20:05:11 by gtertysh ### ########.fr */
|
/* Updated: 2016/12/27 18:02:00 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -19,15 +19,15 @@
|
||||||
|
|
||||||
# define BUFF_SIZE 640000
|
# define BUFF_SIZE 640000
|
||||||
|
|
||||||
typedef struct s_fd
|
typedef struct s_fd
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char b[BUFF_SIZE + 1];
|
char b[BUFF_SIZE + 1];
|
||||||
char *n;
|
char *n;
|
||||||
struct s_fd *next;
|
struct s_fd *next;
|
||||||
char *t;
|
char *t;
|
||||||
int readed;
|
int readed;
|
||||||
} t_fd;
|
} t_fd;
|
||||||
|
|
||||||
typedef struct s_list
|
typedef struct s_list
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/24 19:37:32 by gtertysh #+# #+# */
|
/* Created: 2017/03/24 19:37:32 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/25 17:35:04 by gtertysh ### ########.fr */
|
/* Updated: 2017/03/24 19:37:33 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ t_frac_data *frac_init(int frac_type)
|
||||||
else
|
else
|
||||||
complex_equal(0, 0, &f->com_const);
|
complex_equal(0, 0, &f->com_const);
|
||||||
f->com_rl_im_change = 1;
|
f->com_rl_im_change = 1;
|
||||||
f->allow_mouse_change = 1;
|
f->allow_mouse_change = -1;
|
||||||
f->mov.x = 0;
|
f->mov.x = 0;
|
||||||
f->mov.y = 0;
|
f->mov.y = 0;
|
||||||
f->mov.z = 1;
|
f->mov.z = 1;
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* fractal_samples.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2017/03/25 14:52:57 by gtertysh #+# #+# */
|
|
||||||
/* Updated: 2017/03/25 14:52:58 by gtertysh ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "fractol.h"
|
|
||||||
|
|
||||||
void julia_samples(t_fractol *fr, double real, double img)
|
|
||||||
{
|
|
||||||
complex_equal(real, img, &fr->frac->com_const);
|
|
||||||
new_and_clear_image(fr);
|
|
||||||
parallel_fractal(fr);
|
|
||||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mandelbrot_samples(t_fractol *fr, double x, double y)
|
|
||||||
{
|
|
||||||
fr->frac->mov.x = x;
|
|
||||||
fr->frac->mov.y = y;
|
|
||||||
fr->frac->mov.z = 1;
|
|
||||||
new_and_clear_image(fr);
|
|
||||||
parallel_fractal(fr);
|
|
||||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
|
||||||
}
|
|
32
src/hooks.c
32
src/hooks.c
|
@ -6,52 +6,30 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/16 18:59:03 by gtertysh #+# #+# */
|
/* Created: 2017/03/16 18:59:03 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/25 14:59:09 by gtertysh ### ########.fr */
|
/* Updated: 2017/03/24 14:02:46 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "fractol.h"
|
#include "fractol.h"
|
||||||
|
|
||||||
void sample(t_fractol *fr, int key)
|
|
||||||
{
|
|
||||||
if (fr->frac->frac_type == 0 && key == 18)
|
|
||||||
julia_samples(fr, -1.037, 0.17);
|
|
||||||
if (fr->frac->frac_type == 0 && key == 19)
|
|
||||||
julia_samples(fr, -0.1, 0.651);
|
|
||||||
if (fr->frac->frac_type == 0 && key == 20)
|
|
||||||
julia_samples(fr, 0.285, 0.01);
|
|
||||||
if (fr->frac->frac_type == 1 && key == 18)
|
|
||||||
mandelbrot_samples(fr, -1.30000000000002603931, 0);
|
|
||||||
if (fr->frac->frac_type == 1 && key == 19)
|
|
||||||
mandelbrot_samples(fr, 0.0297908120967462314188, -0.458060975296945872);
|
|
||||||
if (fr->frac->frac_type == 1 && key == 20)
|
|
||||||
mandelbrot_samples(fr, 0.471844506346038136365, -1.1151425080399373598);
|
|
||||||
}
|
|
||||||
|
|
||||||
int key_hook(int keycode, void *fr)
|
int key_hook(int keycode, void *fr)
|
||||||
{
|
{
|
||||||
if (keycode == 53)
|
if (keycode == 53)
|
||||||
quit(fr);
|
quit(fr);
|
||||||
if (keycode == 24)
|
|
||||||
zoom_in_key(fr);
|
|
||||||
if (keycode == 27)
|
|
||||||
zoom_out_key(fr);
|
|
||||||
if (keycode == 49)
|
if (keycode == 49)
|
||||||
gradient_hook(fr);
|
gradient_hook(fr);
|
||||||
if (keycode == 123)
|
|
||||||
move_left(fr);
|
|
||||||
if (keycode == 124)
|
if (keycode == 124)
|
||||||
|
move_left(fr);
|
||||||
|
if (keycode == 123)
|
||||||
move_right(fr);
|
move_right(fr);
|
||||||
if (keycode == 126)
|
|
||||||
move_up(fr);
|
|
||||||
if (keycode == 125)
|
if (keycode == 125)
|
||||||
|
move_up(fr);
|
||||||
|
if (keycode == 126)
|
||||||
move_down(fr);
|
move_down(fr);
|
||||||
if (keycode == 69)
|
if (keycode == 69)
|
||||||
change_limit_up(fr);
|
change_limit_up(fr);
|
||||||
if (keycode == 78)
|
if (keycode == 78)
|
||||||
change_limit_down(fr);
|
change_limit_down(fr);
|
||||||
if (keycode == 18 || keycode == 19 || keycode == 20)
|
|
||||||
sample(fr, keycode);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/24 19:21:45 by gtertysh #+# #+# */
|
/* Created: 2017/03/24 19:21:45 by gtertysh #+# #+# */
|
||||||
/* Updated: 2017/03/25 15:02:31 by gtertysh ### ########.fr */
|
/* Updated: 2017/03/24 19:21:46 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ int change_imagianry(t_fractol *fr, int x, int *start_x)
|
||||||
{
|
{
|
||||||
if (fr->frac->com_const.im < 3)
|
if (fr->frac->com_const.im < 3)
|
||||||
{
|
{
|
||||||
fr->frac->com_const.im += 0.1;
|
fr->frac->com_const.im += 0.01;
|
||||||
to_render = 1;
|
to_render = 1;
|
||||||
}
|
}
|
||||||
*start_x = x;
|
*start_x = x;
|
||||||
|
@ -71,19 +71,3 @@ int change_real(t_fractol *fr, int x, int *start_x)
|
||||||
}
|
}
|
||||||
return (to_render);
|
return (to_render);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zoom_in_key(t_fractol *fr)
|
|
||||||
{
|
|
||||||
fr->frac->mov.z *= 1.5;
|
|
||||||
new_and_clear_image(fr);
|
|
||||||
parallel_fractal(fr);
|
|
||||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void zoom_out_key(t_fractol *fr)
|
|
||||||
{
|
|
||||||
fr->frac->mov.z /= 1.5;
|
|
||||||
new_and_clear_image(fr);
|
|
||||||
parallel_fractal(fr);
|
|
||||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue