lyb-pixi-js 1.12.40 → 1.12.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/Components/Base/LibPixiArc.d.ts +16 -0
  2. package/Components/Base/LibPixiArc.js +14 -0
  3. package/Components/Base/LibPixiBitText.d.ts +20 -0
  4. package/Components/Base/LibPixiBitText.js +26 -0
  5. package/Components/Base/LibPixiCircular.d.ts +7 -0
  6. package/Components/Base/LibPixiCircular.js +12 -0
  7. package/Components/Base/LibPixiContainer.d.ts +22 -0
  8. package/Components/Base/LibPixiContainer.js +51 -0
  9. package/Components/Base/LibPixiHtmlText.d.ts +31 -0
  10. package/Components/Base/LibPixiHtmlText.js +30 -0
  11. package/Components/Base/LibPixiOval.d.ts +5 -0
  12. package/Components/Base/LibPixiOval.js +10 -0
  13. package/Components/Base/LibPixiParticleMove.d.ts +101 -0
  14. package/Components/Base/LibPixiParticleMove.js +136 -0
  15. package/Components/Base/LibPixiPolygon.d.ts +7 -0
  16. package/Components/Base/LibPixiPolygon.js +15 -0
  17. package/Components/Base/LibPixiRectBgColor.d.ts +41 -0
  18. package/Components/Base/LibPixiRectBgColor.js +95 -0
  19. package/Components/Base/LibPixiRectangle.d.ts +7 -0
  20. package/Components/Base/LibPixiRectangle.js +15 -0
  21. package/Components/Base/LibPixiRound.d.ts +5 -0
  22. package/Components/Base/LibPixiRound.js +9 -0
  23. package/Components/Base/LibPixiRoundedRect.d.ts +5 -0
  24. package/Components/Base/LibPixiRoundedRect.js +10 -0
  25. package/Components/Base/LibPixiSpine.d.ts +58 -0
  26. package/Components/Base/LibPixiSpine.js +128 -0
  27. package/Components/Base/LibPixiText.d.ts +37 -0
  28. package/Components/Base/LibPixiText.js +35 -0
  29. package/Components/Custom/LibPixiAreaClick.d.ts +6 -0
  30. package/Components/Custom/LibPixiAreaClick.js +16 -0
  31. package/Components/Custom/LibPixiArrangeLinearV2.d.ts +25 -0
  32. package/Components/Custom/LibPixiArrangeLinearV2.js +80 -0
  33. package/Components/Custom/LibPixiButtonHover.d.ts +40 -0
  34. package/Components/Custom/LibPixiButtonHover.js +53 -0
  35. package/Components/Custom/LibPixiCapsule.d.ts +5 -0
  36. package/Components/Custom/LibPixiCapsule.js +10 -0
  37. package/Components/Custom/LibPixiCloseBtn.d.ts +14 -0
  38. package/Components/Custom/LibPixiCloseBtn.js +36 -0
  39. package/Components/Custom/LibPixiDragLocate.d.ts +36 -0
  40. package/Components/Custom/LibPixiDragLocate.js +230 -0
  41. package/Components/Custom/LibPixiDrawer.d.ts +16 -0
  42. package/Components/Custom/LibPixiDrawer.js +59 -0
  43. package/Components/Custom/LibPixiGridLayoutV2.d.ts +27 -0
  44. package/Components/Custom/LibPixiGridLayoutV2.js +37 -0
  45. package/Components/Custom/LibPixiHeadingParagraphLayout.d.ts +18 -0
  46. package/Components/Custom/LibPixiHeadingParagraphLayout.js +27 -0
  47. package/Components/Custom/LibPixiInput.d.ts +77 -0
  48. package/Components/Custom/LibPixiInput.js +198 -0
  49. package/Components/Custom/LibPixiLabelValue.d.ts +30 -0
  50. package/Components/Custom/LibPixiLabelValue.js +26 -0
  51. package/Components/Custom/LibPixiPerforMon.d.ts +47 -0
  52. package/Components/Custom/LibPixiPerforMon.js +166 -0
  53. package/Components/Custom/LibPixiProgress.d.ts +33 -0
  54. package/Components/Custom/LibPixiProgress.js +47 -0
  55. package/Components/Custom/LibPixiPuzzleBg.d.ts +7 -0
  56. package/Components/Custom/LibPixiPuzzleBg.js +46 -0
  57. package/Components/Custom/LibPixiScrollContainerX.d.ts +71 -0
  58. package/Components/Custom/LibPixiScrollContainerX.js +198 -0
  59. package/Components/Custom/LibPixiScrollContainerY.d.ts +109 -0
  60. package/Components/Custom/LibPixiScrollContainerY.js +340 -0
  61. package/Components/Custom/LibPixiScrollNum.d.ts +67 -0
  62. package/Components/Custom/LibPixiScrollNum.js +184 -0
  63. package/Components/Custom/LibPixiSlide.d.ts +94 -0
  64. package/Components/Custom/LibPixiSlide.js +285 -0
  65. package/Components/Custom/LibPixiSlider.d.ts +82 -0
  66. package/Components/Custom/LibPixiSlider.js +165 -0
  67. package/Components/Custom/LibPixiTable.d.ts +64 -0
  68. package/Components/Custom/LibPixiTable.js +76 -0
  69. package/Components/Custom/LibPixiTextGroupWrap.d.ts +20 -0
  70. package/Components/Custom/LibPixiTextGroupWrap.js +50 -0
  71. package/Components/Custom/LibPixiTriangle.d.ts +5 -0
  72. package/Components/Custom/LibPixiTriangle.js +12 -0
  73. package/Components/Custom/LibPixiTurntable.d.ts +6 -0
  74. package/Components/Custom/LibPixiTurntable.js +14 -0
  75. package/Utils/LibContainerCenter.d.ts +3 -0
  76. package/Utils/LibContainerCenter.js +10 -0
  77. package/Utils/LibControlledDelayedCall.d.ts +5 -0
  78. package/Utils/LibControlledDelayedCall.js +20 -0
  79. package/Utils/LibPixiArrangeLinear.d.ts +16 -0
  80. package/Utils/LibPixiArrangeLinear.js +62 -0
  81. package/Utils/LibPixiAudio.d.ts +53 -0
  82. package/Utils/LibPixiAudio.js +168 -0
  83. package/Utils/LibPixiCreateNineGrid.d.ts +15 -0
  84. package/Utils/LibPixiCreateNineGrid.js +19 -0
  85. package/Utils/LibPixiDialogManager/index.d.ts +25 -0
  86. package/Utils/LibPixiDialogManager/index.js +43 -0
  87. package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.d.ts +11 -0
  88. package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.js +31 -0
  89. package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +40 -0
  90. package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +145 -0
  91. package/Utils/LibPixiDigitalIncreasingAnimation.d.ts +18 -0
  92. package/Utils/LibPixiDigitalIncreasingAnimation.js +26 -0
  93. package/Utils/LibPixiDownScaleAnimation.d.ts +7 -0
  94. package/Utils/LibPixiDownScaleAnimation.js +33 -0
  95. package/Utils/LibPixiEmitContainerEvent.d.ts +7 -0
  96. package/Utils/LibPixiEmitContainerEvent.js +13 -0
  97. package/Utils/LibPixiEvent.d.ts +19 -0
  98. package/Utils/LibPixiEvent.js +68 -0
  99. package/Utils/LibPixiFilter.d.ts +9 -0
  100. package/Utils/LibPixiFilter.js +34 -0
  101. package/Utils/LibPixiGlobalUpdater.d.ts +15 -0
  102. package/Utils/LibPixiGlobalUpdater.js +21 -0
  103. package/Utils/LibPixiGridLayout.d.ts +10 -0
  104. package/Utils/LibPixiGridLayout.js +27 -0
  105. package/Utils/LibPixiHVCenter.d.ts +7 -0
  106. package/Utils/LibPixiHVCenter.js +14 -0
  107. package/Utils/LibPixiHVGap.d.ts +8 -0
  108. package/Utils/LibPixiHVGap.js +26 -0
  109. package/Utils/LibPixiIntervalTrigger.d.ts +7 -0
  110. package/Utils/LibPixiIntervalTrigger.js +35 -0
  111. package/Utils/LibPixiOutsideClick.d.ts +8 -0
  112. package/Utils/LibPixiOutsideClick.js +22 -0
  113. package/Utils/LibPixiOverflowHidden.d.ts +6 -0
  114. package/Utils/LibPixiOverflowHidden.js +14 -0
  115. package/Utils/LibPixiPolygonDrawTool.d.ts +44 -0
  116. package/Utils/LibPixiPolygonDrawTool.js +114 -0
  117. package/Utils/LibPixiPromiseTickerTimeout.d.ts +6 -0
  118. package/Utils/LibPixiPromiseTickerTimeout.js +22 -0
  119. package/Utils/LibPixiScaleContainer.d.ts +8 -0
  120. package/Utils/LibPixiScaleContainer.js +14 -0
  121. package/Utils/LibPixiShadow.d.ts +17 -0
  122. package/Utils/LibPixiShadow.js +18 -0
  123. package/Utils/LibPixiSlideInput.d.ts +55 -0
  124. package/Utils/LibPixiSlideInput.js +61 -0
  125. package/Utils/LibPixiTicker.d.ts +14 -0
  126. package/Utils/LibPixiTicker.js +49 -0
  127. package/Utils/LibPixiTickerTimeout.d.ts +6 -0
  128. package/Utils/LibPixiTickerTimeout.js +22 -0
  129. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 矩形类,可用于一些场景的局部点击,传颜色是为了方便定位,最终可能需要将颜色隐藏掉
