@datamoc/mw_games 0.41.0 → 0.43.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 (160) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +62 -1
  3. package/REFERENCE.md +73 -8
  4. package/api-surface.json +696 -0
  5. package/data/microgm-essential.PROVENANCE.md +13 -0
  6. package/data/microgm-essential.sf2 +0 -0
  7. package/data/soundfont-catalog.json +8 -0
  8. package/dist/audio/AudioLoader.d.ts +28 -0
  9. package/dist/audio/AudioLoader.d.ts.map +1 -0
  10. package/dist/audio/AudioLoader.js +53 -0
  11. package/dist/audio/AudioLoader.js.map +1 -0
  12. package/dist/audio/Channels.d.ts +1 -0
  13. package/dist/audio/Channels.d.ts.map +1 -1
  14. package/dist/audio/Channels.js +2 -1
  15. package/dist/audio/Channels.js.map +1 -1
  16. package/dist/audio/MidiRender.d.ts +19 -1
  17. package/dist/audio/MidiRender.d.ts.map +1 -1
  18. package/dist/audio/MidiRender.js +24 -1
  19. package/dist/audio/MidiRender.js.map +1 -1
  20. package/dist/audio/MusicPlayer.d.ts +80 -0
  21. package/dist/audio/MusicPlayer.d.ts.map +1 -0
  22. package/dist/audio/MusicPlayer.js +147 -0
  23. package/dist/audio/MusicPlayer.js.map +1 -0
  24. package/dist/audio/SampleDecoder.d.ts +16 -2
  25. package/dist/audio/SampleDecoder.d.ts.map +1 -1
  26. package/dist/audio/SampleDecoder.js +10 -6
  27. package/dist/audio/SampleDecoder.js.map +1 -1
  28. package/dist/audio/Sound.d.ts +2 -0
  29. package/dist/audio/Sound.d.ts.map +1 -1
  30. package/dist/audio/Sound.js +3 -0
  31. package/dist/audio/Sound.js.map +1 -1
  32. package/dist/audio/SoundFont.d.ts +40 -5
  33. package/dist/audio/SoundFont.d.ts.map +1 -1
  34. package/dist/audio/SoundFont.js +52 -14
  35. package/dist/audio/SoundFont.js.map +1 -1
  36. package/dist/audio/Synth.d.ts +1 -1
  37. package/dist/audio/Synth.d.ts.map +1 -1
  38. package/dist/audio/Synth.js +4 -0
  39. package/dist/audio/Synth.js.map +1 -1
  40. package/dist/audio/index.d.ts +8 -4
  41. package/dist/audio/index.d.ts.map +1 -1
  42. package/dist/audio/index.js +4 -2
  43. package/dist/audio/index.js.map +1 -1
  44. package/dist/core/DialogueText.d.ts +25 -0
  45. package/dist/core/DialogueText.d.ts.map +1 -1
  46. package/dist/core/DialogueText.js +25 -0
  47. package/dist/core/DialogueText.js.map +1 -1
  48. package/dist/core/Motion.d.ts +20 -0
  49. package/dist/core/Motion.d.ts.map +1 -1
  50. package/dist/core/Motion.js +20 -0
  51. package/dist/core/Motion.js.map +1 -1
  52. package/dist/core/Save.d.ts +31 -0
  53. package/dist/core/Save.d.ts.map +1 -1
  54. package/dist/core/Save.js +31 -0
  55. package/dist/core/Save.js.map +1 -1
  56. package/dist/core/Twee.d.ts +34 -0
  57. package/dist/core/Twee.d.ts.map +1 -1
  58. package/dist/core/Twee.js +34 -0
  59. package/dist/core/Twee.js.map +1 -1
  60. package/dist/mw_games.global.js +22 -22
  61. package/dist/mwl/index.d.ts +2 -0
  62. package/dist/mwl/index.d.ts.map +1 -1
  63. package/dist/mwl/index.js +1 -0
  64. package/dist/mwl/index.js.map +1 -1
  65. package/dist/mwl/objects.d.ts +31 -0
  66. package/dist/mwl/objects.d.ts.map +1 -0
  67. package/dist/mwl/objects.js +83 -0
  68. package/dist/mwl/objects.js.map +1 -0
  69. package/dist/mwl/schema.d.ts +1 -1
  70. package/dist/mwl/schema.d.ts.map +1 -1
  71. package/dist/mwl/tables.d.ts +2 -0
  72. package/dist/mwl/tables.d.ts.map +1 -1
  73. package/dist/mwl/tables.js +13 -0
  74. package/dist/mwl/tables.js.map +1 -1
  75. package/dist/physics/XpbdWorld.d.ts +68 -5
  76. package/dist/physics/XpbdWorld.d.ts.map +1 -1
  77. package/dist/physics/XpbdWorld.js +135 -6
  78. package/dist/physics/XpbdWorld.js.map +1 -1
  79. package/dist/testing/index.d.ts +16 -0
  80. package/dist/testing/index.d.ts.map +1 -1
  81. package/dist/testing/index.js +21 -0
  82. package/dist/testing/index.js.map +1 -1
  83. package/dist/three-d/Collision3D.d.ts +46 -2
  84. package/dist/three-d/Collision3D.d.ts.map +1 -1
  85. package/dist/three-d/Collision3D.js +46 -2
  86. package/dist/three-d/Collision3D.js.map +1 -1
  87. package/dist/three-d/Grid.d.ts +12 -1
  88. package/dist/three-d/Grid.d.ts.map +1 -1
  89. package/dist/three-d/Grid.js +12 -1
  90. package/dist/three-d/Grid.js.map +1 -1
  91. package/dist/three-d/Vox.d.ts +13 -1
  92. package/dist/three-d/Vox.d.ts.map +1 -1
  93. package/dist/three-d/Vox.js +13 -1
  94. package/dist/three-d/Vox.js.map +1 -1
  95. package/dist/two-d/Game.d.ts +21 -1
  96. package/dist/two-d/Game.d.ts.map +1 -1
  97. package/dist/two-d/Game.js +73 -6
  98. package/dist/two-d/Game.js.map +1 -1
  99. package/dist/two-d/Scene2D.d.ts +24 -0
  100. package/dist/two-d/Scene2D.d.ts.map +1 -1
  101. package/dist/two-d/Scene2D.js +30 -0
  102. package/dist/two-d/Scene2D.js.map +1 -1
  103. package/dist/two-d/render/SceneTransition.d.ts +272 -0
  104. package/dist/two-d/render/SceneTransition.d.ts.map +1 -0
  105. package/dist/two-d/render/SceneTransition.js +431 -0
  106. package/dist/two-d/render/SceneTransition.js.map +1 -0
  107. package/dist/two-d/render/index.d.ts +2 -0
  108. package/dist/two-d/render/index.d.ts.map +1 -1
  109. package/dist/two-d/render/index.js +1 -0
  110. package/dist/two-d/render/index.js.map +1 -1
  111. package/dist/two-d/ui/Button.d.ts +23 -0
  112. package/dist/two-d/ui/Button.d.ts.map +1 -1
  113. package/dist/two-d/ui/Button.js +37 -0
  114. package/dist/two-d/ui/Button.js.map +1 -1
  115. package/dist/two-d/ui/DropdownView.d.ts +49 -3
  116. package/dist/two-d/ui/DropdownView.d.ts.map +1 -1
  117. package/dist/two-d/ui/DropdownView.js +150 -9
  118. package/dist/two-d/ui/DropdownView.js.map +1 -1
  119. package/dist/two-d/ui/ScrollBox.d.ts +90 -0
  120. package/dist/two-d/ui/ScrollBox.d.ts.map +1 -1
  121. package/dist/two-d/ui/ScrollBox.js +206 -4
  122. package/dist/two-d/ui/ScrollBox.js.map +1 -1
  123. package/dist/two-d/ui/ScrollText.d.ts +122 -0
  124. package/dist/two-d/ui/ScrollText.d.ts.map +1 -0
  125. package/dist/two-d/ui/ScrollText.js +202 -0
  126. package/dist/two-d/ui/ScrollText.js.map +1 -0
  127. package/dist/two-d/ui/Tooltip.d.ts +70 -1
  128. package/dist/two-d/ui/Tooltip.d.ts.map +1 -1
  129. package/dist/two-d/ui/Tooltip.js +115 -3
  130. package/dist/two-d/ui/Tooltip.js.map +1 -1
  131. package/dist/two-d/ui/Window.d.ts +35 -2
  132. package/dist/two-d/ui/Window.d.ts.map +1 -1
  133. package/dist/two-d/ui/Window.js +58 -3
  134. package/dist/two-d/ui/Window.js.map +1 -1
  135. package/dist/two-d/ui/index.d.ts +7 -5
  136. package/dist/two-d/ui/index.d.ts.map +1 -1
  137. package/dist/two-d/ui/index.js +3 -2
  138. package/dist/two-d/ui/index.js.map +1 -1
  139. package/dist/two-d/ui/theme.d.ts +18 -0
  140. package/dist/two-d/ui/theme.d.ts.map +1 -1
  141. package/dist/two-d/ui/theme.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +14 -3
  145. package/sbom.cdx.json +462 -243
  146. package/tools/browser-driver.mjs +3 -3
  147. package/tools/browser-smoke.mjs +19 -2
  148. package/tools/build-tablebases.mjs +7 -3
  149. package/tools/compile-openings.mjs +7 -3
  150. package/tools/compile-resources.d.mts +8 -0
  151. package/tools/compile-resources.mjs +62 -14
  152. package/tools/emit-page.d.mts +9 -0
  153. package/tools/emit-page.mjs +57 -4
  154. package/tools/find-chrome.mjs +4 -2
  155. package/tools/init.mjs +11 -3
  156. package/tools/play-uci.mjs +9 -5
  157. package/tools/svg-optimise.d.mts +8 -0
  158. package/tools/svg-optimise.mjs +45 -0
  159. package/tools/vite.mjs +10 -1
  160. package/tools.md +5 -2
