Beispiel #1
1
void ft_bresenham(t_id *s)
{
	s->dx = ft_abs(s->x1 - s->x0);
	s->dy = ft_abs(s->y1 - s->y0);
	s->sx = s->x0 < s->x1 ? 1 : -1;
	s->sy = s->y0 < s->y1 ? 1 : -1;
	s->err = (s->dx > s->dy ? s->dx : -s->dy) / 2;
	while (1)
	{	
 	   	mlx_image_put_pixel(s, s->x0, s->y0);
    	if (s->x0 == s->x1 && s->y0 == s->y1)
    		break;
   		s->e2 = s->err;
    	if (s->e2 > -s->dx)
    	{
    		s->err-= s->dy;
    		s->x0+= s->sx;
    	}
    	if (s->e2 < s->dy)
    	{
    		s->err+= s->dx;
    		s->y0+= s->sy; 
    	}
	}
}
Beispiel #2
0
void		drawline(int x, t_env *e, t_rgb *c)
{
	t_coordint	p;
	t_rgb		skyfloor;

	p.x = x;
	e->img.d = mlx_get_data_addr(e->img.img, &e->img.bp, &e->img.s, &e->img.e);
	set_colors(&skyfloor, 128, 128, 128);
	p.y = 0;
	while (p.y < e->r.ystart)
	{
		mlx_image_put_pixel(e, &(e->img), p, &skyfloor);
		p.y++;
	}
	p.y = e->r.ystart;
	while (p.y < e->r.yend)
	{
		mlx_image_put_pixel(e, &(e->img), p, c);
		p.y++;
	}
	set_colors(&skyfloor, 102, 51, 0);
	p.y = e->r.yend;
	while (p.y < WIN_HEIGH)
	{
		mlx_image_put_pixel(e, &(e->img), p, &skyfloor);
		p.y++;
	}
}
Beispiel #3
0
void ft_draw_mandelbrot(t_id *s)
{
	
	int x;
	int y;

	for (x = 0; x < W_X; x++)
	{
    	for (y = 0; y < W_Y; y++)
    	{
        	s->c_r = (x * (s->x2-s->x1) / W_X + s->x1) * s->zoom;
        	s->c_i = (y * (s->y2-s->y1) / W_Y + s->y1) * s->zoom;
        	s->z_r = 0;
        	s->z_i = 0;
        	s->i = 0;

        	do
        	{
            	double tmp = s->z_r;
            	s->z_r = s->z_r*s->z_r - s->z_i*s->z_i + s->c_r;
            	s->z_i = 2*s->z_i*tmp + s->c_i;
            	s->i = s->i+1;
            }
        	while (s->z_r*s->z_r + s->z_i*s->z_i < 4 && s->i < s->iter_max);

        	if (s->i == s->iter_max)
            	mlx_image_put_pixel(s, x, y, 0x000000);
        	else
                mlx_image_put_pixel(s, x, y , s->i * rgb_d(0,255,200)/s->iter_max);

    	}
	}
    mlx_put_image_to_window(s->mlx, s->win, s->img, 0, 0);

}
Beispiel #4
0
void	ft_draw_fire(t_id *s, int x, int y)
{
	static int fire[1200] = {FIRE};

	mlx_image_put_pixel(s, x, y, fire[(int)(fabsl(fmod(s->i * 20 *
		s->z_i, 999)))]);
}
Beispiel #5
0
void	ft_draw_retoba(t_id *s, int x, int y)
{
	static int retoba[1200] = {RETOBA};

	mlx_image_put_pixel(s, x, y, retoba[(int)(fabsl(fmod(s->i * 20 *
		s->z_i, 999)))]);
}
Beispiel #6
0
void ft_julia(t_id *s)
{
	int x;
	int y;

	y = 200;
	while (++y < 300)
	{
		x = 200;
		while (++x < 300)
		{
	mlx_image_put_pixel(s, x, y, 0xFF0FF);

		}
	}
}