Skip to content

Commit

Permalink
ok norme
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasvienot committed Mar 16, 2019
1 parent 62ef196 commit 741b153
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 138 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
# By: nvienot <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/12/14 15:52:13 by nvienot #+# #+# #
# Updated: 2019/03/15 12:45:35 by nvienot ### ########.fr #
# Updated: 2019/03/16 18:18:24 by nvienot ### ########.fr #
# #
# **************************************************************************** #

NAME = fractol

SRCS = srcs/main.c srcs/ft_error.c srcs/ft_print.c srcs/ft_start.c \
SRCS = srcs/main.c srcs/ft_start.c srcs/ft_multithreading.c \
srcs/ft_create.c srcs/ft_utilities.c srcs/ft_calc.c \
srcs/ft_vignettes.c srcs/ft_deal_key.c srcs/ft_deal_mouse.c \
srcs/ft_create.c srcs/ft_calc.c srcs/ft_multithreading.c
srcs/ft_print.c

CC = gcc

Expand Down Expand Up @@ -91,4 +92,4 @@ recl : all clean

norm : fclean
echo "$(_RED)Starting norminette...$(_END)"
norminette $(SRCS) $(INCL) | grep -B 1 '^Error' 2> /dev/null && echo "$(_RED)Norme KO :(" || echo "$(_GREEN)Norme OK ! :)$(_END)";
norminette $(SRCS) $(INCL) | grep -B 1 '^Error' 2> /dev/null && echo "$(_RED)Norm KO :(" || echo "$(_GREEN)Norm OK ! :)$(_END)";
63 changes: 29 additions & 34 deletions includes/fractol.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/16 11:41:57 by nvienot #+# #+# */
/* Updated: 2019/03/16 03:27:08 by nvienot ### ########.fr */
/* Updated: 2019/03/16 18:19:44 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -163,18 +163,19 @@ struct s_win
};

/*
** ft_error.c
** ft_calc.c
*/

void ft_usage(void);
int ft_exit(t_win *win);
void ft_calc(t_render *r, int fract, int it_max, double pow);

/*
** ft_deal_mouse.c
** ft_create.c
*/

int deal_motion(int x, int y, t_win *win);
int deal_mouse(int mouse, int x, int y, t_win *win);
void *ft_create_mandelbrot(void *thrds);
void *ft_create_julia(void *thrds);
void ft_create_vig(t_win *win, int test);
void ft_create_all(t_win *win);

/*
** ft_deal_key.c
Expand All @@ -183,59 +184,53 @@ int deal_mouse(int mouse, int x, int y, t_win *win);
int deal_key(int key, t_win *win);

/*
** ft_print.c
** ft_deal_mouse.c
*/

void ft_print_menu(t_win *w);
void mlx_put_pixel_to_image(t_img img, int x, int y, int a);
void ft_viseur(t_win *win);
int deal_motion(int x, int y, t_win *win);
int deal_mouse(int mouse, int x, int y, t_win *win);

/*
** ft_init_struct.c
** ft_multithreading.c
*/

void ft_init_start(t_win *win);
void ft_init_mandelbrot(t_win *win);
void ft_init_julia(t_win *win);
void *ft_vig(void *thrds);
void ft_multithreading(t_win *win);
void ft_multithreading_vig(t_win *win);

/*
** ft_select_fractales.c
** ft_print.c
*/

void ft_select_fractale(t_win *win, char *str);
void ft_reset_fractale(t_win *win);
void ft_multithreading(t_win *win);
void ft_multithreading_vig(t_win *win);
void ft_print_menu(t_win *w);

/*
** ft_vignettes.c
** ft_start.c
*/

void ft_create_vig(t_win *win, int test);
void ft_init_julia(t_win *win);
void ft_init_mandelbrot(t_win *win);
void ft_init_start(t_win *win);
void ft_reset_fractal(t_win *win);
void ft_select_fractal(t_win *win, char *str);

/*
** ft_create.c
** ft_utilities.c
*/

void ft_create_all(t_win *win);
void *ft_create_mandelbrot(void *thrds);
void *ft_create_julia(void *thrds);
void ft_usage(void);
int ft_exit(t_win *win);
void ft_viseur(t_win *win);
void mlx_put_pixel_to_image(t_img img, int x, int y, int a);

/*
** ft_fractales_vig.c
** ft_vignettes.c
*/

void *ft_vig(void *thrds);
void ft_create_mandelbrot_vig(t_thrd *thrd);
void ft_create_duobrot_vig(t_thrd *thrd);
void ft_create_tricorn_vig(t_thrd *thrd);
void ft_create_julia_vig(t_thrd *thrd);
void ft_create_andy_vig(t_thrd *thrd);

/*
** ft_calc.c
*/

void ft_calc(t_render *r, int fract, int it_max, double pow);

#endif
12 changes: 7 additions & 5 deletions libft/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: nvienot <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/11/09 14:10:45 by nvienot #+# #+# #
# Updated: 2019/03/16 01:40:48 by nvienot ### ########.fr #
# Updated: 2019/03/16 17:21:07 by nvienot ### ########.fr #
# #
# **************************************************************************** #

Expand All @@ -32,12 +32,14 @@ ft_getfirstdecimal.c ft_strjoinnfree.c

OBJS = $(SRCS:.c=.o)

.SILENT :

all: $(NAME)

$(NAME): libft.h
@$(CC) $(FLAGS) -c $(SRCS)
@ar rc $(NAME) $(OBJS)
@ranlib $(NAME)
$(NAME): $(OBJS) libft.h
$(CC) $(FLAGS) -c $(SRCS)
ar rc $(NAME) $(OBJS)
ranlib $(NAME)

