cmdfx 0.2.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
58
71
78void Canvas_setChar(int x, int y, char c);
79
89void Canvas_setAnsiCurrent(const char* ansi);
90
102void Canvas_setAnsi(int x, int y, const char* ansi);
103
104// Utility Functions - ANSI
105
117
125
133
141
150
159
167void Canvas_setColor8(int color);
168
177
186
193
203
212
224
233
242
249
256
265
272
281
288
299
306
317
324
325// Utility Functions - Shapes
326
334void Canvas_hLine(int x, int y, int width, char c);
335
343void Canvas_vLine(int x, int y, int height, char c);
344
353void Canvas_rect(int x, int y, int width, int height, char c);
354
363void Canvas_fillRect(int x, int y, int width, int height, char c);
364
372void Canvas_circle(int x, int y, int radius, char c);
373
381void Canvas_fillCircle(int x, int y, int radius, char c);
382
391void Canvas_ellipse(int x, int y, int xradius, int yradius, char c);
392
401void Canvas_fillEllipse(int x, int y, int xradius, int yradius, char c);
402
411void Canvas_line(int x1, int y1, int x2, int y2, char c);
412
425void Canvas_polygon(int x, int y, int sides, int radius, char c);
426
439void Canvas_fillPolygon(int x, int y, int sides, int radius, char c);
440
441// Utility Functions - Text
442
449void Canvas_drawText(int x, int y, char* text);
450
451#pragma region ASCII Art
452
456extern char ASCII_EMPTY[8][5];
457
461extern char ASCII_UPPER_A[8][5];
462
466extern char ASCII_LOWER_A[8][5];
467
471extern char ASCII_UPPER_B[8][5];
472
476extern char ASCII_LOWER_B[8][5];
477
481extern char ASCII_UPPER_C[8][5];
482
486extern char ASCII_LOWER_C[8][5];
487
491extern char ASCII_UPPER_D[8][5];
492
496extern char ASCII_LOWER_D[8][5];
497
501extern char ASCII_UPPER_E[8][5];
502
506extern char ASCII_LOWER_E[8][5];
507
511extern char ASCII_UPPER_F[8][5];
512
516extern char ASCII_LOWER_F[8][5];
517
521extern char ASCII_UPPER_G[8][5];
522
526extern char ASCII_LOWER_G[8][5];
527
531extern char ASCII_UPPER_H[8][5];
532
536extern char ASCII_LOWER_H[8][5];
537
541extern char ASCII_UPPER_I[8][5];
542
546extern char ASCII_LOWER_I[8][5];
547
551extern char ASCII_UPPER_J[8][5];
552
556extern char ASCII_LOWER_J[8][5];
557
561extern char ASCII_UPPER_K[8][5];
562
566extern char ASCII_LOWER_K[8][5];
567
571extern char ASCII_UPPER_L[8][5];
572
576extern char ASCII_LOWER_L[8][5];
577
581extern char ASCII_UPPER_M[8][5];
582
586extern char ASCII_LOWER_M[8][5];
587
591extern char ASCII_UPPER_N[8][5];
592
596extern char ASCII_LOWER_N[8][5];
597
601extern char ASCII_UPPER_O[8][5];
602
606extern char ASCII_LOWER_O[8][5];
607
611extern char ASCII_UPPER_P[8][5];
612
616extern char ASCII_LOWER_P[8][5];
617
621extern char ASCII_UPPER_Q[8][5];
622
626extern char ASCII_LOWER_Q[8][5];
627
631extern char ASCII_UPPER_R[8][5];
632
636extern char ASCII_LOWER_R[8][5];
637
641extern char ASCII_UPPER_S[8][5];
642
646extern char ASCII_LOWER_S[8][5];
647
651extern char ASCII_UPPER_T[8][5];
652
656extern char ASCII_LOWER_T[8][5];
657
661extern char ASCII_UPPER_U[8][5];
662
666extern char ASCII_LOWER_U[8][5];
667
671extern char ASCII_UPPER_V[8][5];
672
676extern char ASCII_LOWER_V[8][5];
677
681extern char ASCII_UPPER_W[8][5];
682
686extern char ASCII_LOWER_W[8][5];
687
691extern char ASCII_UPPER_X[8][5];
692
696extern char ASCII_LOWER_X[8][5];
697
701extern char ASCII_UPPER_Y[8][5];
702
706extern char ASCII_LOWER_Y[8][5];
707
711extern char ASCII_UPPER_Z[8][5];
712
716extern char ASCII_LOWER_Z[8][5];
717
721extern char ASCII_ZERO[8][5];
722
726extern char ASCII_ONE[8][5];
727
731extern char ASCII_TWO[8][5];
732
736extern char ASCII_THREE[8][5];
737
741extern char ASCII_FOUR[8][5];
742
746extern char ASCII_FIVE[8][5];
747
751extern char ASCII_SIX[8][5];
752
756extern char ASCII_SEVEN[8][5];
757
761extern char ASCII_EIGHT[8][5];
762
766extern char ASCII_NINE[8][5];
767
778extern char ASCII_MAP[128][8][5];
779
780#pragma endregion
781
788void Canvas_drawAscii(int x, int y, char ascii[8][5]);
789
801void Canvas_drawAsciiText(int x, int y, char character, const char* text);
802
803#ifdef __cplusplus
804}
805#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.
void Canvas_drawText(int x, int y, char *text)
Draws text at the current cursor position.
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.
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.
void Canvas_fillPolygon(int x, int y, int sides, int radius, char c)
Fills a polygon with a 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_polygon(int x, int y, int sides, int radius, char c)
Draws a polygon.
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.