@combos-fun/renderer-adapter 0.0.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/README.md +3 -0
- package/dist/renderer-adapter.cjs.js +130 -0
- package/dist/renderer-adapter.cjs.js.map +1 -0
- package/dist/renderer-adapter.cjs.prod.js +1 -0
- package/dist/renderer-adapter.d.ts +50 -0
- package/dist/renderer-adapter.esm.js +119 -0
- package/dist/renderer-adapter.esm.js.map +1 -0
- package/index.js +7 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pixi_js = require('pixi.js');
|
|
4
|
+
|
|
5
|
+
class Container extends pixi_js.Container {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class Graphics extends pixi_js.Graphics {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class NinePatch extends pixi_js.NineSliceSprite {
|
|
12
|
+
constructor(img, leftWidth, topHeight, rightWidth, bottomHeight) {
|
|
13
|
+
const texture = typeof img === 'string' ? pixi_js.Texture.from(img) : img;
|
|
14
|
+
super({
|
|
15
|
+
texture,
|
|
16
|
+
leftWidth,
|
|
17
|
+
topHeight,
|
|
18
|
+
rightWidth,
|
|
19
|
+
bottomHeight,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class Sprite {
|
|
25
|
+
constructor(image) {
|
|
26
|
+
this._image = null;
|
|
27
|
+
this._image = image;
|
|
28
|
+
if (image) {
|
|
29
|
+
if (image instanceof HTMLImageElement) {
|
|
30
|
+
this.sprite = pixi_js.Sprite.from(image);
|
|
31
|
+
}
|
|
32
|
+
else if (image instanceof pixi_js.Texture) {
|
|
33
|
+
this.sprite = new pixi_js.Sprite(image);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.sprite = new pixi_js.Sprite();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
set image(val) {
|
|
41
|
+
if (this._image === val) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (val instanceof HTMLImageElement) {
|
|
45
|
+
this.sprite.texture && this.sprite.texture.destroy(false);
|
|
46
|
+
this.sprite.texture = pixi_js.Texture.from(val);
|
|
47
|
+
}
|
|
48
|
+
else if (val instanceof pixi_js.Texture) {
|
|
49
|
+
this.sprite.texture = val;
|
|
50
|
+
}
|
|
51
|
+
this._image = val;
|
|
52
|
+
}
|
|
53
|
+
get image() {
|
|
54
|
+
return this._image;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class SpriteAnimation {
|
|
59
|
+
constructor({ frames }) {
|
|
60
|
+
this.animatedSprite = new pixi_js.AnimatedSprite(frames);
|
|
61
|
+
}
|
|
62
|
+
play() {
|
|
63
|
+
this.animatedSprite.play();
|
|
64
|
+
}
|
|
65
|
+
stop() {
|
|
66
|
+
this.animatedSprite.stop();
|
|
67
|
+
}
|
|
68
|
+
gotoAndPlay(frameNumber) {
|
|
69
|
+
this.animatedSprite.gotoAndPlay(frameNumber);
|
|
70
|
+
}
|
|
71
|
+
gotoAndStop(frameNumber) {
|
|
72
|
+
this.animatedSprite.gotoAndStop(frameNumber);
|
|
73
|
+
}
|
|
74
|
+
set speed(val) {
|
|
75
|
+
this.animatedSprite.animationSpeed = val;
|
|
76
|
+
}
|
|
77
|
+
get speed() {
|
|
78
|
+
return this.animatedSprite.animationSpeed;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class Text extends pixi_js.Text {
|
|
83
|
+
constructor(text, style) {
|
|
84
|
+
super(text, style);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
class TilingSprite {
|
|
89
|
+
constructor(image) {
|
|
90
|
+
this._image = null;
|
|
91
|
+
this._image = image;
|
|
92
|
+
if (image instanceof HTMLImageElement) {
|
|
93
|
+
this.tilingSprite = pixi_js.TilingSprite.from(pixi_js.Texture.from(image));
|
|
94
|
+
}
|
|
95
|
+
else if (image instanceof pixi_js.Texture) {
|
|
96
|
+
this.tilingSprite = pixi_js.TilingSprite.from(image);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.tilingSprite = pixi_js.TilingSprite.from(pixi_js.Texture.EMPTY);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
set image(val) {
|
|
103
|
+
if (this._image === val) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (val instanceof HTMLImageElement) {
|
|
107
|
+
this.tilingSprite.texture = pixi_js.Texture.from(val);
|
|
108
|
+
}
|
|
109
|
+
else if (val instanceof pixi_js.Texture) {
|
|
110
|
+
this.tilingSprite.texture = val;
|
|
111
|
+
}
|
|
112
|
+
this._image = val;
|
|
113
|
+
}
|
|
114
|
+
get image() {
|
|
115
|
+
return this._image;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Object.defineProperty(exports, "Application", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () { return pixi_js.Application; }
|
|
122
|
+
});
|
|
123
|
+
exports.Container = Container;
|
|
124
|
+
exports.Graphics = Graphics;
|
|
125
|
+
exports.NinePatch = NinePatch;
|
|
126
|
+
exports.Sprite = Sprite;
|
|
127
|
+
exports.SpriteAnimation = SpriteAnimation;
|
|
128
|
+
exports.Text = Text;
|
|
129
|
+
exports.TilingSprite = TilingSprite;
|
|
130
|
+
//# sourceMappingURL=renderer-adapter.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-adapter.cjs.js","sources":["../lib/Container.ts","../lib/Graphics.ts","../lib/NinePatch.ts","../lib/Sprite.ts","../lib/SpriteAnimation.ts","../lib/Text.ts","../lib/TilingSprite.ts"],"sourcesContent":["import { Container as PixiContainer } from 'pixi.js';\n\nexport default class Container extends PixiContainer {\n [propName: string]: any;\n}\n","import { Graphics as PixiGraphics } from 'pixi.js';\nexport default class Graphics extends PixiGraphics {\n [propName: string]: any;\n}\n","import { NineSliceSprite, Texture } from 'pixi.js';\n\nexport default class NinePatch extends NineSliceSprite {\n constructor(\n img: string | Texture,\n leftWidth: number,\n topHeight: number,\n rightWidth: number,\n bottomHeight: number,\n ) {\n const texture = typeof img === 'string' ? Texture.from(img) : img;\n super({\n texture,\n leftWidth,\n topHeight,\n rightWidth,\n bottomHeight,\n });\n }\n}\n","import { Texture as PixiTexture, Sprite as PixiSprite } from 'pixi.js';\n\nexport default class Sprite {\n _image: HTMLImageElement | PixiTexture = null;\n public sprite: PixiSprite;\n constructor(image: HTMLImageElement | PixiTexture) {\n this._image = image;\n if (image) {\n if (image instanceof HTMLImageElement) {\n this.sprite = PixiSprite.from(image);\n } else if (image instanceof PixiTexture) {\n this.sprite = new PixiSprite(image);\n }\n } else {\n this.sprite = new PixiSprite();\n }\n }\n set image(val) {\n if (this._image === val) {\n return;\n }\n\n if (val instanceof HTMLImageElement) {\n this.sprite.texture && this.sprite.texture.destroy(false);\n this.sprite.texture = PixiTexture.from(val);\n } else if (val instanceof PixiTexture) {\n this.sprite.texture = val;\n }\n this._image = val;\n }\n get image() {\n return this._image;\n }\n}\n","import { AnimatedSprite, Texture } from 'pixi.js';\n\nexport default class SpriteAnimation {\n animatedSprite: AnimatedSprite;\n constructor({ frames }: { frames: Texture[] }) {\n this.animatedSprite = new AnimatedSprite(frames);\n }\n play() {\n this.animatedSprite.play();\n }\n stop() {\n this.animatedSprite.stop();\n }\n gotoAndPlay(frameNumber: number) {\n this.animatedSprite.gotoAndPlay(frameNumber);\n }\n gotoAndStop(frameNumber: number) {\n this.animatedSprite.gotoAndStop(frameNumber);\n }\n set speed(val: number) {\n this.animatedSprite.animationSpeed = val;\n }\n get speed() {\n return this.animatedSprite.animationSpeed;\n }\n}\n","import { Text as PixiText } from 'pixi.js';\nimport type { TextStyle } from 'pixi.js';\n\nexport default class Text extends PixiText {\n constructor(text: string, style?: Partial<TextStyle>) {\n super(text, style);\n }\n}\n","import { Texture, TilingSprite as PixiTilingSprite } from 'pixi.js';\n\nexport default class TilingSprite {\n _image: HTMLImageElement | Texture | null = null;\n public tilingSprite: PixiTilingSprite;\n constructor(image: HTMLImageElement | Texture | null) {\n this._image = image;\n if (image instanceof HTMLImageElement) {\n this.tilingSprite = PixiTilingSprite.from(Texture.from(image));\n } else if (image instanceof Texture) {\n this.tilingSprite = PixiTilingSprite.from(image);\n } else {\n this.tilingSprite = PixiTilingSprite.from(Texture.EMPTY);\n }\n }\n set image(val: HTMLImageElement | Texture | null) {\n if (this._image === val) {\n return;\n }\n\n if (val instanceof HTMLImageElement) {\n this.tilingSprite.texture = Texture.from(val);\n } else if (val instanceof Texture) {\n this.tilingSprite.texture = val;\n }\n this._image = val;\n }\n get image() {\n return this._image;\n }\n}\n"],"names":["PixiContainer","PixiGraphics","NineSliceSprite","Texture","PixiSprite","PixiTexture","AnimatedSprite","PixiText","PixiTilingSprite"],"mappings":";;;;AAEc,MAAO,SAAU,SAAQA,iBAAa,CAAA;AAEnD;;ACHa,MAAO,QAAS,SAAQC,gBAAY,CAAA;AAEjD;;ACDa,MAAO,SAAU,SAAQC,uBAAe,CAAA;IACpD,WAAA,CACE,GAAqB,EACrB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,YAAoB,EAAA;AAEpB,QAAA,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,GAAGC,eAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG;AACjE,QAAA,KAAK,CAAC;YACJ,OAAO;YACP,SAAS;YACT,SAAS;YACT,UAAU;YACV,YAAY;AACb,SAAA,CAAC;IACJ;AACD;;ACjBa,MAAO,MAAM,CAAA;AAGzB,IAAA,WAAA,CAAY,KAAqC,EAAA;QAFjD,IAAA,CAAA,MAAM,GAAmC,IAAI;AAG3C,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;QACnB,IAAI,KAAK,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G,YAAYA,eAAO,EAAE;AACjC,YAAA,IAAI,CAAC,YAAY,CAAC,OAAO,GAAG,GAAG;QACjC;AACA,QAAA,IAAI,CAAC,MAAM,GAAG,GAAG;IACnB;AACA,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM;IACpB;AACD;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("pixi.js");class e extends t.Container{}class i extends t.Graphics{}class r extends t.NineSliceSprite{constructor(e,i,r,s,n){super({texture:"string"==typeof e?t.Texture.from(e):e,leftWidth:i,topHeight:r,rightWidth:s,bottomHeight:n})}}class s extends t.Text{constructor(t,e){super(t,e)}}Object.defineProperty(exports,"Application",{enumerable:!0,get:function(){return t.Application}}),exports.Container=e,exports.Graphics=i,exports.NinePatch=r,exports.Sprite=class{constructor(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=t.Sprite.from(e):e instanceof t.Texture&&(this.sprite=new t.Sprite(e)):this.sprite=new t.Sprite}set image(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=t.Texture.from(e)):e instanceof t.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}},exports.SpriteAnimation=class{constructor({frames:e}){this.animatedSprite=new t.AnimatedSprite(e)}play(){this.animatedSprite.play()}stop(){this.animatedSprite.stop()}gotoAndPlay(t){this.animatedSprite.gotoAndPlay(t)}gotoAndStop(t){this.animatedSprite.gotoAndStop(t)}set speed(t){this.animatedSprite.animationSpeed=t}get speed(){return this.animatedSprite.animationSpeed}},exports.Text=s,exports.TilingSprite=class{constructor(e){this._image=null,this._image=e,e instanceof HTMLImageElement?this.tilingSprite=t.TilingSprite.from(t.Texture.from(e)):e instanceof t.Texture?this.tilingSprite=t.TilingSprite.from(e):this.tilingSprite=t.TilingSprite.from(t.Texture.EMPTY)}set image(e){this._image!==e&&(e instanceof HTMLImageElement?this.tilingSprite.texture=t.Texture.from(e):e instanceof t.Texture&&(this.tilingSprite.texture=e),this._image=e)}get image(){return this._image}};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as pixi_js from 'pixi.js';
|
|
2
|
+
import { Container as Container$1, Graphics as Graphics$1, NineSliceSprite, Texture, Sprite as Sprite$1, AnimatedSprite, Text as Text$1, TextStyle, TilingSprite as TilingSprite$1 } from 'pixi.js';
|
|
3
|
+
export { Application } from 'pixi.js';
|
|
4
|
+
|
|
5
|
+
declare class Container extends Container$1 {
|
|
6
|
+
[propName: string]: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare class Graphics extends Graphics$1 {
|
|
10
|
+
[propName: string]: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class NinePatch extends NineSliceSprite {
|
|
14
|
+
constructor(img: string | Texture, leftWidth: number, topHeight: number, rightWidth: number, bottomHeight: number);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class Sprite {
|
|
18
|
+
_image: HTMLImageElement | Texture;
|
|
19
|
+
sprite: Sprite$1;
|
|
20
|
+
constructor(image: HTMLImageElement | Texture);
|
|
21
|
+
set image(val: HTMLImageElement | Texture<pixi_js.TextureSource<any>>);
|
|
22
|
+
get image(): HTMLImageElement | Texture<pixi_js.TextureSource<any>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class SpriteAnimation {
|
|
26
|
+
animatedSprite: AnimatedSprite;
|
|
27
|
+
constructor({ frames }: {
|
|
28
|
+
frames: Texture[];
|
|
29
|
+
});
|
|
30
|
+
play(): void;
|
|
31
|
+
stop(): void;
|
|
32
|
+
gotoAndPlay(frameNumber: number): void;
|
|
33
|
+
gotoAndStop(frameNumber: number): void;
|
|
34
|
+
set speed(val: number);
|
|
35
|
+
get speed(): number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare class Text extends Text$1 {
|
|
39
|
+
constructor(text: string, style?: Partial<TextStyle>);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare class TilingSprite {
|
|
43
|
+
_image: HTMLImageElement | Texture | null;
|
|
44
|
+
tilingSprite: TilingSprite$1;
|
|
45
|
+
constructor(image: HTMLImageElement | Texture | null);
|
|
46
|
+
set image(val: HTMLImageElement | Texture | null);
|
|
47
|
+
get image(): HTMLImageElement | Texture | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { Container, Graphics, NinePatch, Sprite, SpriteAnimation, Text, TilingSprite };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Container as Container$1, Graphics as Graphics$1, NineSliceSprite, Texture, Sprite as Sprite$1, AnimatedSprite, Text as Text$1, TilingSprite as TilingSprite$1 } from 'pixi.js';
|
|
2
|
+
export { Application } from 'pixi.js';
|
|
3
|
+
|
|
4
|
+
class Container extends Container$1 {
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class Graphics extends Graphics$1 {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class NinePatch extends NineSliceSprite {
|
|
11
|
+
constructor(img, leftWidth, topHeight, rightWidth, bottomHeight) {
|
|
12
|
+
const texture = typeof img === 'string' ? Texture.from(img) : img;
|
|
13
|
+
super({
|
|
14
|
+
texture,
|
|
15
|
+
leftWidth,
|
|
16
|
+
topHeight,
|
|
17
|
+
rightWidth,
|
|
18
|
+
bottomHeight,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class Sprite {
|
|
24
|
+
constructor(image) {
|
|
25
|
+
this._image = null;
|
|
26
|
+
this._image = image;
|
|
27
|
+
if (image) {
|
|
28
|
+
if (image instanceof HTMLImageElement) {
|
|
29
|
+
this.sprite = Sprite$1.from(image);
|
|
30
|
+
}
|
|
31
|
+
else if (image instanceof Texture) {
|
|
32
|
+
this.sprite = new Sprite$1(image);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.sprite = new Sprite$1();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
set image(val) {
|
|
40
|
+
if (this._image === val) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (val instanceof HTMLImageElement) {
|
|
44
|
+
this.sprite.texture && this.sprite.texture.destroy(false);
|
|
45
|
+
this.sprite.texture = Texture.from(val);
|
|
46
|
+
}
|
|
47
|
+
else if (val instanceof Texture) {
|
|
48
|
+
this.sprite.texture = val;
|
|
49
|
+
}
|
|
50
|
+
this._image = val;
|
|
51
|
+
}
|
|
52
|
+
get image() {
|
|
53
|
+
return this._image;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class SpriteAnimation {
|
|
58
|
+
constructor({ frames }) {
|
|
59
|
+
this.animatedSprite = new AnimatedSprite(frames);
|
|
60
|
+
}
|
|
61
|
+
play() {
|
|
62
|
+
this.animatedSprite.play();
|
|
63
|
+
}
|
|
64
|
+
stop() {
|
|
65
|
+
this.animatedSprite.stop();
|
|
66
|
+
}
|
|
67
|
+
gotoAndPlay(frameNumber) {
|
|
68
|
+
this.animatedSprite.gotoAndPlay(frameNumber);
|
|
69
|
+
}
|
|
70
|
+
gotoAndStop(frameNumber) {
|
|
71
|
+
this.animatedSprite.gotoAndStop(frameNumber);
|
|
72
|
+
}
|
|
73
|
+
set speed(val) {
|
|
74
|
+
this.animatedSprite.animationSpeed = val;
|
|
75
|
+
}
|
|
76
|
+
get speed() {
|
|
77
|
+
return this.animatedSprite.animationSpeed;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class Text extends Text$1 {
|
|
82
|
+
constructor(text, style) {
|
|
83
|
+
super(text, style);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
class TilingSprite {
|
|
88
|
+
constructor(image) {
|
|
89
|
+
this._image = null;
|
|
90
|
+
this._image = image;
|
|
91
|
+
if (image instanceof HTMLImageElement) {
|
|
92
|
+
this.tilingSprite = TilingSprite$1.from(Texture.from(image));
|
|
93
|
+
}
|
|
94
|
+
else if (image instanceof Texture) {
|
|
95
|
+
this.tilingSprite = TilingSprite$1.from(image);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.tilingSprite = TilingSprite$1.from(Texture.EMPTY);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
set image(val) {
|
|
102
|
+
if (this._image === val) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (val instanceof HTMLImageElement) {
|
|
106
|
+
this.tilingSprite.texture = Texture.from(val);
|
|
107
|
+
}
|
|
108
|
+
else if (val instanceof Texture) {
|
|
109
|
+
this.tilingSprite.texture = val;
|
|
110
|
+
}
|
|
111
|
+
this._image = val;
|
|
112
|
+
}
|
|
113
|
+
get image() {
|
|
114
|
+
return this._image;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { Container, Graphics, NinePatch, Sprite, SpriteAnimation, Text, TilingSprite };
|
|
119
|
+
//# sourceMappingURL=renderer-adapter.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-adapter.esm.js","sources":["../lib/Container.ts","../lib/Graphics.ts","../lib/NinePatch.ts","../lib/Sprite.ts","../lib/SpriteAnimation.ts","../lib/Text.ts","../lib/TilingSprite.ts"],"sourcesContent":["import { Container as PixiContainer } from 'pixi.js';\n\nexport default class Container extends PixiContainer {\n [propName: string]: any;\n}\n","import { Graphics as PixiGraphics } from 'pixi.js';\nexport default class Graphics extends PixiGraphics {\n [propName: string]: any;\n}\n","import { NineSliceSprite, Texture } from 'pixi.js';\n\nexport default class NinePatch extends NineSliceSprite {\n constructor(\n img: string | Texture,\n leftWidth: number,\n topHeight: number,\n rightWidth: number,\n bottomHeight: number,\n ) {\n const texture = typeof img === 'string' ? Texture.from(img) : img;\n super({\n texture,\n leftWidth,\n topHeight,\n rightWidth,\n bottomHeight,\n });\n }\n}\n","import { Texture as PixiTexture, Sprite as PixiSprite } from 'pixi.js';\n\nexport default class Sprite {\n _image: HTMLImageElement | PixiTexture = null;\n public sprite: PixiSprite;\n constructor(image: HTMLImageElement | PixiTexture) {\n this._image = image;\n if (image) {\n if (image instanceof HTMLImageElement) {\n this.sprite = PixiSprite.from(image);\n } else if (image instanceof PixiTexture) {\n this.sprite = new PixiSprite(image);\n }\n } else {\n this.sprite = new PixiSprite();\n }\n }\n set image(val) {\n if (this._image === val) {\n return;\n }\n\n if (val instanceof HTMLImageElement) {\n this.sprite.texture && this.sprite.texture.destroy(false);\n this.sprite.texture = PixiTexture.from(val);\n } else if (val instanceof PixiTexture) {\n this.sprite.texture = val;\n }\n this._image = val;\n }\n get image() {\n return this._image;\n }\n}\n","import { AnimatedSprite, Texture } from 'pixi.js';\n\nexport default class SpriteAnimation {\n animatedSprite: AnimatedSprite;\n constructor({ frames }: { frames: Texture[] }) {\n this.animatedSprite = new AnimatedSprite(frames);\n }\n play() {\n this.animatedSprite.play();\n }\n stop() {\n this.animatedSprite.stop();\n }\n gotoAndPlay(frameNumber: number) {\n this.animatedSprite.gotoAndPlay(frameNumber);\n }\n gotoAndStop(frameNumber: number) {\n this.animatedSprite.gotoAndStop(frameNumber);\n }\n set speed(val: number) {\n this.animatedSprite.animationSpeed = val;\n }\n get speed() {\n return this.animatedSprite.animationSpeed;\n }\n}\n","import { Text as PixiText } from 'pixi.js';\nimport type { TextStyle } from 'pixi.js';\n\nexport default class Text extends PixiText {\n constructor(text: string, style?: Partial<TextStyle>) {\n super(text, style);\n }\n}\n","import { Texture, TilingSprite as PixiTilingSprite } from 'pixi.js';\n\nexport default class TilingSprite {\n _image: HTMLImageElement | Texture | null = null;\n public tilingSprite: PixiTilingSprite;\n constructor(image: HTMLImageElement | Texture | null) {\n this._image = image;\n if (image instanceof HTMLImageElement) {\n this.tilingSprite = PixiTilingSprite.from(Texture.from(image));\n } else if (image instanceof Texture) {\n this.tilingSprite = PixiTilingSprite.from(image);\n } else {\n this.tilingSprite = PixiTilingSprite.from(Texture.EMPTY);\n }\n }\n set image(val: HTMLImageElement | Texture | null) {\n if (this._image === val) {\n return;\n }\n\n if (val instanceof HTMLImageElement) {\n this.tilingSprite.texture = Texture.from(val);\n } else if (val instanceof Texture) {\n this.tilingSprite.texture = val;\n }\n this._image = val;\n }\n get image() {\n return this._image;\n }\n}\n"],"names":["PixiContainer","PixiGraphics","PixiSprite","PixiTexture","PixiText","PixiTilingSprite"],"mappings":";;;AAEc,MAAO,SAAU,SAAQA,WAAa,CAAA;AAEnD;;ACHa,MAAO,QAAS,SAAQC,UAAY,CAAA;AAEjD;;ACDa,MAAO,SAAU,SAAQ,eAAe,CAAA;IACpD,WAAA,CACE,GAAqB,EACrB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,YAAoB,EAAA;AAEpB,QAAA,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG;AACjE,QAAA,KAAK,CAAC;YACJ,OAAO;YACP,SAAS;YACT,SAAS;YACT,UAAU;YACV,YAAY;AACb,SAAA,CAAC;IACJ;AACD;;ACjBa,MAAO,MAAM,CAAA;AAGzB,IAAA,WAAA,CAAY,KAAqC,EAAA;QAFjD,IAAA,CAAA,MAAM,GAAmC,IAAI;AAG3C,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;QACnB,IAAI,KAAK,EAAE;AACT,YAAA,IAAI,KAAK,YAAY,gBAAgB,EAAE;gBACrC,IAAI,CAAC,MAAM,GAAGC,QAAU,CAAC,IAAI,CAAC,KAAK,CAAC;YACtC;AAAO,iBAAA,IAAI,KAAK,YAAYC,OAAW,EAAE;gBACvC,IAAI,CAAC,MAAM,GAAG,IAAID,QAAU,CAAC,KAAK,CAAC;YACrC;QACF;aAAO;AACL,YAAA,IAAI,CAAC,MAAM,GAAG,IAAIA,QAAU,EAAE;QAChC;IACF;IACA,IAAI,KAAK,CAAC,GAAG,EAAA;AACX,QAAA,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,WAAA,CAAY,IAAY,EAAE,KAA0B,EAAA;AAClD,QAAA,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;IACpB;AACD;;ACLa,MAAO,YAAY,CAAA;AAG/B,IAAA,WAAA,CAAY,KAAwC,EAAA;QAFpD,IAAA,CAAA,MAAM,GAAsC,IAAI;AAG9C,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,KAAK,YAAY,gBAAgB,EAAE;AACrC,YAAA,IAAI,CAAC,YAAY,GAAGC,cAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChE;AAAO,aAAA,IAAI,KAAK,YAAY,OAAO,EAAE;YACnC,IAAI,CAAC,YAAY,GAAGA,cAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;QAClD;aAAO;YACL,IAAI,CAAC,YAAY,GAAGA,cAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1D;IACF;IACA,IAAI,KAAK,CAAC,GAAsC,EAAA;AAC9C,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE;YACvB;QACF;AAEA,QAAA,IAAI,GAAG,YAAY,gBAAgB,EAAE;YACnC,IAAI,CAAC,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/C;AAAO,aAAA,IAAI,GAAG,YAAY,OAAO,EAAE;AACjC,YAAA,IAAI,CAAC,YAAY,CAAC,OAAO,GAAG,GAAG;QACjC;AACA,QAAA,IAAI,CAAC,MAAM,GAAG,GAAG;IACnB;AACA,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM;IACpB;AACD;;;;"}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@combos-fun/renderer-adapter",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "@combos-fun/renderer-adapter",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "dist/renderer-adapter.esm.js",
|
|
7
|
+
"bundle": "CombosFun.rendererAdapter",
|
|
8
|
+
"unpkg": "dist/CombosFun.rendererAdapter.min.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"types": "dist/renderer-adapter.d.ts",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"combos-fun",
|
|
16
|
+
"game"
|
|
17
|
+
],
|
|
18
|
+
"author": "sun668 <q947692259@gmail.com>",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"pixi.js": "^8.18.1"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node ../../scripts/build-package.mjs"
|
|
24
|
+
}
|
|
25
|
+
}
|