@@ -1,5 +1,6 @@
1
1
  import { Scene } from '../core/Scene.ts';
2
2
  import type { Container2D } from './render/Types2D.ts';
3
+ import type { TransitionOptions } from './render/SceneTransition.ts';
3
4
  /**
4
5
  * A scene that draws through Pixi: `core.Scene`'s lifecycle plus the container everything
5
6
  * this screen shows hangs off.
@@ -13,6 +14,29 @@ import type { Container2D } from './render/Types2D.ts';
13
14
  export declare abstract class Scene2D extends Scene {
14
15
  /** everything this scene draws hangs off here */
15
16
  readonly stage: Container2D;
17
+ /**
18
+ * Replaces what this scene shows under a transition: the current picture is photographed, `swap`
19
+ * changes the content (a new level, decor, layout), and the transition plays over the result.
20
+ * Without a running `Game` (a test) `swap` just runs.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { Scene2D } from '@datamoc/mw_games/two-d';
25
+ * import { tileShrink } from '@datamoc/mw_games/two-d/render';
26
+ *
27
+ * class Levels extends Scene2D {
28
+ * override create(): void {}
29
+ * private level = 1;
30
+ * next(): void {
31
+ * this.transitionTo(() => this.load(++this.level), { transition: tileShrink({ columns: 8, rows: 5 }), duration: 0.6 });
32
+ * }
33
+ * private load(level: number): void {
34
+ * console.log('loading level', level);
35
+ * }
36
+ * }
37
+ * ```
38
+ */
39
+ transitionTo(swap: () => void, options: TransitionOptions): void;
16
40
  protected teardown(): void;
