/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rush00.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jtorrez- +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/18 20:15:12 by jtorrez- #+# #+# */ /* Updated: 2023/03/19 19:10:59 by tischmid ### ########.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 = '|'; // Display a rectangle on standard output, specified by a width (x), // a height (y), a char array (g_corners) that contains the corners // in clockwise direction (starting from the top left), a char that // contains the horizontal character (g_horizontal), a char that contains // the vertical character (g_vertical), and additionally a char that // contains the inside ("the filling") character of the rectangle. void rush(int x, int y) { int i; i = 0; if (x < 1 && y < 1) 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); } // Display a horizontal line on standard output, specified by a single // left char, (width - 2) middle chars, and a single right char, // followed by a newline at the end. 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'); }