예제 #1
0
파일: image.c 프로젝트: amineau/fractol
void	image(t_env *e)
{
	if (e->img)
		mlx_destroy_image(e->mlx, e->img);
	e->img = mlx_new_image(e->mlx, e->image_x, e->image_y);
	e->img_addr = mlx_get_data_addr(e->img,
			&e->bits_pix, &e->size_line, &e->end);
	if (ft_strcasecmp(e->fract, "mandelbrot") == 0)
		display_mandelbrot(e);
	if (ft_strcasecmp(e->fract, "julia") == 0)
		display_julia(e);
	if (ft_strcasecmp(e->fract, "carpet") == 0)
		display_carpet(e);
	mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
}
예제 #2
0
void		ft_get_materials(t_data *d, char *file_mat, char *file_obj)
{
	int		fd;
	char	*line;
	char	**tab;
	int		i;
	size_t	j;

	i = -1;
	fd = ft_open_file_mat(file_mat, file_obj);
	while (get_next_line(fd, &line) > 0 && !(j = 0))
	{
		tab = ft_strsplit_space(line);
		if (tab[0] && tab[0][0] != '#')
		{
			while (j < sizeof(g_parse) / sizeof(*g_parse))
			{
				if (!ft_strcasecmp(tab[0], g_parse[j].cmp))
					g_parse[j].func(d, &i, tab);
				j++;
			}
		}
		ft_tabdel(&tab);
		ft_strdel(&line);
	}
	close(fd);
}
예제 #3
0
파일: image.c 프로젝트: amineau/fractol
void	move(t_env *e, int keycode)
{
	double	dif_x;
	double	dif_y;

	if (ft_strcasecmp(e->fract, "carpet") == 0)
	{
		e->z_i -= (keycode == 125) ? e->image_y / 20 : 0;
		e->z_i += (keycode == 126) ? e->image_y / 20 : 0;
		e->z_r -= (keycode == 124) ? e->image_x / 20 : 0;
		e->z_r += (keycode == 123) ? e->image_x / 20 : 0;
	}
	else
	{
		dif_x = e->x2 - e->x1;
		dif_y = e->y2 - e->y1;
		e->y1 += (keycode == 125) ? dif_y / 20 : 0;
		e->y1 -= (keycode == 126) ? dif_y / 20 : 0;
		e->x1 -= (keycode == 123) ? dif_x / 20 : 0;
		e->x1 += (keycode == 124) ? dif_x / 20 : 0;
		e->x2 = e->x1 + dif_x;
		e->y2 = e->y1 + dif_y;
	}
}
예제 #4
0
int			ft_strcasecmp(const char *s1, const char *s2)
{
	if (!*s1 || ft_tolower(*s1) != ft_tolower(*s2))
		return (ft_tolower(*s1) - ft_tolower(*s2));
	return (ft_strcasecmp(++s1, ++s2));
}