clean:
@/bin/rm -f $(OBJS)
Expand Down
2 changes: 1 addition & 1 deletion libft/ft_atoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/12 17:35:00 by nvienot #+# #+# */
/* Updated: 2018/11/21 21:24:18 by nvienot ### ########.fr */
/* Updated: 2019/03/16 17:19:23 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion libft/ft_putstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/09 17:43:45 by nvienot #+# #+# */
/* Updated: 2018/11/21 19:22:54 by nvienot ### ########.fr */
/* Updated: 2019/03/16 17:19:32 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion libft/ft_strdup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/12 17:39:58 by nvienot #+# #+# */
/* Updated: 2018/11/21 19:45:02 by nvienot ### ########.fr */
/* Updated: 2019/03/16 17:21:25 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion libft/ft_toupper.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/15 21:33:45 by nvienot #+# #+# */
/* Updated: 2018/11/15 21:59:07 by nvienot ### ########.fr */
/* Updated: 2019/03/16 17:20:28 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
23 changes: 14 additions & 9 deletions srcs/ft_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/13 21:07:55 by nvienot #+# #+# */
/* Updated: 2019/03/16 04:08:04 by nvienot ### ########.fr */
/* Updated: 2019/03/16 18:02:49 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

#include "fractol.h"

static void ft_modif_julia(t_render *r, int fract)
{
if (fract == 8 || fract == 12)
{
if (fract == 8)
r->rc = r->rc + 0.155;
if (fract == 12)
r->rc = r->rc + 0.253;
r->ic = r->ic + 0.013;
}
}

static void ft_calc_3(t_render *r, int fract, int it_max, double y)
{
double x;
Expand Down Expand Up @@ -93,15 +105,8 @@ void ft_calc(t_render *r, int fract, int it_max, double p)

y = 0;
r->a = 0;
if (fract == 8 || fract == 12)
{
if (fract == 8)
r->rc = r->rc + 0.155;
if (fract == 12)
r->rc = r->rc + 0.253;
r->ic = r->ic + 0.013;
}
y = r->iz * r->iz;
ft_modif_julia(r, fract);
if (fract == 1 || fract == 2 || fract == 7 || fract == 8)
ft_calc_1(r, fract, it_max, y);
else if (fract == 3 || fract == 4 || fract == 9 || fract == 10)
Expand Down
4 changes: 2 additions & 2 deletions srcs/ft_deal_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/11 18:39:39 by nvienot #+# #+# */
/* Updated: 2019/03/16 03:21:03 by nvienot ### ########.fr */
/* Updated: 2019/03/16 18:32:24 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -18,7 +18,7 @@ static void deal_key_reset(int key, t_win *win)
(win->fract == 12) ? (win->fract = 1) : (win->fract += 1);
else if (key == TOUCH_LESS)
(win->fract == 1) ? (win->fract = 12) : (win->fract -= 1);
ft_reset_fractale(win);
ft_reset_fractal(win);
}

static void deal_key_2(int key, t_win *win)
Expand Down
27 changes: 20 additions & 7 deletions srcs/ft_deal_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/11 18:40:43 by nvienot #+# #+# */
/* Updated: 2019/03/16 03:38:00 by nvienot ### ########.fr */
/* Updated: 2019/03/16 18:19:44 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */

#include "fractol.h"

static void ft_pick_fractale(int x, int y, t_win *win)
static void ft_immersive(t_win *win, int test)
{
if (test == 1)
{
if (win->immersive == 1 && win->p.it_max > 2)
win->p.it_max -= 1;
}
else if (test == 2)
{
if (win->immersive == 1)
win->p.it_max += 1;
}
}

static void ft_pick_fractal(int x, int y, t_win *win)
{
if (x > WIN_HOR_SIZE - VIG_HOR_SIZE - MRG && x < WIN_HOR_SIZE - MRG)
{
Expand Down Expand Up @@ -49,8 +63,8 @@ static void deal_mouse_click(t_win *win, int x, int y)
if (x > WIN_HOR_SIZE - VIG_HOR_SIZE - MRG && x < WIN_HOR_SIZE \
- MRG && y > MRG && y < (MRG + VIG_VER_SIZE * 5))
{
ft_pick_fractale(x, y, win);
ft_reset_fractale(win);
ft_pick_fractal(x, y, win);
ft_reset_fractal(win);
}
else if (win->fract > 6)
(win->motion == 0) ? (win->motion += 1) : (win->motion = 0);
Expand All @@ -70,15 +84,14 @@ int deal_mouse(int mouse, int x, int y, t_win *win)
win->p.zoom /= (double)COEF_ZOOM;
win->p.x1 = oldx - (double)x / win->p.zoom;
win->p.y1 = oldy - (double)y / win->p.zoom;
if (win->immersive == 1 && win->p.it_max > 2)
win->p.it_max -= 1;
ft_immersive(win, 1);
}
else if (mouse == 5)
{
win->p.zoom *= (double)COEF_ZOOM;
win->p.x1 = oldx - (double)x / win->p.zoom;
win->p.y1 = oldy - (double)y / win->p.zoom;
(win->immersive == 1) ? win->p.it_max += 1 : 0;
ft_immersive(win, 2);
}
(mouse == 1) ? deal_mouse_click(win, x, y) : 0;
}
Expand Down
Loading

0 comments on commit 741b153

Please sign in to comment.