96 lines
2.7 KiB
C
96 lines
2.7 KiB
C
#ifndef TART_H
|
|
#define TART_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
// #========================================================================#
|
|
// | PreacherDHM:TART
|
|
// |
|
|
// | Tarts stands for Terminal Art. Tart is a terminal renderer that uses a |
|
|
// | render buffer like system that takes csprites or character sprites and |
|
|
// | displays them in the terminal. The render buffer consists of cells and |
|
|
// | each cell consists of
|
|
// | - Color
|
|
// | - Rendered Character
|
|
// | - Reset
|
|
// | In toaltol around 19 to 24 bytes. This alows for complete controle |
|
|
// | over each cell.
|
|
// #========================================================================#
|
|
|
|
#define NULL_CELL 0
|
|
|
|
typedef unsigned char tart_byte;
|
|
typedef unsigned short tart_id;
|
|
|
|
struct tart_vec2 {
|
|
unsigned short x,y;
|
|
};
|
|
|
|
struct tart_rgb {
|
|
tart_byte r,g,b;
|
|
};
|
|
|
|
/* Tart Cell
|
|
*
|
|
* This holds a rgb for the foreground and the background.
|
|
* Includeing the display character.
|
|
*
|
|
*/
|
|
|
|
struct tart_cell {
|
|
struct tart_rgb foreground;
|
|
struct tart_rgb background;
|
|
tart_byte style;
|
|
char display;
|
|
};
|
|
|
|
/* Tart Buffer
|
|
*
|
|
* The Buffer is a contner that holds all of the cells for that buffer.
|
|
* Allso containes the size of the buffer.
|
|
*
|
|
* ........................width...............
|
|
* ..........<-------------------------------->.
|
|
* ........^ @################################@.
|
|
* ........| #................................#.
|
|
* ........| #................................#.
|
|
* height--| #.............Buffer.............#.
|
|
* ........| #................................#.
|
|
* ........| #................................#.
|
|
* ........V @################################@.
|
|
*/
|
|
struct tart_buffer {
|
|
unsigned int cell_count;
|
|
tart_byte layer;
|
|
tart_id id;
|
|
struct tart_vec2 size;
|
|
struct tart_vec2 position;
|
|
struct tart_cell* cells;
|
|
};
|
|
|
|
/* Tart Window
|
|
*
|
|
* The tart window will have the window size and all of the buffers.
|
|
**/
|
|
struct tart_window {
|
|
struct tart_buffer buffers[0xFF+1];
|
|
tart_byte buffer_count;
|
|
struct tart_vec2 size;
|
|
};
|
|
|
|
struct tart_window tart_create_window();
|
|
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position);
|
|
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background);
|
|
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
|
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
|
|
|
struct tart_buffer* tart_get_buffer(struct tart_window*, tart_byte);
|
|
|
|
struct tart_cell* tart_get_cell(struct tart_buffer*, int);
|
|
struct tart_cell tart_set_cell(struct tart_buffer*, struct tart_cell,int);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|