Пример #1
0
static void			norm(t_clist *param, t_env *e)
{
	while (e->x < e->image_x && e->x < LARGEUR)
	{
		e->y = 0;
		while (e->y < e->image_y && e->y < HAUTEUR)
		{
			e->c_r = e->x / e->zoom + e->x1;
			e->c_i = e->y / e->zoom + e->y1;
			e->z_r = 0;
			e->z_i = 0;
			e->i = 0;
			e->d = 1;
			while (e->d < 4 && e->i < e->iteration_max)
			{
				e->tmp = e->z_r;
				e->z_r = (e->z_r * e->z_r) - (e->z_i * e->z_i) + e->c_r;
				e->z_i = (2 * e->z_i * e->tmp) + e->c_i;
				e->d = (e->z_r * e->z_r + e->z_i * e->z_i);
				e->i++;
			}
			if (e->i != e->iteration_max)
				pixel_put(param, e->y, e->x, (0x0000FF) + e->i * 15);
			e->y++;
		}
		e->x++;
	}
}
Пример #2
0
void	calculate_m(t_env *e, double x0, double y0)
{
	double	x;
	double	y;
	double	x2;
	double	y2;
	double	i;

	x = 0.0;
	y = 0.0;
	x2 = e->xs;
	y2 = e->ys;
	i = -1.0;
	while (++i < e->iter && (x2 + y2) < e->iter)
	{
		y = 2.0 * x * y + y0;
		x = x2 - y2 + x0;
		x2 = x * x;
		y2 = y * y;
	}
	if (e->theme < 3)
		i = ft_mix(i, i - log2(log2(x2 + y2)), 1.0);
	e->color = palette(i, (e->theme > 2 ? e->theme - 3 : e->theme));
	pixel_put(e);
}
Пример #3
0
void	ft_draw_down(t_env *e, t_coord *p1, t_coord *p2)
{
	int		y;
	double	z;

	y = p1->y - 1;
	z = p1->z;
	while (++y <= p2->y)
	{
		pixel_put(e, p1->x + ((p2->x - p1->x) * (y - p1->y)) / \
			(p2->y - p1->y), y, ft_level(e, z));
		z += e->pasz;
	}
}
Пример #4
0
void	ft_draw_left(t_env *e, t_coord *p1, t_coord *p2)
{
	int		x;
	double	z;

	x = p2->x - 1;
	z = p2->z;
	while (++x <= p1->x)
	{
		pixel_put(e, x, p2->y + ((p1->y - p2->y) * (x - p2->x)) / \
			(p1->x - p2->x), ft_level(e, z));
		z += e->pasz;
	}
}
Пример #5
0
void	draw_line(t_env *e, int x)
{
	int				height;
	int				i;

	i = 0;
	if (e->dist_ray <= 0)
	{
		e->dist_ray = 0.01;
		e->side = 0x0000ff;
	}
	fog(e);
	height = 277 / e->dist_ray;
	while (i < (double)WIN_Y / 2.0 - (double)height / 2.0)
		get_pixel_color(e, x, i++);
	while (i < (double)WIN_Y / 2.0 + (double)height / 2.0)
		pixel_put(e, x, i++, e->fog);
	while (i < WIN_Y - 1)
	{
		pixel_put(e, x, i, find_ground_color(e, i, x));
		i++;
	}
}
Пример #6
0
void	window_reset(t_env *env)
{
	int		x;
	int		y;

	y = 0;
	while (y < env->window->height)
	{
		x = 0;
		while (x < env->window->width)
		{
			pixel_put(env, x, y, 0);
			x++;
		}
		y++;
	}
}
Пример #7
0
int				draw(t_env env)
{
	int		color;
	int		pixel;
	int		x;
	int		y;

	y = 0;
	while (y < H)
	{
		x = 0;
		while (x < W)
		{
			pixel = ft_fractal(env, x, y);
			color = color_get(pixel, env);
			pixel_put(env, x, y, color);
			x++;
		}
		y++;
	}
	mlx_put_image_to_window(env.mlx, env.win, env.img.ptr, 0, 0);
	display(env);
	return (0);
}