![]() |
cmdfx 0.1.1
Lightweight game engine for your terminal
|
Sprites API for CmdFX. More...
Go to the source code of this file.
Classes | |
struct | CmdFX_Sprite |
Represents a sprite that can be drawn to the terminal. More... | |
Typedefs | |
typedef struct CmdFX_Sprite | CmdFX_Sprite |
Represents a sprite that can be drawn to the terminal. | |
Enumerations | |
enum | CmdFX_GradientDirection { GRADIENT_HORIZONTAL , GRADIENT_HORIZONTAL_REVERSE , GRADIENT_VERTICAL , GRADIENT_VERTICAL_REVERSE , GRADIENT_ANGLE_45 , GRADIENT_ANGLE_135 , GRADIENT_RADIAL , GRADIENT_CONICAL } |
Represents a color gradient that can be applied to a sprite. More... | |
Functions | |
CmdFX_Sprite ** | Canvas_getDrawnSprites () |
Gets the sprites that have been drawn to the terminal. | |
int | Canvas_getDrawnSpritesCount () |
Gets the number of sprites that have been drawn to the terminal. | |
CmdFX_Sprite * | Canvas_getSpriteAt (int x, int y) |
Gets a sprite at the given position with the highest Z-index. | |
CmdFX_Sprite * | Sprite_create (char **text, char ***ansi, int z) |
Creates a new sprite. | |
void | Sprite_free (CmdFX_Sprite *sprite) |
Frees the memory allocated for a sprite. | |
int | Sprite_draw (int x, int y, CmdFX_Sprite *sprite) |
Draws a sprite to the terminal. | |
void | Sprite_remove (CmdFX_Sprite *sprite) |
Removes a sprite from the terminal, making it no longer visble. | |
int | Sprite_setData (CmdFX_Sprite *sprite, char **data) |
Sets the text data for the sprite. | |
int | Sprite_setChar (CmdFX_Sprite *sprite, int x, int y, char c) |
Sets the character at the given position in the sprite. | |
int | Sprite_fillChar (CmdFX_Sprite *sprite, int x, int y, char c, int width, int height) |
Fills positions in the sprite. | |
int | Sprite_fillCharEmpty (CmdFX_Sprite *sprite, int x, int y, char c, int width, int height) |
Fills positions in the sprite where there isn't a character. | |
int | Sprite_fillCharAll (CmdFX_Sprite *sprite, char c) |
Sets the character at all positions in the sprite. | |
int | Sprite_fillCharAllEmpty (CmdFX_Sprite *sprite, char c) |
Sets the character at all positions in the sprite where there isn't a character. | |
int | Sprite_setAnsi (CmdFX_Sprite *sprite, int x, int y, char *ansi) |
Sets the ANSI code at the given position in the sprite. | |
int | Sprite_appendAnsi (CmdFX_Sprite *sprite, int x, int y, char *ansi) |
Appends an ANSI code to the given position in the sprite. | |
int | Sprite_fillAnsi (CmdFX_Sprite *sprite, int x, int y, char *ansi, int width, int height) |
Fills positions in the sprite with an ANSI code. | |
int | Sprite_setAnsiAll (CmdFX_Sprite *sprite, char *ansi) |
Sets the character at all positions in the sprite. | |
int | Sprite_appendAnsiAll (CmdFX_Sprite *sprite, char *ansi) |
Appends an ANSI code to all positions in the sprite. | |
CmdFX_Sprite * | Sprite_createFilled (int width, int height, char c, char *ansi, int z) |
Creates a new sprite with the given dimensions. | |
CmdFX_Sprite * | Sprite_loadFromFile (const char *path, int z) |
Creates a new sprite from a file. | |
int | Sprite_resize (CmdFX_Sprite *sprite, int width, int height) |
Resizes the sprite to the given dimensions. | |
int | Sprite_resizeWithPadding (CmdFX_Sprite *sprite, int width, int height, char padding) |
Resizes the sprite to the given dimensions. | |
int | Sprite_center (CmdFX_Sprite *sprite) |
Centers the sprite on the terminal. | |
int | Sprite_resizeAndCenter (CmdFX_Sprite *sprite, int width, int height) |
Resizes and centers the sprite on the terminal. | |
void | Sprite_moveTo (CmdFX_Sprite *sprite, int x, int y) |
Moves a sprite to the given position. | |
void | Sprite_moveBy (CmdFX_Sprite *sprite, int dx, int dy) |
Moves a sprite by the given amount. | |
CmdFX_Sprite ** | Sprite_getCollidingSprites (CmdFX_Sprite *sprite) |
Gets the sprites that are colliding with the given sprite. | |
int | Sprite_isColliding (CmdFX_Sprite *sprite1, CmdFX_Sprite *sprite2) |
Checks if two sprites are colliding. | |
int | Sprite_isOnTop (CmdFX_Sprite *sprite, int x, int y) |
Gets whether the sprite is the top-most sprite at the given position. | |
int | Sprite_isOnBottom (CmdFX_Sprite *sprite, int x, int y) |
Gets whether the sprite is the bottom-most sprite at the given position. | |
int | Sprite_setForeground (CmdFX_Sprite *sprite, int x, int y, int rgb) |
Sets the foreground color of the sprite at the given position. | |
int | Sprite_setForegroundAll (CmdFX_Sprite *sprite, int rgb) |
Sets the foreground color of the sprite at the given position. | |
int | Sprite_setForegroundAll256 (CmdFX_Sprite *sprite, int color) |
Sets the foreground color of the sprite at the given position using 256-bit color codes. | |
int | Sprite_setBackground (CmdFX_Sprite *sprite, int x, int y, int rgb) |
Sets the background color of the sprite at the given position. | |
int | Sprite_setBackgroundAll (CmdFX_Sprite *sprite, int rgb) |
Sets the background color of the sprite at the given position. | |
int | Sprite_setBackgroundAll256 (CmdFX_Sprite *sprite, int color) |
Sets the background color of the sprite at the given position using 256-bit color codes. | |
int | Sprite_setForegroundGradient (CmdFX_Sprite *sprite, int x, int y, int width, int height, enum CmdFX_GradientDirection direction, int numColors,...) |
Sets a foreground gradient using RGB colors for a specified section of the sprite. | |
int | Sprite_setForegroundGradientAll (CmdFX_Sprite *sprite, enum CmdFX_GradientDirection direction, int numColors,...) |
Sets a foreground gradient using RGB colors. | |
int | Sprite_setBackgroundGradient (CmdFX_Sprite *sprite, int x, int y, int width, int height, enum CmdFX_GradientDirection direction, int numColors,...) |
Sets a background gradient using RGB colors for a specified section of the sprite. | |
int | Sprite_setBackgroundGradientAll (CmdFX_Sprite *sprite, enum CmdFX_GradientDirection direction, int numColors,...) |
Sets a background gradient using RGB colors. | |
int | Sprite_rotate (CmdFX_Sprite *sprite, double radians) |
Rotates the sprite by the given angle. | |
double | Sprite_getRotationAngle (CmdFX_Sprite *sprite) |
Gets the rotation angle of the sprite. | |
int | Sprite_hFlip (CmdFX_Sprite *sprite) |
Flips the sprite horizontally. | |
int | Sprite_vFlip (CmdFX_Sprite *sprite) |
Flips the sprite vertically. | |
int | Sprite_scale (CmdFX_Sprite *sprite, double scale) |
Scales the sprite by the given factor. | |
int | Sprite_transpose (CmdFX_Sprite *sprite) |
Transposes the sprite. | |
Sprites API for CmdFX.
typedef struct CmdFX_Sprite CmdFX_Sprite |
Represents a sprite that can be drawn to the terminal.
A sprite is a 2D image that can be drawn to the terminal. It consists of a 2D array of characters that represent the sprite, as well as a Z-index that determines the order in which sprites are drawn. Sprites are useful for keeping track of complex images or animations that need to be drawn to the terminal.
Represents a color gradient that can be applied to a sprite.
A color gradient is a smooth transition between two or more colors. The gradient can be applied to the foreground or background of a sprite, and can be applied in different directions.
CmdFX_Sprite ** Canvas_getDrawnSprites | ( | ) |
Gets the sprites that have been drawn to the terminal.
This method returns an array of pointers to the sprites that have been drawn to the terminal. The array is terminated with a NULL
pointer. The sprites should not be modified or freed by the caller.
int Canvas_getDrawnSpritesCount | ( | ) |
Gets the number of sprites that have been drawn to the terminal.
CmdFX_Sprite * Canvas_getSpriteAt | ( | int | x, |
int | y ) |
Gets a sprite at the given position with the highest Z-index.
This method returns the sprite that is drawn at the given position with the highest Z-index. If there is no sprite at the given position, the method will return NULL
.
x | The X position. |
y | The Y position. |
NULL
if no sprite is found. int Sprite_appendAnsi | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
char * | ansi ) |
Appends an ANSI code to the given position in the sprite.
This method appends the given ANSI code to the existing ANSI code at the given position in the sprite. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
ansi | The ANSI code to append. |
int Sprite_appendAnsiAll | ( | CmdFX_Sprite * | sprite, |
char * | ansi ) |
Appends an ANSI code to all positions in the sprite.
This method appends the given ANSI code to the existing ANSI code at all positions in the sprite. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
ansi | The ANSI code to append. |
int Sprite_center | ( | CmdFX_Sprite * | sprite | ) |
Centers the sprite on the terminal.
This method centers the sprite on the terminal, both horizontally and vertically. It will reposition the data
and ansi
characters depending on whether there is whitespace surrounding other characters.
The sprite will be drawn at its current position.
sprite | The sprite to center. |
CmdFX_Sprite * Sprite_create | ( | char ** | text, |
char *** | ansi, | ||
int | z ) |
Creates a new sprite.
This method allocates memory for a new sprite and initializes it with the given parameters. The sprite should be freed with Sprite_free
when it is no longer needed.
You can also set text
and ansi
to NULL and built them later using Sprite_setChar
, Sprite_setAnsi
, and Sprite_resize
.
This method does not draw the sprite to the terminal. To draw the sprite, use the Sprite_draw
method.
text | The text data for the sprite. |
ansi | The ANSI data for the sprite. |
z | The Z-index of the sprite. |
CmdFX_Sprite * Sprite_createFilled | ( | int | width, |
int | height, | ||
char | c, | ||
char * | ansi, | ||
int | z ) |
Creates a new sprite with the given dimensions.
This method creates a new sprite with the given dimensions. The sprite will be filled with the specified character and ANSI code. The sprite should be freed with Sprite_free
when it is no longer needed.
This method does not draw the sprite to the terminal. To draw the sprite, use the Sprite_draw
method.
width | The width of the sprite. |
height | The height of the sprite. |
c | The character to fill the sprite with. |
ansi | The ANSI code to fill the sprite with. |
z | The Z-index of the sprite. |
int Sprite_draw | ( | int | x, |
int | y, | ||
CmdFX_Sprite * | sprite ) |
Draws a sprite to the terminal.
This method draws a sprite to the terminal at the given position. The sprite will be drawn starting at the X and Y position, with the top-left corner of the sprite at the X and Y position. The sprite will be drawn on top of any existing content at that position, according to its Z-index. If it is already drawn, it will be redrawn at the new position.
If data
is NULL, the sprite will not be drawn.
x | The X position of the sprite. |
y | The Y position of the sprite. |
sprite | The sprite to draw. |
int Sprite_fillAnsi | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
char * | ansi, | ||
int | width, | ||
int | height ) |
Fills positions in the sprite with an ANSI code.
This method sets the ANSI code at a specific rectangle in the sprite. The fill will start at the given position and fill the specified width and height. If a position is out of bounds, it will be skipped.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
ansi | The ANSI code to set. |
width | The width of the fill. |
height | The height of the fill. |
int Sprite_fillChar | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
char | c, | ||
int | width, | ||
int | height ) |
Fills positions in the sprite.
This method sets the character at a specific rectangle in the sprite. The fill will start at the given position and fill the specified width and height. If a position is out of bounds, it will be skipped.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
c | The character to set. |
width | The width of the fill. |
height | The height of the fill. |
int Sprite_fillCharAll | ( | CmdFX_Sprite * | sprite, |
char | c ) |
Sets the character at all positions in the sprite.
This method sets the character at all positions in the sprite. The character will be set for every position in the sprite, starting from the top-left corner. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
c | The character to set. |
int Sprite_fillCharAllEmpty | ( | CmdFX_Sprite * | sprite, |
char | c ) |
Sets the character at all positions in the sprite where there isn't a character.
This method sets the character at all positions in the sprite. The character will be set for every position in the sprite, starting from the top-left corner. If an error occurs, the method will return 0.
This method will skip any positions that are already filled with a character. Existing ANSI codes at empty positions will be preserved.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
c | The character to set. |
int Sprite_fillCharEmpty | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
char | c, | ||
int | width, | ||
int | height ) |
Fills positions in the sprite where there isn't a character.
This method sets the character at a specific rectangle in the sprite. The fill will start at the given position and fill the specified width and height. If a position is out of bounds, it will be skipped.
This method will skip any positions that are already filled with a character. Existing ANSI codes at empty positions will be preserved.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
c | The character to set. |
width | The width of the fill. |
height | The height of the fill. |
void Sprite_free | ( | CmdFX_Sprite * | sprite | ) |
Frees the memory allocated for a sprite.
If the sprite is currently drawn, it will be removed.
sprite | The sprite to free. |
CmdFX_Sprite ** Sprite_getCollidingSprites | ( | CmdFX_Sprite * | sprite | ) |
Gets the sprites that are colliding with the given sprite.
This method returns an array of pointers to the sprites that are colliding with the given sprite. The array is terminated with a NULL
pointer.
The array must be freed by the caller when it is no longer needed.
sprite | The sprite to check for collisions. |
double Sprite_getRotationAngle | ( | CmdFX_Sprite * | sprite | ) |
Gets the rotation angle of the sprite.
This method returns the rotation angle of the sprite in radians. The angle will be between -PI and PI. If the sprite is not rotated, the method will return 0. Rotation is calculated by the number of whitespace characters in the sprite, meaning this method relies on whether it is visually rotated or not.
sprite | The sprite to get the rotation angle of. |
int Sprite_hFlip | ( | CmdFX_Sprite * | sprite | ) |
Flips the sprite horizontally.
This method flips the sprite horizontally. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to flip. |
int Sprite_isColliding | ( | CmdFX_Sprite * | sprite1, |
CmdFX_Sprite * | sprite2 ) |
Checks if two sprites are colliding.
sprite1 | The first sprite. |
sprite2 | The second sprite. |
int Sprite_isOnBottom | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y ) |
Gets whether the sprite is the bottom-most sprite at the given position.
This method checks if the sprite is the bottom-most sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0. "Bottom-most" refers to the sprite with the lowest Z-index.
sprite | The sprite to check. |
x | The X position. |
y | The Y position. |
int Sprite_isOnTop | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y ) |
Gets whether the sprite is the top-most sprite at the given position.
This method checks if the sprite is the top-most sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0. "Top-most" refers to the sprite with the highest Z-index.
sprite | The sprite to check. |
x | The X position. |
y | The Y position. |
CmdFX_Sprite * Sprite_loadFromFile | ( | const char * | path, |
int | z ) |
Creates a new sprite from a file.
This method creates a new sprite from the given file. The sprite will be loaded from the file and the Z-index will be set to the given value. The data from the file will be used, keeping ansi
empty. The file must be a readable text file. The sprite should be freed with Sprite_free
when it is no longer needed.
This method does not draw the sprite to the terminal. To draw the sprite, use the Sprite_draw
method.
path | The path to the file to load the sprite from. |
z | The Z-index of the sprite. |
void Sprite_moveBy | ( | CmdFX_Sprite * | sprite, |
int | dx, | ||
int | dy ) |
Moves a sprite by the given amount.
sprite | The sprite to move. |
dx | The delta X position to move the sprite by. |
dy | The delta Y position to move the sprite by. |
void Sprite_moveTo | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y ) |
Moves a sprite to the given position.
sprite | The sprite to move. |
x | The new X position of the sprite. |
y | The new Y position of the sprite. |
void Sprite_remove | ( | CmdFX_Sprite * | sprite | ) |
Removes a sprite from the terminal, making it no longer visble.
sprite | The sprite to remove. |
int Sprite_resize | ( | CmdFX_Sprite * | sprite, |
int | width, | ||
int | height ) |
Resizes the sprite to the given dimensions.
This method is functionally identical to Sprite_resizeWithPadding
, but it will pad the sprite with spaces if it is resized larger.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to resize. |
width | The new width of the sprite. |
height | The new height of the sprite. |
int Sprite_resizeAndCenter | ( | CmdFX_Sprite * | sprite, |
int | width, | ||
int | height ) |
Resizes and centers the sprite on the terminal.
This method resizes the sprite to the given width and height, and then centers the sprite on the terminal, both horizontally and vertically. It will reposition the data
and ansi
characters depending on whether there is whitespace surrounding other characters.
The sprite will be drawn at its new position.
sprite | The sprite to resize and center. |
width | The new width of the sprite. |
height | The new height of the sprite. |
int Sprite_resizeWithPadding | ( | CmdFX_Sprite * | sprite, |
int | width, | ||
int | height, | ||
char | padding ) |
Resizes the sprite to the given dimensions.
This method resizes the sprite to the given width and height. If the new dimensions are smaller than the current dimensions, the sprite will be cropped from the top left. If the new dimensions are larger than the current dimensions, the sprite will be padded with the provided character. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to resize. |
width | The new width of the sprite. |
height | The new height of the sprite. |
padding | The character to pad the sprite with if it is resized larger. |
int Sprite_rotate | ( | CmdFX_Sprite * | sprite, |
double | radians ) |
Rotates the sprite by the given angle.
This method rotates the sprite by the given angle in radians. The sprite will be rotated around its center. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to rotate. |
radians | The angle to rotate the sprite by in radians. |
int Sprite_scale | ( | CmdFX_Sprite * | sprite, |
double | scale ) |
Scales the sprite by the given factor.
This method scales the sprite by the given factor. The sprite will be scaled around its center. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to scale. |
scale | The factor to scale the sprite by. |
int Sprite_setAnsi | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
char * | ansi ) |
Sets the ANSI code at the given position in the sprite.
This method sets the ANSI code at the given position in the sprite. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
ansi | The ANSI code to set. |
int Sprite_setAnsiAll | ( | CmdFX_Sprite * | sprite, |
char * | ansi ) |
Sets the character at all positions in the sprite.
This method sets the character at all positions in the sprite. The character will be set for every position in the sprite, starting from the top-left corner. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
ansi | The ANSI code to set. |
int Sprite_setBackground | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
int | rgb ) |
Sets the background color of the sprite at the given position.
This method sets the background color of the sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
rgb | The RGB color to set. |
int Sprite_setBackgroundAll | ( | CmdFX_Sprite * | sprite, |
int | rgb ) |
Sets the background color of the sprite at the given position.
This method sets the background color of the sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
rgb | The RGB color to set. |
int Sprite_setBackgroundAll256 | ( | CmdFX_Sprite * | sprite, |
int | color ) |
Sets the background color of the sprite at the given position using 256-bit color codes.
This method sets the background color of the sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
color | The 256-color code to set. |
int Sprite_setBackgroundGradient | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
enum CmdFX_GradientDirection | direction, | ||
int | numColors, | ||
... ) |
Sets a background gradient using RGB colors for a specified section of the sprite.
This method sets a background gradient using RGB colors between multiple colors. The gradient will be applied to the sprite starting at the given position and extending for the given width and height. The direction of the gradient will be determined by the direction
parameter. The colors should be specified as RGB values in the format 0xRRGGBB
. Non-integer values will not be accepted.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
width | The width of the gradient. |
height | The height of the gradient. |
direction | The direction of the gradient. |
numColors | The number of colors in the gradient. |
... | A variable list of RGB colors in the gradient as an integer. |
int Sprite_setBackgroundGradientAll | ( | CmdFX_Sprite * | sprite, |
enum CmdFX_GradientDirection | direction, | ||
int | numColors, | ||
... ) |
Sets a background gradient using RGB colors.
This method sets a background gradient using RGB colors between multiple colors. The gradient will be applied to the entire sprite. The direction of the gradient will be determined by the direction
parameter. The colors should be specified as RGB values in the format 0xRRGGBB
. Non-integer values will not be accepted.
sprite | The sprite to modify. |
direction | The direction of the gradient. |
numColors | The number of colors in the gradient. |
... | A variable list of RGB colors in the gradient as an integer. |
int Sprite_setChar | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
char | c ) |
Sets the character at the given position in the sprite.
This method sets the character at the given position in the sprite. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the character if the sprite is currently drawn.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
c | The character to set. |
int Sprite_setData | ( | CmdFX_Sprite * | sprite, |
char ** | data ) |
Sets the text data for the sprite.
This method sets the text data for the sprite. The text data should be a 2D array of characters. This will resize the width
and height
of the sprite to match the dimensions of the text data. If an error occurs, the method will return 0.
If the size is different than ansi
, the ansi
will be resized to match the new size. If the new size is larger, the new positions will be filled with NULL. If the new size is smaller, then ansi
will be cropped from the top-left.
sprite | The sprite to modify. |
data | The text data to set. |
int Sprite_setForeground | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
int | rgb ) |
Sets the foreground color of the sprite at the given position.
This method sets the foreground color of the sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
rgb | The RGB color to set. |
int Sprite_setForegroundAll | ( | CmdFX_Sprite * | sprite, |
int | rgb ) |
Sets the foreground color of the sprite at the given position.
This method sets the foreground color of the sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
rgb | The RGB color to set. |
int Sprite_setForegroundAll256 | ( | CmdFX_Sprite * | sprite, |
int | color ) |
Sets the foreground color of the sprite at the given position using 256-bit color codes.
This method sets the foreground color of the sprite at the given position. The position is specified by the X and Y coordinates, where (0, 0) is the top-left corner of the sprite. If the position is out of bounds, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to modify. |
color | The 256-color code to set. |
int Sprite_setForegroundGradient | ( | CmdFX_Sprite * | sprite, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
enum CmdFX_GradientDirection | direction, | ||
int | numColors, | ||
... ) |
Sets a foreground gradient using RGB colors for a specified section of the sprite.
This method sets a foreground gradient using RGB colors between multiple colors. The gradient will be applied to the sprite starting at the given position and extending for the given width and height. The direction of the gradient will be determined by the direction
parameter. The colors should be specified as RGB values in the format 0xRRGGBB
. Non-integer values will not be accepted.
sprite | The sprite to modify. |
x | The X position in the sprite. |
y | The Y position in the sprite. |
width | The width of the gradient. |
height | The height of the gradient. |
direction | The direction of the gradient. |
numColors | The number of colors in the gradient. |
... | A variable list of RGB colors in the gradient as an integer. |
int Sprite_setForegroundGradientAll | ( | CmdFX_Sprite * | sprite, |
enum CmdFX_GradientDirection | direction, | ||
int | numColors, | ||
... ) |
Sets a foreground gradient using RGB colors.
This method sets a foreground gradient using RGB colors between multiple colors. The gradient will be applied to the entire sprite. The direction of the gradient will be determined by the direction
parameter. The colors should be specified as RGB values in the format 0xRRGGBB
. Non-integer values will not be accepted.
sprite | The sprite to modify. |
direction | The direction of the gradient. |
numColors | The number of colors in the gradient. |
... | A variable list of RGB colors in the gradient as an integer. |
int Sprite_transpose | ( | CmdFX_Sprite * | sprite | ) |
Transposes the sprite.
This method transposes the sprite, swapping the rows and columns. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to transpose. |
int Sprite_vFlip | ( | CmdFX_Sprite * | sprite | ) |
Flips the sprite vertically.
This method flips the sprite vertically. If an error occurs, the method will return 0.
This method will also redraw the sprite if it is currently drawn.
sprite | The sprite to flip. |