#pragma once

#include "pxl8_gfx.h"
#include "pxl8_types.h"

typedef enum pxl8_transition_type {
    PXL8_TRANSITION_FADE,
    PXL8_TRANSITION_WIPE_LEFT,
    PXL8_TRANSITION_WIPE_RIGHT,
    PXL8_TRANSITION_WIPE_UP,
    PXL8_TRANSITION_WIPE_DOWN,
    PXL8_TRANSITION_CIRCLE_OPEN,
    PXL8_TRANSITION_CIRCLE_CLOSE,
    PXL8_TRANSITION_DISSOLVE,
    PXL8_TRANSITION_PIXELATE
} pxl8_transition_type;

typedef struct pxl8_transition {
    pxl8_transition_type type;
    f32 duration;
    f32 time;
    bool active;
    bool reverse;

    u32 color;

    void (*on_complete)(void* userdata);
    void* userdata;
} pxl8_transition;

#ifdef __cplusplus
extern "C" {
#endif

pxl8_transition* pxl8_transition_create(pxl8_transition_type type, f32 duration);
void pxl8_transition_destroy(pxl8_transition* transition);

f32 pxl8_transition_get_progress(const pxl8_transition* transition);
bool pxl8_transition_is_active(const pxl8_transition* transition);
bool pxl8_transition_is_complete(const pxl8_transition* transition);

void pxl8_transition_set_color(pxl8_transition* transition, u32 color);
void pxl8_transition_set_reverse(pxl8_transition* transition, bool reverse);

void pxl8_transition_render(const pxl8_transition* transition, pxl8_gfx* gfx);
void pxl8_transition_reset(pxl8_transition* transition);
void pxl8_transition_start(pxl8_transition* transition);
void pxl8_transition_stop(pxl8_transition* transition);
void pxl8_transition_update(pxl8_transition* transition, f32 dt);

#ifdef __cplusplus
}
#endif
