@datamoc/mw_games 0.7.9 → 0.8.1
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/CHANGELOG.md +135 -0
- package/dist/i18n/FormatSpec.d.ts +3 -2
- package/dist/i18n/FormatSpec.d.ts.map +1 -1
- package/dist/i18n/FormatSpec.js +4 -3
- package/dist/i18n/FormatSpec.js.map +1 -1
- package/dist/i18n/Po.d.ts +4 -1
- package/dist/i18n/Po.d.ts.map +1 -1
- package/dist/i18n/Po.js +18 -2
- package/dist/i18n/Po.js.map +1 -1
- package/dist/i18n/index.d.ts +8 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +20 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/mw_games.global.js +16 -16
- package/dist/mwl/catalog.d.ts +7 -2
- package/dist/mwl/catalog.d.ts.map +1 -1
- package/dist/mwl/catalog.js +0 -0
- package/dist/mwl/catalog.js.map +1 -1
- package/dist/mwl/grammar.d.ts.map +1 -1
- package/dist/mwl/grammar.js +37 -0
- package/dist/mwl/grammar.js.map +1 -1
- package/dist/mwl/hooks.d.ts +42 -1
- package/dist/mwl/hooks.d.ts.map +1 -1
- package/dist/mwl/hooks.js +41 -0
- package/dist/mwl/hooks.js.map +1 -1
- package/dist/mwl/index.d.ts +5 -5
- package/dist/mwl/index.d.ts.map +1 -1
- package/dist/mwl/index.js +2 -2
- package/dist/mwl/index.js.map +1 -1
- package/dist/mwl/runtime.d.ts +9 -0
- package/dist/mwl/runtime.d.ts.map +1 -1
- package/dist/mwl/runtime.js +62 -7
- package/dist/mwl/runtime.js.map +1 -1
- package/dist/mwl/schema.d.ts +33 -1
- package/dist/mwl/schema.d.ts.map +1 -1
- package/dist/mwl/schema.js +56 -5
- package/dist/mwl/schema.js.map +1 -1
- package/dist/roguelike/Targeting.d.ts +35 -0
- package/dist/roguelike/Targeting.d.ts.map +1 -1
- package/dist/roguelike/Targeting.js +72 -0
- package/dist/roguelike/Targeting.js.map +1 -1
- package/dist/roguelike/index.d.ts +2 -0
- package/dist/roguelike/index.d.ts.map +1 -1
- package/dist/roguelike/index.js +1 -0
- package/dist/roguelike/index.js.map +1 -1
- package/dist/two-d/render/ImageModifiers.d.ts +44 -6
- package/dist/two-d/render/ImageModifiers.d.ts.map +1 -1
- package/dist/two-d/render/ImageModifiers.js +94 -16
- package/dist/two-d/render/ImageModifiers.js.map +1 -1
- package/dist/two-d/render/PaletteRemap.d.ts +35 -16
- package/dist/two-d/render/PaletteRemap.d.ts.map +1 -1
- package/dist/two-d/render/PaletteRemap.js +47 -22
- package/dist/two-d/render/PaletteRemap.js.map +1 -1
- package/dist/two-d/render/Particles.d.ts +30 -9
- package/dist/two-d/render/Particles.d.ts.map +1 -1
- package/dist/two-d/render/Particles.js +42 -7
- package/dist/two-d/render/Particles.js.map +1 -1
- package/dist/two-d/render/SpriteSheet.d.ts +19 -3
- package/dist/two-d/render/SpriteSheet.d.ts.map +1 -1
- package/dist/two-d/render/SpriteSheet.js +26 -5
- package/dist/two-d/render/SpriteSheet.js.map +1 -1
- package/dist/two-d/render/index.d.ts +2 -2
- package/dist/two-d/render/index.d.ts.map +1 -1
- package/dist/two-d/render/index.js +1 -1
- package/dist/two-d/render/index.js.map +1 -1
- package/dist/two-d/ui/MessageBox.d.ts +10 -1
- package/dist/two-d/ui/MessageBox.d.ts.map +1 -1
- package/dist/two-d/ui/MessageBox.js +4 -1
- package/dist/two-d/ui/MessageBox.js.map +1 -1
- package/dist/two-d/ui/Window.d.ts +37 -1
- package/dist/two-d/ui/Window.d.ts.map +1 -1
- package/dist/two-d/ui/Window.js +55 -2
- package/dist/two-d/ui/Window.js.map +1 -1
- package/dist/two-d/ui/WindowStack.d.ts +24 -2
- package/dist/two-d/ui/WindowStack.d.ts.map +1 -1
- package/dist/two-d/ui/WindowStack.js +22 -1
- package/dist/two-d/ui/WindowStack.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -7,27 +7,46 @@ export interface PaletteMapping {
|
|
|
7
7
|
/**
|
|
8
8
|
* How a pixel that is not an exact `from` colour is treated. `'exact'` (the default for
|
|
9
9
|
* `remapPixels`/`recolorTexture`) leaves it untouched - the correct behaviour for a discrete
|
|
10
|
-
* swap like `~RC`/`~PAL`,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* swap like `~RC`/`~PAL`, and for a `paletteRangeMapping` over a reference palette, where the
|
|
11
|
+
* pixels that are not in the palette are the ones the artists deliberately left alone (shading,
|
|
12
|
+
* outlines, anti-aliased edges). `'nearest'` repaints every opaque pixel with whichever `from`
|
|
13
|
+
* entry it is closest to, which is what a palette that covers the whole image wants - a dense
|
|
14
|
+
* generated ramp where every pixel is meant to be recoloured. Using `'nearest'` with a sparse
|
|
15
|
+
* `from` list (an `~RC` pair or two, a three-colour reference palette) repaints the entire image
|
|
16
|
+
* toward whichever entry happens to be closest, which is the bug this mode exists to prevent.
|
|
16
17
|
*/
|
|
17
18
|
export type PaletteRemapMode = 'exact' | 'nearest';
|
|
18
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* The three-stop gradient a team colour (or any palette range) is built from. `mid` is the
|
|
21
|
+
* shade the reference's own anchor colour becomes, `min` the one at the dark end of the range
|
|
22
|
+
* and `max` the one at the bright end.
|
|
23
|
+
*/
|
|
19
24
|
export interface PaletteRange {
|
|
20
25
|
readonly min: number;
|
|
21
26
|
readonly mid: number;
|
|
22
27
|
readonly max: number;
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
|
-
* Builds a `PaletteMapping` that
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* Builds a `PaletteMapping` that recolours every entry of `reference` into a shade of the
|
|
31
|
+
* `min -> mid -> max` gradient, the shape a team colour or any other `[color_range]`-style
|
|
32
|
+
* remap is defined by. `reference` is the exact list of colours the art was painted with, so
|
|
33
|
+
* pixels outside it - anti-aliased edges, shading, outlines - are left alone by an `'exact'`
|
|
34
|
+
* remap, which is the mode this pairs with.
|
|
35
|
+
*
|
|
36
|
+
* The reference's *first* entry is its anchor, and it is the one colour whose shade is fixed by
|
|
37
|
+
* the range alone: it becomes `mid`. Every other entry is placed by its own brightness rather
|
|
38
|
+
* than by its position, so the *rest* of the list needs no order - a darker entry blends towards
|
|
39
|
+
* `min` and a brighter one towards `max`, each in proportion to how its average compares with
|
|
40
|
+
* the anchor's. That is what lets one mapping reproduce art as shaded as the reference it was
|
|
41
|
+
* painted from, and what the first entry has to be: the base shade the art was built around.
|
|
42
|
+
*
|
|
43
|
+
* Brightness and the blend are computed the way the engine they mirror does, a floored integer
|
|
44
|
+
* average and a truncated blend, which is what makes the shades equal the engine's byte for byte
|
|
45
|
+
* rather than merely close. The engine's own black-and-white special cases fall out of the two
|
|
46
|
+
* branches here rather than being spelled out: an anchor with an average of 0 has no ratio to
|
|
47
|
+
* divide by, so every entry takes the brighter branch and `mid` is the top of the scale instead
|
|
48
|
+
* of the middle of it, and a white anchor is at least as bright as everything, so every entry
|
|
49
|
+
* takes the darker one.
|
|
31
50
|
*
|
|
32
51
|
* @example
|
|
33
52
|
* ```ts
|
|
@@ -35,10 +54,10 @@ export interface PaletteRange {
|
|
|
35
54
|
* import type { Texture2D } from '@datamoc/mw_games/two-d/render';
|
|
36
55
|
*
|
|
37
56
|
* declare const texture: Texture2D;
|
|
38
|
-
* declare const magentaReference: readonly number[]; //
|
|
57
|
+
* declare const magentaReference: readonly number[]; // the exact colours the art was painted with
|
|
39
58
|
*
|
|
40
|
-
* const redTeam = paletteRangeMapping(magentaReference, { min:
|
|
41
|
-
* const recolored = recolorTexture(texture, redTeam);
|
|
59
|
+
* const redTeam = paletteRangeMapping(magentaReference, { min: 0x000000, mid: 0xff0000, max: 0xffffff });
|
|
60
|
+
* const recolored = recolorTexture(texture, redTeam); // 'exact': only those pixels are repainted
|
|
42
61
|
* ```
|
|
43
62
|
*/
|
|
44
63
|
export declare function paletteRangeMapping(reference: readonly number[], range: PaletteRange): PaletteMapping;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaletteRemap.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/PaletteRemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED
|
|
1
|
+
{"version":3,"file":"PaletteRemap.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/PaletteRemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AA8BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,GAAG,cAAc,CAUrG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,iBAAiB,EACzB,O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GAAE,gBAA0B,GAC9B,OAAO,CAMT"}
|
|
@@ -2,24 +2,48 @@ import { Texture } from 'pixi.js';
|
|
|
2
2
|
function hexToRgb(hex) {
|
|
3
3
|
return [(hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff];
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** a colour's brightness, as the integer average of its channels - the engine's own ruler */
|
|
6
|
+
function brightnessOf(color) {
|
|
7
|
+
const [r, g, b] = hexToRgb(color);
|
|
8
|
+
return Math.floor((r + g + b) / 3);
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* One channel of `ratio * a + (1 - ratio) * b`, truncated rather than rounded, because that is
|
|
12
|
+
* the arithmetic a palette range's shades are defined in: rounding instead of truncating puts
|
|
13
|
+
* every shade up to a whole step brighter, and the difference shows wherever art is painted
|
|
14
|
+
* from the shades. No clamp goes on top of it, and none is needed: a ratio never leaves 0..1
|
|
15
|
+
* and both ends are channels, so a value between them is already a channel.
|
|
16
|
+
*/
|
|
17
|
+
function blendedChannel(a, b, ratio) {
|
|
18
|
+
return Math.trunc(ratio * a + (1 - ratio) * b);
|
|
10
19
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const [
|
|
14
|
-
|
|
20
|
+
/** `ratio` of the way from `b` to `a`, per channel, as a packed `0xRRGGBB` */
|
|
21
|
+
function blend(a, b, ratio) {
|
|
22
|
+
const [ar, ag, ab] = hexToRgb(a);
|
|
23
|
+
const [br, bg, bb] = hexToRgb(b);
|
|
24
|
+
return (blendedChannel(ar, br, ratio) << 16) | (blendedChannel(ag, bg, ratio) << 8) | blendedChannel(ab, bb, ratio);
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
|
-
* Builds a `PaletteMapping` that
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
27
|
+
* Builds a `PaletteMapping` that recolours every entry of `reference` into a shade of the
|
|
28
|
+
* `min -> mid -> max` gradient, the shape a team colour or any other `[color_range]`-style
|
|
29
|
+
* remap is defined by. `reference` is the exact list of colours the art was painted with, so
|
|
30
|
+
* pixels outside it - anti-aliased edges, shading, outlines - are left alone by an `'exact'`
|
|
31
|
+
* remap, which is the mode this pairs with.
|
|
32
|
+
*
|
|
33
|
+
* The reference's *first* entry is its anchor, and it is the one colour whose shade is fixed by
|
|
34
|
+
* the range alone: it becomes `mid`. Every other entry is placed by its own brightness rather
|
|
35
|
+
* than by its position, so the *rest* of the list needs no order - a darker entry blends towards
|
|
36
|
+
* `min` and a brighter one towards `max`, each in proportion to how its average compares with
|
|
37
|
+
* the anchor's. That is what lets one mapping reproduce art as shaded as the reference it was
|
|
38
|
+
* painted from, and what the first entry has to be: the base shade the art was built around.
|
|
39
|
+
*
|
|
40
|
+
* Brightness and the blend are computed the way the engine they mirror does, a floored integer
|
|
41
|
+
* average and a truncated blend, which is what makes the shades equal the engine's byte for byte
|
|
42
|
+
* rather than merely close. The engine's own black-and-white special cases fall out of the two
|
|
43
|
+
* branches here rather than being spelled out: an anchor with an average of 0 has no ratio to
|
|
44
|
+
* divide by, so every entry takes the brighter branch and `mid` is the top of the scale instead
|
|
45
|
+
* of the middle of it, and a white anchor is at least as bright as everything, so every entry
|
|
46
|
+
* takes the darker one.
|
|
23
47
|
*
|
|
24
48
|
* @example
|
|
25
49
|
* ```ts
|
|
@@ -27,18 +51,19 @@ function lerpColor(from, to, t) {
|
|
|
27
51
|
* import type { Texture2D } from '@datamoc/mw_games/two-d/render';
|
|
28
52
|
*
|
|
29
53
|
* declare const texture: Texture2D;
|
|
30
|
-
* declare const magentaReference: readonly number[]; //
|
|
54
|
+
* declare const magentaReference: readonly number[]; // the exact colours the art was painted with
|
|
31
55
|
*
|
|
32
|
-
* const redTeam = paletteRangeMapping(magentaReference, { min:
|
|
33
|
-
* const recolored = recolorTexture(texture, redTeam);
|
|
56
|
+
* const redTeam = paletteRangeMapping(magentaReference, { min: 0x000000, mid: 0xff0000, max: 0xffffff });
|
|
57
|
+
* const recolored = recolorTexture(texture, redTeam); // 'exact': only those pixels are repainted
|
|
34
58
|
* ```
|
|
35
59
|
*/
|
|
36
60
|
export function paletteRangeMapping(reference, range) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
const anchor = reference.length > 0 ? brightnessOf(reference[0]) : 255;
|
|
62
|
+
const to = reference.map((color) => {
|
|
63
|
+
const brightness = brightnessOf(color);
|
|
64
|
+
if (anchor !== 0 && brightness <= anchor)
|
|
65
|
+
return blend(range.mid, range.min, brightness / anchor);
|
|
66
|
+
return blend(range.mid, range.max, (255 - brightness) / (255 - anchor));
|
|
42
67
|
});
|
|
43
68
|
return { from: reference, to };
|
|
44
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaletteRemap.js","sourceRoot":"","sources":["../../../src/two-d/render/PaletteRemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"PaletteRemap.js","sourceRoot":"","sources":["../../../src/two-d/render/PaletteRemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAgClC,SAAS,QAAQ,CAAC,GAAW;IAC5B,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED,6FAA6F;AAC7F,SAAS,YAAY,CAAC,KAAa;IAClC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG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E,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -18,9 +18,11 @@ export interface Particle {
|
|
|
18
18
|
life: number;
|
|
19
19
|
rotation: number;
|
|
20
20
|
spin: number;
|
|
21
|
-
/** current interpolated values, recomputed every step from the emitter's
|
|
21
|
+
/** current interpolated values, recomputed every step from the emitter's range or curve */
|
|
22
22
|
scale: number;
|
|
23
23
|
alpha: number;
|
|
24
|
+
/** this particle's own tint, picked once at birth from the emitter's range */
|
|
25
|
+
tint: number;
|
|
24
26
|
/**
|
|
25
27
|
* Index into the emitter's `frames` for this particle's own age, or 0 without a frame
|
|
26
28
|
* sequence. Readable here for the same reason the rest of this interface is: a frame
|
|
@@ -33,6 +35,12 @@ export interface Particle {
|
|
|
33
35
|
}
|
|
34
36
|
/** a `[min, max]` range picked per particle; a bare number means that value exactly */
|
|
35
37
|
export type ParticleRange = number | readonly [number, number];
|
|
38
|
+
/**
|
|
39
|
+
* A value driven by a particle's own age, `t` running 0 at birth to 1 at death. What a pair
|
|
40
|
+
* of endpoints cannot say: a smoke puff whose alpha falls fast and then lingers, a spark that
|
|
41
|
+
* shrinks by halves, anything that curves.
|
|
42
|
+
*/
|
|
43
|
+
export type ParticleCurve = (t: number) => number;
|
|
36
44
|
/**
|
|
37
45
|
* Where in the emitter's local space a particle is born. Without one every particle starts at
|
|
38
46
|
* the emitter's origin, which is right for a hit spark and wrong for anything with an extent:
|
|
@@ -74,16 +82,27 @@ export interface ParticleEmitterOptions {
|
|
|
74
82
|
x: number;
|
|
75
83
|
y: number;
|
|
76
84
|
};
|
|
77
|
-
/** scale at birth and at death, interpolated across a particle's life */
|
|
78
|
-
scale?: readonly [number, number];
|
|
79
|
-
/** alpha at birth and at death */
|
|
80
|
-
alpha?: readonly [number, number];
|
|
85
|
+
/** scale at birth and at death, interpolated across a particle's life, or a curve of it */
|
|
86
|
+
scale?: readonly [number, number] | ParticleCurve;
|
|
87
|
+
/** alpha at birth and at death, or a curve of the particle's age - see `scale` */
|
|
88
|
+
alpha?: readonly [number, number] | ParticleCurve;
|
|
89
|
+
/**
|
|
90
|
+
* A per-frame wobble on the scale, between 0 and 1: each frame every particle's scale is
|
|
91
|
+
* multiplied by a seeded draw in `[1 - flicker, 1]`, so a flame's size jumps instead of
|
|
92
|
+
* sliding. 1 lets it drop to nothing, which with a `scale` curve of `(t) => 1 - t` is a
|
|
93
|
+
* torch spark. Dropped under reduced motion, like the travel and the spin.
|
|
94
|
+
*/
|
|
95
|
+
flicker?: number;
|
|
81
96
|
/** rotation change in radians per second */
|
|
82
97
|
spin?: ParticleRange;
|
|
83
98
|
/** where in local space particles are born; without one they all start at the origin */
|
|
84
99
|
spawn?: ParticleSpawnArea;
|
|
85
|
-
/**
|
|
86
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Multiplied into every particle sprite, either one colour for the whole emitter or a
|
|
102
|
+
* `[from, to]` pair each particle draws its own colour from, channel by channel - water
|
|
103
|
+
* with a depth to it rather than one flat tint. Ignored without a `texture`.
|
|
104
|
+
*/
|
|
105
|
+
tint?: ParticleRange;
|
|
87
106
|
}
|
|
88
107
|
/**
|
|
89
108
|
* A pooled particle emitter: sparks off a sword hit, dust under a footstep, rain over a map.
|
|
@@ -131,9 +150,11 @@ export declare class ParticleEmitter extends Container {
|
|
|
131
150
|
private readonly angleRange;
|
|
132
151
|
private readonly gravityX;
|
|
133
152
|
private readonly gravityY;
|
|
134
|
-
private readonly
|
|
135
|
-
private readonly
|
|
153
|
+
private readonly scaleOf;
|
|
154
|
+
private readonly alphaOf;
|
|
155
|
+
private readonly flicker;
|
|
136
156
|
private readonly spin;
|
|
157
|
+
private readonly tintRange;
|
|
137
158
|
/** the frame sequence to walk, if one was given - `texture` is ignored in its favour */
|
|
138
159
|
private readonly frames?;
|
|
139
160
|
/** where in local space births happen, or null for a single point at the origin */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Particles.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/Particles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IAEX,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IAEZ,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IAEb,
|
|
1
|
+
{"version":3,"file":"Particles.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/Particles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IAEX,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IAEZ,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IAEb,2FAA2F;IAC3F,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd,uDAAuD;IACvD,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,uFAAuF;AACvF,MAAM,MAAM,aAAa,GAAG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G;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO3B;IAED,OAAO,CAAC,KAAK;IAoCb;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAgBnB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAsDvB;IAED,2EAA2E;IAC3E,OAAO,CAAC,IAAI;IA0BZ,2EAA2E;IAC3E,KAAK,IAAI,IAAI,CAIZ;CACD"}
|
|
@@ -4,6 +4,27 @@ import { reducedMotion } from '../../core/Motion.js';
|
|
|
4
4
|
function pick(range) {
|
|
5
5
|
return typeof range === 'number' ? range : Random.float(range[0], range[1]);
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* A colour from a range, mixed channel by channel: interpolating the packed value instead
|
|
9
|
+
* would carry from one channel into the next and walk through colours that are not between
|
|
10
|
+
* the two. One seeded draw drives all three channels, so a particle's colour is a point on
|
|
11
|
+
* the line between them rather than three unrelated picks.
|
|
12
|
+
*/
|
|
13
|
+
function pickTint(range) {
|
|
14
|
+
if (typeof range === 'number')
|
|
15
|
+
return range;
|
|
16
|
+
const t = Random.float();
|
|
17
|
+
const channel = (shift) => {
|
|
18
|
+
const from = (range[0] >> shift) & 0xff;
|
|
19
|
+
const to = (range[1] >> shift) & 0xff;
|
|
20
|
+
return Math.round(from + (to - from) * t) << shift;
|
|
21
|
+
};
|
|
22
|
+
return channel(16) | channel(8) | channel(0);
|
|
23
|
+
}
|
|
24
|
+
/** a pair of endpoints as a curve, so the update path only ever calls a function */
|
|
25
|
+
function curveOf(range) {
|
|
26
|
+
return typeof range === 'function' ? range : (t) => range[0] + (range[1] - range[0]) * t;
|
|
27
|
+
}
|
|
7
28
|
/**
|
|
8
29
|
* A pooled particle emitter: sparks off a sword hit, dust under a footstep, rain over a map.
|
|
9
30
|
*
|
|
@@ -58,9 +79,11 @@ export class ParticleEmitter extends Container {
|
|
|
58
79
|
this.angleRange = options.angle ?? [0, Math.PI * 2];
|
|
59
80
|
this.gravityX = options.gravity?.x ?? 0;
|
|
60
81
|
this.gravityY = options.gravity?.y ?? 0;
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
82
|
+
this.scaleOf = curveOf(options.scale ?? [1, 1]);
|
|
83
|
+
this.alphaOf = curveOf(options.alpha ?? [1, 0]);
|
|
84
|
+
this.flicker = Math.min(1, Math.max(0, options.flicker ?? 0));
|
|
63
85
|
this.spin = options.spin ?? 0;
|
|
86
|
+
this.tintRange = options.tint ?? 0xffffff;
|
|
64
87
|
this.frames = options.frames;
|
|
65
88
|
this.spawnArea = options.spawn ?? null;
|
|
66
89
|
for (let i = 0; i < max; i++) {
|
|
@@ -75,6 +98,7 @@ export class ParticleEmitter extends Container {
|
|
|
75
98
|
spin: 0,
|
|
76
99
|
scale: 1,
|
|
77
100
|
alpha: 1,
|
|
101
|
+
tint: 0xffffff,
|
|
78
102
|
frame: 0,
|
|
79
103
|
active: false,
|
|
80
104
|
});
|
|
@@ -83,7 +107,8 @@ export class ParticleEmitter extends Container {
|
|
|
83
107
|
const sprite = new Sprite(base);
|
|
84
108
|
sprite.anchor.set(0.5);
|
|
85
109
|
sprite.visible = false;
|
|
86
|
-
|
|
110
|
+
//one colour for the emitter is set once here; a range is per particle, in `draw`
|
|
111
|
+
if (typeof options.tint === 'number')
|
|
87
112
|
sprite.tint = options.tint;
|
|
88
113
|
this.sprites.push(sprite);
|
|
89
114
|
this.addChild(sprite);
|
|
@@ -155,8 +180,9 @@ export class ParticleEmitter extends Container {
|
|
|
155
180
|
particle.life = Math.max(1e-6, pick(this.life));
|
|
156
181
|
particle.rotation = 0;
|
|
157
182
|
particle.spin = pick(this.spin) * motion;
|
|
158
|
-
particle.scale = this.
|
|
159
|
-
particle.alpha = this.
|
|
183
|
+
particle.scale = this.scaleOf(0);
|
|
184
|
+
particle.alpha = this.alphaOf(0);
|
|
185
|
+
particle.tint = pickTint(this.tintRange);
|
|
160
186
|
particle.frame = 0;
|
|
161
187
|
particle.active = true;
|
|
162
188
|
return true;
|
|
@@ -217,8 +243,12 @@ export class ParticleEmitter extends Container {
|
|
|
217
243
|
particle.y += particle.vy * dt;
|
|
218
244
|
particle.rotation += particle.spin * dt;
|
|
219
245
|
const t = particle.age / particle.life;
|
|
220
|
-
particle.scale = this.
|
|
221
|
-
particle.alpha = this.
|
|
246
|
+
particle.scale = this.scaleOf(t);
|
|
247
|
+
particle.alpha = this.alphaOf(t);
|
|
248
|
+
//a flicker is motion that goes nowhere, so reduced motion drops it along with the
|
|
249
|
+
//travel and the spin; the curve underneath still plays
|
|
250
|
+
if (this.flicker > 0 && !frozen)
|
|
251
|
+
particle.scale *= 1 - this.flicker * Random.float();
|
|
222
252
|
//a frame sequence plays across the particle's own life, so `t` picks the frame the
|
|
223
253
|
//same way it interpolates scale and alpha; the last frame holds until it dies rather
|
|
224
254
|
//than falling off the end of the array
|
|
@@ -232,6 +262,9 @@ export class ParticleEmitter extends Container {
|
|
|
232
262
|
draw() {
|
|
233
263
|
if (this.sprites.length === 0)
|
|
234
264
|
return;
|
|
265
|
+
//asked once per frame rather than per particle: a plain tint was set at construction,
|
|
266
|
+
//while a range belongs to the particle and has to be assigned as it is drawn
|
|
267
|
+
const tintPerParticle = typeof this.tintRange !== 'number';
|
|
235
268
|
for (let i = 0; i < this.pool.length; i++) {
|
|
236
269
|
const particle = this.pool[i];
|
|
237
270
|
const sprite = this.sprites[i];
|
|
@@ -245,6 +278,8 @@ export class ParticleEmitter extends Container {
|
|
|
245
278
|
sprite.rotation = particle.rotation;
|
|
246
279
|
sprite.alpha = particle.alpha;
|
|
247
280
|
sprite.scale.set(particle.scale);
|
|
281
|
+
if (tintPerParticle)
|
|
282
|
+
sprite.tint = particle.tint;
|
|
248
283
|
//a frame sequence swaps the sprite's texture; a single-texture emitter leaves it
|
|
249
284
|
if (this.frames)
|
|
250
285
|
sprite.texture = this.frames[particle.frame] ?? sprite.texture;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Particles.js","sourceRoot":"","sources":["../../../src/two-d/render/Particles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Particles.js","sourceRoot":"","sources":["../../../src/two-d/render/Particles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAmIrD,SAAS,IAAI,CAAC,KAAoB;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,KAAoB;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE;QACzC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC;QACxC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC;IACpD,CAAC,CAAC;IACF,OAAO,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC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C,IAAI,MAAM,CAAC,OAAO,CAAC;QACjF,CAAC;IACF,CAAC;IAED,2EAA2E;IAC3E,KAAK;QACJ,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,IAAI;YAAE,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;CACD"}
|
|
@@ -6,6 +6,10 @@ import { type TextureRegion, type Texture2D } from './Types2D.ts';
|
|
|
6
6
|
* case and `name` labels the frames that matter. Frames are cut once and cached: asking
|
|
7
7
|
* for the same index twice returns the same Texture, so sprites sharing a frame also share
|
|
8
8
|
* a texture and stay in one batch.
|
|
9
|
+
*
|
|
10
|
+
* The rest are not grids at all: a hand-packed icon atlas, a strip of bar segments, a
|
|
11
|
+
* nine-patch's corners. Those declare their own rectangles with `rect`, and the sheet is
|
|
12
|
+
* built with no frame size, which leaves it with no grid and only the frames declared.
|
|
9
13
|
*/
|
|
10
14
|
export declare class SpriteSheet {
|
|
11
15
|
readonly texture: Texture2D;
|
|
@@ -17,12 +21,13 @@ export declare class SpriteSheet {
|
|
|
17
21
|
private names;
|
|
18
22
|
private constructor();
|
|
19
23
|
/**
|
|
20
|
-
* Cuts a loaded texture into a grid, numbered left to right then top to bottom
|
|
24
|
+
* Cuts a loaded texture into a grid, numbered left to right then top to bottom, or, with
|
|
25
|
+
* no frame size, leaves the sheet with no grid for `rect` to fill in.
|
|
21
26
|
*
|
|
22
27
|
* @param path the asset path the texture was loaded with
|
|
23
28
|
*/
|
|
24
|
-
static grid(path: string, frameWidth
|
|
25
|
-
static fromTexture(texture: Texture2D, frameWidth
|
|
29
|
+
static grid(path: string, frameWidth?: number, frameHeight?: number): SpriteSheet;
|
|
30
|
+
static fromTexture(texture: Texture2D, frameWidth?: number, frameHeight?: number): SpriteSheet;
|
|
26
31
|
get count(): number;
|
|
27
32
|
/** gives a frame a name, so game code reads `sheet.get('door')` rather than `sheet.get(6)` */
|
|
28
33
|
name(name: string, index: number): this;
|
|
@@ -30,6 +35,17 @@ export declare class SpriteSheet {
|
|
|
30
35
|
nameAll(names: Readonly<Record<string, number>>): this;
|
|
31
36
|
indexOf(name: string): number;
|
|
32
37
|
get(frame: number | string): Texture2D;
|
|
38
|
+
/**
|
|
39
|
+
* Cuts an arbitrary rectangle out of the texture, for a sheet that is not a grid: one
|
|
40
|
+
* hand-packed icon, two banner frames, the corners of a nine-patch.
|
|
41
|
+
*
|
|
42
|
+
* The rectangle is cached under `index` exactly like a grid frame, so `get`, `region`,
|
|
43
|
+
* `name` and `pick` all treat it as a frame and asking for it twice returns the same
|
|
44
|
+
* `Texture` rather than cutting a second one. Declaring a rect for an index the grid
|
|
45
|
+
* also covers replaces that frame, which is what a tightened sub-rect of a cell is:
|
|
46
|
+
* an item whose art is smaller than its 16 by 16 cell keeps its index and its name.
|
|
47
|
+
*/
|
|
48
|
+
rect(index: number, x: number, y: number, width: number, height: number): this;
|
|
33
49
|
/** the texture and frame rectangle together, as plain MWG types rather than `pixi.js`'s
|
|
34
50
|
* `Texture`/`Rectangle` - for a game that needs the geometry, not just the cut texture */
|
|
35
51
|
region(frame: number | string): TextureRegion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpriteSheet.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/SpriteSheet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E
|
|
1
|
+
{"version":3,"file":"SpriteSheet.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/SpriteSheet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,qBAAa,WAAW;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,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AK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,EAAE,CAEnD;CACD"}
|
|
@@ -8,6 +8,10 @@ import { rectOf } from './Types2D.js';
|
|
|
8
8
|
* case and `name` labels the frames that matter. Frames are cut once and cached: asking
|
|
9
9
|
* for the same index twice returns the same Texture, so sprites sharing a frame also share
|
|
10
10
|
* a texture and stay in one batch.
|
|
11
|
+
*
|
|
12
|
+
* The rest are not grids at all: a hand-packed icon atlas, a strip of bar segments, a
|
|
13
|
+
* nine-patch's corners. Those declare their own rectangles with `rect`, and the sheet is
|
|
14
|
+
* built with no frame size, which leaves it with no grid and only the frames declared.
|
|
11
15
|
*/
|
|
12
16
|
export class SpriteSheet {
|
|
13
17
|
constructor(texture, frameWidth, frameHeight) {
|
|
@@ -16,18 +20,19 @@ export class SpriteSheet {
|
|
|
16
20
|
this.texture = texture;
|
|
17
21
|
this.frameWidth = frameWidth;
|
|
18
22
|
this.frameHeight = frameHeight;
|
|
19
|
-
this.columns = Math.floor(texture.width / frameWidth);
|
|
20
|
-
this.rows = Math.floor(texture.height / frameHeight);
|
|
23
|
+
this.columns = frameWidth > 0 ? Math.floor(texture.width / frameWidth) : 0;
|
|
24
|
+
this.rows = frameHeight > 0 ? Math.floor(texture.height / frameHeight) : 0;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
|
-
* Cuts a loaded texture into a grid, numbered left to right then top to bottom
|
|
27
|
+
* Cuts a loaded texture into a grid, numbered left to right then top to bottom, or, with
|
|
28
|
+
* no frame size, leaves the sheet with no grid for `rect` to fill in.
|
|
24
29
|
*
|
|
25
30
|
* @param path the asset path the texture was loaded with
|
|
26
31
|
*/
|
|
27
|
-
static grid(path, frameWidth, frameHeight = frameWidth) {
|
|
32
|
+
static grid(path, frameWidth = 0, frameHeight = frameWidth) {
|
|
28
33
|
return new SpriteSheet(Resources.texture(path), frameWidth, frameHeight);
|
|
29
34
|
}
|
|
30
|
-
static fromTexture(texture, frameWidth, frameHeight = frameWidth) {
|
|
35
|
+
static fromTexture(texture, frameWidth = 0, frameHeight = frameWidth) {
|
|
31
36
|
return new SpriteSheet(texture, frameWidth, frameHeight);
|
|
32
37
|
}
|
|
33
38
|
get count() {
|
|
@@ -65,6 +70,22 @@ export class SpriteSheet {
|
|
|
65
70
|
this.frames.set(index, texture);
|
|
66
71
|
return texture;
|
|
67
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Cuts an arbitrary rectangle out of the texture, for a sheet that is not a grid: one
|
|
75
|
+
* hand-packed icon, two banner frames, the corners of a nine-patch.
|
|
76
|
+
*
|
|
77
|
+
* The rectangle is cached under `index` exactly like a grid frame, so `get`, `region`,
|
|
78
|
+
* `name` and `pick` all treat it as a frame and asking for it twice returns the same
|
|
79
|
+
* `Texture` rather than cutting a second one. Declaring a rect for an index the grid
|
|
80
|
+
* also covers replaces that frame, which is what a tightened sub-rect of a cell is:
|
|
81
|
+
* an item whose art is smaller than its 16 by 16 cell keeps its index and its name.
|
|
82
|
+
*/
|
|
83
|
+
rect(index, x, y, width, height) {
|
|
84
|
+
if (width <= 0 || height <= 0)
|
|
85
|
+
throw new Error('a sprite sheet rect needs a positive width and height');
|
|
86
|
+
this.frames.set(index, new Texture({ source: this.texture.source, frame: new Rectangle(x, y, width, height) }));
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
68
89
|
/** the texture and frame rectangle together, as plain MWG types rather than `pixi.js`'s
|
|
69
90
|
* `Texture`/`Rectangle` - for a game that needs the geometry, not just the cut texture */
|
|
70
91
|
region(frame) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpriteSheet.js","sourceRoot":"","sources":["../../../src/two-d/render/SpriteSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAsC,MAAM,cAAc,CAAC;AAE1E
|
|
1
|
+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CAAC,IAAI,EAAE,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,iEAAiE;IACjE,IAAI,CAAC,GAAG,MAA8B;QACrC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ColorTransformBatcher, packColorAdd, packTintAdd, NO_COLOR_ADD } from './ColorTransformBatcher.ts';
|
|
2
2
|
export type { HasColorAdd } from './ColorTransformBatcher.ts';
|
|
3
3
|
export { TintedSprite, registerColorTransform } from './TintedSprite.ts';
|
|
4
|
-
export { applyAllImageModifiers, applyImageModifiers, applyTextureModifiers, blendMatrix, blendPixels, channelScaleMatrix, channelSwapMatrix, colorShiftMatrix, croppedTexture, imageModifier, maskPixels, parseColorPairs, parseImagePath, parsePaletteLists, rotatePixels, spriteColorMatrix, } from './ImageModifiers.ts';
|
|
5
|
-
export type { ChannelSource, ImageModifier, ImageTextureProbe, ParsedImagePath, RotatedPixels, } from './ImageModifiers.ts';
|
|
4
|
+
export { applyAllImageModifiers, applyImageModifiers, applyTextureModifiers, blendMatrix, blendPixels, channelScaleMatrix, channelSwapMatrix, colorShiftMatrix, croppedTexture, imageModifier, maskPixels, parseColorPairs, parseImagePath, parsePaletteLists, parseRotateMode, rotatePixels, spriteColorMatrix, } from './ImageModifiers.ts';
|
|
5
|
+
export type { ChannelSource, ImageModifier, ImageTextureProbe, ParsedImagePath, RotateMode, RotatedPixels, } from './ImageModifiers.ts';
|
|
6
6
|
export { AnimatedSprite, Animation } from './AnimatedSprite.ts';
|
|
7
7
|
export type { AnimationFrame, AnimationFrameInput, AnimationOptions } from './AnimatedSprite.ts';
|
|
8
8
|
export { SpriteSheet } from './SpriteSheet.ts';
|