@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.
- package/NOTICE.md +256 -0
- package/README.md +241 -0
- package/dist/animaguru.js +27338 -0
- package/package.json +37 -0
- package/skills/animaguru/SKILL.md +115 -0
- package/skills/animaguru-advertising/SKILL.md +25 -0
- package/skills/animaguru-advertising/references/brand-bumper.md +11 -0
- package/skills/animaguru-advertising/references/comparison.md +11 -0
- package/skills/animaguru-advertising/references/creator-testimonial.md +11 -0
- package/skills/animaguru-advertising/references/editorial-advertorial.md +11 -0
- package/skills/animaguru-advertising/references/game-reward.md +11 -0
- package/skills/animaguru-advertising/references/offer-promotion.md +11 -0
- package/skills/animaguru-advertising/references/product-launch.md +11 -0
- package/skills/animaguru-advertising/references/product-proof.md +11 -0
- package/skills/animaguru-analog-film-tape/SKILL.md +29 -0
- package/skills/animaguru-analog-film-tape/references/recipe.md +23 -0
- package/skills/animaguru-animated-data-visualization/SKILL.md +39 -0
- package/skills/animaguru-animated-data-visualization/references/data-contract.md +16 -0
- package/skills/animaguru-animated-data-visualization/references/variants.md +17 -0
- package/skills/animaguru-art-deco-motion/SKILL.md +29 -0
- package/skills/animaguru-art-deco-motion/references/recipe.md +22 -0
- package/skills/animaguru-ascii-crt/SKILL.md +29 -0
- package/skills/animaguru-ascii-crt/references/recipe.md +22 -0
- package/skills/animaguru-blueprint-drafting/SKILL.md +29 -0
- package/skills/animaguru-blueprint-drafting/references/recipe.md +22 -0
- package/skills/animaguru-cartoon-character-animation/SKILL.md +35 -0
- package/skills/animaguru-cartoon-character-animation/references/variants.md +17 -0
- package/skills/animaguru-cutout-animation/SKILL.md +33 -0
- package/skills/animaguru-cutout-animation/references/production-recipe.md +37 -0
- package/skills/animaguru-cutout-animation/references/variants.md +17 -0
- package/skills/animaguru-cutout-animation/references/visual-style.md +34 -0
- package/skills/animaguru-dark-tech-stage/SKILL.md +29 -0
- package/skills/animaguru-dark-tech-stage/references/recipe.md +23 -0
- package/skills/animaguru-diagram-formula-motion/SKILL.md +36 -0
- package/skills/animaguru-diagram-formula-motion/references/variants.md +17 -0
- package/skills/animaguru-engraved-relief-print/SKILL.md +29 -0
- package/skills/animaguru-engraved-relief-print/references/recipe.md +24 -0
- package/skills/animaguru-flat-vector-motion/SKILL.md +35 -0
- package/skills/animaguru-flat-vector-motion/references/variants.md +17 -0
- package/skills/animaguru-general-video/SKILL.md +20 -0
- package/skills/animaguru-general-video/references/ambient-loop.md +11 -0
- package/skills/animaguru-general-video/references/music-lyrics.md +11 -0
- package/skills/animaguru-general-video/references/short-film.md +11 -0
- package/skills/animaguru-general-video/references/titles-event.md +11 -0
- package/skills/animaguru-general-video/references/visual-essay.md +11 -0
- package/skills/animaguru-generative-light-signal/SKILL.md +29 -0
- package/skills/animaguru-generative-light-signal/references/recipe.md +23 -0
- package/skills/animaguru-glass-mosaic/SKILL.md +29 -0
- package/skills/animaguru-glass-mosaic/references/recipe.md +23 -0
- package/skills/animaguru-halftone-editorial/SKILL.md +29 -0
- package/skills/animaguru-halftone-editorial/references/recipe.md +23 -0
- package/skills/animaguru-holographic-scan/SKILL.md +29 -0
- package/skills/animaguru-holographic-scan/references/recipe.md +22 -0
- package/skills/animaguru-interface-motion/SKILL.md +36 -0
- package/skills/animaguru-interface-motion/references/screen-mapping.md +16 -0
- package/skills/animaguru-interface-motion/references/variants.md +17 -0
- package/skills/animaguru-isometric-worlds/SKILL.md +35 -0
- package/skills/animaguru-isometric-worlds/references/variants.md +17 -0
- package/skills/animaguru-kinetic-typography/SKILL.md +35 -0
- package/skills/animaguru-kinetic-typography/references/variants.md +17 -0
- package/skills/animaguru-miniature-diorama/SKILL.md +29 -0
- package/skills/animaguru-miniature-diorama/references/recipe.md +23 -0
- package/skills/animaguru-painterly-depth-animation/SKILL.md +35 -0
- package/skills/animaguru-painterly-depth-animation/references/variants.md +17 -0
- package/skills/animaguru-paper-popup/SKILL.md +29 -0
- package/skills/animaguru-paper-popup/references/recipe.md +22 -0
- package/skills/animaguru-photo-footage-editorial/SKILL.md +29 -0
- package/skills/animaguru-photo-footage-editorial/references/recipe.md +23 -0
- package/skills/animaguru-pixel-art-animation/SKILL.md +36 -0
- package/skills/animaguru-pixel-art-animation/references/variants.md +17 -0
- package/skills/animaguru-portal-zoom/SKILL.md +29 -0
- package/skills/animaguru-portal-zoom/references/recipe.md +21 -0
- package/skills/animaguru-risograph-print/SKILL.md +29 -0
- package/skills/animaguru-risograph-print/references/recipe.md +23 -0
- package/skills/animaguru-sand-drawing/SKILL.md +29 -0
- package/skills/animaguru-sand-drawing/references/recipe.md +21 -0
- package/skills/animaguru-shadow-theatre/SKILL.md +29 -0
- package/skills/animaguru-shadow-theatre/references/recipe.md +23 -0
- package/skills/animaguru-silkscreen-poster/SKILL.md +29 -0
- package/skills/animaguru-silkscreen-poster/references/recipe.md +22 -0
- package/skills/animaguru-stop-motion-objects/SKILL.md +29 -0
- package/skills/animaguru-stop-motion-objects/references/recipe.md +23 -0
- package/skills/animaguru-studio-product-reveal/SKILL.md +29 -0
- package/skills/animaguru-studio-product-reveal/references/recipe.md +23 -0
- package/skills/animaguru-video/SKILL.md +79 -0
- package/skills/animaguru-whiteboard-line-drawing/SKILL.md +34 -0
- package/skills/animaguru-whiteboard-line-drawing/references/variants.md +17 -0
- package/templates/video/AGENTS.md +34 -0
- package/templates/video/CLAUDE.md +19 -0
- package/templates/video/README.md +101 -0
- package/templates/video/VIDEO-STYLE-NOTICES.txt +54 -0
- package/templates/video/film.config.json +10 -0
- package/templates/video/gitignore +11 -0
- package/templates/video/index.html +14 -0
- package/templates/video/package.json +28 -0
- package/templates/video/public/brand/logo-mark.svg +5 -0
- package/templates/video/scripts/build.mjs +12 -0
- package/templates/video/scripts/export-html.mjs +12 -0
- package/templates/video/scripts/export-mp4.mjs +209 -0
- package/templates/video/scripts/html-export-plugin.mjs +35 -0
- package/templates/video/scripts/html-export.mjs +54 -0
- package/templates/video/scripts/install-example.mjs +32 -0
- package/templates/video/scripts/review-analysis.mjs +29 -0
- package/templates/video/scripts/review-audio.mjs +24 -0
- package/templates/video/scripts/review.mjs +37 -0
- package/templates/video/scripts/starter-film.sha256 +1 -0
- package/templates/video/shared/locales/en/export.json +10 -0
- package/templates/video/shared/locales/en/film.json +42 -0
- package/templates/video/shared/locales/en/player.json +31 -0
- package/templates/video/shared/locales/en/style-studies.json +168 -0
- package/templates/video/shared/locales/en/timeline.json +33 -0
- package/templates/video/src/assets.ts +4 -0
- package/templates/video/src/download.ts +27 -0
- package/templates/video/src/exporter.ts +70 -0
- package/templates/video/src/film-resources.ts +29 -0
- package/templates/video/src/film.ts +132 -0
- package/templates/video/src/main.ts +219 -0
- package/templates/video/src/resource-timeline.ts +193 -0
- package/templates/video/src/review.ts +50 -0
- package/templates/video/src/studies/film.ts +26 -0
- package/templates/video/src/studies/media.ts +46 -0
- package/templates/video/src/studies/model.ts +60 -0
- package/templates/video/src/studies/pixi-renderer.ts +121 -0
- package/templates/video/src/studies/scenes.ts +410 -0
- package/templates/video/src/studies/timing.ts +53 -0
- package/templates/video/src/studies/variants.ts +39 -0
- package/templates/video/src/style.css +111 -0
- package/templates/video/src/timeline-model.ts +55 -0
- package/templates/video/style-source-provenance.json +11 -0
- package/templates/video/tsconfig.json +15 -0
- package/templates/video/vite.config.mjs +9 -0
- package/vendor/pixijs-skills/LICENSE +21 -0
- package/vendor/pixijs-skills/provenance.json +79 -0
- package/vendor/pixijs-skills/skills/pixijs/SKILL.md +66 -0
- package/vendor/pixijs-skills/skills/pixijs/references/index.md +136 -0
- package/vendor/pixijs-skills/skills/pixijs-accessibility/SKILL.md +224 -0
- package/vendor/pixijs-skills/skills/pixijs-application/SKILL.md +293 -0
- package/vendor/pixijs-skills/skills/pixijs-application/references/application-options.md +314 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/SKILL.md +303 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/background.md +137 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/bundles.md +122 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/caching.md +143 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/compressed-textures.md +120 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/fonts.md +205 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/gif.md +171 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/manifests.md +175 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/progress.md +142 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/resolution.md +142 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/spritesheet.md +119 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/svg.md +132 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/video.md +158 -0
- package/vendor/pixijs-skills/skills/pixijs-blend-modes/SKILL.md +215 -0
- package/vendor/pixijs-skills/skills/pixijs-color/SKILL.md +299 -0
- package/vendor/pixijs-skills/skills/pixijs-core-concepts/SKILL.md +132 -0
- package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/render-loop.md +216 -0
- package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/renderers.md +287 -0
- package/vendor/pixijs-skills/skills/pixijs-create/SKILL.md +276 -0
- package/vendor/pixijs-skills/skills/pixijs-custom-rendering/SKILL.md +405 -0
- package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/advanced-gpu.md +244 -0
- package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/uniform-types.md +94 -0
- package/vendor/pixijs-skills/skills/pixijs-environments/SKILL.md +243 -0
- package/vendor/pixijs-skills/skills/pixijs-events/SKILL.md +387 -0
- package/vendor/pixijs-skills/skills/pixijs-filters/SKILL.md +300 -0
- package/vendor/pixijs-skills/skills/pixijs-html-source/SKILL.md +228 -0
- package/vendor/pixijs-skills/skills/pixijs-math/SKILL.md +489 -0
- package/vendor/pixijs-skills/skills/pixijs-migration-v8/SKILL.md +415 -0
- package/vendor/pixijs-skills/skills/pixijs-performance/SKILL.md +489 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-container/SKILL.md +345 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/SKILL.md +243 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/constructor-options.md +155 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/container-hierarchy.md +232 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/layers.md +145 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/masking.md +129 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/render-groups.md +140 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/scene-management.md +169 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/transforms.md +198 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-dom-container/SKILL.md +193 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-gif/SKILL.md +233 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-graphics/SKILL.md +576 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/SKILL.md +141 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-perspective.md +189 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-plane.md +159 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-rope.md +176 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-simple.md +144 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh.md +213 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-particle-container/SKILL.md +323 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/SKILL.md +120 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/animated-sprite.md +262 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/nineslice-sprite.md +202 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/sprite.md +181 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/tiling-sprite.md +216 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/SKILL.md +136 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/bitmap-text.md +232 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/html-text.md +192 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-bitmap-text.md +187 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-text.md +168 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/text.md +311 -0
- package/vendor/pixijs-skills/skills/pixijs-ticker/SKILL.md +292 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixijs-accessibility
|
|
3
|
+
description: "Use this skill when adding screen reader and keyboard navigation to PixiJS v8 apps. Covers AccessibilitySystem options (enabledByDefault, debug, activateOnTab, deactivateOnMouseMove), per-container accessibility properties, shadow DOM overlay, mobile touch-hook activation. Triggers on: accessibility, a11y, screen reader, ARIA, keyboard navigation, tab order, AccessibilitySystem, accessibleTitle, accessibleHint, tabIndex, accessibleChildren."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Enable screen reader and keyboard navigation via PixiJS's AccessibilitySystem. The system creates an invisible shadow DOM overlay positioned over accessible containers so assistive technology can discover and activate them.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const button = new Sprite(await Assets.load("button.png"));
|
|
13
|
+
button.accessible = true;
|
|
14
|
+
button.accessibleTitle = "Play game";
|
|
15
|
+
button.accessibleHint = "Starts a new game session";
|
|
16
|
+
button.eventMode = "static";
|
|
17
|
+
button.tabIndex = 0;
|
|
18
|
+
app.stage.addChild(button);
|
|
19
|
+
|
|
20
|
+
app.renderer.accessibility.setAccessibilityEnabled(true);
|
|
21
|
+
|
|
22
|
+
button.on("pointertap", () => startGame());
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Related skills:** `pixijs-events` (pointer/tap handlers), `pixijs-scene-dom-container` (HTML elements on canvas), `pixijs-application` (init options).
|
|
26
|
+
|
|
27
|
+
**Key points:**
|
|
28
|
+
|
|
29
|
+
- By default the system activates only after the user presses Tab. Set `enabledByDefault: true` in Application init for immediate activation.
|
|
30
|
+
- On mobile, the system creates a hidden touch hook; screen-reader focus activates accessibility for the whole session.
|
|
31
|
+
- The AccessibilitySystem requires the main thread; it is not available in a Web Worker.
|
|
32
|
+
|
|
33
|
+
## Core Patterns
|
|
34
|
+
|
|
35
|
+
### Container accessible properties
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { Container, Sprite } from "pixi.js";
|
|
39
|
+
|
|
40
|
+
const container = new Container();
|
|
41
|
+
container.accessible = true;
|
|
42
|
+
container.accessibleTitle = "Navigation menu";
|
|
43
|
+
container.accessibleHint = "Contains links to other pages";
|
|
44
|
+
container.eventMode = "static"; // required for custom tabIndex to apply
|
|
45
|
+
container.tabIndex = 0;
|
|
46
|
+
container.accessibleType = "div"; // defaults to 'button'
|
|
47
|
+
|
|
48
|
+
const sprite = new Sprite();
|
|
49
|
+
sprite.accessible = true;
|
|
50
|
+
sprite.accessibleTitle = "Close dialog";
|
|
51
|
+
sprite.accessibleText = "X"; // text content of the shadow div
|
|
52
|
+
sprite.eventMode = "static";
|
|
53
|
+
sprite.tabIndex = 1;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Available properties on any Container:
|
|
57
|
+
|
|
58
|
+
- `accessible` (boolean) - enables the accessible overlay div
|
|
59
|
+
- `accessibleTitle` (string) - sets the `title` attribute on the shadow div
|
|
60
|
+
- `accessibleHint` (string) - sets the `aria-label` attribute
|
|
61
|
+
- `accessibleText` (string) - sets inner text content of the shadow div
|
|
62
|
+
- `accessibleType` (string) - HTML tag for the shadow element, defaults to `'button'`
|
|
63
|
+
- `tabIndex` (number) - tab order for keyboard navigation (only applied when `interactive` is true / `eventMode` is `'static'` or `'dynamic'`)
|
|
64
|
+
- `accessibleChildren` (boolean, default `true`) - when `false`, prevents child containers from being accessible
|
|
65
|
+
- `accessiblePointerEvents` (string) - CSS `pointer-events` value on the shadow div
|
|
66
|
+
|
|
67
|
+
### Custom tab order
|
|
68
|
+
|
|
69
|
+
Give each accessible container a `tabIndex` to control the order assistive tech walks through them. Higher numbers come later; equal numbers fall back to scene-graph order.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
menuButton.accessible = true;
|
|
73
|
+
menuButton.eventMode = "static";
|
|
74
|
+
menuButton.tabIndex = 1;
|
|
75
|
+
|
|
76
|
+
playButton.accessible = true;
|
|
77
|
+
playButton.eventMode = "static";
|
|
78
|
+
playButton.tabIndex = 2;
|
|
79
|
+
|
|
80
|
+
settingsButton.accessible = true;
|
|
81
|
+
settingsButton.eventMode = "static";
|
|
82
|
+
settingsButton.tabIndex = 3;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`tabIndex` is only forwarded to the shadow div when the container is `interactive` (`eventMode` is `'static'` or `'dynamic'`). Without that, the system clamps the div's tabIndex back to `0`, and the order you set is ignored.
|
|
86
|
+
|
|
87
|
+
### Programmatic control
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { Application } from "pixi.js";
|
|
91
|
+
|
|
92
|
+
const app = new Application();
|
|
93
|
+
await app.init({ width: 800, height: 600 });
|
|
94
|
+
|
|
95
|
+
// Enable accessibility at runtime
|
|
96
|
+
app.renderer.accessibility.setAccessibilityEnabled(true);
|
|
97
|
+
|
|
98
|
+
// Check current state
|
|
99
|
+
console.log(app.renderer.accessibility.isActive);
|
|
100
|
+
console.log(app.renderer.accessibility.isMobileAccessibility);
|
|
101
|
+
|
|
102
|
+
// Full init options:
|
|
103
|
+
await app.init({
|
|
104
|
+
accessibilityOptions: {
|
|
105
|
+
enabledByDefault: true, // activate immediately (default: false)
|
|
106
|
+
debug: true, // makes overlay divs visible (default: false)
|
|
107
|
+
activateOnTab: true, // Tab key activates system (default: true)
|
|
108
|
+
deactivateOnMouseMove: false, // stay active when mouse moves (default: true)
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The system can also be configured via static defaults before creating the Application:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { AccessibilitySystem, Application } from "pixi.js";
|
|
117
|
+
|
|
118
|
+
AccessibilitySystem.defaultOptions.enabledByDefault = true;
|
|
119
|
+
AccessibilitySystem.defaultOptions.deactivateOnMouseMove = false;
|
|
120
|
+
|
|
121
|
+
const app = new Application();
|
|
122
|
+
await app.init();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Handling accessible interactions
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { Sprite } from "pixi.js";
|
|
129
|
+
|
|
130
|
+
const button = new Sprite();
|
|
131
|
+
button.eventMode = "static";
|
|
132
|
+
button.accessible = true;
|
|
133
|
+
button.accessibleTitle = "Submit form";
|
|
134
|
+
button.tabIndex = 0;
|
|
135
|
+
|
|
136
|
+
// Screen readers trigger click/tap events through the shadow DOM element
|
|
137
|
+
button.on("pointertap", () => {
|
|
138
|
+
submitForm();
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
When accessibility is active and a user activates a shadow div (via Enter/Space key or screen reader action), the system dispatches `click`, `pointertap`, and `tap` FederatedEvents to the corresponding container. Focus on the shadow div dispatches `mouseover`, and focus-out dispatches `mouseout`. Both `eventMode` and `accessible` should be set for full keyboard + pointer support.
|
|
143
|
+
|
|
144
|
+
## Common Mistakes
|
|
145
|
+
|
|
146
|
+
### [MEDIUM] Expecting accessibility to be active without Tab key press
|
|
147
|
+
|
|
148
|
+
The AccessibilitySystem does not create its DOM overlay until the user presses Tab (or, on mobile, focuses the touch hook). If your application needs accessibility immediately:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const app = new Application();
|
|
152
|
+
await app.init({
|
|
153
|
+
accessibilityOptions: {
|
|
154
|
+
enabledByDefault: true,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Or at runtime:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
app.renderer.accessibility.setAccessibilityEnabled(true);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Without one of these, automated accessibility testing tools will not find the overlay elements.
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
### [MEDIUM] Setting accessible without accessibleTitle
|
|
169
|
+
|
|
170
|
+
Wrong:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
const sprite = new Sprite();
|
|
174
|
+
sprite.accessible = true;
|
|
175
|
+
// no title or hint set
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Correct:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
const sprite = new Sprite();
|
|
182
|
+
sprite.accessible = true;
|
|
183
|
+
sprite.accessibleTitle = "Play button";
|
|
184
|
+
sprite.accessibleHint = "Click to start the game";
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
A container with `accessible = true` but no `accessibleTitle` or `accessibleHint` gets a fallback title of `"container {tabIndex}"`. Screen readers will announce this generic label with no useful context. Always provide at least `accessibleTitle`.
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
### [MEDIUM] Accessibility deactivates when moving mouse
|
|
191
|
+
|
|
192
|
+
By default, `deactivateOnMouseMove` is `true`. Any mouse movement after Tab-activation will deactivate the overlay. This is by design (assumes keyboard-only users don't use a mouse), but it makes testing with a mouse frustrating.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
await app.init({
|
|
196
|
+
accessibilityOptions: {
|
|
197
|
+
deactivateOnMouseMove: false,
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
### [MEDIUM] Not importing accessibility extension in custom builds
|
|
204
|
+
|
|
205
|
+
When using `skipExtensionImports: true` for a custom build, the accessibility extension is not automatically registered. You must import it explicitly:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import "pixi.js/accessibility";
|
|
209
|
+
import { Application } from "pixi.js";
|
|
210
|
+
|
|
211
|
+
const app = new Application();
|
|
212
|
+
await app.init({ skipExtensionImports: true });
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Without this import, `app.renderer.accessibility` will be undefined and no shadow DOM layer will be created.
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
## API Reference
|
|
219
|
+
|
|
220
|
+
- [AccessibilitySystem](https://pixijs.download/release/docs/accessibility.AccessibilitySystem.html.md)
|
|
221
|
+
- [AccessibilitySystemOptions](https://pixijs.download/release/docs/accessibility.AccessibilitySystemOptions.html.md)
|
|
222
|
+
- [AccessibilityOptions](https://pixijs.download/release/docs/accessibility.AccessibilityOptions.html.md)
|
|
223
|
+
- [AccessibleOptions](https://pixijs.download/release/docs/accessibility.AccessibleOptions.html.md)
|
|
224
|
+
- [PointerEvents](https://pixijs.download/release/docs/accessibility.PointerEvents.html.md)
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixijs-application
|
|
3
|
+
description: "Use this skill when creating and configuring a PixiJS v8 Application. Covers new Application() + async app.init() options (width, height, background, antialias, resolution, autoDensity, preference, resizeTo, autoStart, sharedTicker, canvas, useBackBuffer, powerPreference, eventFeatures, accessibilityOptions, gcActive, bezierSmoothness, webgl/webgpu/canvasOptions per-renderer overrides), app.stage/renderer/canvas/screen/domContainerRoot access, ResizePlugin, TickerPlugin, CullerPlugin (cullable, cullArea), custom ApplicationPlugin via ExtensionType.Application, start/stop lifecycle, and app.destroy() with releaseGlobalResources. Triggers on: Application, app.init, app.stage, app.renderer, app.canvas, app.screen, app.domContainerRoot, ApplicationOptions, ApplicationPlugin, ExtensionType.Application, resizeTo, sharedTicker, skipExtensionImports, preferWebGLVersion, preserveDrawingBuffer, cullable, CullerPlugin, app.start, app.stop, app.destroy, releaseGlobalResources."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`Application` is the convenience wrapper that owns a renderer, a root `stage` Container, a canvas, and the Ticker/Resize plugins. In v8 the constructor takes no arguments; all configuration is passed to the async `app.init()` call which instantiates the renderer via `autoDetectRenderer`.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Application } from "pixi.js";
|
|
13
|
+
|
|
14
|
+
const app = new Application();
|
|
15
|
+
|
|
16
|
+
await app.init({
|
|
17
|
+
resizeTo: window,
|
|
18
|
+
background: "#1099bb",
|
|
19
|
+
antialias: true,
|
|
20
|
+
preference: "webgl",
|
|
21
|
+
autoDensity: true,
|
|
22
|
+
resolution: window.devicePixelRatio,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
document.body.appendChild(app.canvas);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Related skills:** `pixijs-core-concepts` (renderers, render pipeline), `pixijs-ticker` (render loop detail), `pixijs-scene-container` (working with `app.stage`), `pixijs-environments` (non-browser setups).
|
|
29
|
+
|
|
30
|
+
## Core Patterns
|
|
31
|
+
|
|
32
|
+
### Lifecycle: construct, init, render, destroy
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { Application } from "pixi.js";
|
|
36
|
+
|
|
37
|
+
const app = new Application();
|
|
38
|
+
|
|
39
|
+
await app.init({ width: 800, height: 600 });
|
|
40
|
+
document.body.appendChild(app.canvas);
|
|
41
|
+
|
|
42
|
+
// ... run scene, ticker drives app.render() automatically ...
|
|
43
|
+
|
|
44
|
+
app.destroy(
|
|
45
|
+
{ removeView: true, releaseGlobalResources: true },
|
|
46
|
+
{ children: true, texture: true, textureSource: true },
|
|
47
|
+
);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- `new Application()` allocates the instance but creates nothing. Options passed here are ignored with a v8 deprecation warning.
|
|
51
|
+
- `app.init(options)` is async. It builds the renderer, wires up plugins, and must complete before you can use `app.canvas`, `app.renderer`, or `app.screen`.
|
|
52
|
+
- The TickerPlugin calls `app.render()` every frame once init resolves (unless `autoStart: false`).
|
|
53
|
+
- `app.destroy(rendererDestroyOptions, stageDestroyOptions)` — the first argument forwards to `renderer.destroy()`. Pass `true` or `{ removeView: true }` to remove the canvas from the DOM. Add `releaseGlobalResources: true` to drain global pools (batches, texture caches) when tearing down and re-creating an app in the same tab; omitting it is the usual cause of flickering and stale textures after a re-init (see `pixijs-performance`).
|
|
54
|
+
|
|
55
|
+
### Key init options
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
await app.init({
|
|
59
|
+
width: 800,
|
|
60
|
+
height: 600,
|
|
61
|
+
background: 0x1099bb,
|
|
62
|
+
backgroundAlpha: 1,
|
|
63
|
+
|
|
64
|
+
antialias: true,
|
|
65
|
+
resolution: window.devicePixelRatio,
|
|
66
|
+
autoDensity: true,
|
|
67
|
+
|
|
68
|
+
preference: "webgpu",
|
|
69
|
+
|
|
70
|
+
autoStart: true,
|
|
71
|
+
sharedTicker: false,
|
|
72
|
+
|
|
73
|
+
resizeTo: window,
|
|
74
|
+
|
|
75
|
+
canvas: document.querySelector("#game-canvas") as HTMLCanvasElement,
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For every option — view/canvas, background, renderer preference (including the array form), ticker, resize, culler, events, accessibility, WebGL/WebGPU context flags, Graphics bezier smoothness, GC, and per-renderer overrides (`webgl` / `webgpu` / `canvasOptions`) — see [references/application-options.md](references/application-options.md).
|
|
80
|
+
|
|
81
|
+
### Application properties
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
app.stage; // root Container; add all display objects here
|
|
85
|
+
app.renderer; // the WebGL/WebGPU/Canvas renderer instance
|
|
86
|
+
app.canvas; // the HTMLCanvasElement (insert it into the DOM yourself)
|
|
87
|
+
app.screen; // Rectangle describing the visible area in CSS pixels
|
|
88
|
+
app.domContainerRoot; // HTMLDivElement that holds DOMContainer overlays
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`app.stage` is a plain `Container`. For scene graph detail (transforms, addChild, destroy) see `pixijs-scene-container`. For renderer-level operations (extract, generateTexture, custom systems) see `pixijs-core-concepts` and `pixijs-custom-rendering`. `app.domContainerRoot` is the `<div>` that the renderer uses to host `DOMContainer` overlays; append it next to `app.canvas` when you need DOM elements pinned to scene nodes (see `pixijs-scene-dom-container`).
|
|
92
|
+
|
|
93
|
+
### ResizePlugin
|
|
94
|
+
|
|
95
|
+
Set `resizeTo` at init (or reassign `app.resizeTo` later) to have the plugin listen for the `resize` event and call `renderer.resize()` with the target element's client size. Combine with `autoDensity: true` and `resolution: window.devicePixelRatio` for high-DPI output.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
await app.init({ resizeTo: window });
|
|
99
|
+
|
|
100
|
+
app.resizeTo = document.querySelector("#game-container") as HTMLElement;
|
|
101
|
+
|
|
102
|
+
app.resize(); // immediate resize to the target's current size
|
|
103
|
+
app.queueResize(); // defer the resize to the next animation frame
|
|
104
|
+
app.cancelResize(); // drop a pending queueResize
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The plugin keeps the canvas matched to the target. `app.screen` and `app.canvas.width/height` update in response; read them after the resize to place UI.
|
|
108
|
+
|
|
109
|
+
- `app.resize()` — immediate synchronous resize.
|
|
110
|
+
- `app.queueResize()` — coalesces rapid calls by deferring to the next frame; internally used by the `window.resize` listener to avoid redundant work.
|
|
111
|
+
- `app.cancelResize()` — cancels a queued resize. Call this before tearing down your own layout code that triggered `queueResize`.
|
|
112
|
+
|
|
113
|
+
### Ticker basics
|
|
114
|
+
|
|
115
|
+
The TickerPlugin creates `app.ticker` and registers `app.render()` on it at `UPDATE_PRIORITY.LOW`. Control the loop with `app.start()`/`app.stop()` and add callbacks with `app.ticker.add` / `app.ticker.addOnce`:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
app.ticker.add((ticker) => {
|
|
119
|
+
sprite.rotation += 0.01 * ticker.deltaTime;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
app.ticker.addOnce(() => {
|
|
123
|
+
console.log("runs once on the next frame, then removes itself");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
app.stop(); // pause the render loop (e.g. tab hidden)
|
|
127
|
+
app.start(); // resume
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The callback receives the `Ticker` instance; read `ticker.deltaTime` for a frame-rate-independent multiplier (~1.0 at 60fps), `ticker.deltaMS` for real milliseconds, or `ticker.FPS` for the current frame rate. See `pixijs-ticker` for priorities, FPS capping, `onRender`, shared vs private tickers, and the v8 callback signature change.
|
|
131
|
+
|
|
132
|
+
### Manual render loop
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
await app.init({ autoStart: false, width: 800, height: 600 });
|
|
136
|
+
document.body.appendChild(app.canvas);
|
|
137
|
+
|
|
138
|
+
function frame() {
|
|
139
|
+
updateScene();
|
|
140
|
+
app.render();
|
|
141
|
+
requestAnimationFrame(frame);
|
|
142
|
+
}
|
|
143
|
+
frame();
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`autoStart: false` prevents the TickerPlugin from starting the ticker automatically. Call `app.render()` yourself (or `app.renderer.render({ container: app.stage })` for the same effect). If you still want registered ticker callbacks to fire, call `app.ticker.update()` inside your loop before `app.render()`.
|
|
147
|
+
|
|
148
|
+
### CullerPlugin (opt-in)
|
|
149
|
+
|
|
150
|
+
The CullerPlugin skips rendering containers that fall outside `app.renderer.screen`. It isn't registered by default; add it before creating your app:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import {
|
|
154
|
+
Application,
|
|
155
|
+
Container,
|
|
156
|
+
Sprite,
|
|
157
|
+
extensions,
|
|
158
|
+
CullerPlugin,
|
|
159
|
+
Rectangle,
|
|
160
|
+
} from "pixi.js";
|
|
161
|
+
|
|
162
|
+
extensions.add(CullerPlugin);
|
|
163
|
+
|
|
164
|
+
const app = new Application();
|
|
165
|
+
await app.init({ width: 800, height: 600 });
|
|
166
|
+
|
|
167
|
+
const world = new Container();
|
|
168
|
+
world.cullable = true; // this container is culled when its bounds leave the screen
|
|
169
|
+
world.cullableChildren = true; // default; set `false` to skip recursing into children
|
|
170
|
+
|
|
171
|
+
const tile = Sprite.from("tile.png");
|
|
172
|
+
tile.cullable = true;
|
|
173
|
+
world.addChild(tile);
|
|
174
|
+
app.stage.addChild(world);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Containers are not culled unless `cullable` is set. Override the default bounds check with `container.cullArea = new Rectangle(x, y, w, h)` when child bounds are expensive to compute. The plugin wraps `app.render()` so `Culler.shared.cull(app.stage, app.renderer.screen)` runs before every frame. See `pixijs-performance` for when culling pays off.
|
|
178
|
+
|
|
179
|
+
### Custom Application plugins
|
|
180
|
+
|
|
181
|
+
Extend `Application` by registering a class with `static init`, `static destroy`, and `static extension = ExtensionType.Application`. Both methods are called with `this` bound to the Application instance, so `this.renderer` and `this.stage` are available.
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import {
|
|
185
|
+
Application,
|
|
186
|
+
ExtensionType,
|
|
187
|
+
extensions,
|
|
188
|
+
type ApplicationOptions,
|
|
189
|
+
} from "pixi.js";
|
|
190
|
+
|
|
191
|
+
class FpsOverlay {
|
|
192
|
+
public static extension = ExtensionType.Application;
|
|
193
|
+
|
|
194
|
+
public static init(this: Application, options: Partial<ApplicationOptions>) {
|
|
195
|
+
// runs inside app.init() after the renderer is created
|
|
196
|
+
// attach props/methods to `this` to expose them on the app
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public static destroy(this: Application) {
|
|
200
|
+
// runs inside app.destroy() — tear down anything you attached
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
extensions.add(FpsOverlay);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Plugins initialize in registration order and destroy in reverse. To add typed options for your plugin, extend `PixiMixins.ApplicationOptions`:
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
declare global {
|
|
211
|
+
namespace PixiMixins {
|
|
212
|
+
interface ApplicationOptions {
|
|
213
|
+
fpsOverlay?: { visible?: boolean };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
await app.init({ fpsOverlay: { visible: true } });
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The built-in `ResizePlugin`, `TickerPlugin`, and opt-in `CullerPlugin` all use this same contract. If you set `skipExtensionImports: true`, register the built-ins you need yourself (`extensions.add(ResizePlugin, TickerPlugin)`).
|
|
222
|
+
|
|
223
|
+
## Common Mistakes
|
|
224
|
+
|
|
225
|
+
### [CRITICAL] Passing options to the constructor
|
|
226
|
+
|
|
227
|
+
Wrong:
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
const app = new Application({ width: 800, height: 600 });
|
|
231
|
+
document.body.appendChild(app.canvas);
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Correct:
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
const app = new Application();
|
|
238
|
+
await app.init({ width: 800, height: 600 });
|
|
239
|
+
document.body.appendChild(app.canvas);
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
In v8 the `Application` constructor takes no arguments. Options passed there are ignored and log a deprecation warning; the renderer is only created inside the async `init()` call.
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
### [HIGH] Using app.view instead of app.canvas
|
|
246
|
+
|
|
247
|
+
Wrong:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
document.body.appendChild(app.view);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Correct:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
document.body.appendChild(app.canvas);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`app.view` was renamed to `app.canvas` in v8. The old getter still works but emits a deprecation warning.
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
### [MEDIUM] Touching app.canvas or app.renderer before init resolves
|
|
263
|
+
|
|
264
|
+
Wrong:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const app = new Application();
|
|
268
|
+
document.body.appendChild(app.canvas);
|
|
269
|
+
app.init({ width: 800, height: 600 });
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Correct:
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
const app = new Application();
|
|
276
|
+
await app.init({ width: 800, height: 600 });
|
|
277
|
+
document.body.appendChild(app.canvas);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
`app.renderer`, `app.canvas`, and `app.screen` are only populated once the `init()` promise resolves. Accessing them earlier returns `undefined`.
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
## API Reference
|
|
284
|
+
|
|
285
|
+
- [Application](https://pixijs.download/release/docs/app.Application.html.md)
|
|
286
|
+
- [ApplicationOptions](https://pixijs.download/release/docs/app.ApplicationOptions.html.md)
|
|
287
|
+
- [ApplicationPlugin](https://pixijs.download/release/docs/app.ApplicationPlugin.html.md)
|
|
288
|
+
- [ResizePlugin](https://pixijs.download/release/docs/app.ResizePlugin.html.md)
|
|
289
|
+
- [ResizePluginOptions](https://pixijs.download/release/docs/app.ResizePluginOptions.html.md)
|
|
290
|
+
- [TickerPlugin](https://pixijs.download/release/docs/app.TickerPlugin.html.md)
|
|
291
|
+
- [TickerPluginOptions](https://pixijs.download/release/docs/app.TickerPluginOptions.html.md)
|
|
292
|
+
- [CullerPlugin](https://pixijs.download/release/docs/app.CullerPlugin.html.md)
|
|
293
|
+
- [autoDetectRenderer](https://pixijs.download/release/docs/rendering.autoDetectRenderer.html.md)
|