cmdfx 0.1.0
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
canvas.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17// Core Functions
18
24
30
37
43void Canvas_setCursor(int x, int y);
44
56
68
75void Canvas_setChar(int x, int y, char c);
76
86void Canvas_setAnsiCurrent(const char* ansi);
87
99void Canvas_setAnsi(int x, int y, const char* ansi);
100
101// Utility Functions - ANSI
102
114
122
130
138
147
156
164void Canvas_setColor8(int color);
165
174
183
190
200
209
221
230
239
246
253
262
269
278
285
296
303
314
321
322// Utility Functions - Shapes
323
331void Canvas_hLine(int x, int y, int width, char c);
332
340void Canvas_vLine(int x, int y, int height, char c);
341
350void Canvas_rect(int x, int y, int width, int height, char c);
351
360void Canvas_fillRect(int x, int y, int width, int height, char c);
361
369void Canvas_circle(int x, int y, int radius, char c);
370
378void Canvas_fillCircle(int x, int y, int radius, char c);
379
388void Canvas_ellipse(int x, int y, int xradius, int yradius, char c);
389
398void Canvas_fillEllipse(int x, int y, int xradius, int yradius, char c);
399
408void Canvas_line(int x1, int y1, int x2, int y2, char c);
409
410// Utility Functions - Text
411
418void Canvas_drawText(int x, int y, const char* text);
419
420#pragma region ASCII Art
421
425extern char ASCII_EMPTY[8][5];
426
430extern char ASCII_UPPER_A[8][5];
431
435extern char ASCII_LOWER_A[8][5];
436
440extern char ASCII_UPPER_B[8][5];
441
445extern char ASCII_LOWER_B[8][5];
446
450extern char ASCII_UPPER_C[8][5];
451
455extern char ASCII_LOWER_C[8][5];
456
460extern char ASCII_UPPER_D[8][5];
461
465extern char ASCII_LOWER_D[8][5];
466
470extern char ASCII_UPPER_E[8][5];
471
475extern char ASCII_LOWER_E[8][5];
476
480extern char ASCII_UPPER_F[8][5];
481
485extern char ASCII_LOWER_F[8][5];
486
490extern char ASCII_UPPER_G[8][5];
491
495extern char ASCII_LOWER_G[8][5];
496
500extern char ASCII_UPPER_H[8][5];
501
505extern char ASCII_LOWER_H[8][5];
506
510extern char ASCII_UPPER_I[8][5];
511
515extern char ASCII_LOWER_I[8][5];
516
520extern char ASCII_UPPER_J[8][5];
521
525extern char ASCII_LOWER_J[8][5];
526
530extern char ASCII_UPPER_K[8][5];
531
535extern char ASCII_LOWER_K[8][5];
536
540extern char ASCII_UPPER_L[8][5];
541
545extern char ASCII_LOWER_L[8][5];
546
550extern char ASCII_UPPER_M[8][5];
551
555extern char ASCII_LOWER_M[8][5];
556
560extern char ASCII_UPPER_N[8][5];
561
565extern char ASCII_LOWER_N[8][5];
566
570extern char ASCII_UPPER_O[8][5];
571
575extern char ASCII_LOWER_O[8][5];
576
580extern char ASCII_UPPER_P[8][5];
581
585extern char ASCII_LOWER_P[8][5];
586
590extern char ASCII_UPPER_Q[8][5];
591
595extern char ASCII_LOWER_Q[8][5];
596
600extern char ASCII_UPPER_R[8][5];
601
605extern char ASCII_LOWER_R[8][5];
606
610extern char ASCII_UPPER_S[8][5];
611
615extern char ASCII_LOWER_S[8][5];
616
620extern char ASCII_UPPER_T[8][5];
621
625extern char ASCII_LOWER_T[8][5];
626
630extern char ASCII_UPPER_U[8][5];
631
635extern char ASCII_LOWER_U[8][5];
636
640extern char ASCII_UPPER_V[8][5];
641
645extern char ASCII_LOWER_V[8][5];
646
650extern char ASCII_UPPER_W[8][5];
651
655extern char ASCII_LOWER_W[8][5];
656
660extern char ASCII_UPPER_X[8][5];
661
665extern char ASCII_LOWER_X[8][5];
666
670extern char ASCII_UPPER_Y[8][5];
671
675extern char ASCII_LOWER_Y[8][5];
676
680extern char ASCII_UPPER_Z[8][5];
681
685extern char ASCII_LOWER_Z[8][5];
686
690extern char ASCII_ZERO[8][5];
691
695extern char ASCII_ONE[8][5];
696
700extern char ASCII_TWO[8][5];
701
705extern char ASCII_THREE[8][5];
706
710extern char ASCII_FOUR[8][5];
711
715extern char ASCII_FIVE[8][5];
716
720extern char ASCII_SIX[8][5];
721
725extern char ASCII_SEVEN[8][5];
726
730extern char ASCII_EIGHT[8][5];
731
735extern char ASCII_NINE[8][5];
736
747extern char ASCII_MAP[128][8][5];
748
749#pragma endregion
750
757void Canvas_drawAscii(int x, int y, char ascii[8][5]);
758
770void Canvas_drawAsciiText(int x, int y, char character, const char* text);
771
772#ifdef __cplusplus
773}
774#endif
char ASCII_UPPER_X[8][5]
An 'X' character in ASCII art using the '#' character.
void Canvas_disableUnderline()
Disables the underline text attribute.
void Canvas_enableStrikethrough()
Enables the strikethrough text attribute.
char ASCII_LOWER_D[8][5]
A 'd' character in ASCII art using the '#' character.
char ASCII_UPPER_R[8][5]
A 'R' character in ASCII art using the '#' character.
char ASCII_LOWER_Z[8][5]
A 'z' character in ASCII art using the '#' character.
char ASCII_LOWER_P[8][5]
A 'p' character in ASCII art using the '#' character.
char ASCII_UPPER_K[8][5]
A 'K' character in ASCII art using the '#' character.
void Canvas_enableBlink()
Enables the blink text attribute.
char ASCII_UPPER_Y[8][5]
A 'Y' character in ASCII art using the '#' character.
char ASCII_LOWER_M[8][5]
A 'm' character in ASCII art using the '#' character.
char ASCII_UPPER_Q[8][5]
A 'Q' character in ASCII art using the '#' character.
void Canvas_circle(int x, int y, int radius, char c)
Draws a hollow circle.
void Canvas_setColor8(int color)
Sets the color at the current cursor position using the built-in 8-bit color palette.
void Canvas_disableHidden()
Disables the hidden text attribute.
void Canvas_enableBold()
Enables the bold text attribute.
char ASCII_LOWER_S[8][5]
A 's' character in ASCII art using the '#' character.
void Canvas_ellipse(int x, int y, int xradius, int yradius, char c)
Draws a hollow ellipse.
char ASCII_UPPER_E[8][5]
An 'E' character in ASCII art using the '#' character.
char ASCII_LOWER_J[8][5]
A 'j' character in ASCII art using the '#' character.
char ASCII_LOWER_U[8][5]
A 'u' character in ASCII art using the '#' character.
void Canvas_disableStrikethrough()
Disables the strikethrough text attribute.
char ASCII_LOWER_T[8][5]
A 't' character in ASCII art using the '#' character.
void Canvas_fillRect(int x, int y, int width, int height, char c)
Fills a rectangle with a character.
void Canvas_setChar(int x, int y, char c)
Sets a character at a specific position.
char ASCII_LOWER_E[8][5]
An 'e' character in ASCII art using the '#' character.
char ASCII_UPPER_N[8][5]
A 'N' character in ASCII art using the '#' character.
void Canvas_rect(int x, int y, int width, int height, char c)
Draws a hollow rectangle.
void Canvas_setBackground(int rgb)
Sets the background color at the current cursor position.
char ASCII_LOWER_H[8][5]
A 'h' character in ASCII art using the '#' character.
void Canvas_enableItalic()
Enables the italic text attribute.
char ASCII_THREE[8][5]
A '3' character in ASCII art using the '#' character.
char ASCII_EMPTY[8][5]
Represents empty space in ASCII art.
void Canvas_setAnsiCurrent(const char *ansi)
Appends the ANSI code at the current cursor position.
char ASCII_LOWER_W[8][5]
A 'w' character in ASCII art using the '#' character.
void Canvas_hLine(int x, int y, int width, char c)
Draws a horizontal line.
void Canvas_setForeground256(int color)
Sets the foreground color at the current cursor position using the built-in 256-color palette.
char ASCII_LOWER_B[8][5]
A 'b' character in ASCII art using the '#' character.
void Canvas_setForeground(int rgb)
Sets the foreground color at the current cursor position.
char ASCII_LOWER_L[8][5]
A 'l' character in ASCII art using the '#' character.
char ASCII_NINE[8][5]
A '9' character in ASCII art using the '#' character.
void Canvas_drawAsciiText(int x, int y, char character, const char *text)
Draws text at a specific position.
char ASCII_LOWER_Y[8][5]
A 'y' character in ASCII art using the '#' character.
char ASCII_UPPER_P[8][5]
A 'P' character in ASCII art using the '#' character.
void Canvas_setBackground256(int color)
Sets the background color at the current cursor position using the built-in 256-color palette.
void Canvas_hideCursor()
Hides the cursor.
void Canvas_showCursor()
Shows the cursor.
void Canvas_enableInvert()
Enables the invert text attribute.
char ASCII_TWO[8][5]
A '2' character in ASCII art using the '#' character.
char ASCII_UPPER_B[8][5]
A 'B' character in ASCII art using the '#' character.
char ASCII_LOWER_V[8][5]
A 'v' character in ASCII art using the '#' character.
void Canvas_line(int x1, int y1, int x2, int y2, char c)
Draws a line between two points.
char ASCII_SEVEN[8][5]
A '7' character in ASCII art using the '#' character.
char ASCII_UPPER_A[8][5]
An 'A' character in ASCII art using the '#' character.
char ASCII_UPPER_J[8][5]
A 'J' character in ASCII art using the '#' character.
void Canvas_drawText(int x, int y, const char *text)
Draws text at the current cursor position.
int Canvas_getWidth()
Gets the width of the canvas, which is the width of the terminal.
int Canvas_isCursorVisible()
Gets the cursor visibility.
char ASCII_UPPER_L[8][5]
A 'L' character in ASCII art using the '#' character.
char ASCII_LOWER_C[8][5]
A 'c' character in ASCII art using the '#' character.
int Canvas_getCursorX()
Gets the cursor position.
char ASCII_UPPER_S[8][5]
A 'S' character in ASCII art using the '#' character.
char ASCII_UPPER_C[8][5]
A 'C' character in ASCII art using the '#' character.
char ASCII_FOUR[8][5]
A '4' character in ASCII art using the '#' character.
void Canvas_disableBlink()
Disables the blink text attribute.
char ASCII_UPPER_G[8][5]
A 'G' character in ASCII art using the '#' character.
char ASCII_UPPER_W[8][5]
A 'W' character in ASCII art using the '#' character.
char ASCII_UPPER_F[8][5]
A 'F' character in ASCII art using the '#' character.
char ASCII_UPPER_M[8][5]
A 'M' character in ASCII art using the '#' character.
void Canvas_resetFormat()
Resets all formatting at the current cursor position.
char ASCII_LOWER_R[8][5]
A 'r' character in ASCII art using the '#' character.
void Canvas_enableDim()
Enables the dim text attribute.
char ASCII_SIX[8][5]
A '6' character in ASCII art using the '#' character.
char ASCII_UPPER_U[8][5]
An 'U' character in ASCII art using the '#' character.
char ASCII_UPPER_Z[8][5]
A 'Z' character in ASCII art using the '#' character.
void Canvas_disableDim()
Disables the dim text attribute.
void Canvas_enableUnderline()
Enables the underline text attribute.
char ASCII_ZERO[8][5]
A '0' character in ASCII art using the '#' character.
void Canvas_disableBold()
Disables the bold text attribute.
char ASCII_UPPER_T[8][5]
A 'T' character in ASCII art using the '#' character.
void Canvas_setCursor(int x, int y)
Sets the cursor position.
void Canvas_clearScreen()
Clears the screen.
void Canvas_disableItalic()
Disables the italic text attribute.
void Canvas_fillEllipse(int x, int y, int xradius, int yradius, char c)
Fills an ellipse with a character.
char ASCII_UPPER_H[8][5]
A 'H' character in ASCII art using the '#' character.
char ASCII_FIVE[8][5]
A '5' character in ASCII art using the '#' character.
int Canvas_getCursorY()
Gets the cursor position.
char ASCII_UPPER_V[8][5]
A 'V' character in ASCII art using the '#' character.
char ASCII_LOWER_A[8][5]
An 'a' character in ASCII art using the '#' character.
void Canvas_fillCircle(int x, int y, int radius, char c)
Fills a circle with a character.
char ASCII_LOWER_G[8][5]
A 'g' character in ASCII art using the '#' character.
void Canvas_setAnsi(int x, int y, const char *ansi)
Appends the ANSI code at a specific position.
int Canvas_getHeight()
Gets the height of the canvas, which is the height of the terminal.
char ASCII_LOWER_K[8][5]
A 'k' character in ASCII art using the '#' character.
char ASCII_LOWER_N[8][5]
A 'n' character in ASCII art using the '#' character.
char ASCII_LOWER_X[8][5]
A 'x' character in ASCII art using the '#' character.
char ASCII_UPPER_D[8][5]
A 'D' character in ASCII art using the '#' character.
void Canvas_drawAscii(int x, int y, char ascii[8][5])
Draws an ASCII character at a specific position.
void Canvas_vLine(int x, int y, int height, char c)
Draws a vertical line.
void Canvas_enableHidden()
Enables the hidden text attribute.
char ASCII_EIGHT[8][5]
A '8' character in ASCII art using the '#' character.
char ASCII_LOWER_Q[8][5]
A 'q' character in ASCII art using the '#' character.
char ASCII_ONE[8][5]
A '1' character in ASCII art using the '#' character.
void Canvas_disableInvert()
Disables the invert text attribute.
char ASCII_LOWER_O[8][5]
An 'o' character in ASCII art using the '#' character.
char ASCII_MAP[128][8][5]
Represents a mapping of ASCII characters to their respective ASCII art.
char ASCII_UPPER_I[8][5]
An 'I' character in ASCII art using the '#' character.
char ASCII_UPPER_O[8][5]
An 'O' character in ASCII art using the '#' character.
char ASCII_LOWER_I[8][5]
An 'i' character in ASCII art using the '#' character.
char ASCII_LOWER_F[8][5]
A 'f' character in ASCII art using the '#' character.