V2.0.0
This commit is contained in:
1 parent
7f7fcd545d
commit
4d9a339421
114 files changed
+11383
-1837
No files matched your search
@@ -0,0 +1,62 @@
|
||||
/* Lienzo de píxeles RGBA de 8 bits (NO premultiplicado), sin dependencias
|
||||
* de raylib ni del sistema operativo.
|
||||
* Propiedad: tgb_canvas_create/clone devuelven un objeto con 1 referencia;
|
||||
* quien lo recibe debe llamar a tgb_canvas_release una vez. */
|
||||
#ifndef TAHGIBU_CANVAS_H
|
||||
#define TAHGIBU_CANVAS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "tahgibu/error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TGB_MAX_DIMENSION 4096 /* ancho/alto máximos de un lienzo */
|
||||
|
||||
typedef struct tgb_color { uint8_t r, g, b, a; } tgb_color;
|
||||
typedef struct tgb_rect { int x, y, w, h; } tgb_rect;
|
||||
|
||||
typedef struct tgb_canvas tgb_canvas;
|
||||
|
||||
tgb_canvas *tgb_canvas_create(int width, int height); /* transparente; NULL si falla */
|
||||
tgb_canvas *tgb_canvas_clone(const tgb_canvas *src); /* copia profunda */
|
||||
tgb_canvas *tgb_canvas_retain(tgb_canvas *c); /* +1 referencia */
|
||||
void tgb_canvas_release(tgb_canvas *c); /* -1; libera al llegar a 0; acepta NULL */
|
||||
int tgb_canvas_refs(const tgb_canvas *c);
|
||||
|
||||
int tgb_canvas_width(const tgb_canvas *c);
|
||||
int tgb_canvas_height(const tgb_canvas *c);
|
||||
size_t tgb_canvas_bytes(const tgb_canvas *c);
|
||||
/* Lectura directa (filas contiguas, 4 bytes por píxel: R,G,B,A). */
|
||||
const uint8_t *tgb_canvas_pixels(const tgb_canvas *c);
|
||||
|
||||
tgb_color tgb_canvas_get(const tgb_canvas *c, int x, int y); /* transparente fuera del lienzo */
|
||||
void tgb_canvas_set(tgb_canvas *c, int x, int y, tgb_color col); /* reemplaza */
|
||||
void tgb_canvas_blend(tgb_canvas *c, int x, int y, tgb_color col); /* "source-over" */
|
||||
void tgb_canvas_erase_px(tgb_canvas *c, int x, int y, uint8_t amount);/* resta opacidad */
|
||||
|
||||
void tgb_canvas_clear(tgb_canvas *c);
|
||||
void tgb_canvas_fill_rect(tgb_canvas *c, tgb_rect r, tgb_color col, bool blend);
|
||||
/* Copia src sobre dst en (dx,dy). opacity 0..255. blend=false reemplaza. */
|
||||
void tgb_canvas_blit(tgb_canvas *dst, const tgb_canvas *src, int dx, int dy,
|
||||
uint8_t opacity, bool blend);
|
||||
tgb_status tgb_canvas_crop(const tgb_canvas *src, tgb_rect r, tgb_canvas **out);
|
||||
bool tgb_canvas_is_empty(const tgb_canvas *c); /* todo alfa = 0 */
|
||||
bool tgb_canvas_equal(const tgb_canvas *a, const tgb_canvas *b);
|
||||
tgb_status tgb_canvas_copy_pixels(tgb_canvas *dst, const tgb_canvas *src); /* mismas dimensiones */
|
||||
|
||||
/* Seguimiento de la zona modificada (lo usan las sesiones de edición). */
|
||||
tgb_rect tgb_canvas_dirty(const tgb_canvas *c); /* w==0 si no hay cambios */
|
||||
void tgb_canvas_reset_dirty(tgb_canvas *c);
|
||||
void tgb_canvas_mark_dirty(tgb_canvas *c, tgb_rect r);
|
||||
|
||||
tgb_rect tgb_rect_intersect(tgb_rect a, tgb_rect b);
|
||||
tgb_rect tgb_rect_union(tgb_rect a, tgb_rect b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user