60 lines
2.4 KiB
C
60 lines
2.4 KiB
C
/* Composición, Onion Skin y reproducción. */
|
|
#ifndef TAHGIBU_ANIMATION_H
|
|
#define TAHGIBU_ANIMATION_H
|
|
|
|
#include "tahgibu/document.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct tgb_onion_settings {
|
|
bool enabled;
|
|
int frames_before; /* 0..8 */
|
|
int frames_after; /* 0..8 */
|
|
float opacity_before; /* 0..1 opacidad del fotograma más cercano */
|
|
float opacity_after;
|
|
float falloff; /* 0..1: cuánto se atenúa cada fotograma más lejano */
|
|
bool tint; /* teñir anteriores/posteriores */
|
|
tgb_color tint_before; /* por defecto rojizo */
|
|
tgb_color tint_after; /* por defecto azulado */
|
|
} tgb_onion_settings;
|
|
|
|
void tgb_onion_defaults(tgb_onion_settings *s);
|
|
tgb_status tgb_onion_validate(tgb_onion_settings *s); /* recorta a rangos válidos */
|
|
|
|
/* Aplana las capas visibles (con su opacidad) del fotograma en 'out'
|
|
* (mismas dimensiones que el documento; se sobrescribe). */
|
|
tgb_status tgb_render_flatten(const tgb_document *doc, size_t frame_index, tgb_canvas *out);
|
|
|
|
/* Vista de edición: fondo + Onion Skin + fotograma actual.
|
|
* background.a == 0 deja el fondo transparente. */
|
|
tgb_status tgb_render_view(const tgb_document *doc, size_t frame_index,
|
|
const tgb_onion_settings *onion, tgb_color background,
|
|
tgb_canvas *out);
|
|
|
|
typedef enum tgb_play_mode { TGB_PLAY_ONCE = 0, TGB_PLAY_LOOP, TGB_PLAY_PINGPONG } tgb_play_mode;
|
|
|
|
/* Reproductor: lógica pura de tiempo, respeta la duración de cada fotograma.
|
|
* El documento debe sobrevivir al reproductor. */
|
|
typedef struct tgb_player tgb_player;
|
|
tgb_player *tgb_player_create(const tgb_document *doc);
|
|
void tgb_player_destroy(tgb_player *p);
|
|
void tgb_player_play(tgb_player *p);
|
|
void tgb_player_pause(tgb_player *p);
|
|
void tgb_player_stop(tgb_player *p); /* pausa y vuelve al inicio del rango */
|
|
bool tgb_player_is_playing(const tgb_player *p);
|
|
void tgb_player_set_mode(tgb_player *p, tgb_play_mode mode);
|
|
void tgb_player_set_speed(tgb_player *p, float speed); /* 0.1 .. 8 */
|
|
tgb_status tgb_player_set_range(tgb_player *p, size_t first, size_t last);
|
|
void tgb_player_clear_range(tgb_player *p);
|
|
tgb_status tgb_player_seek(tgb_player *p, size_t frame_index);
|
|
size_t tgb_player_frame(const tgb_player *p);
|
|
/* Avanza dt_ms milisegundos; devuelve el fotograma actual. */
|
|
size_t tgb_player_update(tgb_player *p, double dt_ms);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|