lyb-pixi-js 1.0.2 → 1.0.3
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 +28 -28
- package/dist/Base/LibPixiBitText/index.d.ts +18 -0
- package/dist/Base/LibPixiBitText/index.js +26 -0
- package/dist/Base/LibPixiContainer/index.d.ts +27 -0
- package/dist/Base/LibPixiContainer/index.js +65 -0
- package/dist/Base/LibPixiParticleMove/index.d.ts +37 -0
- package/dist/Base/LibPixiParticleMove/index.js +127 -0
- package/dist/Base/LibPixiRectBgColor/index.d.ts +27 -0
- package/dist/Base/LibPixiRectBgColor/index.js +54 -0
- package/dist/Base/LibPixiSpine/index.d.ts +56 -0
- package/dist/Base/LibPixiSpine/index.js +151 -0
- package/dist/Base/LibPixiText/index.d.ts +35 -0
- package/dist/Base/LibPixiText/index.js +50 -0
- package/dist/libPixiJs.d.ts +12 -12
- package/dist/libPixiJs.js +12 -12
- package/package.json +1 -1
- package/umd/lyb-pixi.js +33 -33
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
```ts
|
|
16
16
|
import { LibPixiJs } from "lyb-pixi-js";
|
|
17
17
|
|
|
18
|
-
const text = new LibPixiJs.Base.
|
|
18
|
+
const text = new LibPixiJs.Base.LibPixiText({
|
|
19
19
|
text: "Hello World!",
|
|
20
20
|
fontSize: 50,
|
|
21
21
|
fontColor:"red",
|
|
@@ -26,9 +26,9 @@ app.stage.addChild(text);
|
|
|
26
26
|
> 按需引入,打包时就不会把整个库打进去
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import { LibRectBgColor } from "lyb-pixi-js/dist/Base/
|
|
29
|
+
import { LibRectBgColor } from "lyb-pixi-js/dist/Base/LibPixiRectBgColor";
|
|
30
30
|
|
|
31
|
-
const box = new
|
|
31
|
+
const box = new LibPixiRectBgColor({
|
|
32
32
|
width: 100,
|
|
33
33
|
height: 100,
|
|
34
34
|
bgColor: "red",
|
|
@@ -40,20 +40,20 @@ app.stage.addChild(box);
|
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
42
|
//你的公共工具函数文件 utils.ts
|
|
43
|
-
export * from "lyb-pixi-js/dist/Base/
|
|
44
|
-
export * from "lyb-pixi-js/dist/Base/
|
|
43
|
+
export * from "lyb-pixi-js/dist/Base/LibPixiText";
|
|
44
|
+
export * from "lyb-pixi-js/dist/Base/LibPixiRectBgColor";
|
|
45
45
|
|
|
46
46
|
//你的项目文件 index.ts
|
|
47
47
|
import { LibText,LibRectBgColor } from "utils";
|
|
48
48
|
|
|
49
|
-
const text = new
|
|
49
|
+
const text = new LibPixiText({
|
|
50
50
|
text: "Hello World!",
|
|
51
51
|
fontSize: 50,
|
|
52
52
|
fontColor:"red",
|
|
53
53
|
});
|
|
54
54
|
app.stage.addChild(text);
|
|
55
55
|
|
|
56
|
-
const box = new
|
|
56
|
+
const box = new LibPixiRectBgColor({
|
|
57
57
|
width: 100,
|
|
58
58
|
height: 100,
|
|
59
59
|
bgColor: "red",
|
|
@@ -69,7 +69,7 @@ app.stage.addChild(box);
|
|
|
69
69
|
<script src="https://unpkg.com/lyb-pixi-js/umd/lyb-pixi.js"></script>
|
|
70
70
|
|
|
71
71
|
<script>
|
|
72
|
-
const text = new LibPixiJs.Base.
|
|
72
|
+
const text = new LibPixiJs.Base.LibPixiText({
|
|
73
73
|
text: "Hello World!",
|
|
74
74
|
fontSize: 50,
|
|
75
75
|
fontColor:"red",
|
|
@@ -82,27 +82,27 @@ app.stage.addChild(text);
|
|
|
82
82
|
|
|
83
83
|
### 基础
|
|
84
84
|
|
|
85
|
-
\- [
|
|
85
|
+
\- [LibPixiText-文本](#LibPixiText-文本)
|
|
86
86
|
|
|
87
|
-
\- [
|
|
87
|
+
\- [LibPixiBitText-位图](#LibPixiBitText-位图)
|
|
88
88
|
|
|
89
|
-
\- [
|
|
89
|
+
\- [LibPixiContainer-容器](#LibPixiContainer-容器)
|
|
90
90
|
|
|
91
|
-
\- [
|
|
91
|
+
\- [LibPixiRectBgColor-矩形](#LibPixiRectBgColor-矩形)
|
|
92
92
|
|
|
93
|
-
\- [
|
|
93
|
+
\- [LibPixiSpine-动画](#LibPixiSpine-动画)
|
|
94
94
|
|
|
95
|
-
\- [
|
|
95
|
+
\- [LibPixiParticleMove-粒子容器](#LibPixiParticleMove-粒子容器)
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
## Base-基础
|
|
99
99
|
|
|
100
|
-
###
|
|
100
|
+
### LibPixiText-文本
|
|
101
101
|
|
|
102
102
|
> 自定义文本类
|
|
103
103
|
|
|
104
104
|
```ts
|
|
105
|
-
const text = new LibPixiJs.Base.
|
|
105
|
+
const text = new LibPixiJs.Base.LibPixiText({
|
|
106
106
|
text: "Hello World!",
|
|
107
107
|
fontSize: 50,
|
|
108
108
|
fontColor:"red",
|
|
@@ -110,30 +110,30 @@ const text = new LibPixiJs.Base.LibText({
|
|
|
110
110
|
this.addChild(text);
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
###
|
|
113
|
+
### LibPixiBitText-位图
|
|
114
114
|
|
|
115
115
|
> 自定义位图文本
|
|
116
116
|
|
|
117
117
|
```ts
|
|
118
118
|
//所有文字使用同一个字体大小
|
|
119
|
-
const font = new
|
|
119
|
+
const font = new LibPixiBitText("FontName", 16);
|
|
120
120
|
const fontText = font.createText("10");
|
|
121
121
|
this.addChild(fontText);
|
|
122
122
|
|
|
123
123
|
//同字体不同大小
|
|
124
|
-
const font = new
|
|
124
|
+
const font = new LibPixiBitText("FontName");
|
|
125
125
|
const fontText1 = font.createText("10", 16);
|
|
126
126
|
this.addChild(fontText1);
|
|
127
127
|
const fontText2 = font.createText("10", 24);
|
|
128
128
|
this.addChild(fontText2);
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
###
|
|
131
|
+
### LibPixiContainer-容器
|
|
132
132
|
|
|
133
133
|
> 自定义容器大小及背景色
|
|
134
134
|
|
|
135
135
|
```ts
|
|
136
|
-
const box = new LibPixiJs.Base.
|
|
136
|
+
const box = new LibPixiJs.Base.LibPixiContainer({
|
|
137
137
|
width: 100,
|
|
138
138
|
height: 100,
|
|
139
139
|
bgColor: "#fff",
|
|
@@ -142,12 +142,12 @@ const box = new LibPixiJs.Base.LibContainer({
|
|
|
142
142
|
this.addChild(box);
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
###
|
|
145
|
+
### LibPixiRectBgColor-矩形
|
|
146
146
|
|
|
147
147
|
> 自定义矩形背景色
|
|
148
148
|
|
|
149
149
|
```ts
|
|
150
|
-
const rect = new
|
|
150
|
+
const rect = new LibPixiRectBgColor({
|
|
151
151
|
width: 100,
|
|
152
152
|
height: 100,
|
|
153
153
|
bgColor: "red",
|
|
@@ -155,19 +155,19 @@ const rect = new LibRectBgColor({
|
|
|
155
155
|
this.addChild(rect);
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
###
|
|
158
|
+
### LibPixiSpine-动画
|
|
159
159
|
|
|
160
160
|
> 自定义 Spine 动画,内置挂点
|
|
161
161
|
|
|
162
162
|
```ts
|
|
163
163
|
//基础使用
|
|
164
|
-
const spine = new
|
|
164
|
+
const spine = new LibPixiSpine(Assets.get("lihe"));
|
|
165
165
|
spine.setAnimation("in");
|
|
166
166
|
spine.addAnimation("idle", true);
|
|
167
167
|
this.addChild(spine);
|
|
168
168
|
|
|
169
169
|
//挂点
|
|
170
|
-
this.bgSpine = new
|
|
170
|
+
this.bgSpine = new LibPixiSpine("spine_buyfree", {
|
|
171
171
|
followPointList: [
|
|
172
172
|
{
|
|
173
173
|
boneName: "aaa",
|
|
@@ -189,12 +189,12 @@ this.bgSpine = new LibSpine("spine_buyfree", {
|
|
|
189
189
|
});
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
###
|
|
192
|
+
### LibPixiParticleMove-粒子容器
|
|
193
193
|
|
|
194
194
|
> 利用贝塞尔曲线实现粒子移动
|
|
195
195
|
|
|
196
196
|
```ts
|
|
197
|
-
const
|
|
197
|
+
const libPixiParticleMove = new LibPixiJs.Base.LibPixiParticleMove({
|
|
198
198
|
start: { x: 300, y: 600 },
|
|
199
199
|
control: [
|
|
200
200
|
{ x: 600, y: 500 },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BitmapText } from "pixi.js";
|
|
2
|
+
/** @description 自定义位图文本 */
|
|
3
|
+
export declare class LibPixiBitText {
|
|
4
|
+
/** 字体名称 */
|
|
5
|
+
private _fontName;
|
|
6
|
+
private _defaultFontSize?;
|
|
7
|
+
/**
|
|
8
|
+
* @param fontName 字体名称
|
|
9
|
+
* @param defaultFontSize 默认字体大小
|
|
10
|
+
*/
|
|
11
|
+
constructor(fontName: string, defaultFontSize?: number);
|
|
12
|
+
/** @description 创建位图文本
|
|
13
|
+
* @param text 文本内容
|
|
14
|
+
* @param fontSize 字体大小,不填则使用默认大小
|
|
15
|
+
* @returns 位图实例
|
|
16
|
+
*/
|
|
17
|
+
createText(text: string | number, fontSize?: number): BitmapText;
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BitmapText } from "pixi.js";
|
|
2
|
+
/** @description 自定义位图文本 */
|
|
3
|
+
var LibPixiBitText = /** @class */ (function () {
|
|
4
|
+
/**
|
|
5
|
+
* @param fontName 字体名称
|
|
6
|
+
* @param defaultFontSize 默认字体大小
|
|
7
|
+
*/
|
|
8
|
+
function LibPixiBitText(fontName, defaultFontSize) {
|
|
9
|
+
this._fontName = fontName;
|
|
10
|
+
this._defaultFontSize = defaultFontSize;
|
|
11
|
+
}
|
|
12
|
+
/** @description 创建位图文本
|
|
13
|
+
* @param text 文本内容
|
|
14
|
+
* @param fontSize 字体大小,不填则使用默认大小
|
|
15
|
+
* @returns 位图实例
|
|
16
|
+
*/
|
|
17
|
+
LibPixiBitText.prototype.createText = function (text, fontSize) {
|
|
18
|
+
var bitMapText = new BitmapText(text.toString(), {
|
|
19
|
+
fontName: this._fontName,
|
|
20
|
+
fontSize: this._defaultFontSize || fontSize,
|
|
21
|
+
});
|
|
22
|
+
return bitMapText;
|
|
23
|
+
};
|
|
24
|
+
return LibPixiBitText;
|
|
25
|
+
}());
|
|
26
|
+
export { LibPixiBitText };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
interface LibPixiContainerParams {
|
|
3
|
+
/** 宽度 */
|
|
4
|
+
width: number;
|
|
5
|
+
/** 高度 */
|
|
6
|
+
height: number;
|
|
7
|
+
/** 溢出裁剪 */
|
|
8
|
+
overHidden?: boolean;
|
|
9
|
+
/** 背景色 */
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
}
|
|
12
|
+
/** @description 自定义容器大小及背景色 */
|
|
13
|
+
export declare class LibPixiContainer extends Container {
|
|
14
|
+
/** 填充容器 */
|
|
15
|
+
private _fill?;
|
|
16
|
+
/** 背景色填充 */
|
|
17
|
+
private _bgColorFill?;
|
|
18
|
+
/**
|
|
19
|
+
* @param width 容器宽度
|
|
20
|
+
* @param height 容器高度
|
|
21
|
+
* @param bgColor 背景色
|
|
22
|
+
*/
|
|
23
|
+
constructor(params: LibPixiContainerParams);
|
|
24
|
+
/** @description 设置容器大小 */
|
|
25
|
+
setSize(width: number, height: number): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { Container, Graphics, Sprite } from "pixi.js";
|
|
17
|
+
import { LibPixiRectBgColor } from "../LibPixiRectBgColor";
|
|
18
|
+
/** @description 自定义容器大小及背景色 */
|
|
19
|
+
var LibPixiContainer = /** @class */ (function (_super) {
|
|
20
|
+
__extends(LibPixiContainer, _super);
|
|
21
|
+
/**
|
|
22
|
+
* @param width 容器宽度
|
|
23
|
+
* @param height 容器高度
|
|
24
|
+
* @param bgColor 背景色
|
|
25
|
+
*/
|
|
26
|
+
function LibPixiContainer(params) {
|
|
27
|
+
var _this = _super.call(this) || this;
|
|
28
|
+
var width = params.width, height = params.height, overHidden = params.overHidden, bgColor = params.bgColor;
|
|
29
|
+
if (overHidden) {
|
|
30
|
+
var mask = new Graphics();
|
|
31
|
+
mask.beginFill(0xffffff); // 创建一个白色矩形
|
|
32
|
+
mask.drawRect(0, 0, width, height);
|
|
33
|
+
mask.endFill();
|
|
34
|
+
_this.addChild(mask);
|
|
35
|
+
_this.mask = mask;
|
|
36
|
+
}
|
|
37
|
+
if (bgColor) {
|
|
38
|
+
_this._bgColorFill = new LibPixiRectBgColor({
|
|
39
|
+
width: width,
|
|
40
|
+
height: height,
|
|
41
|
+
bgColor: bgColor,
|
|
42
|
+
});
|
|
43
|
+
_this.addChild(_this._bgColorFill);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
_this._fill = new Sprite();
|
|
47
|
+
_this._fill.width = width;
|
|
48
|
+
_this._fill.height = height;
|
|
49
|
+
_this.addChild(_this._fill);
|
|
50
|
+
}
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
/** @description 设置容器大小 */
|
|
54
|
+
LibPixiContainer.prototype.setSize = function (width, height) {
|
|
55
|
+
if (this._fill) {
|
|
56
|
+
this._fill.width = width;
|
|
57
|
+
this._fill.height = height;
|
|
58
|
+
}
|
|
59
|
+
if (this._bgColorFill) {
|
|
60
|
+
this._bgColorFill.renderBg(width, height);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return LibPixiContainer;
|
|
64
|
+
}(Container));
|
|
65
|
+
export { LibPixiContainer };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { type EmitterConfigV3 } from "@pixi/particle-emitter";
|
|
3
|
+
export interface LibPixiParticleMoveParams {
|
|
4
|
+
/** 粒子JSON资源 */
|
|
5
|
+
json: EmitterConfigV3;
|
|
6
|
+
/** 运动时长 */
|
|
7
|
+
duration: number;
|
|
8
|
+
/** 粒子开始位置 */
|
|
9
|
+
start: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
/** 粒子控制点 */
|
|
14
|
+
control: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}[];
|
|
18
|
+
/** 粒子结束点 */
|
|
19
|
+
end: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
/** 运动曲线 */
|
|
24
|
+
ease?: gsap.EaseString;
|
|
25
|
+
/** 是否显示控制点,调试使用 */
|
|
26
|
+
showControl?: boolean;
|
|
27
|
+
/** 是否循环,调试使用 */
|
|
28
|
+
loop?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** @description 利用贝塞尔曲线实现粒子移动 */
|
|
31
|
+
export declare class LibPixiParticleMove extends Container {
|
|
32
|
+
private _particleContainer;
|
|
33
|
+
constructor(params: LibPixiParticleMoveParams);
|
|
34
|
+
private _createBezierPoints;
|
|
35
|
+
private _multiPointBezier;
|
|
36
|
+
private _binomial;
|
|
37
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
17
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18
|
+
if (ar || !(i in from)) {
|
|
19
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
20
|
+
ar[i] = from[i];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
|
+
};
|
|
25
|
+
import { Container, ParticleContainer, Ticker } from "pixi.js";
|
|
26
|
+
import { Emitter } from "@pixi/particle-emitter";
|
|
27
|
+
import gsap from "gsap";
|
|
28
|
+
import { LibPixiText } from "../LibPixiText";
|
|
29
|
+
/** @description 利用贝塞尔曲线实现粒子移动 */
|
|
30
|
+
var LibPixiParticleMove = /** @class */ (function (_super) {
|
|
31
|
+
__extends(LibPixiParticleMove, _super);
|
|
32
|
+
function LibPixiParticleMove(params) {
|
|
33
|
+
var _this = _super.call(this) || this;
|
|
34
|
+
var start = params.start, control = params.control, end = params.end, json = params.json, duration = params.duration, _a = params.ease, ease = _a === void 0 ? "power1.out" : _a, _b = params.showControl, showControl = _b === void 0 ? false : _b, _c = params.loop, loop = _c === void 0 ? false : _c;
|
|
35
|
+
_this._particleContainer = new ParticleContainer();
|
|
36
|
+
_this.addChild(_this._particleContainer);
|
|
37
|
+
// 初始化粒子发射器
|
|
38
|
+
var flyParticle = new Emitter(_this._particleContainer, json);
|
|
39
|
+
// 创建贝塞尔曲线的路径
|
|
40
|
+
var path = _this._createBezierPoints(__spreadArray(__spreadArray([start], control, true), [end], false), 100, showControl);
|
|
41
|
+
// 用来控制路径动画的对象
|
|
42
|
+
var flyObj = { pathThrough: 0 };
|
|
43
|
+
gsap.to(flyObj, {
|
|
44
|
+
duration: duration,
|
|
45
|
+
pathThrough: path.length - 1,
|
|
46
|
+
repeat: loop ? -1 : 0,
|
|
47
|
+
ease: ease,
|
|
48
|
+
onStart: function () {
|
|
49
|
+
flyParticle.emit = true;
|
|
50
|
+
},
|
|
51
|
+
onUpdate: function () {
|
|
52
|
+
var i = Math.floor(flyObj.pathThrough);
|
|
53
|
+
var p = path[i];
|
|
54
|
+
flyParticle.updateOwnerPos(p.x, p.y);
|
|
55
|
+
},
|
|
56
|
+
onComplete: function () {
|
|
57
|
+
gsap.to(_this, {
|
|
58
|
+
alpha: 0,
|
|
59
|
+
duration: 0.5,
|
|
60
|
+
onComplete: function () {
|
|
61
|
+
flyParticle.emit = false;
|
|
62
|
+
ticker.destroy();
|
|
63
|
+
_this.removeFromParent();
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
var ticker = new Ticker();
|
|
69
|
+
ticker.add(function () {
|
|
70
|
+
flyParticle.update(1 / 75);
|
|
71
|
+
});
|
|
72
|
+
ticker.start();
|
|
73
|
+
return _this;
|
|
74
|
+
}
|
|
75
|
+
LibPixiParticleMove.prototype._createBezierPoints = function (anchorPoints, pointsAmount, showControl) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
var points = [];
|
|
78
|
+
// 渲染控制点
|
|
79
|
+
if (showControl) {
|
|
80
|
+
anchorPoints.forEach(function (item, index) {
|
|
81
|
+
//创建一个小圆点
|
|
82
|
+
var text = new LibPixiText({
|
|
83
|
+
text: index + 1,
|
|
84
|
+
fontSize: 16,
|
|
85
|
+
});
|
|
86
|
+
text.position.set(item.x, item.y);
|
|
87
|
+
_this.addChild(text);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// 计算并存储贝塞尔曲线上的点
|
|
91
|
+
for (var i = 0; i < pointsAmount; i++) {
|
|
92
|
+
var point = this._multiPointBezier(anchorPoints, i / pointsAmount);
|
|
93
|
+
points.push(point);
|
|
94
|
+
}
|
|
95
|
+
return points;
|
|
96
|
+
};
|
|
97
|
+
LibPixiParticleMove.prototype._multiPointBezier = function (points, t) {
|
|
98
|
+
var len = points.length;
|
|
99
|
+
var x = 0, y = 0;
|
|
100
|
+
// 预计算组合数
|
|
101
|
+
var binomials = [];
|
|
102
|
+
for (var i = 0; i < len; i++) {
|
|
103
|
+
binomials[i] = this._binomial(len - 1, i);
|
|
104
|
+
}
|
|
105
|
+
// 计算贝塞尔曲线上的点
|
|
106
|
+
for (var i = 0; i < len; i++) {
|
|
107
|
+
var point = points[i];
|
|
108
|
+
var binom = binomials[i];
|
|
109
|
+
var factorT = Math.pow(t, i);
|
|
110
|
+
var factor1MinusT = Math.pow(1 - t, len - 1 - i);
|
|
111
|
+
x += point.x * factor1MinusT * factorT * binom;
|
|
112
|
+
y += point.y * factor1MinusT * factorT * binom;
|
|
113
|
+
}
|
|
114
|
+
return { x: x, y: y };
|
|
115
|
+
};
|
|
116
|
+
LibPixiParticleMove.prototype._binomial = function (n, k) {
|
|
117
|
+
if (k === 0 || k === n)
|
|
118
|
+
return 1;
|
|
119
|
+
var res = 1;
|
|
120
|
+
for (var i = 1; i <= k; i++) {
|
|
121
|
+
res = (res * (n - i + 1)) / i;
|
|
122
|
+
}
|
|
123
|
+
return res;
|
|
124
|
+
};
|
|
125
|
+
return LibPixiParticleMove;
|
|
126
|
+
}(Container));
|
|
127
|
+
export { LibPixiParticleMove };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
export interface LibPixiRectBgColorParams {
|
|
3
|
+
/** 宽度 */
|
|
4
|
+
width?: number;
|
|
5
|
+
/** 高度 */
|
|
6
|
+
height?: number;
|
|
7
|
+
/** 背景颜色 */
|
|
8
|
+
bgColor?: string | number;
|
|
9
|
+
/** x轴偏移 */
|
|
10
|
+
x?: number;
|
|
11
|
+
/** y轴偏移 */
|
|
12
|
+
y?: number;
|
|
13
|
+
/** 是否启用变色功能 */
|
|
14
|
+
enableTint?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** @description 自定义矩形背景色 */
|
|
17
|
+
export declare class LibPixiRectBgColor extends Graphics {
|
|
18
|
+
/** 启用着色 */
|
|
19
|
+
private enableTint;
|
|
20
|
+
/** 背景颜色 */
|
|
21
|
+
private bgColor;
|
|
22
|
+
constructor(options: LibPixiRectBgColorParams);
|
|
23
|
+
/** @description 重新绘制并添加颜色 */
|
|
24
|
+
updateColor(tint: string): void;
|
|
25
|
+
/** @description 更新宽度 */
|
|
26
|
+
renderBg(width: number, height: number): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { Graphics } from "pixi.js";
|
|
17
|
+
import gsap from "gsap";
|
|
18
|
+
/** @description 自定义矩形背景色 */
|
|
19
|
+
var LibPixiRectBgColor = /** @class */ (function (_super) {
|
|
20
|
+
__extends(LibPixiRectBgColor, _super);
|
|
21
|
+
function LibPixiRectBgColor(options) {
|
|
22
|
+
var _this = _super.call(this) || this;
|
|
23
|
+
/** 启用着色 */
|
|
24
|
+
_this.enableTint = true;
|
|
25
|
+
/** 背景颜色 */
|
|
26
|
+
_this.bgColor = "#fff";
|
|
27
|
+
var _a = options.x, x = _a === void 0 ? 0 : _a, _b = options.y, y = _b === void 0 ? 0 : _b, _c = options.width, width = _c === void 0 ? 0 : _c, _d = options.height, height = _d === void 0 ? 0 : _d, _e = options.bgColor, bgColor = _e === void 0 ? "#fff" : _e, _f = options.enableTint, enableTint = _f === void 0 ? true : _f;
|
|
28
|
+
_this.x = x;
|
|
29
|
+
_this.y = y;
|
|
30
|
+
_this.enableTint = enableTint;
|
|
31
|
+
_this.bgColor = bgColor;
|
|
32
|
+
_this.renderBg(width, height);
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
/** @description 重新绘制并添加颜色 */
|
|
36
|
+
LibPixiRectBgColor.prototype.updateColor = function (tint) {
|
|
37
|
+
gsap.to(this, { tint: tint, duration: 0.25 });
|
|
38
|
+
};
|
|
39
|
+
/** @description 更新宽度 */
|
|
40
|
+
LibPixiRectBgColor.prototype.renderBg = function (width, height) {
|
|
41
|
+
this.clear();
|
|
42
|
+
if (this.enableTint) {
|
|
43
|
+
this.beginFill("#fff");
|
|
44
|
+
this.tint = this.bgColor;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.beginFill(this.bgColor);
|
|
48
|
+
}
|
|
49
|
+
this.drawRect(0, 0, width, height);
|
|
50
|
+
this.endFill();
|
|
51
|
+
};
|
|
52
|
+
return LibPixiRectBgColor;
|
|
53
|
+
}(Graphics));
|
|
54
|
+
export { LibPixiRectBgColor };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Container } from "pixi.js";
|
|
2
|
+
import { Spine } from "@pixi-spine/runtime-3.8";
|
|
3
|
+
export interface OnUpdateParams {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
rotate: number;
|
|
7
|
+
scaleX: number;
|
|
8
|
+
scaleY: number;
|
|
9
|
+
}
|
|
10
|
+
export interface LibPixiSpineParams {
|
|
11
|
+
/** 默认是否可见 */
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
/** 挂点列表 */
|
|
14
|
+
followPointList?: {
|
|
15
|
+
/** 挂点名称 */
|
|
16
|
+
boneName: string;
|
|
17
|
+
/** 跟随的精灵或容器 */
|
|
18
|
+
follow: Container;
|
|
19
|
+
/** 是否启用角度 */
|
|
20
|
+
angleFollow?: boolean;
|
|
21
|
+
/** 是否启用缩放 */
|
|
22
|
+
scaleFollow?: boolean;
|
|
23
|
+
/** 更新回调,不传则接受内置挂点更新 */
|
|
24
|
+
onUpdate?: (config: OnUpdateParams) => void;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
/** @description 自定义 Spine 动画 */
|
|
28
|
+
export declare class LibPixiSpine extends Spine {
|
|
29
|
+
/** 挂点 */
|
|
30
|
+
private _followDots;
|
|
31
|
+
/** 是否已开始 */
|
|
32
|
+
private _isStart;
|
|
33
|
+
/** spine更新函数 */
|
|
34
|
+
private _loopFn;
|
|
35
|
+
constructor(texture: any, params?: LibPixiSpineParams);
|
|
36
|
+
/** @description 设置动画
|
|
37
|
+
* @param animationName 动画名称
|
|
38
|
+
* @param loop 是否循环播放
|
|
39
|
+
* @param delay 是否延迟播放
|
|
40
|
+
*/
|
|
41
|
+
setAnimation(animationName?: string, loop?: boolean, delay?: boolean): Promise<void>;
|
|
42
|
+
/** @description 添加动画
|
|
43
|
+
* @param animationName 动画名称
|
|
44
|
+
* @param loop 是否循环播放
|
|
45
|
+
* @param delay 延迟播放时间
|
|
46
|
+
*/
|
|
47
|
+
addAnimation(animationName?: string, loop?: boolean, delay?: number): Promise<void>;
|
|
48
|
+
/** @description 改变骨骼数据 */
|
|
49
|
+
setSkin(skinName: string): void;
|
|
50
|
+
/** @description 销毁动画及挂点 */
|
|
51
|
+
destroyAll(): void;
|
|
52
|
+
/** @description 更新渲染 */
|
|
53
|
+
private _loop;
|
|
54
|
+
/** @description 更新挂点 */
|
|
55
|
+
private _updateFollowPoint;
|
|
56
|
+
}
|