17
41
  }
18
42
  export type Scene2DClass = new () => Scene2D;
@@ -1 +1 @@
1
- {"version":3,"file":"Scene2D.d.ts","sourceRoot":"","sources":["../../src/two-d/Scene2D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;GASG;AACH,8BAAsB,OAAQ,SAAQ,KAAK;IAC1C,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAmB;IAE9C,UAAmB,QAAQ,IAAI,IAAI,CAElC;CACD;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,OAAO,CAAC"}
1
+ {"version":3,"file":"Scene2D.d.ts","sourceRoot":"","sources":["../../src/two-d/Scene2D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;;;;;;GASG;AACH,8BAAsB,OAAQ,SAAQ,KAAK;IAC1C,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAmB;IAE9C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAI/D;IAED,UAAmB,QAAQ,IAAI,IAAI,CAElC;CACD;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,OAAO,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { Container } from 'pixi.js';
2
2
  import { Scene } from '../core/Scene.js';
3
+ import { Game } from './Game.js';
3
4
  /**
4
5
  * A scene that draws through Pixi: `core.Scene`'s lifecycle plus the container everything
5
6
  * this screen shows hangs off.
@@ -16,6 +17,35 @@ export class Scene2D extends Scene {
16
17
  /** everything this scene draws hangs off here */
17
18
  this.stage = new Container();
18
19
  }
20
+ /**
21
+ * Replaces what this scene shows under a transition: the current picture is photographed, `swap`
22
+ * changes the content (a new level, decor, layout), and the transition plays over the result.
23
+ * Without a running `Game` (a test) `swap` just runs.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { Scene2D } from '@datamoc/mw_games/two-d';
28
+ * import { tileShrink } from '@datamoc/mw_games/two-d/render';
29
+ *
30
+ * class Levels extends Scene2D {
31
+ * override create(): void {}
32
+ * private level = 1;
33
+ * next(): void {
34
+ * this.transitionTo(() => this.load(++this.level), { transition: tileShrink({ columns: 8, rows: 5 }), duration: 0.6 });
35
+ * }
36
+ * private load(level: number): void {
37
+ * console.log('loading level', level);
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ transitionTo(swap, options) {
43
+ const game = Game.active;
44
+ if (game)
45
+ game.transition(swap, options);
46
+ else
47
+ swap();
48
+ }
19
49
  teardown() {
20
50
  this.stage.destroy({ children: true });
21
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Scene2D.js","sourceRoot":"","sources":["../../src/two-d/Scene2D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC;;;;;;;;;GASG;AACH,MAAM,OAAgB,OAAQ,SAAQ,KAAK;IAA3C;;QACC,iDAAiD;QACxC,UAAK,GAAgB,IAAI,SAAS,EAAE,CAAC;IAK/C,CAAC;IAHmB,QAAQ;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;CACD"}
1
+ {"version":3,"file":"Scene2D.js","sourceRoot":"","sources":["../../src/two-d/Scene2D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC;;;;;;;;;GASG;AACH,MAAM,OAAgB,OAAQ,SAAQ,KAAK;IAA3C;;QACC,iDAAiD;QACxC,UAAK,GAAgB,IAAI,SAAS,EAAE,CAAC;IAiC/C,CAAC;IA/BA;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,CAAC,IAAgB,EAAE,OAA0B;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,IAAI,IAAI;YAAE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;YACpC,IAAI,EAAE,CAAC;IACb,CAAC;IAEkB,QAAQ;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;CACD"}
@@ -0,0 +1,272 @@
1
+ import { Easing, type Easing as EasingFunction } from '../../core/Tween.ts';
2
+ import type { Container2D, Texture2D } from './Types2D.ts';
3
+ /**
4
+ * Screen transitions: how one picture hands over to the next. `Game.switchScene(Next, { transition })`
5
+ * photographs the outgoing scene, starts the new one underneath and animates the photograph away
6
+ * (`tileShrink`, `slide`, `dissolve`, `shrink`) or grows the new scene over it (`pop`, `grow`, `iris`).
7
+ * `Scene2D.transitionTo(swap, options)` does the same for a scene that replaces its own content.
8
+ *
9
+ * Each transition is a small factory: `start(context)` builds what it needs from the outgoing
10
+ * `snapshot` and the `incoming` container and returns a runtime whose `update(progress)` is called
11
+ * with eased progress from 0 to 1. The geometry (`tileDelays`, `tileProgress`, `popScale`) is plain
12
+ * functions, so a transition's timing is testable without drawing it.
13
+ */
14
+ /** what a transition is given to work with */
15
+ export interface TransitionContext {
16
+ /** the size of the screen in logical pixels */
17
+ width: number;
18
+ height: number;
19
+ /** a picture of the outgoing scene, or null when there was none to photograph */
20
+ snapshot: Texture2D | null;
21
+ /** the new scene, in a container the transition may move, scale, fade or mask */
22
+ incoming: Container2D;
23
+ /** drawn beneath `incoming`: the old picture, for a transition that grows the new scene over it */
24
+ under: Container2D;
25
+ /** drawn over `incoming`: the old picture, for a transition that takes it away */
26
+ over: Container2D;
27
+ }
28
+ export interface TransitionRuntime {
29
+ /** @param progress eased, 0 at the start and 1 at the end */
30
+ update(progress: number): void;
31
+ /** removes whatever the transition added, leaving `incoming` as it found it */
32
+ destroy(): void;
33
+ }
34
+ export interface SceneTransition {
35
+ readonly name: string;
36
+ start(context: TransitionContext): TransitionRuntime;
37
+ }
38
+ /** how a transition is run; `transition` is the only required part */
39
+ export interface TransitionOptions {
40
+ transition: SceneTransition;
41
+ /** seconds, counted in real time; 0.5 when omitted. Reduced motion skips the transition entirely */
42
+ duration?: number;
43
+ /** a name from `Easing` or a function of progress; `easeInOutQuad` when omitted */
44
+ easing?: keyof typeof Easing | EasingFunction;
45
+ /** hold the scene still while the transition plays; false when omitted */
46
+ pause?: boolean;
47
+ /** runs once, the frame the transition ends */
48
+ onDone?: () => void;
49
+ }
50
+ /** where a transition starts from or aims at, in screen pixels; the screen's centre when omitted */
51
+ export interface TransitionPoint {
52
+ x: number;
53
+ y: number;
54
+ }
55
+ export type TileOrder = 'diagonal' | 'random' | 'spiral' | 'rows';
56
+ /**
57
+ * When each tile of a `columns` by `rows` grid starts, from 0 (first) to 1 (last), in row-major order.
58
+ * `diagonal` sweeps from the top left, `spiral` from the outside in, `rows` top to bottom, and
59
+ * `random` is a fixed shuffle for a given `seed`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * import { tileDelays } from '@datamoc/mw_games/two-d/render';
64
+ *
65
+ * console.log(tileDelays(3, 2, 'diagonal')); // [0, 1/3, 2/3, 1/3, 2/3, 1]
66
+ * ```
67
+ */
68
+ export declare function tileDelays(columns: number, rows: number, order?: TileOrder, seed?: number): number[];
69
+ /**
70
+ * One tile's progress when the whole transition is at `progress`: tiles start spread across the first
71
+ * `stagger` of the time, according to their `delay` from `tileDelays`, and each then takes the rest
72
+ * of it, so the last tile finishes exactly as the transition does.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { tileProgress } from '@datamoc/mw_games/two-d/render';
77
+ *
78
+ * console.log(tileProgress(0, 0.5, 0.5)); // 1: the first tile is already done
79
+ * console.log(tileProgress(1, 0.5, 0.5)); // 0: the last one has not started
80
+ * ```
81
+ */
82
+ export declare function tileProgress(delay: number, progress: number, stagger: number): number;
83
+ /**
84
+ * The scale of something that pops in: 0 growing past 1 to `overshoot`, then settling on 1.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { popScale } from '@datamoc/mw_games/two-d/render';
89
+ *
90
+ * console.log(popScale(0)); // 0
91
+ * console.log(popScale(0.7)); // 1.08, the peak
92
+ * console.log(popScale(1)); // 1
93
+ * ```
94
+ */
95
+ export declare function popScale(progress: number, overshoot?: number): number;
96
+ /**
97
+ * the `Easing` function for a name or a function, defaulting to `easeInOutQuad`
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { resolveEasing } from '@datamoc/mw_games/two-d/render';
102
+ *
103
+ * console.log(resolveEasing('linear')(0.25)); // 0.25
104
+ * console.log(resolveEasing((t) => t * t)(0.5)); // 0.25
105
+ * ```
106
+ */
107
+ export declare function resolveEasing(easing: TransitionOptions['easing']): EasingFunction;
108
+ export interface TileShrinkOptions {
109
+ columns?: number;
110
+ rows?: number;
111
+ /** the part of the duration over which tiles start, 0 to 1; 0.5 when omitted */
112
+ stagger?: number;
113
+ order?: TileOrder;
114
+ /** how far each tile turns while it shrinks, in radians; 0 when omitted */
115
+ rotation?: number;
116
+ seed?: number;
117
+ }
118
+ /**
119
+ * The old picture cut into tiles that each shrink to nothing, in `order`, uncovering the new scene.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { tileShrink } from '@datamoc/mw_games/two-d/render';
124
+ *
125
+ * const transition = tileShrink({ columns: 8, rows: 5, order: 'diagonal' });
126
+ * // Game.current.switchScene(NextLevel, { transition, duration: 0.6 });
127
+ * console.log(transition.name); // 'tileShrink'
128
+ * ```
129
+ */
130
+ export declare function tileShrink(options?: TileShrinkOptions): SceneTransition;
131
+ /**
132
+ * The old picture shrinking to a point (the screen's centre unless `to` names one) over the new scene.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * import { shrink } from '@datamoc/mw_games/two-d/render';
137
+ *
138
+ * const closeToButton = shrink({ to: { x: 700, y: 40 } });
139
+ * console.log(closeToButton.name); // 'shrink'
140
+ * ```
141
+ */
142
+ export declare function shrink(options?: {
143
+ to?: TransitionPoint;
144
+ }): SceneTransition;
145
+ /**
146
+ * The new scene springing out of a point (the centre unless `from` names one), overshooting a little
147
+ * (`overshoot`, 1.08 when omitted) before it settles.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { pop } from '@datamoc/mw_games/two-d/render';
152
+ *
153
+ * console.log(pop({ from: { x: 400, y: 300 } }).name); // 'pop'
154
+ * ```
155
+ */
156
+ export declare function pop(options?: {
157
+ from?: TransitionPoint;
158
+ overshoot?: number;
159
+ }): SceneTransition;
160
+ /**
161
+ * The new scene growing from a point (the centre unless `from` names one) without overshoot.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import { grow } from '@datamoc/mw_games/two-d/render';
166
+ *
167
+ * console.log(grow().name); // 'grow'
168
+ * ```
169
+ */
170
+ export declare function grow(options?: {
171
+ from?: TransitionPoint;
172
+ }): SceneTransition;
173
+ /**
174
+ * Old and new pictures sliding together: the new one enters from the `direction` side while the old
175
+ * one leaves the other way.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * import { slide } from '@datamoc/mw_games/two-d/render';
180
+ *
181
+ * console.log(slide({ direction: 'left' }).name); // 'slide'
182
+ * ```
183
+ */
184
+ export declare function slide(options?: {
185
+ direction?: 'left' | 'right' | 'up' | 'down';
186
+ }): SceneTransition;
187
+ /**
188
+ * A circle opening from a point (the centre unless `from` names one) that shows the new scene
189
+ * through it, the old picture around it.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * import { iris } from '@datamoc/mw_games/two-d/render';
194
+ *
195
+ * console.log(iris({ from: { x: 120, y: 80 } }).name); // 'iris'
196
+ * ```
197
+ */
198
+ export declare function iris(options?: {
199
+ from?: TransitionPoint;
200
+ }): SceneTransition;
201
+ /**
202
+ * The old picture fading out over the new scene.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * import { dissolve } from '@datamoc/mw_games/two-d/render';
207
+ *
208
+ * console.log(dissolve().name); // 'dissolve'
209
+ * ```
210
+ */
211
+ export declare function dissolve(): SceneTransition;
212
+ /** how a window or panel comes and goes */
213
+ export type OpenAnimationKind = 'pop' | 'grow' | 'slide' | 'fade';
214
+ /**
215
+ * What a window opening (or closing, run backwards) looks like at `progress`: its scale, opacity and
216
+ * how far it is still pushed down by a `slide`. Closing never overshoots.
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * import { openAnimationFrame } from '@datamoc/mw_games/two-d/render';
221
+ *
222
+ * console.log(openAnimationFrame('pop', 0).scale); // 0
223
+ * console.log(openAnimationFrame('pop', 1).scale); // 1
224
+ * console.log(openAnimationFrame('slide', 0.5).offset > 0); // true: still sliding up
225
+ * ```
226
+ */
227
+ export declare function openAnimationFrame(kind: OpenAnimationKind, progress: number, closing?: boolean): {
228
+ scale: number;
229
+ alpha: number;
230
+ offset: number;
231
+ };
232
+ /**
233
+ * Plays one transition: owns the `under` and `over` layers, advances with `update(dt)` in real
234
+ * time and tells its `onDone` once. `Game` runs one of these around a scene change; it is exported so
235
+ * a game with its own compositing can run a transition the same way.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * import { Container2D as Container } from '@datamoc/mw_games/two-d/render';
240
+ * import { TransitionRunner, dissolve } from '@datamoc/mw_games/two-d/render';
241
+ *
242
+ * const incoming = new Container();
243
+ * const runner = new TransitionRunner({ transition: dissolve(), duration: 0.5 }, { width: 800, height: 600 }, null, incoming);
244
+ * // put runner.under, incoming and runner.over on the stage, in that order
245
+ * while (!runner.update(1 / 60)) continue;
246
+ * console.log(runner.done); // true
247
+ * ```
248
+ */
249
+ export declare class TransitionRunner {
250
+ readonly under: Container2D;
251
+ readonly over: Container2D;
252
+ readonly pause: boolean;
253
+ private readonly runtime;
254
+ private readonly duration;
255
+ private readonly ease;
256
+ private readonly onDone?;
257
+ private readonly snapshot;
258
+ private elapsed;
259
+ private finished;
260
+ constructor(options: TransitionOptions, size: {
261
+ width: number;
262
+ height: number;
263
+ }, snapshot: Texture2D | null, incoming: Container2D);
264
+ /** how far along it is, 0 to 1, before easing */
265
+ get progress(): number;
266
+ get done(): boolean;
267
+ /** @returns true on the frame it ends (and on every call after) */
268
+ update(dt: number): boolean;
269
+ /** jumps to the end: the transition's last frame is applied, its layers are emptied, `onDone` runs */
270
+ finish(): void;
271
+ }
272
+ //# sourceMappingURL=SceneTransition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneTransition.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/SceneTransition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;;;;;;GAUG;AAEH,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IACjC,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,iFAAiF;IACjF,QAAQ,EAAE,WAAW,CAAC;IACtB,mGAAmG;IACnG,KAAK,EAAE,WAAW,CAAC;IACnB,kFAAkF;IAClF,IAAI,EAAE,WAAW,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IACjC,6DAA6D;IAC7D,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,+EAA+E;IAC/E,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAAC;CACrD;AAED,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,eAAe,CAAC;IAC5B,oGAAoG;IACpG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,OAAO,MAAM,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