This commit is contained in:
Camille Chauvet 2023-01-04 20:07:13 +01:00
parent b2dfb505bd
commit 909bb442b6
81 changed files with 500 additions and 77 deletions

View File

@ -1,12 +1,12 @@
SRC = main.c draw.c SRCS = draw.c main.c shape.c xpm.c
OBJ = ${SRC:.c=.o} OBJ = ${SRCS:.c=.o}
NAME = so_long NAME = so_long
LIBS = libftx/libftx.a minilibx-linux/libmlx.a LIBS = libftx/libftx.a minilibx-linux/libmlx.a
CC = gcc CC = clang
FLAG = -Wall -Wextra -Werror -g FLAG = -Wall -Wextra -Werror -g

35
draw.c
View File

@ -6,39 +6,22 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */ /* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */
/* Updated: 2022/12/14 18:14:38 by cchauvet ### ########.fr */ /* Updated: 2023/01/04 19:05:04 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "solong.h" #include "solong.h"
void ft_draw_pixel(void *window_manager, void *window, t_pixel pixel) void ft_draw_xpm(void *mlx, void *window, char *file, size_t *cord)
{ {
char *img_path;
void *img; void *img;
int bozo; int bozo;
img = mlx_xpm_file_to_image(window_manager, PIXEL_PATH, &bozo, &bozo); img_path = ft_strmerger(2, XPM_PATH, file);
mlx_put_image_to_window(window_manager, window, img, pixel.x, pixel.y); if (img_path == NULL)
} return ;
img = mlx_xpm_file_to_image(mlx, img_path, &bozo, &bozo);
void ft_draw_square(void *window_manager, void *window, t_square square) mlx_put_image_to_window(mlx, window, img, cord[0], cord[1]);
{ mlx_destroy_image(mlx, img);
int y;
int x;
t_pixel pixel;
pixel.color = square.color;
y = square.y;
while (y < square.size + square.y)
{
pixel.y = y;
x = square.x;
while (x < square.size + square.x)
{
pixel.x = x;
ft_draw_pixel(window_manager, window, pixel);
x++;
}
y++;
}
} }

BIN
draw.o

Binary file not shown.

View File

@ -2,7 +2,7 @@ OBJ = ${SRC:.c=.o}
NAME = libftx.a NAME = libftx.a
LIBS = libft/libft.a gnl/get_next_line.a printf/ft_printf.a LIBS = libft/libft.a gnl/get_next_line.a printf/ft_printf.a extra/extra.a
CC = clang CC = clang
@ -11,18 +11,21 @@ FLAG = -Wall -Wextra -Werror
all: ${NAME} all: ${NAME}
${NAME}: ${OBJ} ${NAME}: ${OBJ}
make -C extra
make -C libft make -C libft
make -C gnl make -C gnl
make -C printf make -C printf
ar -rcT $(NAME) $(LIBS) ar -rcT $(NAME) $(LIBS)
clean: clean:
make -C extra clean
make -C libft clean make -C libft clean
make -C gnl clean make -C gnl clean
make -C printf clean make -C printf clean
fclean: clean fclean: clean
rm -f ${NAME} rm -f ${NAME}
make -C extra fclean
make -C libft fclean make -C libft fclean
make -C printf fclean make -C printf fclean
make -C gnl fclean make -C gnl fclean

39
libftx/extra/Makefile Normal file
View File

@ -0,0 +1,39 @@
:# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/04 20:00:03 by cchauvet ### ########.fr #
# #
# **************************************************************************** #
CC = clang
SRCS = ft_strcmp.c ft_strfjoin.c ft_strmerger.c
OBJS = $(SRCS:.c=.o)
NAME = extra.a
CFLAGS = -Wall -Werror -Wextra
%.o: %.c extra.h
$(CC) $(CFLAGS) -c -o $@ $<
all: $(NAME)
$(NAME): $(OBJS)
ar -rc $(NAME) $(OBJS)
clean:
rm -f $(OBJS) $(BOBJS)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all bonus clean fclean re

BIN
libftx/extra/extra.a Normal file

Binary file not shown.

22
libftx/extra/extra.h Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* extra.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:59:10 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef EXTRA_H
# define EXTRA_H
# include <stdarg.h>
# include <stdlib.h>
# include "../libft/libft.h"
char *ft_strfjoin(char *s1, char *s2);
char *ft_strmerger(size_t arg_len, ...);
int ft_strcmp(char *s1, char *s2);
#endif

20
libftx/extra/ft_strcmp.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 19:20:47 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:22:20 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
int ft_strcmp(char *s1, char *s2)
{
while (*s1 == *s2 && *s1 != '\0')
s1++;
return (*s1 - *s2);
}

BIN
libftx/extra/ft_strcmp.o Normal file

Binary file not shown.

View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strfjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:06:04 by cchauvet #+# #+# */
/* Updated: 2023/01/04 14:17:40 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strfjoin(char *s1, char *s2)
{
size_t i;
size_t y;
char *out;
out = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
if (out == NULL)
return (NULL);
i = -1;
if (s1 != NULL)
while (s1[++i] != '\0')
out[i] = s1[i];
free(s1);
y = -1;
if (s2 != NULL)
while (s2[++y] != '\0')
out[i + y] = s2[y];
free(s2);
out[i + y] = '\0';
return (out);
}

BIN
libftx/extra/ft_strfjoin.o Normal file

Binary file not shown.

View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmerger.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 15:09:15 by cchauvet #+# #+# */
/* Updated: 2023/01/04 15:24:17 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strmerger(size_t arg_len, ...)
{
va_list va;
char *out;
char *temp;
va_start(va, arg_len);
out = ft_strjoin(va_arg(va, char *), va_arg(va, char *));
while (arg_len > 2)
{
temp = ft_strjoin(out, va_arg(va, char *));
free(out);
if (temp == NULL)
return (NULL);
out = temp;
arg_len--;
}
return (out);
}

BIN
libftx/extra/ft_strmerger.o Normal file

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */ /* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */
/* Updated: 2022/11/14 17:28:39 by cchauvet ### ########.fr */ /* Updated: 2023/01/04 20:05:54 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,11 +6,11 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ # # By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# # # Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2022/10/28 19:51:46 by cchauvet ### ########.fr # # Updated: 2023/01/04 15:35:42 by cchauvet ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
CC = gcc CC = clang
SRCS = ft_isalpha.c \ SRCS = ft_isalpha.c \
ft_isdigit.c \ ft_isdigit.c \

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */ /* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2022/10/21 15:02:44 by cchauvet ### ########.fr */ /* Updated: 2023/01/04 15:20:30 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -58,10 +58,10 @@ typedef struct s_list
} t_list; } t_list;
t_list *ft_lstnew(void *content); t_list *ft_lstnew(void *content);
void ft_lstadd_front(t_list **lst, t_list *new); void ft_lstadd_front(t_list **lst, t_list *nouveau);
int ft_lstsize(t_list *lst); int ft_lstsize(t_list *lst);
t_list *ft_lstlast(t_list *lst); t_list *ft_lstlast(t_list *lst);
void ft_lstadd_back(t_list **lst, t_list *new); void ft_lstadd_back(t_list **lst, t_list *nouveau);
void ft_lstdelone(t_list *lst, void (*del)(void *)); void ft_lstdelone(t_list *lst, void (*del)(void *));
void ft_lstclear(t_list **lst, void (*del)(void *)); void ft_lstclear(t_list **lst, void (*del)(void *));
void ft_lstiter(t_list *lst, void (*f)(void *)); void ft_lstiter(t_list *lst, void (*f)(void *));

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */ /* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2022/12/14 16:05:13 by cchauvet ### ########.fr */ /* Updated: 2023/01/04 20:07:06 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,10 +14,15 @@
# define LIBFTX_H # define LIBFTX_H
# include <stdlib.h> # include <stdlib.h>
# include <unistd.h> # include <unistd.h>
# include <stdarg.h>
int ft_printf(const char *format, ...); int ft_printf(const char *format, ...);
char *get_next_line(int fd); char *get_next_line(int fd);
char *ft_strfjoin(char *s1, char *s2);
char *ft_strmerger(size_t arg_len, ...);
int ft_strcmp(char *s1, char *s2);
int ft_atoi(const char *nptr); int ft_atoi(const char *nptr);
void ft_bzero(void *s, size_t n); void ft_bzero(void *s, size_t n);
void *ft_calloc(size_t nmemb, size_t size); void *ft_calloc(size_t nmemb, size_t size);

View File

@ -6,9 +6,12 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ # # By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# # # Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2022/12/14 16:15:10 by cchauvet ### ########.fr # # Updated: 2023/01/04 15:36:08 by cchauvet ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
CC = clang
SRCS = ft_dprintul_base.c ft_isdigit.c ft_dprintul.c ft_dprintx.c ft_dprintflag.c ft_skipflag.c ft_vdprintf.c ft_dprintl_base.c ft_dprintX.c ft_dprintptr.c ft_strlen.c ft_putstr_fd.c ft_dprintarg.c ft_printf.c ft_putchar_fd.c ft_isarg.c SRCS = ft_dprintul_base.c ft_isdigit.c ft_dprintul.c ft_dprintx.c ft_dprintflag.c ft_skipflag.c ft_vdprintf.c ft_dprintl_base.c ft_dprintX.c ft_dprintptr.c ft_strlen.c ft_putstr_fd.c ft_dprintarg.c ft_printf.c ft_putchar_fd.c ft_isarg.c
OBJS = ${SRCS:.c=.o} OBJS = ${SRCS:.c=.o}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

22
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */ /* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */
/* Updated: 2022/12/14 18:15:00 by cchauvet ### ########.fr */ /* Updated: 2023/01/04 19:47:28 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,14 +16,22 @@ int main(void)
{ {
void *window_manager; void *window_manager;
void *window; void *window;
t_square square; t_shape shape;
window_manager = mlx_init(); window_manager = mlx_init();
window = mlx_new_window(window_manager, 500, 500, "Hello world!"); window = mlx_new_window(window_manager, 500, 500, "Hello world!");
square.x = 10; shape.x = 10;
square.y = 10; shape.y = 10;
square.size = 400; shape.size = 100;
square.color = ft_strdup("blue"); shape.color = ft_strdup("purple");
ft_draw_square(window_manager, window, square); shape.bcolor = ft_strdup("black");
shape.shape = ft_strdup("square");
ft_xpm_gen_file(shape);
free(shape.color);
free(shape.bcolor);
free(shape.shape);
mlx_loop(window_manager); mlx_loop(window_manager);
mlx_destroy_window(window_manager, window);
mlx_destroy_display(window_manager);
free(window_manager);
} }

BIN
main.o

Binary file not shown.

69
shape.c Normal file
View File

@ -0,0 +1,69 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* shape.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 19:13:01 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:55:25 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
char *ft_square(char c, size_t x_len, size_t y_len)
{
char *map;
size_t x;
size_t y;
map = malloc(((x_len + 4) * y_len) * sizeof(char));
if (map == NULL)
return (map);
y = 0;
while (y < y_len)
{
map[(x_len + 4) * y] = '"';
x = 0;
while (x < x_len)
{
map[y * (x_len + 4) + x + 1] = c;
x++;
}
map[(x_len + 4) * y + x_len + 1] = '"';
map[(x_len + 4) * y + x_len + 2] = ',';
map[(x_len + 4) * y + x_len + 3] = '\n';
y++;
}
map[(x_len + 4) * y_len - 2] = '\0';
return (map);
}
char *ft_triangle(char c, char b, size_t x_len, size_t y_len)
{
char *map;
size_t x;
size_t y;
map = malloc(((x_len + 4) * y_len) * sizeof(char));
if (map == NULL)
return (map);
y = 0;
while (y < y_len)
{
map[(x_len + 4) * y] = '"';
x = 0;
while (x < x_len)
{
map[y * (x_len + 4) + x + 1] = b + c;
x++;
}
map[(x_len + 4) * y + x_len + 1] = '"';
map[(x_len + 4) * y + x_len + 2] = ',';
map[(x_len + 4) * y + x_len + 3] = '\n';
y++;
}
map[(x_len + 4) * y_len - 2] = '\0';
return (map);
}

BIN
shape.o Normal file

Binary file not shown.

BIN
so_long

Binary file not shown.

View File

@ -5,38 +5,34 @@
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/12 17:18:30 by cchauvet #+# #+# */ /* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */
/* Updated: 2022/12/14 17:56:34 by cchauvet ### ########.fr */ /* Updated: 2023/01/04 19:48:18 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef SOLONG_H #ifndef SOLONG_H
# define SOLONG_H # define SOLONG_H
# include "minilibx-linux/mlx.h"
# include "libftx/libftx.h" # include "libftx/libftx.h"
# define PIXEL_PATH "./textures/pixel.xpm" # define XPM_PATH "./textures/"
# include <stdio.h>
typedef struct s_data { # include <unistd.h>
void *img; # include <fcntl.h>
char *addr; # include "minilibx-linux/mlx.h"
int bits_per_pixel; typedef struct s_shape
int line_length; {
int endian;
} t_data;
typedef struct s_square {
int x;
int y;
int size;
char *color; char *color;
} t_square; char *bcolor;
char *shape;
typedef struct s_pixel { size_t size;
int x; size_t x;
int y; size_t y;
char *color; } t_shape;
} t_pixel; void ft_draw_xpm(void *mlx, void *window, char *file, size_t *cord);
void ft_draw_square(void *window_manager, void *window, t_shape shape);
void ft_draw_square(void *window_manager, void *window, t_square square); char *xpm_square_generator(t_shape);
char *ft_gen_xpm_file(t_shape);
char *ft_square(char c, size_t x_len, size_t y_len);
char *ft_triangle(char c, char b, size_t x_len, size_t y_len);
char *ft_xpm_gen_file(t_shape shape);
#endif #endif

16
test.c Normal file
View File

@ -0,0 +1,16 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(int ac, char **av)
{
int fd;
if (ac)
{
fd = open(av[1], O_RDONLY);
printf("%d", fd);
close(fd);
}
return (0);
}

View File

@ -1,8 +1,105 @@
/* XPM */ /* XPM */
static char *_ca03a9095ee4203bcb3ca312dbb1520h08f8qZJS8cIAZS2[] = { static char * XFACE[] = {"
/* columns rows colors chars-per-pixel */ 100 100 1 1",
"1 1 1 1 ", "a c purple",
" c red", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
/* pixels */ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
" " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa""
}; };

