61 lines
2.3 KiB
C
61 lines
2.3 KiB
C
/* Documento de animación: dimensiones, fps, capas y fotogramas.
|
|
* Modelo: las CAPAS son del documento; cada FOTOGRAMA tiene una "celda"
|
|
* (lienzo) por capa. Las celdas vacías no ocupan memoria. Los índices
|
|
* empiezan en 0; la capa 0 es la de más abajo.
|
|
* Propiedad: tgb_document_create devuelve un objeto que debes destruir
|
|
* con tgb_document_destroy ANTES de destruir el contexto. */
|
|
#ifndef TAHGIBU_DOCUMENT_H
|
|
#define TAHGIBU_DOCUMENT_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include "tahgibu/canvas.h"
|
|
#include "tahgibu/context.h"
|
|
#include "tahgibu/error.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TGB_MAX_FRAMES 5000
|
|
#define TGB_MAX_LAYERS 64
|
|
#define TGB_NAME_MAX 64 /* bytes, incluye el NUL; UTF-8 */
|
|
#define TGB_MIN_FPS 1
|
|
#define TGB_MAX_FPS 60
|
|
#define TGB_MIN_FRAME_MS 16
|
|
#define TGB_MAX_FRAME_MS 60000
|
|
|
|
/* Crea un documento con 1 capa ("Capa 1") y 1 fotograma vacío. */
|
|
tgb_status tgb_document_create(tgb_context *ctx, int width, int height, int fps,
|
|
tgb_document **out);
|
|
void tgb_document_destroy(tgb_document *doc); /* acepta NULL */
|
|
|
|
tgb_context *tgb_document_context(const tgb_document *doc);
|
|
int tgb_document_width(const tgb_document *doc);
|
|
int tgb_document_height(const tgb_document *doc);
|
|
int tgb_document_fps(const tgb_document *doc);
|
|
/* Cambia el fps por defecto (y, si apply_to_all, la duración de todos los
|
|
* fotogramas). Se puede deshacer. */
|
|
tgb_status tgb_document_set_fps(tgb_document *doc, int fps, bool apply_to_all);
|
|
|
|
/* Cada cambio incrementa la revisión. "Sucio" = revisión distinta de la guardada. */
|
|
uint64_t tgb_document_revision(const tgb_document *doc);
|
|
bool tgb_document_dirty(const tgb_document *doc);
|
|
void tgb_document_mark_saved(tgb_document *doc);
|
|
|
|
/* Ruta asociada (de la última carga/guardado). Puede ser NULL. */
|
|
const char *tgb_document_path(const tgb_document *doc);
|
|
tgb_status tgb_document_set_path(tgb_document *doc, const char *path);
|
|
|
|
/* false si una operación falló a medias y no se pudo restaurar el estado. */
|
|
bool tgb_document_is_consistent(const tgb_document *doc);
|
|
|
|
/* Campo desconocido conservado de un archivo .tgb (JSON crudo) o NULL. */
|
|
const char *tgb_document_extra_field(const tgb_document *doc, const char *key);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|