3
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiRectangle-矩形
4
+ */
5
+ export class LibPixiRectangle extends Graphics {
6
+ constructor(width, height, color) {
7
+ super();
8
+ this.beginFill(color || 0x000000);
9
+ this.drawRect(0, 0, width, height);
10
+ this.endFill();
11
+ if (!color) {
12
+ this.alpha = 0;
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 圆圈 */
3
+ export declare class LibPixiRound extends Graphics {
4
+ constructor(width: number, radius: number, color: string);
5
+ }
@@ -0,0 +1,9 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 圆圈 */
3
+ export class LibPixiRound extends Graphics {
4
+ constructor(width, radius, color) {
5
+ super();
6
+ this.lineStyle(width, color);
7
+ this.drawCircle(0, 0, radius);
8
+ }
9
+ }
@@ -0,0 +1,5 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 圆角矩形 */
3
+ export declare class LibPixiRoundedRect extends Graphics {
4
+ constructor(width: number, height: number, radius: number, color: string);
5
+ }
@@ -0,0 +1,10 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 圆角矩形 */
3
+ export class LibPixiRoundedRect extends Graphics {
4
+ constructor(width, height, radius, color) {
5
+ super();
6
+ this.beginFill(color);
7
+ this.drawRoundedRect(0, 0, width, height, radius);
8
+ this.endFill();
9
+ }
10
+ }
@@ -0,0 +1,58 @@
1
+ import { type Container } from "pixi.js";
2
+ import { Spine } from "@pixi-spine/runtime-3.8";
3
+ import "pixi-spine";
4
+ export interface OnUpdateParams {
5
+ x: number;
6
+ y: number;
7
+ rotate: number;
8
+ scaleX: number;
9
+ scaleY: number;
10
+ }
11
+ export interface LibPixiSpineParams {
12
+ /** 默认是否可见 */
13
+ visible?: boolean;
14
+ /** 挂点列表 */
15
+ followPointList?: {
16
+ /** 挂点名称 */
17
+ boneName: string;
18
+ /** 跟随的精灵或容器 */
19
+ follow: Container;
20
+ /** 是否启用角度 */
21
+ angleFollow?: boolean;
22
+ /** 是否启用缩放 */
23
+ scaleFollow?: boolean;
24
+ /** 更新回调,不传则接受内置挂点更新 */
25
+ onUpdate?: (config: OnUpdateParams) => void;
26
+ }[];
27
+ }
28
+ /** @description 自定义 Spine 动画
29
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSpine-动画
30
+ */
31
+ export declare class LibPixiSpine extends Spine {
32
+ /** 挂点 */
33
+ private _followDots;
34
+ /** 是否已开始 */
35
+ private _isStart;
36
+ /** spine更新函数 */
37
+ private _loopFn;
38
+ constructor(spineNameOrTexture: string | any, params?: LibPixiSpineParams);
39
+ /** @description 设置动画
40
+ * @param animationName 动画名称
41
+ * @param loop 是否循环播放
42
+ */
43
+ setAnimation(animationName?: string, loop?: boolean): Promise<void>;
44
+ /** @description 添加动画
45
+ * @param animationName 动画名称
46
+ * @param loop 是否循环播放
47
+ * @param delay 延迟播放时间
48
+ */
49
+ addAnimation(animationName?: string, loop?: boolean, delay?: number): Promise<void>;
50
+ /** @description 改变骨骼数据 */
51
+ setSkin(skinName: string): void;
52
+ /** @description 销毁动画及挂点 */
53
+ destroyAll(): void;
54
+ /** @description 更新渲染 */
55
+ private _loop;
56
+ /** @description 更新挂点 */
57
+ private _updateFollowPoint;
58
+ }
@@ -0,0 +1,128 @@
1
+ import { Assets, Ticker } from "pixi.js";
2
+ import { Spine } from "@pixi-spine/runtime-3.8";
3
+ import gsap from "gsap";
4
+ import "pixi-spine";
5
+ /** @description 自定义 Spine 动画
6
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSpine-动画
7
+ */
8
+ export class LibPixiSpine extends Spine {
9
+ constructor(spineNameOrTexture, params) {
10
+ const { followPointList, visible = false } = params || {};
11
+ let spineData;
12
+ if (typeof spineNameOrTexture === "string") {
13
+ spineData = Assets.get(spineNameOrTexture).spineData;
14
+ }
15
+ else {
16
+ spineData = spineNameOrTexture.spineData;
17
+ }
18
+ super(spineData);
19
+ /** 挂点 */
20
+ this._followDots = [];
21
+ /** 是否已开始 */
22
+ this._isStart = false;
23
+ this.alpha = visible ? 1 : 0;
24
+ this.autoUpdate = false;
25
+ //如果存在挂点
26
+ if (followPointList === null || followPointList === void 0 ? void 0 : followPointList.length) {
27
+ followPointList === null || followPointList === void 0 ? void 0 : followPointList.forEach((item) => {
28
+ item.follow.alpha = 0;
29
+ this._followDots.push({
30
+ point: this.skeleton.findBone(item.boneName),
31
+ follow: item.follow,
32
+ onUpdate: item.onUpdate,
33
+ angleFollow: item.angleFollow || false,
34
+ scaleFollow: item.scaleFollow === undefined ? true : item.scaleFollow,
35
+ });
36
+ });
37
+ }
38
+ this._loopFn = this._loop.bind(this);
39
+ Ticker.system.add(this._loopFn);
40
+ }
41
+ /** @description 设置动画
42
+ * @param animationName 动画名称
43
+ * @param loop 是否循环播放
44
+ */
45
+ setAnimation(animationName = "animation", loop = false) {
46
+ return new Promise((resolve) => {
47
+ this.state.setAnimation(0, animationName, loop).listener = {
48
+ complete: () => {
49
+ resolve();
50
+ },
51
+ };
52
+ setTimeout(() => {
53
+ this.alpha = 1;
54
+ });
55
+ });
56
+ }
57
+ /** @description 添加动画
58
+ * @param animationName 动画名称
59
+ * @param loop 是否循环播放
60
+ * @param delay 延迟播放时间
61
+ */
62
+ addAnimation(animationName = "animation", loop = false, delay = 0) {
63
+ return new Promise((resolve) => {
64
+ this.state.addAnimation(0, animationName, loop, delay).listener = {
65
+ complete: () => {
66
+ resolve();
67
+ },
68
+ };
69
+ });
70
+ }
71
+ /** @description 改变骨骼数据 */
72
+ setSkin(skinName) {
73
+ this.skeleton.setSkinByName(skinName);
74
+ }
75
+ /** @description 销毁动画及挂点 */
76
+ destroyAll() {
77
+ Ticker.system.remove(this._loopFn);
78
+ this.destroy({ children: true });
79
+ }
80
+ /** @description 更新渲染 */
81
+ _loop() {
82
+ if (this.destroyed) {
83
+ Ticker.system.remove(this._loopFn);
84
+ return;
85
+ }
86
+ this.update(Ticker.system.deltaMS / 1000);
87
+ this._updateFollowPoint();
88
+ }
89
+ /** @description 更新挂点 */
90
+ _updateFollowPoint() {
91
+ if (this._followDots.length === 0)
92
+ return;
93
+ this._followDots.forEach((item) => {
94
+ const { worldX: x, worldY: y } = item.point;
95
+ const rotate = item.point.getWorldRotationX() * (Math.PI / 180);
96
+ const scaleX = item.point.getWorldScaleX();
97
+ const scaleY = item.point.getWorldScaleY();
98
+ if (item.onUpdate) {
99
+ item.onUpdate({
100
+ x,
101
+ y,
102
+ rotate,
103
+ scaleX,
104
+ scaleY,
105
+ });
106
+ }
107
+ else {
108
+ if (item.angleFollow) {
109
+ item.follow.rotation = rotate;
110
+ }
111
+ if (item.scaleFollow) {
112
+ item.follow.scale.set(scaleX, scaleY);
113
+ }
114
+ item.follow.position.set(x + 1920 / 2 - item.follow.width / 2, y + 1080 / 2 - item.follow.height / 2);
115
+ }
116
+ });
117
+ if (!this._isStart) {
118
+ this._isStart = true;
119
+ this._followDots.forEach((item) => {
120
+ gsap.to(item.follow, {
121
+ alpha: 1,
122
+ duration: 0.25,
123
+ delay: 0.15,
124
+ });
125
+ });
126
+ }
127
+ }
128
+ }
@@ -0,0 +1,37 @@
1
+ import { Text, type TextStyleAlign, type TextStyleFontWeight } from "pixi.js";
2
+ export interface LibPixiTextParams {
3
+ /** 文本内容 */
4
+ text: string | number;
5
+ /** 字体大小 */
6
+ fontSize?: number;
7
+ /** 字体颜色 */
8
+ fontColor?: any;
9
+ /** 渐变方向 */
10
+ gradientDirection?: "v" | "h";
11
+ /** 描边颜色 */
12
+ stroke?: string | number;
13
+ /** 描边宽度 */
14
+ strokeThickness?: number;
15
+ /** 字体样式 */
16
+ fontFamily?: string;
17
+ /** 字体粗细 */
18
+ fontWeight?: TextStyleFontWeight;
19
+ /** 换行宽度 */
20
+ wordWrapWidth?: number;
21
+ /** 行高 */
22
+ lineHeight?: number;
23
+ /** 对齐方式 */
24
+ align?: TextStyleAlign;
25
+ /** 缩进,单位为字数 */
26
+ indent?: number;
27
+ /** 阴影-颜色 角度 模糊度 阴影距离 */
28
+ shadow?: [string, number, number, number];
29
+ }
30
+ /** @description 自定义文本类
31
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiText-文本
32
+ */
33
+ export declare class LibPixiText extends Text {
34
+ /** 字体 */
35
+ static fontFamily: string;
36
+ constructor(options: LibPixiTextParams);
37
+ }
@@ -0,0 +1,35 @@
1
+ import { Text, TEXT_GRADIENT, TextStyle, } from "pixi.js";
2
+ /** @description 自定义文本类
3
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiText-文本
4
+ */
5
+ export class LibPixiText extends Text {
6
+ constructor(options) {
7
+ const { text, fontSize = 36, fontColor = 0xffffff, stroke, strokeThickness, fontFamily = "Arial", fontWeight = "normal", wordWrapWidth, lineHeight = 1, align = "left", indent = 0, shadow, gradientDirection, } = options;
8
+ const style = new TextStyle({
9
+ fontSize,
10
+ wordWrap: !!wordWrapWidth,
11
+ wordWrapWidth,
12
+ fontWeight,
13
+ lineHeight: lineHeight * fontSize,
14
+ breakWords: !!wordWrapWidth,
15
+ fill: fontColor,
16
+ align,
17
+ fontFamily: LibPixiText.fontFamily || fontFamily,
18
+ stroke: stroke ? stroke : "transparent",
19
+ strokeThickness: strokeThickness ? strokeThickness : 0,
20
+ lineJoin: "round",
21
+ fillGradientType: gradientDirection === "h"
22
+ ? TEXT_GRADIENT.LINEAR_HORIZONTAL
23
+ : TEXT_GRADIENT.LINEAR_VERTICAL,
24
+ });
25
+ if (shadow) {
26
+ style.dropShadow = true;
27
+ style.dropShadowColor = shadow[0];
28
+ style.dropShadowAngle = shadow[1] * (Math.PI / 180);
29
+ style.dropShadowBlur = shadow[2];
30
+ style.dropShadowDistance = shadow[3];
31
+ }
32
+ super(text, style);
33
+ this.position.x = indent * fontSize;
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 扩大点击范围 */
3
+ export declare class LibPixiAreaClick extends Container {
4
+ constructor(w: number, h: number);
5
+ push(container: Container): void;
6
+ }
@@ -0,0 +1,16 @@
1
+ import { Container, Sprite } from "pixi.js";
2
+ /** @description 扩大点击范围 */
3
+ export class LibPixiAreaClick extends Container {
4
+ constructor(w, h) {
5
+ super();
6
+ const fill = new Sprite();
7
+ this.addChild(fill);
8
+ fill.anchor.set(0.5);
9
+ fill.width = w;
10
+ fill.height = h;
11
+ }
12
+ push(container) {
13
+ this.addChild(container);
14
+ container.position.set(-container.width / 2, -container.height / 2);
15
+ }
16
+ }
@@ -0,0 +1,25 @@
1
+ import { Container } from "pixi.js";
2
+ export interface GridLayoutParams {
3
+ gap?: number | number[];
4
+ direction?: "x" | "y";
5
+ colNum?: number;
6
+ elementList?: any[];
7
+ anchorX?: number;
8
+ anchorY?: number;
9
+ }
10
+ /** @description 线性排列 */
11
+ export declare class LibPixiArrangeLinearV2<T extends Container> extends Container {
12
+ /** 参数 */
13
+ private _params;
14
+ /** 元素列表 */
15
+ private _elementList;
16
+ constructor(params?: GridLayoutParams);
17
+ /** @description 追加元素 */
18
+ push(element: T): void;
19
+ /** @description 布局 */
20
+ layout(): void;
21
+ /** @description 获取列表元素 */
22
+ getList(): T[];
23
+ /** @description 销毁列表元素 */
24
+ destroyList(): void;
25
+ }
@@ -0,0 +1,80 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 线性排列 */
3
+ export class LibPixiArrangeLinearV2 extends Container {
4
+ constructor(params) {
5
+ super();
6
+ /** 元素列表 */
7
+ this._elementList = [];
8
+ this._params = params || {};
9
+ this._elementList = this._params.elementList || [];
10
+ }
11
+ /** @description 追加元素 */
12
+ push(element) {
13
+ this.addChild(element);
14
+ this._elementList.push(element);
15
+ }
16
+ /** @description 布局 */
17
+ layout() {
18
+ const { colNum = this._elementList.length, gap = 0, direction = "x", anchorX = 0, anchorY = 0, } = this._params;
19
+ let lastRowMax = 0; // 当前行(或列)的最大高度(或宽度),用于多行/多列换行时计算偏移
20
+ let rowOffset = 0; // 累计偏移量,控制换行后的整体偏移位置
21
+ this._elementList.forEach((item, index) => {
22
+ var _a, _b;
23
+ const row = Math.floor(index / colNum); // 当前行号
24
+ const col = index % colNum; // 当前列号
25
+ if (direction === "x") {
26
+ //间隔
27
+ const gapValue = Array.isArray(gap) ? (_a = gap[index - 1]) !== null && _a !== void 0 ? _a : 0 : gap;
28
+ //在每行第一列重置列偏移量
29
+ if (col === 0 && row > 0) {
30
+ rowOffset += lastRowMax + gapValue;
31
+ lastRowMax = 0;
32
+ }
33
+ // 横向位置 = 前一个元素的右侧 + 间隔;首列则从 0 开始
34
+ item.x =
35
+ col === 0
36
+ ? 0
37
+ : this._elementList[index - 1].x +
38
+ this._elementList[index - 1].width +
39
+ gapValue;
40
+ // 纵向位置 = 当前累计的行偏移
41
+ rowOffset && (item.y = rowOffset);
42
+ // 更新当前行的最大高度
43
+ lastRowMax = Math.max(lastRowMax, item.height);
44
+ }
45
+ else {
46
+ //间隔
47
+ const gapValue = Array.isArray(gap) ? (_b = gap[index - 1]) !== null && _b !== void 0 ? _b : 0 : gap;
48
+ //在每列第一行重置行偏移
49
+ if (col === 0 && row > 0) {
50
+ rowOffset += lastRowMax + gapValue;
51
+ lastRowMax = 0;
52
+ }
53
+ // 纵向位置 = 首列则从 0 开始,其余从前一个元素的y坐标 + 高度 + 间隔;
54
+ item.y =
55
+ col === 0
56
+ ? 0
57
+ : this._elementList[index - 1].y +
58
+ this._elementList[index - 1].height +
59
+ gapValue;
60
+ // 横向位置 = 当前累计的列偏移
61
+ rowOffset && (item.x = rowOffset);
62
+ // 更新当前列的最大宽度
63
+ lastRowMax = Math.max(lastRowMax, item.width);
64
+ }
65
+ });
66
+ const bounds = this.getLocalBounds();
67
+ this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
68
+ }
69
+ /** @description 获取列表元素 */
70
+ getList() {
71
+ return this._elementList;
72
+ }
73
+ /** @description 销毁列表元素 */
74
+ destroyList() {
75
+ this._elementList.forEach((item) => {
76
+ item.destroy();
77
+ });
78
+ this._elementList = [];
79
+ }
80
+ }
@@ -0,0 +1,40 @@
1
+ import { Container, type Texture } from "pixi.js";
2
+ export interface LibPixiButtonHoverParams {
3
+ /** 图标资源 */
4
+ texture: Texture;
5
+ /** 悬浮图标,type为"texture"时生效 */
6
+ hoverTexture?: Texture;
7
+ /** 默认颜色 */
8
+ tintColor?: string;
9
+ /** 悬浮颜色,默认白色 */
10
+ hoverTintColor?: string;
11
+ /** 置灰颜色 */
12
+ disabledColor?: string;
13
+ }
14
+ /** @description 悬浮切换材质
15
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiButtonHover-按钮悬浮
16
+ */
17
+ export declare class LibPixiButtonHover extends Container {
18
+ /** 是否被禁用 */
19
+ private disabled;
20
+ /** 按钮 */
21
+ private _btn;
22
+ /** 默认材质 */
23
+ private _texture;
24
+ /** 悬浮材质 */
25
+ private _hoverTexture?;
26
+ /** 默认颜色 */
27
+ private _tintColor?;
28
+ /** 置灰颜色 */
29
+ private _disabledColor;
30
+ constructor(params: LibPixiButtonHoverParams);
31
+ /** @description 切换材质
32
+ * @param texture 默认材质
33
+ * @param hoverTexture 悬浮材质
34
+ */
35
+ toggleTexture(texture: Texture, hoverTexture: Texture): void;
36
+ /** @description 屏蔽
37
+ * @param status 状态
38
+ */
39
+ setDisabled(status: boolean): void;
40
+ }
@@ -0,0 +1,53 @@
1
+ import { Container, Sprite } from "pixi.js";
2
+ import { libPixiEvent } from "../../Utils/LibPixiEvent";
3
+ /** @description 悬浮切换材质
4
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiButtonHover-按钮悬浮
5
+ */
6
+ export class LibPixiButtonHover extends Container {
7
+ constructor(params) {
8
+ super();
9
+ /** 是否被禁用 */
10
+ this.disabled = false;
11
+ const { texture, hoverTexture, tintColor, hoverTintColor = "#fff", disabledColor = "#999", } = params;
12
+ this._texture = texture;
13
+ this._hoverTexture = hoverTexture;
14
+ this._tintColor = tintColor;
15
+ this._disabledColor = disabledColor;
16
+ //创建图标
17
+ this._btn = new Sprite(texture);
18
+ this.addChild(this._btn);
19
+ this._btn.anchor.set(0.5);
20
+ tintColor && (this._btn.tint = tintColor);
21
+ libPixiEvent(this._btn, "pointerenter", () => {
22
+ if (this.disabled)
23
+ return;
24
+ this._btn.tint = hoverTintColor;
25
+ if (this._hoverTexture) {
26
+ this._btn._texture = this._hoverTexture;
27
+ }
28
+ });
29
+ libPixiEvent(this._btn, "pointerleave", () => {
30
+ if (this.disabled)
31
+ return;
32
+ this._btn._texture = this._texture;
33
+ tintColor && (this._btn.tint = tintColor);
34
+ });
35
+ }
36
+ /** @description 切换材质
37
+ * @param texture 默认材质
38
+ * @param hoverTexture 悬浮材质
39
+ */
40
+ toggleTexture(texture, hoverTexture) {
41
+ this._texture = texture;
42
+ this._hoverTexture = hoverTexture;
43
+ this._btn._texture = hoverTexture;
44
+ }
45
+ /** @description 屏蔽
46
+ * @param status 状态
47
+ */
48
+ setDisabled(status) {
49
+ this.disabled = status;
50
+ this._btn.tint = status ? this._disabledColor : this._tintColor || "#fff";
51
+ this._btn.texture = this._texture;
52
+ }
53
+ }
@@ -0,0 +1,5 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 胶囊形 */
3
+ export declare class LibPixiCapsule extends Graphics {
4
+ constructor(width: number, height: number, color: string);
5
+ }
@@ -0,0 +1,10 @@
1
+ import { Graphics } from "pixi.js";
2
+ /** @description 胶囊形 */
3
+ export class LibPixiCapsule extends Graphics {
4
+ constructor(width, height, color) {
5
+ super();
6
+ this.beginFill(color);
7
+ this.drawRoundedRect(0, 0, width, height, width / 2);
8
+ this.endFill();
9
+ }
10
+ }
@@ -0,0 +1,14 @@
1
+ import type { Sprite } from "pixi.js";
2
+ import { LibPixiContainer } from "../Base/LibPixiContainer";
3
+ export interface LibPixiCloseBtnParams {
4
+ /** 按钮素材 */
5
+ sprite: Sprite;
6
+ /** 点击回调 */
7
+ onClick: () => void;
8
+ }
9
+ /** @description 右上角关闭按钮,支持悬浮旋转动画
10
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCloseBtn-关闭按钮
11
+ */
12
+ export declare class LibPixiCloseBtn extends LibPixiContainer {
13
+ constructor(params: LibPixiCloseBtnParams);
14
+ }
@@ -0,0 +1,36 @@
1
+ import gsap from "gsap";
2
+ import { libPixiEvent } from "../../Utils/LibPixiEvent";
3
+ import { LibPixiContainer } from "../Base/LibPixiContainer";
4
+ /** @description 右上角关闭按钮,支持悬浮旋转动画
5
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCloseBtn-关闭按钮
6
+ */
7
+ export class LibPixiCloseBtn extends LibPixiContainer {
8
+ constructor(params) {
9
+ const { sprite, onClick } = params;
10
+ super(sprite.width, sprite.height);
11
+ this.addChild(sprite);
12
+ sprite.anchor.set(0.5);
13
+ sprite.x = sprite.width / 2;
14
+ sprite.y = sprite.height / 2;
15
+ libPixiEvent(this, "pointerenter", () => {
16
+ gsap.to(sprite, {
17
+ duration: 0.25,
18
+ rotation: 180 * (Math.PI / 180),
19
+ });
20
+ });
21
+ const offLeave = libPixiEvent(this, "pointerleave", () => {
22
+ sprite.alpha = 1;
23
+ gsap.to(sprite, {
24
+ duration: 0.25,
25
+ rotation: 0,
26
+ });
27
+ });
28
+ libPixiEvent(this, "pointerdown", () => {
29
+ sprite.alpha = 0.5;
30
+ });
31
+ libPixiEvent(this, "pointertap", () => {
32
+ onClick();
33
+ offLeave();
34
+ });
35
+ }
36
+ }
@@ -0,0 +1,36 @@
1
+ import { Container } from "pixi.js";
2
+ /** @description 元素拖拽定位 */
3
+ export declare class LibPixiDragLocate extends Container {
4
+ static stage: Container;
5
+ /** 输入框 */
6
+ private _inputEl;
7
+ /** 搜索结果 */
8
+ private _resultEl;
9
+ /** 状态栏元素 */
10
+ private _statusBarEl;
11
+ /** 坐标元素 */
12
+ private _positionEl;
13
+ /** 当前坐标值 */
14
+ private _positionValue;
15
+ /** 是否处于定位状态 */
16
+ private _isLocalte;
17
+ /** 是否显示输入框 */
18
+ private _showInput;
19
+ /** 是否允许移动 */
20
+ private _allowMove;
21
+ /** 按下坐标 */
22
+ private _downPos;
23
+ /** 当前处于移动的元素 */
24
+ private _currentMoveContainer?;
25
+ constructor();
26
+ /** @description 创建输入框 */
27
+ private _createInput;
28
+ /** @description 创建用于展示搜索结果的列表 */
29
+ private _createResultList;
30
+ /** @description 创建搜索结果元素 */
31
+ private _createResultEl;
32
+ /** @description 创建状态栏 */
33
+ private _createStatusBar;
34
+ /** @description 递归搜索 */
35
+ private _findByName;
36
+ }