fractol/src/hooks_funcs.c
Gregory Tertyshny 4a955f0f17 fix mouse hook
2017-03-24 21:13:50 +02:00

73 lines
1.8 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hooks_funcs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/24 19:21:45 by gtertysh #+# #+# */
/* Updated: 2017/03/24 21:12:49 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void gradient_hook(t_fractol *fr)
{
fr->frac->grd = random_gradient();
new_and_clear_image(fr);
parallel_fractal(fr);
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
}
int change_imagianry(t_fractol *fr, int x, int *start_x)
{
int to_render;
to_render = 0;
if (x > *start_x)
{
if (fr->frac->com_const.im < 3)
{
fr->frac->com_const.im += 0.05;
to_render = 1;
}
*start_x = x;
}
else if (x < *start_x)
{
if (fr->frac->com_const.im > -4)
{
fr->frac->com_const.im -= 0.05;
to_render = 1;
}
*start_x = x;
}
return (to_render);
}
int change_real(t_fractol *fr, int x, int *start_x)
{
int to_render;
to_render = 0;
if (x > *start_x)
{
if (fr->frac->com_const.rl < 3)
{
fr->frac->com_const.rl += 0.05;
to_render = 1;
}
*start_x = x;
}
else if (x < *start_x)
{
if (fr->frac->com_const.rl > -4)
{
fr->frac->com_const.rl -= 0.05;
to_render = 1;
}
*start_x = x;
}
return (to_render);
}