80 virtual bool getElemOffset(uint32_t elemId, int16_t* ox, int16_t* oy) = 0;
81 virtual bool setElemOffset(uint32_t elemId, int16_t ox, int16_t oy) = 0;
134 uint32_t
blink(uint32_t elemId, uint16_t periodMs, uint16_t count,
135 uint32_t doneActionId, uint32_t nowMs);
138 bool cancel(uint32_t handle);
141 bool pause(uint32_t handle,
bool paused, uint32_t nowMs);
143 int8_t
state(uint32_t handle)
const;
160 Completion* done, uint8_t doneCap, uint8_t* doneCount);
163 enum class Kind : uint8_t { Move, Blink };
164 enum class Phase : uint8_t { Free, Chained, Delayed, Running };
169 uint32_t doneActionId = 0;
170 uint32_t startAfter = 0;
171 uint32_t startMs = 0;
172 int16_t fromX = 0, fromY = 0, toX = 0, toY = 0;
173 uint16_t durationMs = 0;
174 uint16_t delayMs = 0;
175 uint16_t remaining = 0;
176 uint16_t blinkCount = 0;
177 uint32_t pausedAtMs = 0;
180 int16_t lastX = 0, lastY = 0;
181 Kind kind = Kind::Move;
182 Phase phase = Phase::Free;
184 bool reversed =
false;
185 bool started =
false;
186 bool hasLast =
false;
190 Slot* findSlot(uint32_t handle);
191 const Slot* findSlot(uint32_t handle)
const;
193 void releaseChain(uint32_t handle);
194 void finishSlot(Slot& s, AnimTarget& target, uint32_t nowMs,
195 Completion* done, uint8_t doneCap, uint8_t* doneCount);
196 bool advanceMove(Slot& s, uint32_t nowMs, AnimTarget& target);
197 bool advanceBlink(Slot& s, uint32_t nowMs, AnimTarget& target);
198 bool writeOffset(Slot& s, AnimTarget& target, int16_t x, int16_t y);
201 uint32_t nextHandle_ = 1;
218 void setArena(uint8_t* buf, uint32_t cap);
219 bool hasArena()
const {
return arena_ !=
nullptr; }
225 int32_t
create(uint16_t w, uint16_t h, uint16_t frameCount,
226 const uint8_t* data, uint32_t len);
228 bool setMask(uint32_t handle,
const uint8_t* mask, uint32_t len);
238 int32_t
frame(uint32_t handle)
const;
247 bool scroll(uint32_t handle, uint16_t windowW, uint16_t stepPx,
248 uint16_t gapPx, uint16_t frameMs, uint32_t nowMs);
250 bool play(uint32_t handle, uint8_t mode, uint16_t frameMs, uint16_t repeat,
251 uint32_t doneActionId, uint32_t nowMs);
252 bool stop(uint32_t handle);
270 uint16_t
w = 0,
h = 0;
282 uint32_t sheetOff = 0;
283 uint32_t maskOff = 0;
286 uint32_t doneActionId = 0;
287 uint32_t nextFrameAt = 0;
288 uint16_t w = 0, h = 0;
289 uint16_t frameCount = 0;
290 uint16_t curFrame = 0;
291 uint16_t frameMs = 0;
292 uint16_t remaining = 0;
293 uint16_t scrollX = 0;
294 uint16_t scrollWindow = 0;
295 uint16_t scrollStep = 0;
296 uint16_t scrollGap = 0;
300 bool playing =
false;
301 bool hasMask =
false;
306 Slot* findSlot(uint32_t handle);
307 const Slot* findSlot(uint32_t handle)
const;
308 uint32_t frameBytes(
const Slot& s)
const;
309 uint16_t frameDuration(
const Slot& s)
const;
310 int32_t arenaAlloc(uint32_t bytes);
311 void arenaFree(uint32_t off, uint32_t bytes);
314 uint8_t* arena_ =
nullptr;
315 uint32_t arenaCap_ = 0;
316 uint32_t arenaUsed_ = 0;
317 uint32_t nextHandle_ = 1;
Interface the animator drives; implemented by CanvasView on its elements.
virtual bool setElemVisible(uint32_t elemId, bool visible)=0
virtual ~AnimTarget()=default
virtual bool getElemOffset(uint32_t elemId, int16_t *ox, int16_t *oy)=0
virtual bool setElemOffset(uint32_t elemId, int16_t ox, int16_t oy)=0
Fixed-slot tween engine animating element offsets (plus a blink convenience that toggles visibility).
uint8_t activeCount() const
Number of live slots (delayed, chained, running or paused).
bool pause(uint32_t handle, bool paused, uint32_t nowMs)
static constexpr uint8_t MAX_TWEENS
void reset()
Drop all slots without firing completions (teardown).
bool advance(uint32_t nowMs, AnimTarget &target, Completion *done, uint8_t doneCap, uint8_t *doneCount)
Advance all tweens to nowMs, applying offsets/visibility.
void cancelForElem(uint32_t elemId)
Silently cancel every tween bound to an element (element was removed).
uint32_t start(const TweenConfig &cfg, uint32_t nowMs)
Start an offset tween. A FROM_CURRENT start captures the live offset lazily on the first advance() af...
void shiftTime(uint32_t deltaMs)
Shift every time base forward (view was paused for deltaMs).
int8_t state(uint32_t handle) const
uint32_t blink(uint32_t elemId, uint16_t periodMs, uint16_t count, uint32_t doneActionId, uint32_t nowMs)
Start a visibility blink: count on/off cycles of periodMs per phase, ending visible....
bool cancel(uint32_t handle)
Cancel a tween and its chain (handle 0 = all). No completion fires.
static constexpr uint16_t MAX_DURATION_MS
Fixed-slot store for multi-frame 1-bpp sprites with host-driven playback. Pixel data lives in an inje...
static constexpr uint16_t MAX_FRAMES
bool stop(uint32_t handle)
bool destroy(uint32_t handle)
bool setMask(uint32_t handle, const uint8_t *mask, uint32_t len)
Attach a mask plane (same sheet layout/size as the frame data).
bool advance(uint32_t nowMs, Completion *done, uint8_t doneCap, uint8_t *doneCount)
bool setFlags(uint32_t handle, uint8_t flags)
int32_t create(uint16_t w, uint16_t h, uint16_t frameCount, const uint8_t *data, uint32_t len)
Copy a frame sheet into the arena and allocate a sprite slot.
void setArena(uint8_t *buf, uint32_t cap)
Inject the pixel arena. Must happen before create(); resets the store.
bool play(uint32_t handle, uint8_t mode, uint16_t frameMs, uint16_t repeat, uint32_t doneActionId, uint32_t nowMs)
int32_t frame(uint32_t handle) const
Current frame or -1.
bool frameView(uint32_t handle, FrameView *out) const
bool scroll(uint32_t handle, uint16_t windowW, uint16_t stepPx, uint16_t gapPx, uint16_t frameMs, uint32_t nowMs)
Turn the sprite into a horizontal scroller (marquee backing).
static constexpr uint8_t MAX_SPRITES
void shiftTime(uint32_t deltaMs)
bool setFrame(uint32_t handle, uint16_t frame)
bool setFrameDurations(uint32_t handle, const uint16_t *ms, uint16_t count)
bool setScale(uint32_t handle, uint8_t scale)
Integer upscale factor 1..4 applied when the sprite is drawn.
@ FLAG_SHOW_START
Show the element when the delay elapses.
@ FLAG_HIDE_DONE
Hide the element on completion.
@ FLAG_YOYO
Each repeat run alternates direction.
@ FLAG_FROM_CURRENT
Ignore from_x/y, start at the live offset.
constexpr uint16_t REPEAT_FOREVER
Repeat-forever sentinel shared by tweens and sprite playback.
@ SPRITE_ONCE
Play to the last frame and hold it.
@ SPRITE_FLAG_ROT_90
Rotate 90 deg clockwise (before flips).
@ SPRITE_FLAG_OPAQUE
Unset data bits paint white.
int32_t ease(uint8_t curve, int32_t t)
Apply an easing curve to a normalized 8.8 fixed-point time.
uint32_t refId
Element id (tween) or final frame (sprite).
uint32_t handle
Tween handle or sprite handle.
Replay accessors: geometry, flags and pixel pointers of a sprite.
const uint8_t * data
Current frame pixels.
const uint8_t * mask
Mask plane or null.
uint16_t scrollGap
Blank gap between wraps.
uint16_t scrollWindow
Window width; 0 = not scrolling.
uint16_t scrollX
Scroll position (scrollWindow > 0).
Tween start configuration (mirrors host_anim_t plus the blink shorthand).
uint16_t repeat
Extra runs; REPEAT_FOREVER = endless.
uint32_t startAfter
Predecessor tween handle; 0 = start now.