93
xpm.c Normal file
View File

@ -0,0 +1,93 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* xpm.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 13:53:03 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:48:36 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
static char *name_generator(t_shape shape)
{
char *out;
char *size;
char *color;
color = ft_strdup(shape.color);
if (color == NULL)
return (NULL);
size = ft_itoa(shape.size);
if (size == NULL)
return (NULL);
out = ft_strmerger(8, shape.shape, "_", color, "_", size, "x", size, ".xpm");
return (out);
}
static char *ft_map_gen(t_shape shape)
{
if (ft_strcmp(shape.shape, "square") == 0)
return (ft_square('a', shape.size, shape.size));
if (ft_strcmp(shape.shape, "triangle") == 0)
return (ft_triangle('a', 'b', shape.size, shape.size));
return (NULL);
}
char *ft_gen_xpm_content(t_shape shape)
{
char *xpm_content;
char *temp;
char *size;
char *map;
size = ft_itoa(shape.size);
if (size == NULL)
return (NULL);
temp = ft_strdup("/* XPM */\nstatic char * XFACE[] = {" "\"\n");
if (temp == NULL)
return (NULL);
xpm_content = ft_strmerger(5, temp, size, " ", size, " 2 1\",\n\"");
free(temp);
if (xpm_content == NULL)
return (NULL);
map = ft_map_gen(shape);
if (map == NULL)
return (NULL);
temp = ft_strmerger(5, xpm_content, "a c ", shape.color, "\",\n", map);
if (temp == NULL)
return (NULL);
free(xpm_content);
xpm_content = ft_strmerger(2, temp, "\"b c ", shape.bcolor, "\",\n};");
free(temp);
return (xpm_content);
}
char *ft_xpm_gen_file(t_shape shape)
{
char *file_content;
char *name;
int fd;
file_content = ft_gen_xpm_content(shape);
if (file_content == NULL)
return (NULL);
name = name_generator(shape);
if (name == NULL)
return (NULL);
name = ft_strfjoin(XPM_PATH, name);
if (name == NULL)
return (NULL);
fd = open(name, O_RDONLY);
if (fd == -1)
{
close(fd);
fd = open(name, O_WRONLY | O_CREAT, 0644);
write(fd, file_content, ft_strlen(file_content));
close(fd);
}
return (name);
}

BIN
xpm.o Normal file

Binary file not shown.