piscine-rush00-ultra/rush00.c

49 lines
1.6 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush00.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/18 20:15:12 by jtorrez- #+# #+# */
/* Updated: 2023/03/18 20:25:05 by jtorrez- ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void horiz_line(char left, char middle, char right, int width);
const char g_inside = ' ';
// corners specified clockwise, starting from top left
const char g_corners[] = {'o', 'o', 'o', 'o', '\0'};
const char g_horizontal = '-';
const char g_vertical = '|';
void rush(int x, int y)
{
int i;
i = 0;
if (x == 0 || y == 0)
return ;
horiz_line(g_corners[0], g_horizontal, g_corners[1], x);
while (i++ < y - 2)
horiz_line(g_vertical, g_inside, g_vertical, x);
if (y > 1)
horiz_line(g_corners[3], g_horizontal, g_corners[2], x);
}
void horiz_line(char left, char middle, char right, int width)
{
int i;
i = 0;
ft_putchar(left);
while (i++ < width - 2)
ft_putchar(middle);
if (width > 1)
ft_putchar(right);
ft_putchar('\n');
}