Пример #1
0
void	while_clit(int y, t_env *e, int x, unsigned long color)
{
	int				i;

	i = 0;
	while (y < S_Y)
	{
		e->newre = (x - S_X / 2) / (0.25 * e->zoom * S_X) + e->movex;
		e->newim = (y - S_Y / 2) / (0.25 * e->zoom * S_Y) + e->movey;
		i = 0;
		while (i++ <= e->maxi
				&& !((e->newre * e->newre + e->newim * e->newim) > 4))
		{
			e->oldre = e->newre;
			e->oldim = e->newim;
			e->newre = e->oldre - e->oldim * e->oldim + e->cre;
			e->newim = 2 * e->oldre * e->oldim + e->cim;
		}
		if (i < e->maxi)
			color = give_color(e->maxi, i, e);
		else
			color = give_color(e->maxi, i, e);
		put_pix_img(e, x, y, color);
		y++;
	}
}
Пример #2
0
void	ray_tracer(t_env *e)
{
	int x;
	int y;
	int a;
	int b;
	int c;
	int d;

	a = 0;
	b = 0;
	c = 0;
	d = 0;
	e->no = 0;
	e->sky = 0;
	e->img = (t_img *)malloc(sizeof(t_img) * 1);
	e->skybox = (t_img *)malloc(sizeof(t_img) * 1);
	e->sol = (t_img *)malloc(sizeof(t_img) * 1);
	e->img->img_ptr = mlx_new_image(e->mlx, e->width, e->height);
	e->img->data = mlx_get_data_addr(e->img->img_ptr,
					 &e->img->bpp, &e->img->sizeline, &e->img->endian);
	e->skybox->img_ptr = mlx_xpm_file_to_image(e->mlx, "cart.xpm", &(c), &(d));
	e->skybox->data = mlx_get_data_addr(e->skybox->img_ptr,
					    &(e->skybox->bpp), &(e->skybox->sizeline), &(e->skybox->endian));
	e->sol->img_ptr = mlx_xpm_file_to_image(e->mlx, "sol.xpm", &(a), &(b));
	e->sol->data = mlx_get_data_addr(e->sol->img_ptr,
                                            &(e->sol->bpp), &(e->sol->sizeline), &(e->sol->endian));
	y = 0;
	while (y < e->height)
	{
	  e->y = y;
		x = 0;
		while (x < e->width)
		{
		  e->s = 0;
		  e->x = x;
		  e->color = give_color(e, x, y);
		  if(e->no == 0)
		    pixel_put_to_img(e, x, y);
		  e->no = 0;
		  x++;
		}
		y++;
	}
	mlx_put_image_to_window(e->mlx, e->win, e->img->img_ptr, 0, 0);
}
Пример #3
0
void	ray_tracer(t_env *e)
{
	int x;
	int y;

	e->img = (t_img *)malloc(sizeof(t_img) * 1);
	e->img->img_ptr = mlx_new_image(e->mlx, e->width, e->height);
	y = 0;
	while (y < e->height)
	{
		x = 0;
		while (x < e->width)
		{
			e->color = give_color(e, x, y);
			pixel_put_to_img(e, x, y);
			x++;
		}
		y++;
	}
	mlx_put_image_to_window(e->mlx, e->win, e->img->img_ptr, 0, 0);
}