Exemple #1
0
int						mouse_hook(int button, int x, int y, t_mlx *mlx)
{
	double				x_real;
	double				y_real;

	if (x > 0 && y > 0)
	{
		x_real = (x / mlx->fractal->zoom) + mlx->fractal->p0->x;
		y_real = (y / mlx->fractal->zoom) + mlx->fractal->p0->y;
		if (button == MOUSE_UP)
		{
			mlx->fractal->zoom *= 1.1;
			mlx->fractal->p0->x = x_real - (x / mlx->fractal->zoom);
			mlx->fractal->p0->y = y_real - (y / mlx->fractal->zoom);
			mlx->fractal->iter++;
		}
		if (button == MOUSE_DOWN)
		{
			mlx->fractal->zoom /= 1.1;
			mlx->fractal->p0->x = x_real - (x / mlx->fractal->zoom);
			mlx->fractal->p0->y = y_real - (y / mlx->fractal->zoom);
			mlx->fractal->iter--;
		}
	}
	fractol(mlx, mlx->fractal->type);
	return (0);
}
Exemple #2
0
int		move_mouse(int x, int y, t_env *e)
{
	if (e->fractype == 2)
	{
		if (x - e->old_x > 10)
		{
			e->c.c_r += 1.0 / 100;
			e->old_x = x;
		}
		else if (x - e->old_x < -10)
		{
			e->c.c_r -= 1.0 / 100;
			e->old_x = x;
		}
		else if (y - e->old_y > 10)
		{
			e->c.c_i += 1.0 / 100;
			e->old_y = y;
		}
		else if (y - e->old_y < -10)
		{
			e->c.c_i -= 1.0 / 100;
			e->old_y = y;
		}
		fractol(e);
	}
	return (0);
}
Exemple #3
0
int			key_hook(int keycode, t_env *e)
{
	if (keycode == 53)
		exit(0);
	if (keycode == 69)
	{
		e->zoom /= 1.5;
		fractol(e);
	}
	if (keycode == 78)
	{
		e->zoom *= 1.5;
		fractol(e);
	}
	if (keycode == 123 || keycode == 124)
		move_around(keycode, e);
	if (keycode == 125 || keycode == 126)
		move_around(keycode, e);
	return (0);
}
Exemple #4
0
static void	move_around(int keycode, t_env *e)
{
	if (keycode == 124)
	{
		e->x -= 1.0 / 100;
		fractol(e);
	}
	if (keycode == 123)
	{
		e->x += 1.0 / 100;
		fractol(e);
	}
	if (keycode == 125)
	{
		e->y -= 1.0 / 100;
		fractol(e);
	}
	if (keycode == 126)
	{
		e->y += 1.0 / 100;
		fractol(e);
	}
}
Exemple #5
0
int		mouse_hook(int button, int x, int y, t_env *e)
{
	e->x += (x - e->hwwidth) * e->zoom;
	e->y += (y - e->hwheight) * e->zoom;
	if (button == 4)
	{
		if (e->zoom > ft_fabs(x) * 1e-16 && e->zoom > ft_fabs(y) * 1e-16)
			e->zoom /= 2;
	}
	if (button == 5)
		e->zoom *= 2;
	fractol(e);
	return (0);
}