@docyrus/animaguru 0.6.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.
Files changed (198) hide show
  1. package/NOTICE.md +256 -0
  2. package/README.md +241 -0
  3. package/dist/animaguru.js +27338 -0
  4. package/package.json +37 -0
  5. package/skills/animaguru/SKILL.md +115 -0
  6. package/skills/animaguru-advertising/SKILL.md +25 -0
  7. package/skills/animaguru-advertising/references/brand-bumper.md +11 -0
  8. package/skills/animaguru-advertising/references/comparison.md +11 -0
  9. package/skills/animaguru-advertising/references/creator-testimonial.md +11 -0
  10. package/skills/animaguru-advertising/references/editorial-advertorial.md +11 -0
  11. package/skills/animaguru-advertising/references/game-reward.md +11 -0
  12. package/skills/animaguru-advertising/references/offer-promotion.md +11 -0
  13. package/skills/animaguru-advertising/references/product-launch.md +11 -0
  14. package/skills/animaguru-advertising/references/product-proof.md +11 -0
  15. package/skills/animaguru-analog-film-tape/SKILL.md +29 -0
  16. package/skills/animaguru-analog-film-tape/references/recipe.md +23 -0
  17. package/skills/animaguru-animated-data-visualization/SKILL.md +39 -0
  18. package/skills/animaguru-animated-data-visualization/references/data-contract.md +16 -0
  19. package/skills/animaguru-animated-data-visualization/references/variants.md +17 -0
  20. package/skills/animaguru-art-deco-motion/SKILL.md +29 -0
  21. package/skills/animaguru-art-deco-motion/references/recipe.md +22 -0
  22. package/skills/animaguru-ascii-crt/SKILL.md +29 -0
  23. package/skills/animaguru-ascii-crt/references/recipe.md +22 -0
  24. package/skills/animaguru-blueprint-drafting/SKILL.md +29 -0
  25. package/skills/animaguru-blueprint-drafting/references/recipe.md +22 -0
  26. package/skills/animaguru-cartoon-character-animation/SKILL.md +35 -0
  27. package/skills/animaguru-cartoon-character-animation/references/variants.md +17 -0
  28. package/skills/animaguru-cutout-animation/SKILL.md +33 -0
  29. package/skills/animaguru-cutout-animation/references/production-recipe.md +37 -0
  30. package/skills/animaguru-cutout-animation/references/variants.md +17 -0
  31. package/skills/animaguru-cutout-animation/references/visual-style.md +34 -0
  32. package/skills/animaguru-dark-tech-stage/SKILL.md +29 -0
  33. package/skills/animaguru-dark-tech-stage/references/recipe.md +23 -0
  34. package/skills/animaguru-diagram-formula-motion/SKILL.md +36 -0
  35. package/skills/animaguru-diagram-formula-motion/references/variants.md +17 -0
  36. package/skills/animaguru-engraved-relief-print/SKILL.md +29 -0
  37. package/skills/animaguru-engraved-relief-print/references/recipe.md +24 -0
  38. package/skills/animaguru-flat-vector-motion/SKILL.md +35 -0
  39. package/skills/animaguru-flat-vector-motion/references/variants.md +17 -0
  40. package/skills/animaguru-general-video/SKILL.md +20 -0
  41. package/skills/animaguru-general-video/references/ambient-loop.md +11 -0
  42. package/skills/animaguru-general-video/references/music-lyrics.md +11 -0
  43. package/skills/animaguru-general-video/references/short-film.md +11 -0
  44. package/skills/animaguru-general-video/references/titles-event.md +11 -0
  45. package/skills/animaguru-general-video/references/visual-essay.md +11 -0
  46. package/skills/animaguru-generative-light-signal/SKILL.md +29 -0
  47. package/skills/animaguru-generative-light-signal/references/recipe.md +23 -0
  48. package/skills/animaguru-glass-mosaic/SKILL.md +29 -0
  49. package/skills/animaguru-glass-mosaic/references/recipe.md +23 -0
  50. package/skills/animaguru-halftone-editorial/SKILL.md +29 -0
  51. package/skills/animaguru-halftone-editorial/references/recipe.md +23 -0
  52. package/skills/animaguru-holographic-scan/SKILL.md +29 -0
  53. package/skills/animaguru-holographic-scan/references/recipe.md +22 -0
  54. package/skills/animaguru-interface-motion/SKILL.md +36 -0
  55. package/skills/animaguru-interface-motion/references/screen-mapping.md +16 -0
  56. package/skills/animaguru-interface-motion/references/variants.md +17 -0
  57. package/skills/animaguru-isometric-worlds/SKILL.md +35 -0
  58. package/skills/animaguru-isometric-worlds/references/variants.md +17 -0
  59. package/skills/animaguru-kinetic-typography/SKILL.md +35 -0
  60. package/skills/animaguru-kinetic-typography/references/variants.md +17 -0
  61. package/skills/animaguru-miniature-diorama/SKILL.md +29 -0
  62. package/skills/animaguru-miniature-diorama/references/recipe.md +23 -0
  63. package/skills/animaguru-painterly-depth-animation/SKILL.md +35 -0
  64. package/skills/animaguru-painterly-depth-animation/references/variants.md +17 -0
  65. package/skills/animaguru-paper-popup/SKILL.md +29 -0
  66. package/skills/animaguru-paper-popup/references/recipe.md +22 -0
  67. package/skills/animaguru-photo-footage-editorial/SKILL.md +29 -0
  68. package/skills/animaguru-photo-footage-editorial/references/recipe.md +23 -0
  69. package/skills/animaguru-pixel-art-animation/SKILL.md +36 -0
  70. package/skills/animaguru-pixel-art-animation/references/variants.md +17 -0
  71. package/skills/animaguru-portal-zoom/SKILL.md +29 -0
  72. package/skills/animaguru-portal-zoom/references/recipe.md +21 -0
  73. package/skills/animaguru-risograph-print/SKILL.md +29 -0
  74. package/skills/animaguru-risograph-print/references/recipe.md +23 -0
  75. package/skills/animaguru-sand-drawing/SKILL.md +29 -0
  76. package/skills/animaguru-sand-drawing/references/recipe.md +21 -0
  77. package/skills/animaguru-shadow-theatre/SKILL.md +29 -0
  78. package/skills/animaguru-shadow-theatre/references/recipe.md +23 -0
  79. package/skills/animaguru-silkscreen-poster/SKILL.md +29 -0
  80. package/skills/animaguru-silkscreen-poster/references/recipe.md +22 -0
  81. package/skills/animaguru-stop-motion-objects/SKILL.md +29 -0
  82. package/skills/animaguru-stop-motion-objects/references/recipe.md +23 -0
  83. package/skills/animaguru-studio-product-reveal/SKILL.md +29 -0
  84. package/skills/animaguru-studio-product-reveal/references/recipe.md +23 -0
  85. package/skills/animaguru-video/SKILL.md +79 -0
  86. package/skills/animaguru-whiteboard-line-drawing/SKILL.md +34 -0
  87. package/skills/animaguru-whiteboard-line-drawing/references/variants.md +17 -0
  88. package/templates/video/AGENTS.md +34 -0
  89. package/templates/video/CLAUDE.md +19 -0
  90. package/templates/video/README.md +101 -0
  91. package/templates/video/VIDEO-STYLE-NOTICES.txt +54 -0
  92. package/templates/video/film.config.json +10 -0
  93. package/templates/video/gitignore +11 -0
  94. package/templates/video/index.html +14 -0
  95. package/templates/video/package.json +28 -0
  96. package/templates/video/public/brand/logo-mark.svg +5 -0
  97. package/templates/video/scripts/build.mjs +12 -0
  98. package/templates/video/scripts/export-html.mjs +12 -0
  99. package/templates/video/scripts/export-mp4.mjs +209 -0
  100. package/templates/video/scripts/html-export-plugin.mjs +35 -0
  101. package/templates/video/scripts/html-export.mjs +54 -0
  102. package/templates/video/scripts/install-example.mjs +32 -0
  103. package/templates/video/scripts/review-analysis.mjs +29 -0
  104. package/templates/video/scripts/review-audio.mjs +24 -0
  105. package/templates/video/scripts/review.mjs +37 -0
  106. package/templates/video/scripts/starter-film.sha256 +1 -0
  107. package/templates/video/shared/locales/en/export.json +10 -0
  108. package/templates/video/shared/locales/en/film.json +42 -0
  109. package/templates/video/shared/locales/en/player.json +31 -0
  110. package/templates/video/shared/locales/en/style-studies.json +168 -0
  111. package/templates/video/shared/locales/en/timeline.json +33 -0
  112. package/templates/video/src/assets.ts +4 -0
  113. package/templates/video/src/download.ts +27 -0
  114. package/templates/video/src/exporter.ts +70 -0
  115. package/templates/video/src/film-resources.ts +29 -0
  116. package/templates/video/src/film.ts +132 -0
  117. package/templates/video/src/main.ts +219 -0
  118. package/templates/video/src/resource-timeline.ts +193 -0
  119. package/templates/video/src/review.ts +50 -0
  120. package/templates/video/src/studies/film.ts +26 -0
  121. package/templates/video/src/studies/media.ts +46 -0
  122. package/templates/video/src/studies/model.ts +60 -0
  123. package/templates/video/src/studies/pixi-renderer.ts +121 -0
  124. package/templates/video/src/studies/scenes.ts +410 -0
  125. package/templates/video/src/studies/timing.ts +53 -0
  126. package/templates/video/src/studies/variants.ts +39 -0
  127. package/templates/video/src/style.css +111 -0
  128. package/templates/video/src/timeline-model.ts +55 -0
  129. package/templates/video/style-source-provenance.json +11 -0
  130. package/templates/video/tsconfig.json +15 -0
  131. package/templates/video/vite.config.mjs +9 -0
  132. package/vendor/pixijs-skills/LICENSE +21 -0
  133. package/vendor/pixijs-skills/provenance.json +79 -0
  134. package/vendor/pixijs-skills/skills/pixijs/SKILL.md +66 -0
  135. package/vendor/pixijs-skills/skills/pixijs/references/index.md +136 -0
  136. package/vendor/pixijs-skills/skills/pixijs-accessibility/SKILL.md +224 -0
  137. package/vendor/pixijs-skills/skills/pixijs-application/SKILL.md +293 -0
  138. package/vendor/pixijs-skills/skills/pixijs-application/references/application-options.md +314 -0
  139. package/vendor/pixijs-skills/skills/pixijs-assets/SKILL.md +303 -0
  140. package/vendor/pixijs-skills/skills/pixijs-assets/references/background.md +137 -0
  141. package/vendor/pixijs-skills/skills/pixijs-assets/references/bundles.md +122 -0
  142. package/vendor/pixijs-skills/skills/pixijs-assets/references/caching.md +143 -0
  143. package/vendor/pixijs-skills/skills/pixijs-assets/references/compressed-textures.md +120 -0
  144. package/vendor/pixijs-skills/skills/pixijs-assets/references/fonts.md +205 -0
  145. package/vendor/pixijs-skills/skills/pixijs-assets/references/gif.md +171 -0
  146. package/vendor/pixijs-skills/skills/pixijs-assets/references/manifests.md +175 -0
  147. package/vendor/pixijs-skills/skills/pixijs-assets/references/progress.md +142 -0
  148. package/vendor/pixijs-skills/skills/pixijs-assets/references/resolution.md +142 -0
  149. package/vendor/pixijs-skills/skills/pixijs-assets/references/spritesheet.md +119 -0
  150. package/vendor/pixijs-skills/skills/pixijs-assets/references/svg.md +132 -0
  151. package/vendor/pixijs-skills/skills/pixijs-assets/references/video.md +158 -0
  152. package/vendor/pixijs-skills/skills/pixijs-blend-modes/SKILL.md +215 -0
  153. package/vendor/pixijs-skills/skills/pixijs-color/SKILL.md +299 -0
  154. package/vendor/pixijs-skills/skills/pixijs-core-concepts/SKILL.md +132 -0
  155. package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/render-loop.md +216 -0
  156. package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/renderers.md +287 -0
  157. package/vendor/pixijs-skills/skills/pixijs-create/SKILL.md +276 -0
  158. package/vendor/pixijs-skills/skills/pixijs-custom-rendering/SKILL.md +405 -0
  159. package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/advanced-gpu.md +244 -0
  160. package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/uniform-types.md +94 -0
  161. package/vendor/pixijs-skills/skills/pixijs-environments/SKILL.md +243 -0
  162. package/vendor/pixijs-skills/skills/pixijs-events/SKILL.md +387 -0
  163. package/vendor/pixijs-skills/skills/pixijs-filters/SKILL.md +300 -0
  164. package/vendor/pixijs-skills/skills/pixijs-html-source/SKILL.md +228 -0
  165. package/vendor/pixijs-skills/skills/pixijs-math/SKILL.md +489 -0
  166. package/vendor/pixijs-skills/skills/pixijs-migration-v8/SKILL.md +415 -0
  167. package/vendor/pixijs-skills/skills/pixijs-performance/SKILL.md +489 -0
  168. package/vendor/pixijs-skills/skills/pixijs-scene-container/SKILL.md +345 -0
  169. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/SKILL.md +243 -0
  170. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/constructor-options.md +155 -0
  171. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/container-hierarchy.md +232 -0
  172. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/layers.md +145 -0
  173. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/masking.md +129 -0
  174. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/render-groups.md +140 -0
  175. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/scene-management.md +169 -0
  176. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/transforms.md +198 -0
  177. package/vendor/pixijs-skills/skills/pixijs-scene-dom-container/SKILL.md +193 -0
  178. package/vendor/pixijs-skills/skills/pixijs-scene-gif/SKILL.md +233 -0
  179. package/vendor/pixijs-skills/skills/pixijs-scene-graphics/SKILL.md +576 -0
  180. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/SKILL.md +141 -0
  181. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-perspective.md +189 -0
  182. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-plane.md +159 -0
  183. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-rope.md +176 -0
  184. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-simple.md +144 -0
  185. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh.md +213 -0
  186. package/vendor/pixijs-skills/skills/pixijs-scene-particle-container/SKILL.md +323 -0
  187. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/SKILL.md +120 -0
  188. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/animated-sprite.md +262 -0
  189. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/nineslice-sprite.md +202 -0
  190. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/sprite.md +181 -0
  191. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/tiling-sprite.md +216 -0
  192. package/vendor/pixijs-skills/skills/pixijs-scene-text/SKILL.md +136 -0
  193. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/bitmap-text.md +232 -0
  194. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/html-text.md +192 -0
  195. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-bitmap-text.md +187 -0
  196. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-text.md +168 -0
  197. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/text.md +311 -0
  198. package/vendor/pixijs-skills/skills/pixijs-ticker/SKILL.md +292 -0
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: pixijs-scene-sprite
3
+ description: "Use this skill when drawing images in PixiJS v8. Covers Sprite with anchor/tint/texture, AnimatedSprite for frame animation, NineSliceSprite for resizable UI panels, TilingSprite for scrolling/repeating backgrounds. Triggers on: Sprite, AnimatedSprite, NineSliceSprite, TilingSprite, Sprite.from, anchor, tint, tilePosition, animationSpeed, gotoAndPlay, leftWidth, topHeight, constructor options, SpriteOptions, AnimatedSpriteOptions, NineSliceSpriteOptions, TilingSpriteOptions."
4
+ license: MIT
5
+ ---
6
+
7
+ PixiJS has three sprite classes for different drawing tasks. `Sprite` is the default image-drawing leaf; `NineSliceSprite` is a resizable UI-panel variant that preserves corner art; `TilingSprite` repeats a texture across an area. The `AnimatedSprite` subclass of `Sprite` cycles through texture frames for frame-based animation.
8
+
9
+ Assumes familiarity with `pixijs-scene-core-concepts`. All sprite classes are leaf nodes; they cannot have children. Wrap multiple sprites in a `Container` to group them.
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ const texture = await Assets.load("bunny.png");
15
+
16
+ const sprite = new Sprite({
17
+ texture,
18
+ anchor: 0.5,
19
+ tint: 0xff8888,
20
+ });
21
+ sprite.x = app.screen.width / 2;
22
+ sprite.y = app.screen.height / 2;
23
+
24
+ app.stage.addChild(sprite);
25
+ ```
26
+
27
+ Position is set after construction because `app.screen.width / 2` depends on the live renderer size. Literal positions can go directly in the options object via `x`/`y` (inherited from `Container`).
28
+
29
+ **Related skills:** `pixijs-scene-core-concepts` (leaves, transforms), `pixijs-assets` (texture loading), `pixijs-scene-particle-container` (thousands of sprites), `pixijs-performance` (spritesheets, batching).
30
+
31
+ ## Variants
32
+
33
+ | Variant | Use when | Trade-offs | Reference |
34
+ | ----------------- | --------------------------------------------------------- | ----------------------------------------------- | ---------------------------------------------------------------- |
35
+ | `Sprite` | Draw a single texture at a position | Fixed size = texture size | [references/sprite.md](references/sprite.md) |
36
+ | `AnimatedSprite` | Frame-based animation from a texture array or spritesheet | Pre-rendered frames only; no tweening | [references/animated-sprite.md](references/animated-sprite.md) |
37
+ | `NineSliceSprite` | Resizable UI panels, buttons, dialog frames | Border width is fixed; center stretches | [references/nineslice-sprite.md](references/nineslice-sprite.md) |
38
+ | `TilingSprite` | Scrolling backgrounds, parallax, repeating patterns | Single texture repeated; `tilePosition` scrolls | [references/tiling-sprite.md](references/tiling-sprite.md) |
39
+
40
+ `AnimatedSprite` is a subclass of `Sprite`; all `Sprite` properties (anchor, tint, position) apply.
41
+
42
+ Each variant's constructor options are documented in its sub-reference file (`references/{variant}.md`). All variants also accept the `Container` options (`position`, `scale`, `tint`, `label`, `filters`, `zIndex`, etc.) — see `skills/pixijs-scene-core-concepts/references/constructor-options.md`.
43
+
44
+ ## When to use what
45
+
46
+ - **"I want to draw a single image at a position"** → `Sprite`. The default choice for 90% of 2D game and app content.
47
+ - **"I want to animate a character through a series of frames"** → `AnimatedSprite`. Load a spritesheet via Assets and pass `sheet.animations['walk']`. See `references/animated-sprite.md`.
48
+ - **"I want a UI button/panel that resizes without stretching the borders"** → `NineSliceSprite`. Set border widths, then set `width`/`height`. See `references/nineslice-sprite.md`.
49
+ - **"I want a scrolling repeating background"** → `TilingSprite`. Animate `tilePosition` to scroll. See `references/tiling-sprite.md`.
50
+ - **"I want thousands of identical sprites"** → Use `ParticleContainer` with `Particle` instances (see `pixijs-scene-particle-container`), not plain sprites.
51
+ - **"I want to draw shapes or paths"** → Use `Graphics` (see `pixijs-scene-graphics`), not a sprite.
52
+
53
+ ## Quick concepts
54
+
55
+ ### Anchor vs pivot
56
+
57
+ `Sprite.anchor` is normalized `[0, 1]` and shifts only the texture draw origin; no position offset. `Container.pivot` is pixel-space and shifts both the transform origin and the visual position. For centering a sprite, always use `anchor.set(0.5)`.
58
+
59
+ ### Loading before creating
60
+
61
+ `Sprite.from(id)` only reads the Assets cache; it does not fetch. Always `await Assets.load(...)` first, or pass the returned `Texture` directly to `new Sprite(texture)`.
62
+
63
+ ### Dynamic textures
64
+
65
+ Once a texture is loaded, modifying its `frame` or swapping its source does not automatically notify sprites. Set `texture.dynamic = true` once, or call `sprite['onViewUpdate']()` manually after changes.
66
+
67
+ ## Common Mistakes
68
+
69
+ ### [HIGH] Using `Texture.from(url)` to load
70
+
71
+ Wrong:
72
+
73
+ ```ts
74
+ const texture = Texture.from("https://example.com/image.png");
75
+ ```
76
+
77
+ Correct:
78
+
79
+ ```ts
80
+ const texture = await Assets.load("https://example.com/image.png");
81
+ ```
82
+
83
+ `Texture.from()` only reads the cache in v8. Use `Assets.load()` first; its return value is the texture.
84
+
85
+
86
+ ### [HIGH] Confusing anchor and pivot
87
+
88
+ Wrong:
89
+
90
+ ```ts
91
+ sprite.pivot.set(sprite.width / 2, sprite.height / 2);
92
+ ```
93
+
94
+ Correct:
95
+
96
+ ```ts
97
+ sprite.anchor.set(0.5);
98
+ ```
99
+
100
+ `anchor` shifts only the draw origin. `pivot` shifts the transform origin AND the visual position, causing the sprite to move unexpectedly.
101
+
102
+
103
+ ### [HIGH] Old `NineSlicePlane` name
104
+
105
+ `NineSlicePlane` was renamed to `NineSliceSprite` in v8 and switched to an options-object constructor: `new NineSliceSprite({ texture, leftWidth, topHeight, rightWidth, bottomHeight })`.
106
+
107
+
108
+ ### [MEDIUM] Adding children to a sprite
109
+
110
+ `Sprite`, `NineSliceSprite`, and `TilingSprite` all set `allowChildren = false`. Wrap in a `Container` to group sprites with other content.
111
+
112
+
113
+ ## API Reference
114
+
115
+ - [Sprite](https://pixijs.download/release/docs/scene.Sprite.html.md)
116
+ - [SpriteOptions](https://pixijs.download/release/docs/scene.SpriteOptions.html.md)
117
+ - [AnimatedSprite](https://pixijs.download/release/docs/scene.AnimatedSprite.html.md)
118
+ - [NineSliceSprite](https://pixijs.download/release/docs/scene.NineSliceSprite.html.md)
119
+ - [TilingSprite](https://pixijs.download/release/docs/scene.TilingSprite.html.md)
120
+ - [Texture](https://pixijs.download/release/docs/rendering.Texture.html.md)
@@ -0,0 +1,262 @@
1
+ # AnimatedSprite
2
+
3
+ A `Sprite` subclass that cycles through an array of textures for frame-based animation. Use for character walk cycles, explosions, UI icon loops, or any sequence driven by pre-rendered frames from a spritesheet.
4
+
5
+ ## Quick Start
6
+
7
+ ```ts
8
+ const sheet = await Assets.load("character.json");
9
+
10
+ const walk = new AnimatedSprite({
11
+ textures: sheet.animations["walk"],
12
+ animationSpeed: 0.15,
13
+ loop: true,
14
+ autoPlay: true,
15
+ });
16
+
17
+ app.stage.addChild(walk);
18
+ ```
19
+
20
+ `AnimatedSprite` extends `Sprite`, so anchor, tint, position, and scale all work the same way. It adds frame playback on top. Inherits `allowChildren = false` from `Sprite`.
21
+
22
+ ## Core Patterns
23
+
24
+ ### Construction
25
+
26
+ ```ts
27
+ new AnimatedSprite(frames, autoUpdate?);
28
+ new AnimatedSprite({ textures, autoUpdate, autoPlay, loop, animationSpeed });
29
+ ```
30
+
31
+ Two constructor forms are supported. The options form accepts all `SpriteOptions` (anchor, tint, position, etc.) plus the animation-specific fields below. The positional form takes a frames array and an optional `autoUpdate` flag.
32
+
33
+ ```ts
34
+ const sheet = await Assets.load("character.json");
35
+
36
+ const walk = new AnimatedSprite({
37
+ textures: sheet.animations["walk"],
38
+ animationSpeed: 0.2,
39
+ loop: true,
40
+ autoPlay: true,
41
+ anchor: 0.5,
42
+ x: 200,
43
+ y: 300,
44
+ });
45
+ ```
46
+
47
+ #### AnimatedSpriteOptions
48
+
49
+ | Option | Type | Default | Description |
50
+ | ---------------- | -------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
51
+ | `textures` | `AnimatedSpriteFrames` | — | Frame list: a `Texture[]` or `FrameObject[]` (each `{ texture, time }` with `time` in ms). Required. |
52
+ | `animationSpeed` | `number` | `1` | Playback multiplier; negative values reverse direction. |
53
+ | `autoPlay` | `boolean` | `false` | Start playback immediately on construction. |
54
+ | `autoUpdate` | `boolean` | `true` | Drive playback from `Ticker.shared`; set `false` to call `update(ticker)` manually. |
55
+ | `loop` | `boolean` | `true` | Restart after the last frame; set `false` for one-shot animations. |
56
+ | `onComplete` | `() => void` | `null` | Fires when a non-looping animation reaches its end. |
57
+ | `onFrameChange` | `(currentFrame: number) => void` | `null` | Fires every time the displayed texture changes. |
58
+ | `onLoop` | `() => void` | `null` | Fires when a looping animation wraps back to the start. |
59
+ | `updateAnchor` | `boolean` | `false` | Copy `texture.defaultAnchor` onto the sprite's anchor on every frame change. Overrides any previously set anchor. |
60
+
61
+ Also inherits `SpriteOptions` minus `texture` (use `textures` for frames) — see `sprite.md`. All `Container` options (`position`, `scale`, `tint`, `label`, `filters`, `zIndex`, etc.) are also valid here — see `skills/pixijs-scene-core-concepts/references/constructor-options.md`.
62
+
63
+ ### Playback control
64
+
65
+ ```ts
66
+ walk.play();
67
+ walk.stop();
68
+ walk.gotoAndStop(3);
69
+ walk.gotoAndPlay(0);
70
+
71
+ walk.currentFrame = 2;
72
+ console.log(walk.totalFrames);
73
+ console.log(walk.playing);
74
+ ```
75
+
76
+ - `play()` / `stop()`: start or freeze playback at the current frame.
77
+ - `gotoAndStop(frame)` / `gotoAndPlay(frame)`: jump to a specific frame index.
78
+ - `currentFrame`: readable and writable. The setter throws if the value is outside `[0, totalFrames - 1]`.
79
+ - `totalFrames` (readonly): number of frames in the current texture list.
80
+ - `playing` (readonly): current playback state.
81
+
82
+ ### Speed and looping
83
+
84
+ ```ts
85
+ walk.animationSpeed = 0.15;
86
+ walk.animationSpeed = -1;
87
+ walk.loop = false;
88
+ ```
89
+
90
+ - `animationSpeed` (default `1`): playback multiplier. Negative reverses direction.
91
+ - `loop` (default `true`): restart after last frame. Set to `false` and use `onComplete` for one-shot animations.
92
+
93
+ ### Callbacks
94
+
95
+ ```ts
96
+ walk.onComplete = () => console.log("animation done");
97
+ walk.onFrameChange = (frame) => console.log(`now on frame ${frame}`);
98
+ walk.onLoop = () => console.log("looped back to start");
99
+ ```
100
+
101
+ - `onComplete`: fires when a non-looping animation reaches its end.
102
+ - `onFrameChange(frameIndex)`: fires every time the displayed texture changes.
103
+ - `onLoop`: fires when a looping animation wraps around to the start.
104
+
105
+ ### Auto update
106
+
107
+ ```ts
108
+ const walk = new AnimatedSprite({
109
+ textures: sheet.animations["walk"],
110
+ autoUpdate: false,
111
+ });
112
+
113
+ app.ticker.add((ticker) => {
114
+ walk.update(ticker);
115
+ });
116
+ ```
117
+
118
+ `autoUpdate` (default `true`): uses `Ticker.shared`. Set `false` and call `update(ticker)` manually to drive playback from a custom ticker or pause it with game logic.
119
+
120
+ ### Per-frame timing
121
+
122
+ ```ts
123
+ const explosion = new AnimatedSprite({
124
+ textures: [
125
+ { texture: frame0, time: 100 },
126
+ { texture: frame1, time: 200 },
127
+ { texture: frame2, time: 300 },
128
+ ],
129
+ });
130
+ ```
131
+
132
+ `FrameObject` entries use `{ texture, time }` where `time` is in **milliseconds**, not seconds. Mix per-frame timing for effects that linger on key frames (impact, reveal, pause).
133
+
134
+ Spritesheets loaded via `Assets.load` expose per-frame `duration` values at `sheet.data.frames[key].duration`. Build a `FrameObject[]` from those durations when you need pre-authored timing:
135
+
136
+ ```ts
137
+ const sheet = await Assets.load("0123456789.json");
138
+ const frames = [];
139
+ for (let i = 0; i < 10; i++) {
140
+ const key = `0123456789 ${i}.ase`;
141
+ frames.push({
142
+ texture: Texture.from(key),
143
+ time: sheet.data.frames[key].duration,
144
+ });
145
+ }
146
+ const sprite = new AnimatedSprite(frames);
147
+ ```
148
+
149
+ ### Factories
150
+
151
+ ```ts
152
+ const walk = AnimatedSprite.fromFrames(["walk0.png", "walk1.png", "walk2.png"]);
153
+ const idle = AnimatedSprite.fromImages(["idle0.png", "idle1.png"]);
154
+ ```
155
+
156
+ - `fromFrames(aliases)`: builds textures via `Texture.from` from Assets cache aliases. Requires the spritesheet to already be loaded.
157
+ - `fromImages(urls)`: builds textures from URLs. Does not await loading; textures resolve asynchronously.
158
+
159
+ Prefer `new AnimatedSprite({ textures: sheet.animations[...] })` after `await Assets.load(...)` for deterministic loading.
160
+
161
+ ### updateAnchor
162
+
163
+ ```ts
164
+ const walk = new AnimatedSprite({
165
+ textures: sheet.animations["walk"],
166
+ updateAnchor: true,
167
+ });
168
+ ```
169
+
170
+ `updateAnchor` (default `false`): when `true`, the sprite's anchor is copied from the current texture's `defaultAnchor` on every frame change. Useful when exporting frames with per-frame pivot points (e.g., to pin the animation to a moving foot or hand). Overrides any previously set anchor on each frame change.
171
+
172
+ ## Common Mistakes
173
+
174
+ ### [HIGH] Using `Texture.from` on unloaded frames
175
+
176
+ Wrong:
177
+
178
+ ```ts
179
+ const walk = new AnimatedSprite([
180
+ Texture.from("walk0.png"),
181
+ Texture.from("walk1.png"),
182
+ ]);
183
+ ```
184
+
185
+ Correct:
186
+
187
+ ```ts
188
+ const sheet = await Assets.load("character.json");
189
+ const walk = new AnimatedSprite(sheet.animations["walk"]);
190
+ ```
191
+
192
+ `Texture.from()` only reads the cache in v8. If the spritesheet has not been loaded, the textures resolve to `Texture.EMPTY` and the sprite shows nothing. Always `await Assets.load()` the spritesheet first, then use `sheet.animations[key]`.
193
+
194
+
195
+ ### [HIGH] Forgetting to call `play()` or set `autoPlay`
196
+
197
+ Wrong:
198
+
199
+ ```ts
200
+ const walk = new AnimatedSprite({ textures: sheet.animations["walk"] });
201
+ app.stage.addChild(walk);
202
+ ```
203
+
204
+ Correct:
205
+
206
+ ```ts
207
+ const walk = new AnimatedSprite({
208
+ textures: sheet.animations["walk"],
209
+ autoPlay: true,
210
+ });
211
+ app.stage.addChild(walk);
212
+ ```
213
+
214
+ `autoPlay` defaults to `false`. Without `autoPlay: true` or a manual `walk.play()` call, the sprite displays only the first frame.
215
+
216
+
217
+ ### [MEDIUM] Using seconds instead of milliseconds for `FrameObject.time`
218
+
219
+ Wrong:
220
+
221
+ ```ts
222
+ new AnimatedSprite([
223
+ { texture: frame0, time: 0.1 },
224
+ { texture: frame1, time: 0.2 },
225
+ ]);
226
+ ```
227
+
228
+ Correct:
229
+
230
+ ```ts
231
+ new AnimatedSprite([
232
+ { texture: frame0, time: 100 },
233
+ { texture: frame1, time: 200 },
234
+ ]);
235
+ ```
236
+
237
+ `FrameObject.time` is in milliseconds. A value of `0.1` will advance frames almost instantly.
238
+
239
+
240
+ ### [MEDIUM] Setting `currentFrame` out of range
241
+
242
+ Wrong:
243
+
244
+ ```ts
245
+ walk.currentFrame = walk.totalFrames;
246
+ ```
247
+
248
+ Correct:
249
+
250
+ ```ts
251
+ walk.currentFrame = walk.totalFrames - 1;
252
+ ```
253
+
254
+ The setter throws if the value is outside `[0, totalFrames - 1]`. Use `totalFrames - 1` for the last frame.
255
+
256
+
257
+ ## API Reference
258
+
259
+ - [AnimatedSprite](https://pixijs.download/release/docs/scene.AnimatedSprite.html.md)
260
+ - [AnimatedSpriteOptions](https://pixijs.download/release/docs/scene.AnimatedSpriteOptions.html.md)
261
+ - [FrameObject](https://pixijs.download/release/docs/scene.FrameObject.html.md)
262
+ - [Spritesheet](https://pixijs.download/release/docs/assets.Spritesheet.html.md)
@@ -0,0 +1,202 @@
1
+ # NineSliceSprite
2
+
3
+ A sprite variant that stretches a texture using 9-slice scaling. The four corner regions stay unscaled, the top and bottom edges stretch horizontally, the left and right edges stretch vertically, and the center stretches both ways. Use this for resizable UI panels, buttons, and dialog frames where you want the border art to remain crisp at any size.
4
+
5
+ ## Quick Start
6
+
7
+ ```ts
8
+ const texture = await Assets.load("panel.png");
9
+
10
+ const panel = new NineSliceSprite({
11
+ texture,
12
+ leftWidth: 20,
13
+ topHeight: 20,
14
+ rightWidth: 20,
15
+ bottomHeight: 20,
16
+ width: 400,
17
+ height: 200,
18
+ });
19
+
20
+ app.stage.addChild(panel);
21
+ ```
22
+
23
+ All four border values default to `10`. Assign `width` / `height` on the sprite (not the texture) to control the stretch region.
24
+
25
+ ## Construction
26
+
27
+ ```ts
28
+ const panel = new NineSliceSprite({
29
+ texture,
30
+ leftWidth: 20,
31
+ topHeight: 20,
32
+ rightWidth: 20,
33
+ bottomHeight: 20,
34
+ width: 400,
35
+ height: 200,
36
+ anchor: 0.5,
37
+ });
38
+ ```
39
+
40
+ ### NineSliceSpriteOptions
41
+
42
+ | Option | Type | Default | Description |
43
+ | -------------- | --------------------- | ----------------------------- | ------------------------------------------------------------------ |
44
+ | `texture` | `Texture` | `Texture.EMPTY` | Source texture for the 9-slice. |
45
+ | `leftWidth` | `number` | `10` | Width of the left border column that stays unscaled. |
46
+ | `topHeight` | `number` | `10` | Height of the top border row that stays unscaled. |
47
+ | `rightWidth` | `number` | `10` | Width of the right border column that stays unscaled. |
48
+ | `bottomHeight` | `number` | `10` | Height of the bottom border row that stays unscaled. |
49
+ | `width` | `number` | `texture.width` (else `100`) | Width of the stretched sprite region; modifies vertices, not UVs. |
50
+ | `height` | `number` | `texture.height` (else `100`) | Height of the stretched sprite region; modifies vertices, not UVs. |
51
+ | `anchor` | `PointData \| number` | `0` | Normalized draw origin in `[0, 1]`. |
52
+ | `roundPixels` | `boolean` | `false` | Snap rendering coordinates to integers for crisp pixel art. |
53
+
54
+ All `Container` options (`position`, `scale`, `tint`, `label`, `filters`, `zIndex`, etc.) are also valid here — see `skills/pixijs-scene-core-concepts/references/constructor-options.md`.
55
+
56
+ Border values fall back to `texture.defaultBorders` if set on the texture; see the Texture-defined borders section below.
57
+
58
+ ## Core Patterns
59
+
60
+ ### The 9-slice grid
61
+
62
+ ```
63
+ leftWidth rightWidth
64
+ +---+--------------------+---+
65
+ | 1 | 2 | 3 | topHeight
66
+ +---+--------------------+---+
67
+ | | | |
68
+ | 4 | 5 | 6 |
69
+ | | | |
70
+ +---+--------------------+---+
71
+ | 7 | 8 | 9 | bottomHeight
72
+ +---+--------------------+---+
73
+ ```
74
+
75
+ - Corners (1, 3, 7, 9): unscaled
76
+ - Top and bottom edges (2, 8): stretched horizontally
77
+ - Left and right edges (4, 6): stretched vertically
78
+ - Center (5): stretched both ways
79
+
80
+ ### Runtime resize
81
+
82
+ ```ts
83
+ panel.width = 600;
84
+ panel.height = 300;
85
+
86
+ panel.setSize(600, 300);
87
+ const size = panel.getSize();
88
+ ```
89
+
90
+ Setting `width` / `height` modifies the sprite's vertices directly. It does not scale the underlying texture. The corners stay fixed-size regardless of how small or large you make the panel. `setSize(value, height?)` and `getSize(out?)` are the override pair used to avoid recomputing bounds twice when both axes change.
91
+
92
+ ### Texture-defined borders
93
+
94
+ ```ts
95
+ const texture = new Texture({
96
+ source: baseSource,
97
+ defaultBorders: { left: 15, top: 15, right: 15, bottom: 15 },
98
+ });
99
+
100
+ const panel = new NineSliceSprite({ texture, width: 400, height: 200 });
101
+ ```
102
+
103
+ `defaultBorders` is a readonly Texture property. Pass it in the constructor options (or set it on the spritesheet data so `Assets.load` bakes it into the loaded texture). If the texture has borders set, the sprite picks them up automatically when no explicit border values are passed to the `NineSliceSprite` constructor. Define them once per texture and reuse across multiple panels.
104
+
105
+
106
+ ### Border updates
107
+
108
+ ```ts
109
+ panel.leftWidth = 25;
110
+ panel.rightWidth = 25;
111
+ panel.topHeight = 15;
112
+ panel.bottomHeight = 15;
113
+ ```
114
+
115
+ All four border values are mutable at runtime. The sprite rebuilds its geometry on the next render.
116
+
117
+ ### Source texture dimensions
118
+
119
+ ```ts
120
+ console.log(panel.originalWidth, panel.originalHeight);
121
+ panel.setSize(panel.originalWidth, panel.originalHeight);
122
+ ```
123
+
124
+ `originalWidth` and `originalHeight` are readonly getters that return the underlying `texture.width` / `texture.height`. Use them to reset a panel to its source size or to compute scaled sizes relative to the unstretched texture.
125
+
126
+ ### Global defaults
127
+
128
+ ```ts
129
+ NineSliceSprite.defaultOptions.texture = Texture.from("defaultPanel.png");
130
+ ```
131
+
132
+ `NineSliceSprite.defaultOptions` is a mutable static object, but only its `texture` field is read as a fallback. Border defaults come from `texture.defaultBorders` (per-texture) or `NineSliceGeometry.defaultOptions` (global), and size defaults fall back to `texture.width` / `texture.height` or `NineSliceGeometry.defaultOptions.width` / `.height`.
133
+
134
+ ### Round pixels for crisp borders
135
+
136
+ ```ts
137
+ const panel = new NineSliceSprite({
138
+ texture,
139
+ leftWidth: 10,
140
+ topHeight: 10,
141
+ rightWidth: 10,
142
+ bottomHeight: 10,
143
+ roundPixels: true,
144
+ });
145
+ ```
146
+
147
+ Use with pixel-art UI textures to avoid sub-pixel seams at the slice boundaries.
148
+
149
+ ## Common Mistakes
150
+
151
+ ### [HIGH] Using the old `NineSlicePlane` name
152
+
153
+ Wrong:
154
+
155
+ ```ts
156
+ import { NineSlicePlane } from "pixi.js";
157
+ const panel = new NineSlicePlane(texture, 10, 10, 10, 10);
158
+ ```
159
+
160
+ Correct:
161
+
162
+ ```ts
163
+ import { NineSliceSprite } from "pixi.js";
164
+ const panel = new NineSliceSprite({
165
+ texture,
166
+ leftWidth: 10,
167
+ topHeight: 10,
168
+ rightWidth: 10,
169
+ bottomHeight: 10,
170
+ });
171
+ ```
172
+
173
+ `NineSlicePlane` was renamed in v8 and switched to an options-object constructor. The old `NineSlicePlane` name is deprecated — use `NineSliceSprite` instead.
174
+
175
+
176
+ ### [HIGH] Setting `texture.scale` to resize the panel
177
+
178
+ Wrong:
179
+
180
+ ```ts
181
+ panel.scale.set(2);
182
+ ```
183
+
184
+ Correct:
185
+
186
+ ```ts
187
+ panel.width = 400;
188
+ panel.height = 200;
189
+ ```
190
+
191
+ `scale` stretches the entire geometry including corners, defeating the purpose of 9-slice. Always use `width` / `height` to resize a `NineSliceSprite`; this preserves corner art.
192
+
193
+
194
+ ### [MEDIUM] Borders larger than half the texture
195
+
196
+ If `leftWidth + rightWidth >= texture.width` (or `topHeight + bottomHeight >= texture.height`), no texture pixels are left for the center strip, so it is filled by stretching the seam between the two borders instead of the texture's middle. Keep the sum of opposing borders less than the corresponding texture dimension.
197
+
198
+
199
+ ## API Reference
200
+
201
+ - [NineSliceSprite](https://pixijs.download/release/docs/scene.NineSliceSprite.html.md)
202
+ - [NineSliceGeometry](https://pixijs.download/release/docs/scene.NineSliceGeometry.html.md)