@almadar/ui 5.49.1 → 5.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @packageDocumentation
9
9
  */
10
- import type { AnimationName, FacingDirection, SpriteDirection, ResolvedFrame, UnitAnimationState, SpriteFrameDims, SpriteSheetUrls } from '../types/spriteAnimation';
10
+ import type { AnimationDef, AnimationName, FacingDirection, SpriteDirection, ResolvedFrame, UnitAnimationState, SpriteFrameDims, SpriteSheetUrls } from '../types/spriteAnimation';
11
11
  /**
12
12
  * Infer facing direction from a movement delta on the isometric grid.
13
13
  * dx/dy are tile coordinate deltas (not screen pixels).
@@ -29,6 +29,34 @@ export declare function resolveSheetDirection(facing: FacingDirection): {
29
29
  sheetDir: SpriteDirection;
30
30
  flipX: boolean;
31
31
  };
32
+ /** A source rectangle into a sprite sheet for a single frame. */
33
+ export interface FrameRect {
34
+ /** Source X in the sheet (pixel offset). */
35
+ sx: number;
36
+ /** Source Y in the sheet (pixel offset). */
37
+ sy: number;
38
+ /** Source width (frame width). */
39
+ sw: number;
40
+ /** Source height (frame height). */
41
+ sh: number;
42
+ }
43
+ /**
44
+ * Compute the source rect for a single frame within a grid sprite sheet.
45
+ * Single home for the `sx = (frame % columns) * frameWidth`, `sy = row * frameHeight`
46
+ * math shared by `Sprite.tsx`, `useUnitSpriteAtlas.ts`, and `resolveFrame`.
47
+ *
48
+ * Pass `row` explicitly for atlas-driven layouts (each animation occupies a row);
49
+ * pass `row = Math.floor(frame / columns)` for flat frame-index sheets.
50
+ */
51
+ export declare function frameRect(frame: number, row: number, columns: number, frameWidth: number, frameHeight: number): FrameRect;
52
+ /**
53
+ * Compute the current frame index from an animation definition.
54
+ * Atlas-driven and constant-driven callers share this one timing core.
55
+ */
56
+ export declare function getCurrentFrameFromDef(def: AnimationDef, elapsed: number): {
57
+ frame: number;
58
+ finished: boolean;
59
+ };
32
60
  /**
33
61
  * Compute the current frame index and whether the animation has finished.
34
62
  */