Example #1
0
int		zoom_m(int button, int x, int y, t_ftol *f)
{
	double	tz_x;
	double	tz_y;

	mlx_destroy_image(f->mlx, f->img);
	mlx_clear_window(f->mlx, f->win);
	f->img = mlx_new_image(f->mlx, 800, 800);
	tz_x = f->zoom_x;
	tz_y = f->zoom_y;
	if (button == 5)
	{
		f->zoom_x = f->zoom_x * 2;
		f->zoom_y = f->zoom_y * 2;
		f->it_max += 10;
	}
	if (button == 4)
	{
		f->zoom_x = f->zoom_x / 2;
		f->zoom_y = f->zoom_y / 2;
		f->it_max -= 10;
	}
	f->x1 += x / tz_x - (x / f->zoom_x);
	f->y1 += y / tz_y - (y / f->zoom_y);
	print_mandelbrot(f);
	mlx_put_image_to_window(f->mlx, f->win, f->img, 0, 0);
	return (0);
}
Example #2
0
void		command4(int keycode, t_box *box)
{
	color_command(keycode, box);
	if (ID == 3 || ID == 1 || ID == 5 || ID == 7 || ID == 9)
		print_mandelbrot(box, ID);
	else if (ID == 2 || ID == 4 || ID == 6 || ID == 8 || ID == 10)
		print_julia(box, ID, box->a);
	mlx_put_image_to_window(box->mlx, box->win, box->img, 0, 0);
	if (box->b_info == 1)
		print_info(box);
}
Example #3
0
int		mouse_cg(int x, int y, t_ftol *f)
{
	mlx_destroy_image(f->mlx, f->img);
	mlx_clear_window(f->mlx, f->win);
	f->img = mlx_new_image(f->mlx, 800, 800);
	if (f->check != 1)
	{
		f->tmp_z_i = ((double)(y - 512)) / 512;
		f->tmp_z_r = ((double)(x - 512)) / 512;
	}
	print_mandelbrot(f);
	mlx_put_image_to_window(f->mlx, f->win, f->img, 0, 0);
	return (0);
}
Example #4
0
void		screen_init(t_box *box, int id)
{
	t_cmplx a;

	ft_bzero(&a, sizeof(t_cmplx));
	if (box->img != NULL)
		mlx_destroy_image(box->mlx, box->img);
	if (box->win != NULL)
		mlx_destroy_window(box->mlx, box->win);
	init(box, id);
	if (id == 1 || id == 3 || id == 5 || id == 7 || id == 9)
		print_mandelbrot(box, id);
	else if (id == 2 || id == 4 || id == 6 || id == 8 || id == 10)
		print_julia(box, id, &a);
	mlx_hook(box->win, 2, (1L << 0), command2, box);
	mlx_hook(box->win, 6, (1L << 6), mouse_command, box);
	mlx_mouse_hook(box->win, mouse_click, box);
	mlx_put_image_to_window(box->mlx, box->win, box->img, 0, 0);
}