Exemplo n.º 1
0
void			*bd1(void *env)
{
	t_env		*e;
	t_frac		m;

	e = env;
	init_fract(e, &m);
	m.x = e->width / 4 * 3;
	while (m.x <= e->width)
	{
		m.y = e->heigth / 2;
		while (m.y <= e->heigth)
		{
			do_fract(e, &m);
			if (e->color_mod == 1)
				mlx_pixel_put_img((int)((m.i * e->color / e->imax)),
					e, e->dx + m.x, e->dy + m.y);
			else if (m.i != e->imax && e->color_mod == 0)
				mlx_pixel_put_img((int)((m.i * e->color / e->imax)),
				e, e->dx + m.x, e->dy + m.y);
			m.y = m.y + 1;
		}
		m.x = m.x + 1;
	}
	pthread_exit(NULL);
}
Exemplo n.º 2
0
int		mouse_hook(int boutton, int x, int y, t_env *e)
{
	printf("bouton = %d, x = %d, y = %d\n", boutton, x, y);
	if (boutton == LEFT_CLIC)
	{
		if (e->nbr_clic == 0)
		{
			ft_putstr("in nrbclic = 0");
			e->nbr_clic++;
			e->xmintmp = e->xmin;
			e->ymintmp = e->ymin;
			e->xmin = e->xmin + x * e->stepx;
			e->ymin = e->ymin + y * e->stepy;
		}
		else if (e->nbr_clic == 1)
		{
			ft_putstr("in nrbclic = 1");
			e->nbr_clic = 0;
			e->xmax = e->xmintmp + x * e->stepx;
			e->ymax = e->ymintmp + y * e->stepy;
			e->stepx = (double)(e->xmax - e->xmin) / WX;
			e->stepy = (double)(e->ymax - e->ymin) / WY;
			double x_f;
			double y_f;
			int nb_it;
			mlx_destroy_image(e->mlx, e->img);
			e->img = mlx_new_image(e->mlx, WX, WY);
			x_f = e->xmin;
			x = 0;
			while (x <= WX)
			{
				y = 0;
				y_f = e->ymin;
				while (y <= WY)
				{
					nb_it = is_converg((mandelbrot), x_f, y_f);
			//			printf("val x_f = %lf, val de y_f = %lf, val de nb_it = %d\n", x_f, y_f, nb_it);
			//			printf("val stepx= %lf, val de stepy = %lf, val de y %d= \n",e->stepx, e->stepy, y);
					if (nb_it < 1000)
						mlx_pixel_put_img(e->img, x, y, rainbow_gen(nb_it * 40));
					else
						mlx_pixel_put_img(e->img, x, y, 0x000000);
					y++;
					y_f += e->stepy;
				}
				x_f += e->stepx;
				x++;
			}
			mlx_put_image_to_window(e->mlx, e->win, e->img, 0,0);
		}
	}
	return (0);
}
Exemplo n.º 3
0
int		main(void)
{
	int x;
	int y;
	int nb_it;
	double x_f;
	double y_f;
	double stepx;
	double stepy;
	t_env e;

	set_env(&e, "titre", WX, WY);
	x = 0;
	x_f = e.xmin;
	while (x <= WX)
	{
		y = 0;
		y_f = e.ymin;
		while (y <= WY)
		{
			nb_it = is_converg((mandelbrot), x_f, y_f);
			//	printf("val x_f = %lf, val de y_f = %lf, val de nb_it = %d\n", x_f, y_f, nb_it);
			if (nb_it < 1000)
				mlx_pixel_put_img(e.img, x, y, rainbow_gen(nb_it * 40));
			y++;
			y_f += e.stepy;
		}
		x_f += e.stepx;
		x++;
	}
	mlx_put_image_to_window(e.mlx, e.win, e.img, 0,0);
	mlx_mouse_hook(e.win, mouse_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}