cmdfx 0.3.1
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
31
38
44void Canvas_setCursor(int x, int y);
45
60
74
81void Canvas_setChar(int x, int y, char c);
82
93void Canvas_setAnsiCurrent(const char* ansi);
94
107void Canvas_setAnsi(int x, int y, const char* ansi);
108
109// Utility Functions - ANSI
110
122
131
140
148
157
166
174void Canvas_setColor8(int color);
175
185
195
202
212
221
233
242
251
258
265
274
281
290
297
308
315
327
334
335// Utility Functions - Shapes
336
344void Canvas_hLine(int x, int y, int width, char c);
345
353void Canvas_vLine(int x, int y, int height, char c);
354
363void Canvas_rect(int x, int y, int width, int height, char c);
364
373void Canvas_fillRect(int x, int y, int width, int height, char c);
374
382void Canvas_circle(int x, int y, int radius, char c);
383
391void Canvas_fillCircle(int x, int y, int radius, char c);
392
401void Canvas_ellipse(int x, int y, int xradius, int yradius, char c);
402
411void Canvas_fillEllipse(int x, int y, int xradius, int yradius, char c);
412
421void Canvas_line(int x1, int y1, int x2, int y2, char c);
422
435void Canvas_polygon(int x, int y, int sides, int radius, char c);
436
449void Canvas_fillPolygon(int x, int y, int sides, int radius, char c);
450
466void Canvas_quad(int x, int y, int x1, int y1, int x2, int y2, char c);
467
486 int x, int y, int x1, int y1, int x2, int y2, int x3, int y3, char c
487);
488
509 int x, int y, int rx, int ry, double xrot, int arcflag, int sweepflag,
510 int dx, int dy, char c
511);
512
513// Utility Functions - Text
514
521void Canvas_drawText(int x, int y, char* text);
522
523#pragma region ASCII Art
524
528extern char ASCII_EMPTY[8][5];
529
533extern char ASCII_UPPER_A[8][5];
534
538extern char ASCII_LOWER_A[8][5];
539
543extern char ASCII_UPPER_B[8][5];
544
548extern char ASCII_LOWER_B[8][5];
549
553extern char ASCII_UPPER_C[8][5];
554
558extern char ASCII_LOWER_C[8][5];
559
563extern char ASCII_UPPER_D[8][5];
564
568extern char ASCII_LOWER_D[8][5];
569
573extern char ASCII_UPPER_E[8][5];
574
578extern char ASCII_LOWER_E[8][5];
579
583extern char ASCII_UPPER_F[8][5];
584
588extern char ASCII_LOWER_F[8][5];
589
593extern char ASCII_UPPER_G[8][5];
594
598extern char ASCII_LOWER_G[8][5];
599
603extern char ASCII_UPPER_H[8][5];
604
608extern char ASCII_LOWER_H[8][5];
609
613extern char ASCII_UPPER_I[8][5];
614
618extern char ASCII_LOWER_I[8][5];
619
623extern char ASCII_UPPER_J[8][5];
624
628extern char ASCII_LOWER_J[8][5];
629
633extern char ASCII_UPPER_K[8][5];
634
638extern char ASCII_LOWER_K[8][5];
639
643extern char ASCII_UPPER_L[8][5];
644
648extern char ASCII_LOWER_L[8][5];
649
653extern char ASCII_UPPER_M[8][5];
654
658extern char ASCII_LOWER_M[8][5];
659
663extern char ASCII_UPPER_N[8][5];
664
668extern char ASCII_LOWER_N[8][5];
669
673extern char ASCII_UPPER_O[8][5];
674
678extern char ASCII_LOWER_O[8][5];
679
683extern char ASCII_UPPER_P[8][5];
684
688extern char ASCII_LOWER_P[8][5];
689
693extern char ASCII_UPPER_Q[8][5];
694
698extern char ASCII_LOWER_Q[8][5];
699
703extern char ASCII_UPPER_R[8][5];
704
708extern char ASCII_LOWER_R[8][5];
709
713extern char ASCII_UPPER_S[8][5];
714
718extern char ASCII_LOWER_S[8][5];
719
723extern char ASCII_UPPER_T[8][5];
724
728extern char ASCII_LOWER_T[8][5];
729
733extern char ASCII_UPPER_U[8][5];
734
738extern char ASCII_LOWER_U[8][5];
739
743extern char ASCII_UPPER_V[8][5];
744
748extern char ASCII_LOWER_V[8][5];
749
753extern char ASCII_UPPER_W[8][5];
754
758extern char ASCII_LOWER_W[8][5];
759
763extern char ASCII_UPPER_X[8][5];
764
768extern char ASCII_LOWER_X[8][5];
769
773extern char ASCII_UPPER_Y[8][5];
774
778extern char ASCII_LOWER_Y[8][5];
779
783extern char ASCII_UPPER_Z[8][5];
784
788extern char ASCII_LOWER_Z[8][5];
789
793extern char ASCII_ZERO[8][5];
794
798extern char ASCII_ONE[8][5];
799
803extern char ASCII_TWO[8][5];
804
808extern char ASCII_THREE[8][5];
809
813extern char ASCII_FOUR[8][5];
814
818extern char ASCII_FIVE[8][5];
819
823extern char ASCII_SIX[8][5];
824
828extern char ASCII_SEVEN[8][5];
829
833extern char ASCII_EIGHT[8][5];
834
838extern char ASCII_NINE[8][5];
839
853extern char ASCII_MAP[128][8][5];
854
855#pragma endregion
856
863void Canvas_drawAscii(int x, int y, char ascii[8][5]);
864
877void Canvas_drawAsciiText(int x, int y, char character, const char* text);
878
879#ifdef __cplusplus
880}
881#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_cubic(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3, char c)
Draws a cubic Bezier curve.
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_quad(int x, int y, int x1, int y1, int x2, int y2, char c)
Draws a quadratic Bezier curve.
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.
void Canvas_arc(int x, int y, int rx, int ry, double xrot, int arcflag, int sweepflag, int dx, int dy, char c)
Draws an elliptical arc.
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.