lyb-pixi-js 1.12.31 → 1.12.33
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 +50 -85
- package/index.js +5 -2
- package/lyb-pixi.js +209 -197
- package/package.json +1 -1
- package/Components/Base/LibDestroyContainer.d.ts +0 -11
- package/Components/Base/LibDestroyContainer.js +0 -28
- package/Components/Base/LibPixiArc.d.ts +0 -16
- package/Components/Base/LibPixiArc.js +0 -14
- package/Components/Base/LibPixiBitText.d.ts +0 -20
- package/Components/Base/LibPixiBitText.js +0 -26
- package/Components/Base/LibPixiCircular.d.ts +0 -7
- package/Components/Base/LibPixiCircular.js +0 -12
- package/Components/Base/LibPixiContainer.d.ts +0 -22
- package/Components/Base/LibPixiContainer.js +0 -51
- package/Components/Base/LibPixiHtmlText.d.ts +0 -31
- package/Components/Base/LibPixiHtmlText.js +0 -30
- package/Components/Base/LibPixiOval.d.ts +0 -5
- package/Components/Base/LibPixiOval.js +0 -10
- package/Components/Base/LibPixiParticleMove.d.ts +0 -101
- package/Components/Base/LibPixiParticleMove.js +0 -136
- package/Components/Base/LibPixiPolygon.d.ts +0 -7
- package/Components/Base/LibPixiPolygon.js +0 -15
- package/Components/Base/LibPixiRectBgColor.d.ts +0 -41
- package/Components/Base/LibPixiRectBgColor.js +0 -95
- package/Components/Base/LibPixiRectangle.d.ts +0 -7
- package/Components/Base/LibPixiRectangle.js +0 -15
- package/Components/Base/LibPixiRound.d.ts +0 -5
- package/Components/Base/LibPixiRound.js +0 -9
- package/Components/Base/LibPixiRoundedRect.d.ts +0 -5
- package/Components/Base/LibPixiRoundedRect.js +0 -10
- package/Components/Base/LibPixiSpine.d.ts +0 -58
- package/Components/Base/LibPixiSpine.js +0 -128
- package/Components/Base/LibPixiText.d.ts +0 -37
- package/Components/Base/LibPixiText.js +0 -35
- package/Components/Custom/LibPixiArrangeLinearV2.d.ts +0 -25
- package/Components/Custom/LibPixiArrangeLinearV2.js +0 -80
- package/Components/Custom/LibPixiButtonHover.d.ts +0 -40
- package/Components/Custom/LibPixiButtonHover.js +0 -53
- package/Components/Custom/LibPixiCapsule.d.ts +0 -5
- package/Components/Custom/LibPixiCapsule.js +0 -10
- package/Components/Custom/LibPixiCloseBtn.d.ts +0 -14
- package/Components/Custom/LibPixiCloseBtn.js +0 -36
- package/Components/Custom/LibPixiDragLocate.d.ts +0 -36
- package/Components/Custom/LibPixiDragLocate.js +0 -230
- package/Components/Custom/LibPixiDrawer.d.ts +0 -16
- package/Components/Custom/LibPixiDrawer.js +0 -59
- package/Components/Custom/LibPixiInput.d.ts +0 -75
- package/Components/Custom/LibPixiInput.js +0 -186
- package/Components/Custom/LibPixiLabelValue.d.ts +0 -30
- package/Components/Custom/LibPixiLabelValue.js +0 -26
- package/Components/Custom/LibPixiPerforMon.d.ts +0 -47
- package/Components/Custom/LibPixiPerforMon.js +0 -166
- package/Components/Custom/LibPixiProgress.d.ts +0 -33
- package/Components/Custom/LibPixiProgress.js +0 -47
- package/Components/Custom/LibPixiPuzzleBg.d.ts +0 -7
- package/Components/Custom/LibPixiPuzzleBg.js +0 -46
- package/Components/Custom/LibPixiScrollContainerX.d.ts +0 -71
- package/Components/Custom/LibPixiScrollContainerX.js +0 -189
- package/Components/Custom/LibPixiScrollContainerY.d.ts +0 -109
- package/Components/Custom/LibPixiScrollContainerY.js +0 -338
- package/Components/Custom/LibPixiScrollNum.d.ts +0 -67
- package/Components/Custom/LibPixiScrollNum.js +0 -184
- package/Components/Custom/LibPixiSlide.d.ts +0 -94
- package/Components/Custom/LibPixiSlide.js +0 -285
- package/Components/Custom/LibPixiSlider.d.ts +0 -82
- package/Components/Custom/LibPixiSlider.js +0 -165
- package/Components/Custom/LibPixiSubAddMinMax.d.ts +0 -40
- package/Components/Custom/LibPixiSubAddMinMax.js +0 -56
- package/Components/Custom/LibPixiTable.d.ts +0 -64
- package/Components/Custom/LibPixiTable.js +0 -76
- package/Components/Custom/LibPixiTextGroup.d.ts +0 -20
- package/Components/Custom/LibPixiTextGroup.js +0 -50
- package/Components/Custom/LibPixiTextGroupWrap.d.ts +0 -20
- package/Components/Custom/LibPixiTextGroupWrap.js +0 -50
- package/Components/Custom/LibPixiTriangle.d.ts +0 -5
- package/Components/Custom/LibPixiTriangle.js +0 -12
- package/Components/Custom/LibPixiTurntable.d.ts +0 -6
- package/Components/Custom/LibPixiTurntable.js +0 -14
- package/Utils/LibContainerCenter.d.ts +0 -3
- package/Utils/LibContainerCenter.js +0 -10
- package/Utils/LibControlledDelayedCall.d.ts +0 -5
- package/Utils/LibControlledDelayedCall.js +0 -20
- package/Utils/LibPixiArrangeLinear.d.ts +0 -16
- package/Utils/LibPixiArrangeLinear.js +0 -62
- package/Utils/LibPixiAudio.d.ts +0 -53
- package/Utils/LibPixiAudio.js +0 -168
- package/Utils/LibPixiCreateNineGrid.d.ts +0 -15
- package/Utils/LibPixiCreateNineGrid.js +0 -19
- package/Utils/LibPixiDialogManager/index.d.ts +0 -25
- package/Utils/LibPixiDialogManager/index.js +0 -43
- package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.d.ts +0 -11
- package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.js +0 -31
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +0 -38
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +0 -133
- package/Utils/LibPixiDigitalIncreasingAnimation.d.ts +0 -18
- package/Utils/LibPixiDigitalIncreasingAnimation.js +0 -26
- package/Utils/LibPixiDownScaleAnimation.d.ts +0 -7
- package/Utils/LibPixiDownScaleAnimation.js +0 -33
- package/Utils/LibPixiEmitContainerEvent.d.ts +0 -7
- package/Utils/LibPixiEmitContainerEvent.js +0 -13
- package/Utils/LibPixiEvent.d.ts +0 -19
- package/Utils/LibPixiEvent.js +0 -68
- package/Utils/LibPixiFilter.d.ts +0 -9
- package/Utils/LibPixiFilter.js +0 -34
- package/Utils/LibPixiGlobalUpdater.d.ts +0 -15
- package/Utils/LibPixiGlobalUpdater.js +0 -21
- package/Utils/LibPixiGridLayout.d.ts +0 -10
- package/Utils/LibPixiGridLayout.js +0 -27
- package/Utils/LibPixiGridLayoutV2.d.ts +0 -27
- package/Utils/LibPixiGridLayoutV2.js +0 -37
- package/Utils/LibPixiHVCenter.d.ts +0 -7
- package/Utils/LibPixiHVCenter.js +0 -14
- package/Utils/LibPixiHVGap.d.ts +0 -8
- package/Utils/LibPixiHVGap.js +0 -26
- package/Utils/LibPixiIntervalTrigger.d.ts +0 -7
- package/Utils/LibPixiIntervalTrigger.js +0 -35
- package/Utils/LibPixiOutsideClick.d.ts +0 -8
- package/Utils/LibPixiOutsideClick.js +0 -22
- package/Utils/LibPixiOverflowHidden.d.ts +0 -6
- package/Utils/LibPixiOverflowHidden.js +0 -14
- package/Utils/LibPixiPolygonDrawTool.d.ts +0 -44
- package/Utils/LibPixiPolygonDrawTool.js +0 -114
- package/Utils/LibPixiPromiseTickerTimeout.d.ts +0 -6
- package/Utils/LibPixiPromiseTickerTimeout.js +0 -22
- package/Utils/LibPixiScaleContainer.d.ts +0 -8
- package/Utils/LibPixiScaleContainer.js +0 -14
- package/Utils/LibPixiShadow.d.ts +0 -17
- package/Utils/LibPixiShadow.js +0 -18
- package/Utils/LibPixiSlideInput.d.ts +0 -55
- package/Utils/LibPixiSlideInput.js +0 -61
- package/Utils/LibPixiTicker.d.ts +0 -14
- package/Utils/LibPixiTicker.js +0 -49
- package/Utils/LibPixiTickerTimeout.d.ts +0 -6
- package/Utils/LibPixiTickerTimeout.js +0 -22
- package/index.d.ts +0 -1
- package/libPixiJs.d.ts +0 -296
- package/libPixiJs.js +0 -315
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Container } from "pixi.js";
|
|
2
|
-
import { libPixiScaleContainer } from "../../Utils/LibPixiScaleContainer";
|
|
3
|
-
/** @description 自适应宽度的标签和值组件
|
|
4
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
|
|
5
|
-
*/
|
|
6
|
-
export class LibPixiLabelValue extends Container {
|
|
7
|
-
constructor(params) {
|
|
8
|
-
super();
|
|
9
|
-
const { label, value, maxWidth, gap = 0 } = params;
|
|
10
|
-
this._label = label;
|
|
11
|
-
this._value = value;
|
|
12
|
-
this._maxWidth = maxWidth;
|
|
13
|
-
this._gap = gap;
|
|
14
|
-
this.addChild(this._label);
|
|
15
|
-
this._label.anchor.set(1, 0.5);
|
|
16
|
-
this.addChild(this._value);
|
|
17
|
-
this._value.anchor.set(0.5);
|
|
18
|
-
this.updatePosition();
|
|
19
|
-
}
|
|
20
|
-
/** @description 更新坐标 */
|
|
21
|
-
updatePosition() {
|
|
22
|
-
this._label.x = this._label.width * 0.5 - this._value.width * 0.5;
|
|
23
|
-
this._value.x = this._label.width * 0.5 + this._gap;
|
|
24
|
-
this._maxWidth && libPixiScaleContainer(this, this._maxWidth);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type Application, Container } from "pixi.js";
|
|
2
|
-
/** @description 监视帧率、Draw Call、Max Draw Call
|
|
3
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPerforMon-性能监视器
|
|
4
|
-
*/
|
|
5
|
-
export declare class LibPixiPerforMon extends Container {
|
|
6
|
-
/** 当前适配模式 */
|
|
7
|
-
static ADAPT_MODE: "h" | "v" | "hv";
|
|
8
|
-
/** 数据收集时间间隔 (5秒) */
|
|
9
|
-
private readonly COLLECT_TIME;
|
|
10
|
-
/** 当前时间 */
|
|
11
|
-
private _nowTime;
|
|
12
|
-
/** 上次更新的时间 */
|
|
13
|
-
private _lastTime;
|
|
14
|
-
/** 当前绘制调用次数 */
|
|
15
|
-
private _drawCount;
|
|
16
|
-
/** 最大绘制调用次数 */
|
|
17
|
-
private _maxDrawCount;
|
|
18
|
-
/** 临时最大绘制调用次数 */
|
|
19
|
-
private _tempMaxDrawCount;
|
|
20
|
-
/** 上次收集数据的时间 */
|
|
21
|
-
private _lastCollectTime;
|
|
22
|
-
/** 整体宽度 */
|
|
23
|
-
private _containerWidth;
|
|
24
|
-
/** 整体高度 */
|
|
25
|
-
private _containerHeight;
|
|
26
|
-
/** 渲染器 */
|
|
27
|
-
private _renderer;
|
|
28
|
-
/** 原始的 drawElements 方法 */
|
|
29
|
-
private _drawElements;
|
|
30
|
-
/** 背景 */
|
|
31
|
-
private _bg;
|
|
32
|
-
/** FPS文本 */
|
|
33
|
-
private _fpsText;
|
|
34
|
-
/** Draw Call文本 */
|
|
35
|
-
private _drawCallText;
|
|
36
|
-
/** Max Draw Call文本 */
|
|
37
|
-
private _maxDrawCallText;
|
|
38
|
-
constructor(app: Application);
|
|
39
|
-
/** @description 初始化显示性能数据 */
|
|
40
|
-
init(): void;
|
|
41
|
-
/** @description 更新文本信息 */
|
|
42
|
-
private _setTextInfo;
|
|
43
|
-
/** @description 获取FPS颜色 */
|
|
44
|
-
getFpsColor(v: number): string;
|
|
45
|
-
/** @description 获取Draw Call颜色 */
|
|
46
|
-
getDrawCallColor(v: number): string;
|
|
47
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { LibJsResizeWatcher } from "lyb-js/Base/LibJsResizeWatcher.js";
|
|
2
|
-
import { Container, Ticker, UPDATE_PRIORITY, } from "pixi.js";
|
|
3
|
-
import { LibPixiRectangle } from "../Base/LibPixiRectangle";
|
|
4
|
-
import { LibPixiText } from "../Base/LibPixiText";
|
|
5
|
-
/** @description 监视帧率、Draw Call、Max Draw Call
|
|
6
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPerforMon-性能监视器
|
|
7
|
-
*/
|
|
8
|
-
export class LibPixiPerforMon extends Container {
|
|
9
|
-
constructor(app) {
|
|
10
|
-
super();
|
|
11
|
-
/** 数据收集时间间隔 (5秒) */
|
|
12
|
-
this.COLLECT_TIME = 5 * 1000;
|
|
13
|
-
/** 当前时间 */
|
|
14
|
-
this._nowTime = 0;
|
|
15
|
-
/** 上次更新的时间 */
|
|
16
|
-
this._lastTime = 0;
|
|
17
|
-
/** 当前绘制调用次数 */
|
|
18
|
-
this._drawCount = 0;
|
|
19
|
-
/** 最大绘制调用次数 */
|
|
20
|
-
this._maxDrawCount = 0;
|
|
21
|
-
/** 临时最大绘制调用次数 */
|
|
22
|
-
this._tempMaxDrawCount = 0;
|
|
23
|
-
/** 上次收集数据的时间 */
|
|
24
|
-
this._lastCollectTime = 0;
|
|
25
|
-
/** 整体宽度 */
|
|
26
|
-
this._containerWidth = 590;
|
|
27
|
-
/** 整体高度 */
|
|
28
|
-
this._containerHeight = 50;
|
|
29
|
-
this.pivot.x = this._containerWidth / 2;
|
|
30
|
-
//创建背景
|
|
31
|
-
this._bg = new LibPixiRectangle(this._containerWidth, this._containerHeight, "#0000007e");
|
|
32
|
-
this.addChild(this._bg);
|
|
33
|
-
//创建内容容器
|
|
34
|
-
const content = new Container();
|
|
35
|
-
this.addChild(content);
|
|
36
|
-
content.x = 25;
|
|
37
|
-
content.y = this._containerHeight / 2;
|
|
38
|
-
//创建FPS文本
|
|
39
|
-
this._fpsText = new TextBox("FPS");
|
|
40
|
-
content.addChild(this._fpsText);
|
|
41
|
-
//创建Draw Call文本
|
|
42
|
-
this._drawCallText = new TextBox("Draw Call");
|
|
43
|
-
content.addChild(this._drawCallText);
|
|
44
|
-
this._drawCallText.x = 125;
|
|
45
|
-
//创建Max Draw Call文本
|
|
46
|
-
this._maxDrawCallText = new TextBox("Max Draw Call");
|
|
47
|
-
content.addChild(this._maxDrawCallText);
|
|
48
|
-
this._maxDrawCallText.x = 320;
|
|
49
|
-
this._renderer = app.renderer;
|
|
50
|
-
this._drawElements = this._renderer["gl"].drawElements;
|
|
51
|
-
this.init();
|
|
52
|
-
if (LibPixiPerforMon.ADAPT_MODE === "h") {
|
|
53
|
-
this.x = 1920 / 2;
|
|
54
|
-
}
|
|
55
|
-
else if (LibPixiPerforMon.ADAPT_MODE === "v") {
|
|
56
|
-
this.x = 1080 / 2;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const resize = new LibJsResizeWatcher();
|
|
60
|
-
resize.on((w, h) => {
|
|
61
|
-
if (w > h) {
|
|
62
|
-
this.x = 1920 / 2;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.x = 1080 / 2;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/** @description 初始化显示性能数据 */
|
|
71
|
-
init() {
|
|
72
|
-
this._renderer["gl"].drawElements = (...args) => {
|
|
73
|
-
this._drawElements.call(this._renderer["gl"], ...args);
|
|
74
|
-
this._drawCount++;
|
|
75
|
-
};
|
|
76
|
-
Ticker.shared.add(() => {
|
|
77
|
-
const fps = Ticker.system.FPS;
|
|
78
|
-
this._nowTime = performance.now();
|
|
79
|
-
if (this._nowTime - this._lastTime >= 100.0) {
|
|
80
|
-
this._setTextInfo("fps", Number(Math.floor(fps).toFixed(0)));
|
|
81
|
-
this._lastTime = this._nowTime;
|
|
82
|
-
}
|
|
83
|
-
if (this._nowTime - this._lastCollectTime < this.COLLECT_TIME) {
|
|
84
|
-
if (this._tempMaxDrawCount < this._drawCount) {
|
|
85
|
-
this._tempMaxDrawCount = this._drawCount;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this._maxDrawCount = this._tempMaxDrawCount;
|
|
90
|
-
this._tempMaxDrawCount = 0;
|
|
91
|
-
this._lastCollectTime = this._nowTime;
|
|
92
|
-
}
|
|
93
|
-
this._setTextInfo("drawCall", this._drawCount);
|
|
94
|
-
this._setTextInfo("maxDrawCall", this._maxDrawCount);
|
|
95
|
-
this._drawCount = 0;
|
|
96
|
-
}, UPDATE_PRIORITY.UTILITY);
|
|
97
|
-
}
|
|
98
|
-
/** @description 更新文本信息 */
|
|
99
|
-
_setTextInfo(p, v) {
|
|
100
|
-
const textObj = {
|
|
101
|
-
fps: this._fpsText,
|
|
102
|
-
drawCall: this._drawCallText,
|
|
103
|
-
maxDrawCall: this._maxDrawCallText,
|
|
104
|
-
};
|
|
105
|
-
const textBox = textObj[p];
|
|
106
|
-
textBox.updateValue(v);
|
|
107
|
-
if (p === "fps") {
|
|
108
|
-
textBox.updateColor(this.getFpsColor(v));
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
textBox.updateColor(this.getDrawCallColor(v));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/** @description 获取FPS颜色 */
|
|
115
|
-
getFpsColor(v) {
|
|
116
|
-
let color = "#00ff04";
|
|
117
|
-
if (v < 30) {
|
|
118
|
-
color = "#ffd20a";
|
|
119
|
-
}
|
|
120
|
-
if (v < 20) {
|
|
121
|
-
color = "#ff000d";
|
|
122
|
-
}
|
|
123
|
-
return color;
|
|
124
|
-
}
|
|
125
|
-
/** @description 获取Draw Call颜色 */
|
|
126
|
-
getDrawCallColor(v) {
|
|
127
|
-
let color = "#00ff04";
|
|
128
|
-
if (v >= 75) {
|
|
129
|
-
color = "#ffd20a";
|
|
130
|
-
}
|
|
131
|
-
if (v >= 100) {
|
|
132
|
-
color = "#ff000d";
|
|
133
|
-
}
|
|
134
|
-
return color;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/** 当前适配模式 */
|
|
138
|
-
LibPixiPerforMon.ADAPT_MODE = "hv";
|
|
139
|
-
class TextBox extends Container {
|
|
140
|
-
constructor(text, fontSize = 26) {
|
|
141
|
-
super();
|
|
142
|
-
const label = new LibPixiText({
|
|
143
|
-
text,
|
|
144
|
-
fontSize,
|
|
145
|
-
fontWeight: "bold",
|
|
146
|
-
});
|
|
147
|
-
this.addChild(label);
|
|
148
|
-
label.anchor.y = 0.5;
|
|
149
|
-
this._valueText = new LibPixiText({
|
|
150
|
-
text: "0",
|
|
151
|
-
fontSize,
|
|
152
|
-
fontWeight: "bold",
|
|
153
|
-
});
|
|
154
|
-
this.addChild(this._valueText);
|
|
155
|
-
this._valueText.anchor.y = 0.5;
|
|
156
|
-
this._valueText.x = label.width + 10;
|
|
157
|
-
}
|
|
158
|
-
/** @description 更改颜色 */
|
|
159
|
-
updateColor(color) {
|
|
160
|
-
this._valueText.style.fill = color;
|
|
161
|
-
}
|
|
162
|
-
/** @description 设置数值 */
|
|
163
|
-
updateValue(value) {
|
|
164
|
-
this._valueText.text = value;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Container, type Texture } from "pixi.js";
|
|
2
|
-
export interface LibPixiProgressParams {
|
|
3
|
-
/** 背景宽度 */
|
|
4
|
-
bgWidth: number;
|
|
5
|
-
/** 背景高度 */
|
|
6
|
-
bgHeight: number;
|
|
7
|
-
/** 进度条宽度 */
|
|
8
|
-
barWidth: number;
|
|
9
|
-
/** 进度条高度 */
|
|
10
|
-
barHeight: number;
|
|
11
|
-
/** 背景纹理 */
|
|
12
|
-
bgTexture: Texture;
|
|
13
|
-
/** 进度条纹理 */
|
|
14
|
-
barTexture: Texture;
|
|
15
|
-
/** 方向 */
|
|
16
|
-
direction?: "h" | "v";
|
|
17
|
-
}
|
|
18
|
-
/** @description 通过裁剪的方式显示进度条
|
|
19
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiProgress-进度条
|
|
20
|
-
*/
|
|
21
|
-
export declare class LibPixiProgress extends Container {
|
|
22
|
-
/** 光条图 */
|
|
23
|
-
private _progressBar;
|
|
24
|
-
/** 蒙版 */
|
|
25
|
-
private _maskGraphics;
|
|
26
|
-
/** 方向 */
|
|
27
|
-
private _direction;
|
|
28
|
-
constructor(params: LibPixiProgressParams);
|
|
29
|
-
/** @description 更新进度
|
|
30
|
-
* @param progress 进度值,范围从0到1
|
|
31
|
-
*/
|
|
32
|
-
setProgress(progress: number): void;
|
|
33
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Container, Graphics, Sprite } from "pixi.js";
|
|
2
|
-
/** @description 通过裁剪的方式显示进度条
|
|
3
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiProgress-进度条
|
|
4
|
-
*/
|
|
5
|
-
export class LibPixiProgress extends Container {
|
|
6
|
-
constructor(params) {
|
|
7
|
-
super();
|
|
8
|
-
const { bgWidth, bgHeight, barWidth, barHeight, bgTexture, barTexture, direction } = params;
|
|
9
|
-
this._direction = direction || "h";
|
|
10
|
-
// 背景图
|
|
11
|
-
const background = new Sprite(bgTexture);
|
|
12
|
-
this.addChild(background);
|
|
13
|
-
// 光条图
|
|
14
|
-
this._progressBar = new Sprite(barTexture);
|
|
15
|
-
this.addChild(this._progressBar);
|
|
16
|
-
this._progressBar.x = (bgWidth - barWidth) / 2;
|
|
17
|
-
this._progressBar.y = (bgHeight - barHeight) / 2;
|
|
18
|
-
// 创建蒙版
|
|
19
|
-
const mask = new Graphics();
|
|
20
|
-
mask.beginFill(0xffffff);
|
|
21
|
-
if (direction === "h") {
|
|
22
|
-
mask.drawRect(0, 0, 0, this._progressBar.height);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
mask.drawRect(0, 0, this._progressBar.width, 0);
|
|
26
|
-
}
|
|
27
|
-
mask.endFill();
|
|
28
|
-
this._progressBar.addChild(mask);
|
|
29
|
-
this._progressBar.mask = mask;
|
|
30
|
-
this._maskGraphics = mask;
|
|
31
|
-
}
|
|
32
|
-
/** @description 更新进度
|
|
33
|
-
* @param progress 进度值,范围从0到1
|
|
34
|
-
*/
|
|
35
|
-
setProgress(progress) {
|
|
36
|
-
const clampedProgress = Math.max(0, Math.min(1, progress));
|
|
37
|
-
this._maskGraphics.clear();
|
|
38
|
-
this._maskGraphics.beginFill(0xffffff);
|
|
39
|
-
if (this._direction === "h") {
|
|
40
|
-
this._maskGraphics.drawRect(0, 0, this._progressBar.width * clampedProgress, this._progressBar.height);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
this._maskGraphics.drawRect(0, this._progressBar.height * (1 - clampedProgress), this._progressBar.width, this._progressBar.height * clampedProgress);
|
|
44
|
-
}
|
|
45
|
-
this._maskGraphics.endFill();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { libJsDecimal } from "lyb-js/Math/LibJsDecimal.js";
|
|
2
|
-
import { Container, Sprite } from "pixi.js";
|
|
3
|
-
/** @description 设计图背景拼接
|
|
4
|
-
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPuzzleBg-设计图背景拼接
|
|
5
|
-
*/
|
|
6
|
-
export class LibPixiPuzzleBg extends Container {
|
|
7
|
-
constructor(texture) {
|
|
8
|
-
super();
|
|
9
|
-
this.eventMode = "none";
|
|
10
|
-
// 背景
|
|
11
|
-
const bg = new Sprite(texture);
|
|
12
|
-
this.addChild(bg);
|
|
13
|
-
bg.visible = false;
|
|
14
|
-
//读取配置
|
|
15
|
-
const config = JSON.parse(localStorage.getItem("puzzle_bg_config") || "{}");
|
|
16
|
-
const { alpha, x, y } = config;
|
|
17
|
-
bg.alpha = alpha || 0.25;
|
|
18
|
-
bg.position.set(x || 0, y || 0);
|
|
19
|
-
//监听鼠标空格事件
|
|
20
|
-
document.addEventListener("keydown", (e) => {
|
|
21
|
-
if (e.ctrlKey && e.key.toLowerCase() === "q" && !e.shiftKey) {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
bg.visible = !bg.visible;
|
|
24
|
-
}
|
|
25
|
-
else if (e.code === "ArrowUp") {
|
|
26
|
-
bg.y -= 2;
|
|
27
|
-
}
|
|
28
|
-
else if (e.code === "ArrowDown") {
|
|
29
|
-
bg.y += 2;
|
|
30
|
-
}
|
|
31
|
-
else if (e.code === "ArrowLeft") {
|
|
32
|
-
bg.x -= 2;
|
|
33
|
-
}
|
|
34
|
-
else if (e.code === "ArrowRight") {
|
|
35
|
-
bg.x += 2;
|
|
36
|
-
}
|
|
37
|
-
if (e.code === "NumpadAdd" && bg.alpha < 1) {
|
|
38
|
-
bg.alpha = libJsDecimal(bg.alpha, 0.1, "+");
|
|
39
|
-
}
|
|
40
|
-
else if (e.code === "NumpadSubtract" && bg.alpha > 0) {
|
|
41
|
-
bg.alpha = libJsDecimal(bg.alpha, 0.1, "-");
|
|
42
|
-
}
|
|
43
|
-
localStorage.setItem("puzzle_bg_config", JSON.stringify({ alpha: bg.alpha, x: bg.x, y: bg.y }));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Container, Texture } from "pixi.js";
|
|
2
|
-
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
3
|
-
export interface LibPixiScrollContainerXParams {
|
|
4
|
-
/** 宽度 */
|
|
5
|
-
width: number;
|
|
6
|
-
/** 高度 */
|
|
7
|
-
height: number;
|
|
8
|
-
/** 滚动内容 */
|
|
9
|
-
scrollContent: Container;
|
|
10
|
-
/** 背景色,用于定位 */
|
|
11
|
-
bgColor?: string;
|
|
12
|
-
/** 自定义遮罩贴图 */
|
|
13
|
-
maskTexture?: Texture;
|
|
14
|
-
/** 遮罩X坐标 */
|
|
15
|
-
maskX?: number;
|
|
16
|
-
/** 遮罩Y坐标 */
|
|
17
|
-
maskY?: number;
|
|
18
|
-
}
|
|
19
|
-
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
|
|
20
|
-
export declare class LibPixiScrollContainerX extends LibPixiContainer {
|
|
21
|
-
/** 舞台 */
|
|
22
|
-
static stage: Container;
|
|
23
|
-
/** 开始位置 */
|
|
24
|
-
private _startX;
|
|
25
|
-
/** 惯性速度 */
|
|
26
|
-
private _velocity;
|
|
27
|
-
/** 上一次滚动时间 */
|
|
28
|
-
private _startTime;
|
|
29
|
-
/** 开始位置 */
|
|
30
|
-
private _startPosition;
|
|
31
|
-
/** 滚动速度 */
|
|
32
|
-
private _scrollSpeed;
|
|
33
|
-
/** 是否处于拖动状态 */
|
|
34
|
-
private _isDragging;
|
|
35
|
-
/** 左边距 */
|
|
36
|
-
private _leftMargin;
|
|
37
|
-
/** 右边距元素 */
|
|
38
|
-
private _rightMarginBox;
|
|
39
|
-
/** 滚动容器 */
|
|
40
|
-
_scrollContent: Container;
|
|
41
|
-
/** 遮罩 */
|
|
42
|
-
private _maskGraphics;
|
|
43
|
-
/** 滚动的内容 */
|
|
44
|
-
private _content;
|
|
45
|
-
constructor(params: LibPixiScrollContainerXParams);
|
|
46
|
-
/** @description 添加边距 */
|
|
47
|
-
addMargin(leftMargin: number, rightMargin?: number): void;
|
|
48
|
-
/** @description 设置滚动容器可视区宽高
|
|
49
|
-
* @param width 宽度
|
|
50
|
-
* @param height 高度
|
|
51
|
-
*/
|
|
52
|
-
setDimensions(width: number, height: number): void;
|
|
53
|
-
/** @description 返回顶部 */
|
|
54
|
-
scrollToTop(): void;
|
|
55
|
-
/** @description 往滚动内容添加元素 */
|
|
56
|
-
addContent(container: Container): void;
|
|
57
|
-
/** @description 更新右边距坐标 */
|
|
58
|
-
private _updateRightMargin;
|
|
59
|
-
/** @description 按下 */
|
|
60
|
-
private _onDragStart;
|
|
61
|
-
/** @description 拖动 */
|
|
62
|
-
private _onDragMove;
|
|
63
|
-
/** @description 拖动结束 */
|
|
64
|
-
private _onDragEnd;
|
|
65
|
-
/** @description 滚轮滚动 */
|
|
66
|
-
private _onWheelScroll;
|
|
67
|
-
/** @description 惯性动画 */
|
|
68
|
-
private _applyInertia;
|
|
69
|
-
/** @description 限制滚动范围 */
|
|
70
|
-
private _limitScrollRange;
|
|
71
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { Container, Sprite, } from "pixi.js";
|
|
2
|
-
import { gsap } from "gsap";
|
|
3
|
-
import { libPixiEvent } from "../../Utils/LibPixiEvent";
|
|
4
|
-
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
5
|
-
import { LibPixiRectangle } from "../Base/LibPixiRectangle";
|
|
6
|
-
/** @description 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹 */
|
|
7
|
-
export class LibPixiScrollContainerX extends LibPixiContainer {
|
|
8
|
-
constructor(params) {
|
|
9
|
-
const { width, height, scrollContent, bgColor, maskTexture, maskX = 0, maskY = 0, } = params;
|
|
10
|
-
super(width, height, bgColor);
|
|
11
|
-
/** 开始位置 */
|
|
12
|
-
this._startX = 0;
|
|
13
|
-
/** 惯性速度 */
|
|
14
|
-
this._velocity = 0;
|
|
15
|
-
/** 上一次滚动时间 */
|
|
16
|
-
this._startTime = 0;
|
|
17
|
-
/** 开始位置 */
|
|
18
|
-
this._startPosition = 0;
|
|
19
|
-
/** 滚动速度 */
|
|
20
|
-
this._scrollSpeed = 200;
|
|
21
|
-
/** 是否处于拖动状态 */
|
|
22
|
-
this._isDragging = false;
|
|
23
|
-
/** 左边距 */
|
|
24
|
-
this._leftMargin = 0;
|
|
25
|
-
this._scrollContent = scrollContent;
|
|
26
|
-
// 创建内容容器
|
|
27
|
-
this._content = new Container();
|
|
28
|
-
this.addChild(this._content);
|
|
29
|
-
this._content.addChild(this._scrollContent);
|
|
30
|
-
//自定义遮罩
|
|
31
|
-
if (maskTexture) {
|
|
32
|
-
this._maskGraphics = new Sprite(maskTexture);
|
|
33
|
-
this.addChild(this._maskGraphics);
|
|
34
|
-
this._maskGraphics.width = width;
|
|
35
|
-
this._maskGraphics.height = height;
|
|
36
|
-
this._maskGraphics.position.set(maskX, maskY);
|
|
37
|
-
this.mask = this._maskGraphics;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this._maskGraphics = new LibPixiRectangle(width, height, "#000");
|
|
41
|
-
this.addChild(this._maskGraphics);
|
|
42
|
-
this.mask = this._maskGraphics;
|
|
43
|
-
}
|
|
44
|
-
// 添加事件监听
|
|
45
|
-
libPixiEvent(this, "pointerdown", (event) => {
|
|
46
|
-
this._onDragStart(event);
|
|
47
|
-
});
|
|
48
|
-
libPixiEvent(LibPixiScrollContainerX.stage, "pointermove", (event) => {
|
|
49
|
-
this._onDragMove(event);
|
|
50
|
-
});
|
|
51
|
-
libPixiEvent(this, "pointerup", () => {
|
|
52
|
-
this._onDragEnd();
|
|
53
|
-
});
|
|
54
|
-
libPixiEvent(this, "wheel", (event) => {
|
|
55
|
-
this._onWheelScroll(event);
|
|
56
|
-
});
|
|
57
|
-
libPixiEvent(this, "pointerupoutside", () => {
|
|
58
|
-
this._onDragEnd();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/** @description 添加边距 */
|
|
62
|
-
addMargin(leftMargin, rightMargin = leftMargin) {
|
|
63
|
-
this._leftMargin = leftMargin;
|
|
64
|
-
if (leftMargin) {
|
|
65
|
-
const leftMarginBox = new Sprite();
|
|
66
|
-
this._content.addChild(leftMarginBox);
|
|
67
|
-
leftMarginBox.width = leftMargin;
|
|
68
|
-
this._scrollContent.x += leftMargin;
|
|
69
|
-
}
|
|
70
|
-
if (rightMargin) {
|
|
71
|
-
this._rightMarginBox = new Sprite();
|
|
72
|
-
this._content.addChild(this._rightMarginBox);
|
|
73
|
-
this._rightMarginBox.height = rightMargin;
|
|
74
|
-
this._rightMarginBox.x = leftMargin + this._scrollContent.width;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/** @description 设置滚动容器可视区宽高
|
|
78
|
-
* @param width 宽度
|
|
79
|
-
* @param height 高度
|
|
80
|
-
*/
|
|
81
|
-
setDimensions(width, height) {
|
|
82
|
-
this._maskGraphics.width = width;
|
|
83
|
-
this._maskGraphics.height = height;
|
|
84
|
-
this.setSize(width, height);
|
|
85
|
-
this._updateRightMargin();
|
|
86
|
-
}
|
|
87
|
-
/** @description 返回顶部 */
|
|
88
|
-
scrollToTop() {
|
|
89
|
-
gsap.killTweensOf(this._content);
|
|
90
|
-
this._content.x = 0;
|
|
91
|
-
}
|
|
92
|
-
/** @description 往滚动内容添加元素 */
|
|
93
|
-
addContent(container) {
|
|
94
|
-
this._scrollContent.addChild(container);
|
|
95
|
-
}
|
|
96
|
-
/** @description 更新右边距坐标 */
|
|
97
|
-
_updateRightMargin() {
|
|
98
|
-
this._rightMarginBox.x = this._leftMargin + this._scrollContent.width;
|
|
99
|
-
}
|
|
100
|
-
/** @description 按下 */
|
|
101
|
-
_onDragStart(event) {
|
|
102
|
-
if (this._content.width <= this._maskGraphics.width)
|
|
103
|
-
return;
|
|
104
|
-
const { x } = event.getLocalPosition(this);
|
|
105
|
-
this._startX = x - this._content.x;
|
|
106
|
-
this._isDragging = true;
|
|
107
|
-
this._velocity = 0;
|
|
108
|
-
this._startTime = Date.now();
|
|
109
|
-
this._startPosition = this._content.x;
|
|
110
|
-
gsap.killTweensOf(this._content);
|
|
111
|
-
}
|
|
112
|
-
/** @description 拖动 */
|
|
113
|
-
_onDragMove(event) {
|
|
114
|
-
if (this._isDragging) {
|
|
115
|
-
const { x } = event.getLocalPosition(this);
|
|
116
|
-
const newPosition = x - this._startX;
|
|
117
|
-
this._content.x = newPosition;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/** @description 拖动结束 */
|
|
121
|
-
_onDragEnd() {
|
|
122
|
-
this._isDragging = false;
|
|
123
|
-
const currentTime = Date.now();
|
|
124
|
-
const deltaTime = currentTime - this._startTime; // 计算停留时间
|
|
125
|
-
if (deltaTime < 250) {
|
|
126
|
-
// 如果停留时间在阈值内,计算惯性速度
|
|
127
|
-
this._velocity = (this._content.x - this._startPosition) / deltaTime;
|
|
128
|
-
this._applyInertia();
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
// 停留时间超出阈值,取消惯性
|
|
132
|
-
this._velocity = 0;
|
|
133
|
-
}
|
|
134
|
-
this._limitScrollRange();
|
|
135
|
-
}
|
|
136
|
-
/** @description 滚轮滚动 */
|
|
137
|
-
_onWheelScroll(event) {
|
|
138
|
-
// 如果内容高度小于遮罩高度,则不滚动
|
|
139
|
-
if (this._content.width <= this._maskGraphics.width)
|
|
140
|
-
return;
|
|
141
|
-
let x = this._content.x - event.deltaY * (this._scrollSpeed / 100);
|
|
142
|
-
if (x > 0) {
|
|
143
|
-
x = 0;
|
|
144
|
-
}
|
|
145
|
-
else if (Math.abs(x) >= this._content.width - this._maskGraphics.width) {
|
|
146
|
-
x = -(this._content.width - this._maskGraphics.width);
|
|
147
|
-
}
|
|
148
|
-
gsap.to(this._content, {
|
|
149
|
-
duration: 0.25,
|
|
150
|
-
ease: "power1.out",
|
|
151
|
-
x,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/** @description 惯性动画 */
|
|
155
|
-
_applyInertia() {
|
|
156
|
-
gsap.to(this._content, {
|
|
157
|
-
x: this._content.x + this._velocity * 250,
|
|
158
|
-
duration: 0.5,
|
|
159
|
-
ease: "power1.out",
|
|
160
|
-
onUpdate: this._limitScrollRange.bind(this),
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/** @description 限制滚动范围 */
|
|
164
|
-
_limitScrollRange() {
|
|
165
|
-
//如果内容顶部离开了滚动容器顶部,则归位
|
|
166
|
-
if (this._content.x > 0) {
|
|
167
|
-
//回弹
|
|
168
|
-
gsap.to(this._content, {
|
|
169
|
-
duration: 0.2,
|
|
170
|
-
ease: "power1.out",
|
|
171
|
-
x: 0,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
// 如果滚动距离大于内容高度减去遮罩高度
|
|
175
|
-
else if (Math.abs(this._content.x) >=
|
|
176
|
-
this._content.width - this._maskGraphics.width) {
|
|
177
|
-
// 如果内容高度大于遮罩高度,则滚动到底部
|
|
178
|
-
if (this._content.width > this._maskGraphics.width) {
|
|
179
|
-
//回弹
|
|
180
|
-
const x = -(this._content.width - this._maskGraphics.width);
|
|
181
|
-
gsap.to(this._content, {
|
|
182
|
-
duration: 0.2,
|
|
183
|
-
ease: "power1.out",
|
|
184
|
-
x,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|