70 lines
1.9 KiB
C
70 lines
1.9 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* 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);
|
|
}
|