cmdfx 0.1.0
Lightweight game engine for your terminal
|
Builder API for building 2D Character Arrays. More...
Go to the source code of this file.
Functions | |
int | getArrayWidth (char **array) |
Gets the width of a 2D Character Array. | |
int | getArrayHeight (char **array) |
Gets the height of a 2D Character Array. | |
char ** | CharBuilder_create (int width, int height) |
Creates a 2D Character Array with a specific width and height. | |
int | CharBuilder_setChar (char **array, int x, int y, char c) |
Sets a character in a 2D Character Array. | |
int | CharBuilder_hLine (char **array, int x, int y, int width, char c) |
Draws a horizontal line in a 2D Character Array. | |
int | CharBuilder_vLine (char **array, int x, int y, int height, char c) |
Draws a vertical line in a 2D Character Array. | |
int | CharBuilder_rect (char **array, int x, int y, int width, int height, char c) |
Draws a rectangle in a 2D Character Array. | |
int | CharBuilder_fillRect (char **array, int x, int y, int width, int height, char c) |
Fills a rectangle in a 2D Character Array. | |
int | CharBuilder_circle (char **array, int x, int y, int radius, char c) |
Draws a circle in a 2D Character Array. | |
int | CharBuilder_fillCircle (char **array, int x, int y, int radius, char c) |
Fills a circle in a 2D Character Array. | |
int | CharBuilder_ellipse (char **array, int x, int y, int xradius, int yradius, char c) |
Draws an ellipse in a 2D Character Array. | |
int | CharBuilder_fillEllipse (char **array, int x, int y, int xradius, int yradius, char c) |
Fills an ellipse in a 2D Character Array. | |
int | CharBuilder_line (char **array, int x1, int y1, int x2, int y2, char c) |
Draws a line in a 2D Character Array. | |
int | CharBuilder_text (char **array, int x, int y, char *text) |
Writes text in a 2D Character Array. | |
int | CharBuilder_resize (char **array, int width, int height) |
Resizes an 2D Character Array to a specific width and height. | |
int | CharBuilder_resizeWithPadding (char **array, int width, int height, char padding) |
Resizes an 2D Character Array to a specific width and height with padding. | |
int | CharBuilder_center (char **array) |
Centers an 2D Character Array. | |
int | CharBuilder_resizeAndCenter (char **array, int width, int height) |
Resizes and centers an 2D Character Array. | |
int | getAnsiArrayWidth (char ***array) |
Gets the width of a 2D String Array. | |
int | getAnsiArrayHeight (char ***array) |
Gets the height of a 2D String Array. | |
char *** | AnsiBuilder_create (int width, int height) |
Creates a 2D String Array with a specific width and height. | |
int | AnsiBuilder_setAnsi (char ***array, int x, int y, char *c) |
Sets an ANSI code in a 2D String Array. | |
int | AnsiBuilder_hLine (char ***array, int x, int y, int width, char *c) |
Draws a horizontal line in a 2D String Array. | |
int | AnsiBuilder_vLine (char ***array, int x, int y, int height, char *c) |
Draws a vertical line in a 2D String Array. | |
int | AnsiBuilder_rect (char ***array, int x, int y, int width, int height, char *c) |
Draws a rectangle in a 2D String Array. | |
int | AnsiBuilder_fillRect (char ***array, int x, int y, int width, int height, char *c) |
Fills a rectangle in a 2D String Array. | |
int | AnsiBuilder_circle (char ***array, int x, int y, int radius, char *c) |
Draws a circle in a 2D String Array. | |
int | AnsiBuilder_fillCircle (char ***array, int x, int y, int radius, char *c) |
Fills a circle in a 2D String Array. | |
int | AnsiBuilder_ellipse (char ***array, int x, int y, int xradius, int yradius, char *c) |
Draws an ellipse in a 2D String Array. | |
int | AnsiBuilder_fillEllipse (char ***array, int x, int y, int xradius, int yradius, char *c) |
Fills an ellipse in a 2D String Array. | |
int | AnsiBuilder_line (char ***array, int x1, int y1, int x2, int y2, char *c) |
Draws a line in a 2D String Array. | |
Builder API for building 2D Character Arrays.
int AnsiBuilder_circle | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | radius, | ||
char * | c ) |
Draws a circle in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
radius | The radius of the circle. |
c | The ANSI code to draw the circle with. |
char *** AnsiBuilder_create | ( | int | width, |
int | height ) |
Creates a 2D String Array with a specific width and height.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
This method creates an array with a specific width and height. The array will be initialized with the space character.
width | The width of the array. |
height | The height of the array. |
int AnsiBuilder_ellipse | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | xradius, | ||
int | yradius, | ||
char * | c ) |
Draws an ellipse in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
xradius | The x radius of the ellipse. |
yradius | The y radius of the ellipse. |
c | The ANSI code to draw the ellipse with. |
int AnsiBuilder_fillCircle | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | radius, | ||
char * | c ) |
Fills a circle in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
radius | The radius of the circle. |
c | The ANSI code to fill the circle with. |
int AnsiBuilder_fillEllipse | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | xradius, | ||
int | yradius, | ||
char * | c ) |
Fills an ellipse in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
xradius | The x radius of the ellipse. |
yradius | The y radius of the ellipse. |
c | The ANSI code to fill the ellipse with. |
int AnsiBuilder_fillRect | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
char * | c ) |
Fills a rectangle in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
c | The ANSI code to fill the rectangle with. |
int AnsiBuilder_hLine | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | width, | ||
char * | c ) |
Draws a horizontal line in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
width | The width of the line. |
c | The ANSI code to draw the line with. |
int AnsiBuilder_line | ( | char *** | array, |
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
char * | c ) |
Draws a line in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x1 | The x coordinate of the first point. |
y1 | The y coordinate of the first point. |
x2 | The x coordinate of the second point. |
y2 | The y coordinate of the second point. |
c | The ANSI code to draw the line with. |
int AnsiBuilder_rect | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
char * | c ) |
Draws a rectangle in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
c | The ANSI code to draw the rectangle with. |
int AnsiBuilder_setAnsi | ( | char *** | array, |
int | x, | ||
int | y, | ||
char * | c ) |
Sets an ANSI code in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
This method sets an ANSI code at the specified x and y coordinates. If the x or y coordinate is out of bounds, the method will return -1.
The values at array[height]
and array[height][width]
will be set to 0 for null termination. It is advised that you create a char***
with this method and pass it to other functions presented in this header file, rather than create a char***
and pass it to other functions, in order to avoid undefined behavior.
array | The 2D String Array. |
x | The x coordinate. |
y | The y coordinate |
c | The ANSI code to set. |
int AnsiBuilder_vLine | ( | char *** | array, |
int | x, | ||
int | y, | ||
int | height, | ||
char * | c ) |
Draws a vertical line in a 2D String Array.
Like all methods in AnsiBuilder, this does not append anything to the string. You will need to input the full ANSI code, like "\033[31m" for red text.
array | The string array. |
x | The x coordinate. |
y | The y coordinate. |
height | The height of the line. |
c | The ANSI to draw the line with. |
int CharBuilder_center | ( | char ** | array | ) |
Centers an 2D Character Array.
This method centers an 2D Character Array both horizontally and vertically. It will reposition the characters depending on whether there is whitespace surrounding other characters.
array | The 2D Character Array. |
int CharBuilder_circle | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | radius, | ||
char | c ) |
Draws a circle in a 2D Character Array.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
radius | The radius of the circle. |
c | The character to draw the circle with. |
char ** CharBuilder_create | ( | int | width, |
int | height ) |
Creates a 2D Character Array with a specific width and height.
This method creates an array with a specific width and height. The array will be initialized with the space character.
The values at array[height]
and array[height][width]
will be set to 0 for null termination. It is advised that you create a char**
with this method and pass it to other functions presented in this header file, rather than create a char**
and pass it to other functions, in order to avoid undefined behavior.
width | The width of the array. |
height | The height of the array. |
int CharBuilder_ellipse | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | xradius, | ||
int | yradius, | ||
char | c ) |
Draws an ellipse in a 2D Character Array.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
xradius | The x radius of the ellipse. |
yradius | The y radius of the ellipse. |
c | The character to draw the ellipse with. |
int CharBuilder_fillCircle | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | radius, | ||
char | c ) |
Fills a circle in a 2D Character Array.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
radius | The radius of the circle. |
c | The character to fill the circle with. |
int CharBuilder_fillEllipse | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | xradius, | ||
int | yradius, | ||
char | c ) |
Fills an ellipse in a 2D Character Array.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
xradius | The x radius of the ellipse. |
yradius | The y radius of the ellipse. |
c | The character to fill the ellipse with. |
int CharBuilder_fillRect | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
char | c ) |
Fills a rectangle in a 2D Character Array.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
c | The character to fill the rectangle with. |
int CharBuilder_hLine | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | width, | ||
char | c ) |
Draws a horizontal line in a 2D Character Array.
This method draws a horizontal line in a 2D Character Array. If the x or y coordinate is out of bounds, the method will return -1. If the line goes out of bounds, the line will be cropped.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
width | The width of the line. |
c | The character to draw the line with. |
int CharBuilder_line | ( | char ** | array, |
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
char | c ) |
Draws a line in a 2D Character Array.
array | The character array. |
x1 | The x coordinate of the first point. |
y1 | The y coordinate of the first point. |
x2 | The x coordinate of the second point. |
y2 | The y coordinate of the second point. |
c | The character to draw the line with. |
int CharBuilder_rect | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
char | c ) |
Draws a rectangle in a 2D Character Array.
This method draws a rectangle in a 2D Character Array. If the x or y coordinate is out of bounds, the method will return -1. If the rectangle goes out of bounds, the rectangle will be cropped.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
c | The character to draw the rectangle with. |
int CharBuilder_resize | ( | char ** | array, |
int | width, | ||
int | height ) |
Resizes an 2D Character Array to a specific width and height.
This method resizes an 2D Character Array to a specific width and height. If the new width or height is smaller than the original width or height, the 2D Character Array will be cropped. If the new width or height is larger than the original width or height, the 2D Character Array will be padded with empty space.
array | The 2D Character Array. |
width | The new width. |
height | The new height. |
int CharBuilder_resizeAndCenter | ( | char ** | array, |
int | width, | ||
int | height ) |
Resizes and centers an 2D Character Array.
This method resizes and centers an 2D Character Array to a specific width and height. If the new width or height is smaller than the original width or height, the ASCII art character will be cropped. If the new width or height is larger than the original width or height, the 2D Character Array will be padded with the specified character.
array | The 2D Character Array. |
width | The new width. |
height | The new height. |
int CharBuilder_resizeWithPadding | ( | char ** | array, |
int | width, | ||
int | height, | ||
char | padding ) |
Resizes an 2D Character Array to a specific width and height with padding.
This method resizes an 2D Character Array to a specific width and height with padding. If the new width or height is smaller than the original width or height, the ASCII art character will be cropped. If the new width or height is larger than the original width or height, the 2D Character Array will be padded with the specified character.
array | The 2D Character Array. |
width | The new width. |
height | The new height. |
padding | The padding character. |
int CharBuilder_setChar | ( | char ** | array, |
int | x, | ||
int | y, | ||
char | c ) |
Sets a character in a 2D Character Array.
This method sets a character at the specified x and y coordinates. If the x or y coordinate is out of bounds, the method will return -1.
array | The 2D Character Array. |
x | The x coordinate. |
y | The y coordinate |
c | The character to set. |
int CharBuilder_text | ( | char ** | array, |
int | x, | ||
int | y, | ||
char * | text ) |
Writes text in a 2D Character Array.
If the text is too long to fit in the array, it will be wrapped to the next line. If the text is too long to fit in the array at all, the string will be truncated.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
text | The text to draw. |
int CharBuilder_vLine | ( | char ** | array, |
int | x, | ||
int | y, | ||
int | height, | ||
char | c ) |
Draws a vertical line in a 2D Character Array.
This method draws a vertical line in a 2D Character Array. If the x or y coordinate is out of bounds, the method will return -1. If the line goes out of bounds, the line will be cropped.
array | The character array. |
x | The x coordinate. |
y | The y coordinate. |
height | The height of the line. |
c | The character to draw the line with. |
int getAnsiArrayHeight | ( | char *** | array | ) |
Gets the height of a 2D String Array.
array | The a 2D String Array. |
int getAnsiArrayWidth | ( | char *** | array | ) |
Gets the width of a 2D String Array.
array | The 2D String Array. |
int getArrayHeight | ( | char ** | array | ) |
Gets the height of a 2D Character Array.
array | The a 2D Character Array. |
int getArrayWidth | ( | char ** | array | ) |
Gets the width of a 2D Character Array.
array | The 2D Character Array. |