working on 250 color palet for cell
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#ifndef TART_H
|
||||
#define TART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../source/term.h"
|
||||
// #========================================================================#
|
||||
// | PreacherDHM:TART
|
||||
@@ -18,7 +20,55 @@ extern "C" {
|
||||
// | over each cell.
|
||||
// #========================================================================#
|
||||
|
||||
#define NULL_CELL 0
|
||||
#define NULL_CELL (struct tart_cell){0,0,0,0,0}
|
||||
#define TART_OK 0
|
||||
|
||||
|
||||
#define TART_STYLE_BOLD 1
|
||||
#define TART_STYLE_DIM 2
|
||||
#define TART_STYLE_UNDERLINE 4
|
||||
#define TART_STYLE_BLINKING 5
|
||||
#define TART_STYLE_INVERSE 7
|
||||
#define TART_STYLE_HIDDEN 8
|
||||
#define TART_STYLE_STRIKETHROUGH 9
|
||||
|
||||
#define TART_COLOR_BLACK_FOREGROUND 30
|
||||
#define TART_COLOR_RED_FOREGROUND 31
|
||||
#define TART_COLOR_GREEN_FOREGROUND 32
|
||||
#define TART_COLOR_YELLOW_FOREGROUND 33
|
||||
#define TART_COLOR_BLUE_FOREGROUND 34
|
||||
#define TART_COLOR_MAGENTA_FOREGROUND 35
|
||||
#define TART_COLOR_CYAN_FOREGROUND 36
|
||||
#define TART_COLOR_WHITE_FOREGROUND 37
|
||||
#define TART_COLOR_DEFAULT_FOREGROUND 39
|
||||
|
||||
#define TART_COLOR_BLACK_BACKGROUND 40
|
||||
#define TART_COLOR_RED_BACKGROUND 41
|
||||
#define TART_COLOR_GREEN_BACKGROUND 42
|
||||
#define TART_COLOR_YELLOW_BACKGROUND 43
|
||||
#define TART_COLOR_BLUE_BACKGROUND 44
|
||||
#define TART_COLOR_MAGENTA_BACKGROUND 55
|
||||
#define TART_COLOR_CYAN_BACKGROUND 46
|
||||
#define TART_COLOR_WHITE_BACKGROUND 47
|
||||
#define TART_COLOR_DEFAULT_BACKGROUND 49
|
||||
|
||||
#define TART_COLOR_BRIGHT_BLACK_FOREGROUND 90
|
||||
#define TART_COLOR_BRIGHT_RED_FOREGROUND 91
|
||||
#define TART_COLOR_BRIGHT_GREEN_FOREGROUND 92
|
||||
#define TART_COLOR_BRIGHT_YELLOW_FOREGROUND 93
|
||||
#define TART_COLOR_BRIGHT_BLUE_FOREGROUND 94
|
||||
#define TART_COLOR_BRIGHT_MAGENTA_FOREGROUND 95
|
||||
#define TART_COLOR_BRIGHT_CYAN_FOREGROUND 96
|
||||
#define TART_COLOR_BRIGHT_WHITE_FOREGROUND 97
|
||||
|
||||
#define TART_COLOR_BRIGHT_BLACK_BACKGROUND 100
|
||||
#define TART_COLOR_BRIGHT_RED_BACKGROUND 101
|
||||
#define TART_COLOR_BRIGHT_GREEN_BACKGROUND 102
|
||||
#define TART_COLOR_BRIGHT_YELLOW_BACKGROUND 103
|
||||
#define TART_COLOR_BRIGHT_BLUE_BACKGROUND 104
|
||||
#define TART_COLOR_BRIGHT_MAGENTA_BACKGROUND 105
|
||||
#define TART_COLOR_BRIGHT_CYAN_BACKGROUND 106
|
||||
#define TART_COLOR_BRIGHT_WHITE_BACKGROUND 107
|
||||
|
||||
typedef unsigned char tart_byte;
|
||||
typedef unsigned short tart_id;
|
||||
@@ -37,13 +87,23 @@ struct tart_rgb {
|
||||
* Includeing the display character.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef TART_RGB_COLORS
|
||||
struct tart_cell {
|
||||
struct tart_rgb foreground;
|
||||
struct tart_rgb background;
|
||||
tart_byte style;
|
||||
char display;
|
||||
char* compiled;
|
||||
};
|
||||
#else
|
||||
struct tart_cell {
|
||||
tart_byte foreground;
|
||||
tart_byte background;
|
||||
tart_byte style;
|
||||
char display;
|
||||
char* compiled;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Tart Buffer
|
||||
*
|
||||
@@ -81,7 +141,13 @@ struct tart_window {
|
||||
|
||||
struct tart_window tart_create_window();
|
||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position);
|
||||
|
||||
#ifdef TART_RGB_COLORS
|
||||
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background);
|
||||
#else
|
||||
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background);
|
||||
#endif
|
||||
|
||||
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
||||
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "../includes/tart.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include "term.h"
|
||||
|
||||
struct tart_cell tart_test() {
|
||||
@@ -18,18 +20,28 @@ struct tart_window tart_create_window() {
|
||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
||||
unsigned int cell_count = position.x * position.y;
|
||||
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
|
||||
struct tart_cell cell = {.foreground = {0,0,0}, .background = {10,0,0}, .style = 0x0, .display = 0x0};
|
||||
memset(&cells,0, size.x * size.y);
|
||||
struct tart_cell cell = NULL_CELL;
|
||||
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
|
||||
return buf;
|
||||
}
|
||||
#ifdef TART_RGB_COLORS
|
||||
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background) {
|
||||
struct tart_cell b = {foreground, background, style, display};
|
||||
return b;
|
||||
}
|
||||
#else
|
||||
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background) {
|
||||
return (struct tart_cell){foreground,background,style,display,0};
|
||||
}
|
||||
#endif
|
||||
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
||||
window->buffers[window->buffer_count] = buffer;
|
||||
window->buffer_count++;
|
||||
return window->buffer_count;
|
||||
if(window->buffer_count <= 0xFF) {
|
||||
window->buffers[window->buffer_count] = buffer;
|
||||
window->buffer_count++;
|
||||
return window->buffer_count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
tart_byte tart_set_buffer(struct tart_window* window, struct tart_buffer buffer, tart_byte layer) {
|
||||
if(layer <= 0xFF) {
|
||||
@@ -52,3 +64,25 @@ struct tart_cell tart_set_cell(struct tart_buffer* buffer, struct tart_cell cell
|
||||
buffer->cells[idx] = cell;
|
||||
return c;
|
||||
}
|
||||
|
||||
int render_cell(struct tart_cell* cell, char* cell_buffer, unsigned char buffer_size) {
|
||||
unsigned char cell_size = 10;
|
||||
|
||||
#ifdef TART_RGB_PALET
|
||||
|
||||
sprintf(cell_buffer, "\x1b[%i;%i;%im%c\x1b[0m",cell->style, cell->foreground.r, cell->background.r, cell->display);
|
||||
|
||||
#endif
|
||||
return TART_OK;
|
||||
}
|
||||
int tart_render(struct tart_buffer* buffer) {
|
||||
for(int i = 0; i < buffer->cell_count; i++) {
|
||||
for(int y = 0; y < buffer->size.x; y++) {
|
||||
for(int x = 0; x < buffer->size.x; x++) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ void tart_run(struct pickle_shelf* shelf) {
|
||||
|
||||
|
||||
PICKLE(Test_create_cell) {
|
||||
|
||||
tart_byte f = 20;
|
||||
tart_byte b = 40;
|
||||
struct tart_cell cell_correct = {f, b, '1', 'f'};
|
||||
struct tart_cell cell_test = tart_create_cell('f', '1', f, b);
|
||||
#ifdef TART_RGB_COLOR
|
||||
struct tart_rgb b = {80,80,80};
|
||||
struct tart_rgb f = {80,80,80};
|
||||
struct tart_cell cell_correct = {f, b, '1', 'f'};
|
||||
@@ -48,6 +54,12 @@ void tart_run(struct pickle_shelf* shelf) {
|
||||
ASSERT("Forground dose not match.",false);
|
||||
if(!rgb_test(&cell_correct.background, &cell_test.background))
|
||||
ASSERT("background dose not match.",false);
|
||||
#else
|
||||
if(DIFFERENT(&cell_correct.foreground, &cell_test.foreground))
|
||||
ASSERT("Forground dose not match.",false);
|
||||
if(DIFFERENT(&cell_correct.background, &cell_test.background))
|
||||
ASSERT("background dose not match.",false);
|
||||
#endif
|
||||
if(DIFFERENT(cell_correct.style, cell_test.style))
|
||||
ASSERT("style dose not match.",false);
|
||||
if(DIFFERENT(cell_correct.display, cell_test.display))
|
||||
|
||||
Reference in New Issue
Block a user