lyb-pixi-js 1.12.32 → 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.
Files changed (137) hide show
  1. package/README.md +50 -85
  2. package/index.js +5 -2
  3. package/lyb-pixi.js +208 -196
  4. package/package.json +1 -1
  5. package/Components/Base/LibDestroyContainer.d.ts +0 -11
  6. package/Components/Base/LibDestroyContainer.js +0 -28
  7. package/Components/Base/LibPixiArc.d.ts +0 -16
  8. package/Components/Base/LibPixiArc.js +0 -14
  9. package/Components/Base/LibPixiBitText.d.ts +0 -20
  10. package/Components/Base/LibPixiBitText.js +0 -26
  11. package/Components/Base/LibPixiCircular.d.ts +0 -7
  12. package/Components/Base/LibPixiCircular.js +0 -12
  13. package/Components/Base/LibPixiContainer.d.ts +0 -22
  14. package/Components/Base/LibPixiContainer.js +0 -51
  15. package/Components/Base/LibPixiHtmlText.d.ts +0 -31
  16. package/Components/Base/LibPixiHtmlText.js +0 -30
  17. package/Components/Base/LibPixiOval.d.ts +0 -5
  18. package/Components/Base/LibPixiOval.js +0 -10
  19. package/Components/Base/LibPixiParticleMove.d.ts +0 -101
  20. package/Components/Base/LibPixiParticleMove.js +0 -136
  21. package/Components/Base/LibPixiPolygon.d.ts +0 -7
  22. package/Components/Base/LibPixiPolygon.js +0 -15
  23. package/Components/Base/LibPixiRectBgColor.d.ts +0 -41
  24. package/Components/Base/LibPixiRectBgColor.js +0 -95
  25. package/Components/Base/LibPixiRectangle.d.ts +0 -7
  26. package/Components/Base/LibPixiRectangle.js +0 -15
  27. package/Components/Base/LibPixiRound.d.ts +0 -5
  28. package/Components/Base/LibPixiRound.js +0 -9
  29. package/Components/Base/LibPixiRoundedRect.d.ts +0 -5
  30. package/Components/Base/LibPixiRoundedRect.js +0 -10
  31. package/Components/Base/LibPixiSpine.d.ts +0 -58
  32. package/Components/Base/LibPixiSpine.js +0 -128
  33. package/Components/Base/LibPixiText.d.ts +0 -37
  34. package/Components/Base/LibPixiText.js +0 -35
  35. package/Components/Custom/LibPixiArrangeLinearV2.d.ts +0 -25
  36. package/Components/Custom/LibPixiArrangeLinearV2.js +0 -80
  37. package/Components/Custom/LibPixiButtonHover.d.ts +0 -40
  38. package/Components/Custom/LibPixiButtonHover.js +0 -53
  39. package/Components/Custom/LibPixiCapsule.d.ts +0 -5
  40. package/Components/Custom/LibPixiCapsule.js +0 -10
  41. package/Components/Custom/LibPixiCloseBtn.d.ts +0 -14
  42. package/Components/Custom/LibPixiCloseBtn.js +0 -36
  43. package/Components/Custom/LibPixiDragLocate.d.ts +0 -36
  44. package/Components/Custom/LibPixiDragLocate.js +0 -230
  45. package/Components/Custom/LibPixiDrawer.d.ts +0 -16
  46. package/Components/Custom/LibPixiDrawer.js +0 -59
  47. package/Components/Custom/LibPixiInput.d.ts +0 -75
  48. package/Components/Custom/LibPixiInput.js +0 -186
  49. package/Components/Custom/LibPixiLabelValue.d.ts +0 -30
  50. package/Components/Custom/LibPixiLabelValue.js +0 -26
  51. package/Components/Custom/LibPixiPerforMon.d.ts +0 -47
  52. package/Components/Custom/LibPixiPerforMon.js +0 -166
  53. package/Components/Custom/LibPixiProgress.d.ts +0 -33
  54. package/Components/Custom/LibPixiProgress.js +0 -47
  55. package/Components/Custom/LibPixiPuzzleBg.d.ts +0 -7
  56. package/Components/Custom/LibPixiPuzzleBg.js +0 -46
  57. package/Components/Custom/LibPixiScrollContainerX.d.ts +0 -71
  58. package/Components/Custom/LibPixiScrollContainerX.js +0 -189
  59. package/Components/Custom/LibPixiScrollContainerY.d.ts +0 -109
  60. package/Components/Custom/LibPixiScrollContainerY.js +0 -338
  61. package/Components/Custom/LibPixiScrollNum.d.ts +0 -67
  62. package/Components/Custom/LibPixiScrollNum.js +0 -184
  63. package/Components/Custom/LibPixiSlide.d.ts +0 -94
  64. package/Components/Custom/LibPixiSlide.js +0 -285
  65. package/Components/Custom/LibPixiSlider.d.ts +0 -82
  66. package/Components/Custom/LibPixiSlider.js +0 -165
  67. package/Components/Custom/LibPixiSubAddMinMax.d.ts +0 -40
  68. package/Components/Custom/LibPixiSubAddMinMax.js +0 -56
  69. package/Components/Custom/LibPixiTable.d.ts +0 -64
  70. package/Components/Custom/LibPixiTable.js +0 -76
  71. package/Components/Custom/LibPixiTextGroup.d.ts +0 -20
  72. package/Components/Custom/LibPixiTextGroup.js +0 -50
  73. package/Components/Custom/LibPixiTextGroupWrap.d.ts +0 -20
  74. package/Components/Custom/LibPixiTextGroupWrap.js +0 -50
  75. package/Components/Custom/LibPixiTriangle.d.ts +0 -5
  76. package/Components/Custom/LibPixiTriangle.js +0 -12
  77. package/Components/Custom/LibPixiTurntable.d.ts +0 -6
  78. package/Components/Custom/LibPixiTurntable.js +0 -14
  79. package/Utils/LibContainerCenter.d.ts +0 -3
  80. package/Utils/LibContainerCenter.js +0 -10
  81. package/Utils/LibControlledDelayedCall.d.ts +0 -5
  82. package/Utils/LibControlledDelayedCall.js +0 -20
  83. package/Utils/LibPixiArrangeLinear.d.ts +0 -16
  84. package/Utils/LibPixiArrangeLinear.js +0 -62
  85. package/Utils/LibPixiAudio.d.ts +0 -53
  86. package/Utils/LibPixiAudio.js +0 -168
  87. package/Utils/LibPixiCreateNineGrid.d.ts +0 -15
  88. package/Utils/LibPixiCreateNineGrid.js +0 -19
  89. package/Utils/LibPixiDialogManager/index.d.ts +0 -25
  90. package/Utils/LibPixiDialogManager/index.js +0 -43
  91. package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.d.ts +0 -11
  92. package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.js +0 -31
  93. package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +0 -38
  94. package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +0 -133
  95. package/Utils/LibPixiDigitalIncreasingAnimation.d.ts +0 -18
  96. package/Utils/LibPixiDigitalIncreasingAnimation.js +0 -26
  97. package/Utils/LibPixiDownScaleAnimation.d.ts +0 -7
  98. package/Utils/LibPixiDownScaleAnimation.js +0 -33
  99. package/Utils/LibPixiEmitContainerEvent.d.ts +0 -7
  100. package/Utils/LibPixiEmitContainerEvent.js +0 -13
  101. package/Utils/LibPixiEvent.d.ts +0 -19
  102. package/Utils/LibPixiEvent.js +0 -68
  103. package/Utils/LibPixiFilter.d.ts +0 -9
  104. package/Utils/LibPixiFilter.js +0 -34
  105. package/Utils/LibPixiGlobalUpdater.d.ts +0 -15
  106. package/Utils/LibPixiGlobalUpdater.js +0 -21
  107. package/Utils/LibPixiGridLayout.d.ts +0 -10
  108. package/Utils/LibPixiGridLayout.js +0 -27
  109. package/Utils/LibPixiGridLayoutV2.d.ts +0 -27
  110. package/Utils/LibPixiGridLayoutV2.js +0 -37
  111. package/Utils/LibPixiHVCenter.d.ts +0 -7
  112. package/Utils/LibPixiHVCenter.js +0 -14
  113. package/Utils/LibPixiHVGap.d.ts +0 -8
  114. package/Utils/LibPixiHVGap.js +0 -26
  115. package/Utils/LibPixiIntervalTrigger.d.ts +0 -7
  116. package/Utils/LibPixiIntervalTrigger.js +0 -35
  117. package/Utils/LibPixiOutsideClick.d.ts +0 -8
  118. package/Utils/LibPixiOutsideClick.js +0 -22
  119. package/Utils/LibPixiOverflowHidden.d.ts +0 -6
  120. package/Utils/LibPixiOverflowHidden.js +0 -14
  121. package/Utils/LibPixiPolygonDrawTool.d.ts +0 -44
  122. package/Utils/LibPixiPolygonDrawTool.js +0 -114
  123. package/Utils/LibPixiPromiseTickerTimeout.d.ts +0 -6
  124. package/Utils/LibPixiPromiseTickerTimeout.js +0 -22
  125. package/Utils/LibPixiScaleContainer.d.ts +0 -8
  126. package/Utils/LibPixiScaleContainer.js +0 -14
  127. package/Utils/LibPixiShadow.d.ts +0 -17
  128. package/Utils/LibPixiShadow.js +0 -18
  129. package/Utils/LibPixiSlideInput.d.ts +0 -55
  130. package/Utils/LibPixiSlideInput.js +0 -61
  131. package/Utils/LibPixiTicker.d.ts +0 -14
  132. package/Utils/LibPixiTicker.js +0 -49
  133. package/Utils/LibPixiTickerTimeout.d.ts +0 -6
  134. package/Utils/LibPixiTickerTimeout.js +0 -22
  135. package/index.d.ts +0 -1
  136. package/libPixiJs.d.ts +0 -296
  137. package/libPixiJs.js +0 -315
@@ -1,56 +0,0 @@
1
- import { LibJsNumberStepper } from "lyb-js/Misc/LibJsNumberStepper.js";
2
- /** @description 最小、最大按钮和增减按钮功能及置灰逻辑
3
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSubAddMinMax-数字控制器
4
- */
5
- export class LibPixiSubAddMinMax {
6
- constructor(params) {
7
- /** 金额列表数量 */
8
- this._betAmountListLength = 0;
9
- const { initialBetIndex, betAmountListLength, onAmountIndex, onDisabled } = params;
10
- this._onAmountIndex = onAmountIndex;
11
- this._onDisabled = onDisabled;
12
- this._betAmountListLength = betAmountListLength;
13
- //金额增减步进器
14
- this._baseNumSteper = new LibJsNumberStepper(betAmountListLength, (index) => {
15
- this._onAmountIndex(index);
16
- this.minMaxUpdateIndex(index);
17
- });
18
- //设置初始状态
19
- this.minMaxUpdateIndex(initialBetIndex);
20
- this._baseNumSteper.updateIndex(initialBetIndex);
21
- }
22
- /** @description 点击最小按钮 */
23
- min() {
24
- this.minMaxUpdateIndex(0);
25
- this._onAmountIndex(0);
26
- }
27
- /** @description 点击最大按钮 */
28
- max() {
29
- const index = this._betAmountListLength - 1;
30
- this.minMaxUpdateIndex(index);
31
- this._onAmountIndex(index);
32
- }
33
- /** @description 点击减少按钮 */
34
- sub() {
35
- this._baseNumSteper.down("sub");
36
- }
37
- /** @description 点击增加按钮 */
38
- add() {
39
- this._baseNumSteper.down("add");
40
- }
41
- /** @description 改变最小最大按钮状态及回调
42
- * @param index 索引
43
- */
44
- minMaxUpdateIndex(index) {
45
- if (index === 0) {
46
- this._onDisabled("min");
47
- }
48
- else if (index === this._betAmountListLength - 1) {
49
- this._onDisabled("max");
50
- }
51
- else {
52
- this._onDisabled();
53
- }
54
- this._baseNumSteper.updateIndex(index);
55
- }
56
- }
@@ -1,64 +0,0 @@
1
- /** @description 表格绘制并填入数字 */
2
- import { Container } from "pixi.js";
3
- export interface LibPixiTableParams {
4
- /** 表格数据 */
5
- data: (number | string)[][];
6
- /** 是否需要表格外框 */
7
- outsideBorder?: boolean;
8
- /** 单元格宽度 */
9
- cellWidth?: number;
10
- /** 单元格高度 */
11
- cellHeight?: number;
12
- /** 字体大小 */
13
- fontSize?: number;
14
- /** 字体颜色 */
15
- fontColor?: string;
16
- /** 表格第一列字体颜色 */
17
- firstColumnFontColor?: string;
18
- /** 是否需要加粗 */
19
- fontBold?: boolean;
20
- /** 线条厚度 */
21
- lineWidth?: number;
22
- /** 线条颜色 */
23
- lineColor?: string;
24
- }
25
- /** @description 绘制表格并填充数字
26
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
27
- */
28
- export declare class LibPixiTable extends Container {
29
- /** 行数 */
30
- private _rows;
31
- /** 列数 */
32
- private _cols;
33
- /** 单元格宽度 */
34
- private _cellWidth;
35
- /** 单元格高度 */
36
- private _cellHeight;
37
- /** 字体大小 */
38
- private _fontSize;
39
- /** 线条宽度 */
40
- private _lineWidth;
41
- /** 字体颜色 */
42
- private _fontColor;
43
- /** 表格第一列字体颜色 */
44
- private _firstColumnFontColor;
45
- /** 线条颜色 */
46
- private _lineColor;
47
- /** 是否需要表格外框 */
48
- private _outsideBorder;
49
- /** 是否需要加粗 */
50
- private _fontBold;
51
- /** 二维数字数组 */
52
- private _data;
53
- constructor(params: LibPixiTableParams);
54
- /** @description 绘制表格 */
55
- private _drawTable;
56
- /** @description 填充数字 */
57
- private fillNumbers;
58
- /** @description 创建数字文本
59
- * @param number 数字
60
- * @param col 列索引
61
- * @param row 行索引
62
- */
63
- private _createNumberText;
64
- }
@@ -1,76 +0,0 @@
1
- /** @description 表格绘制并填入数字 */
2
- import { Container, Graphics, Text } from "pixi.js";
3
- import { libPixiScaleContainer } from '../../Utils/LibPixiScaleContainer';
4
- /** @description 绘制表格并填充数字
5
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
6
- */
7
- export class LibPixiTable extends Container {
8
- constructor(params) {
9
- super();
10
- const { data, cellWidth = 130, cellHeight = 100, fontColor = "#fff", firstColumnFontColor = "#fff", fontSize = 30, lineWidth = 2, lineColor = "#5b5b5b", outsideBorder = true, fontBold = true, } = params;
11
- this._data = data;
12
- this._rows = data.length;
13
- this._cols = data[0].length;
14
- this._cellWidth = cellWidth;
15
- this._cellHeight = cellHeight;
16
- this._fontColor = fontColor;
17
- this._fontSize = fontSize;
18
- this._lineWidth = lineWidth;
19
- this._lineColor = lineColor;
20
- this._outsideBorder = outsideBorder;
21
- this._fontBold = fontBold;
22
- this._firstColumnFontColor = firstColumnFontColor;
23
- this._drawTable();
24
- this.fillNumbers();
25
- }
26
- /** @description 绘制表格 */
27
- _drawTable() {
28
- const tableWidth = this._cellWidth * this._cols;
29
- const tableHeight = this._cellHeight * this._rows;
30
- const graphics = new Graphics();
31
- graphics.lineStyle(this._lineWidth, this._lineColor);
32
- // 绘制表格外框
33
- if (this._outsideBorder) {
34
- graphics.drawRect(0, 0, tableWidth, tableHeight);
35
- }
36
- // 绘制横线
37
- for (let i = 1; i < this._rows; i++) {
38
- graphics.moveTo(0, i * this._cellHeight);
39
- graphics.lineTo(tableWidth, i * this._cellHeight);
40
- }
41
- // 绘制竖线
42
- for (let j = 1; j < this._cols; j++) {
43
- graphics.moveTo(j * this._cellWidth, 0);
44
- graphics.lineTo(j * this._cellWidth, tableHeight);
45
- }
46
- this.addChild(graphics);
47
- }
48
- /** @description 填充数字 */
49
- fillNumbers() {
50
- for (let row = 0; row < this._rows; row++) {
51
- for (let col = 0; col < this._cols; col++) {
52
- const number = this._data[row][col];
53
- this._createNumberText(number, col, row);
54
- }
55
- }
56
- }
57
- /** @description 创建数字文本
58
- * @param number 数字
59
- * @param col 列索引
60
- * @param row 行索引
61
- */
62
- _createNumberText(number, col, row) {
63
- const text = new Text(number.toString(), {
64
- _fontSize: this._fontSize,
65
- fill: col === 0 ? this._firstColumnFontColor : this._fontColor,
66
- fontWeight: this._fontBold ? "bold" : "normal",
67
- });
68
- // 计算文本的居中位置
69
- const x = col * this._cellWidth + this._cellWidth / 2;
70
- const y = row * this._cellHeight + this._cellHeight / 2;
71
- this.addChild(text);
72
- text.anchor.set(0.5);
73
- text.position.set(x, y);
74
- libPixiScaleContainer(text, this._cellWidth * 0.9);
75
- }
76
- }
@@ -1,20 +0,0 @@
1
- import { Container, type ITextStyle } from "pixi.js";
2
- interface TextItem {
3
- text: string;
4
- style?: Partial<ITextStyle>;
5
- }
6
- interface TextGroupOptions {
7
- items: TextItem[];
8
- defaultStyle?: Partial<ITextStyle>;
9
- wordWrapWidth?: number;
10
- paddingX?: number;
11
- paddingY?: number;
12
- align?: "left" | "center" | "right";
13
- anchorX?: number;
14
- anchorY?: number;
15
- }
16
- /** @description 文本组换行 */
17
- export declare class LibPixiTextGroupWrap extends Container {
18
- constructor({ items, defaultStyle, wordWrapWidth, paddingX, paddingY, align, anchorX, anchorY, }: TextGroupOptions);
19
- }
20
- export {};
@@ -1,50 +0,0 @@
1
- import { Container, Text } from "pixi.js";
2
- /** @description 文本组换行 */
3
- export class LibPixiTextGroupWrap extends Container {
4
- constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, }) {
5
- super();
6
- if (!items.length)
7
- return;
8
- const lineGroups = [];
9
- let currentLine = [];
10
- let x = 0;
11
- // 分行
12
- for (const { text, style = {} } of items) {
13
- const instance = new Text(text, Object.assign(Object.assign({}, defaultStyle), style));
14
- const w = instance.width;
15
- if (wordWrapWidth && x + w > wordWrapWidth && x > 0) {
16
- lineGroups.push(currentLine);
17
- currentLine = [];
18
- x = 0;
19
- }
20
- currentLine.push(instance);
21
- x += w + paddingX;
22
- }
23
- if (currentLine.length)
24
- lineGroups.push(currentLine);
25
- // 布局每行
26
- let y = 0;
27
- for (const line of lineGroups) {
28
- const totalWidth = line.reduce((sum, i) => sum + i.width + paddingX, -paddingX);
29
- let offsetX = 0;
30
- if (align === "center" && wordWrapWidth)
31
- offsetX = (wordWrapWidth - totalWidth) / 2;
32
- else if (align === "right" && wordWrapWidth)
33
- offsetX = wordWrapWidth - totalWidth;
34
- let currentX = offsetX;
35
- let maxHeight = 0;
36
- for (const item of line) {
37
- item.x = currentX;
38
- item.y = y;
39
- this.addChild(item);
40
- currentX += item.width + paddingX;
41
- if (item.height > maxHeight)
42
- maxHeight = item.height;
43
- }
44
- y += maxHeight + paddingY;
45
- }
46
- // 根据 anchor 调整整体偏移
47
- const bounds = this.getLocalBounds();
48
- this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
49
- }
50
- }
@@ -1,20 +0,0 @@
1
- import { Container, type ITextStyle } from "pixi.js";
2
- interface TextItem {
3
- text: string;
4
- style?: Partial<ITextStyle>;
5
- }
6
- interface TextGroupOptions {
7
- items: TextItem[];
8
- defaultStyle?: Partial<ITextStyle>;
9
- wordWrapWidth?: number;
10
- paddingX?: number;
11
- paddingY?: number;
12
- align?: "left" | "center" | "right";
13
- anchorX?: number;
14
- anchorY?: number;
15
- }
16
- /** @description 文本组换行 */
17
- export declare class LibPixiTextGroupWrap extends Container {
18
- constructor({ items, defaultStyle, wordWrapWidth, paddingX, paddingY, align, anchorX, anchorY, }: TextGroupOptions);
19
- }
20
- export {};
@@ -1,50 +0,0 @@
1
- import { Container, Text } from "pixi.js";
2
- /** @description 文本组换行 */
3
- export class LibPixiTextGroupWrap extends Container {
4
- constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, }) {
5
- super();
6
- if (!items.length)
7
- return;
8
- const lineGroups = [];
9
- let currentLine = [];
10
- let x = 0;
11
- // 分行
12
- for (const { text, style = {} } of items) {
13
- const instance = new Text(text, Object.assign(Object.assign({}, defaultStyle), style));
14
- const w = instance.width;
15
- if (wordWrapWidth && x + w > wordWrapWidth && x > 0) {
16
- lineGroups.push(currentLine);
17
- currentLine = [];
18
- x = 0;
19
- }
20
- currentLine.push(instance);
21
- x += w + paddingX;
22
- }
23
- if (currentLine.length)
24
- lineGroups.push(currentLine);
25
- // 布局每行
26
- let y = 0;
27
- for (const line of lineGroups) {
28
- const totalWidth = line.reduce((sum, i) => sum + i.width + paddingX, -paddingX);
29
- let offsetX = 0;
30
- if (align === "center" && wordWrapWidth)
31
- offsetX = (wordWrapWidth - totalWidth) / 2;
32
- else if (align === "right" && wordWrapWidth)
33
- offsetX = wordWrapWidth - totalWidth;
34
- let currentX = offsetX;
35
- let maxHeight = 0;
36
- for (const item of line) {
37
- item.x = currentX;
38
- item.y = y;
39
- this.addChild(item);
40
- currentX += item.width + paddingX;
41
- if (item.height > maxHeight)
42
- maxHeight = item.height;
43
- }
44
- y += maxHeight + paddingY;
45
- }
46
- // 根据 anchor 调整整体偏移
47
- const bounds = this.getLocalBounds();
48
- this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
49
- }
50
- }
@@ -1,5 +0,0 @@
1
- import { Graphics } from "pixi.js";
2
- /** @description 三角形 */
3
- export declare class LibPixiTriangle extends Graphics {
4
- constructor(dots: [[number, number], [number, number]], color: string);
5
- }
@@ -1,12 +0,0 @@
1
- import { Graphics } from "pixi.js";
2
- /** @description 三角形 */
3
- export class LibPixiTriangle extends Graphics {
4
- constructor(dots, color) {
5
- super();
6
- this.beginFill(color);
7
- this.moveTo(0, 0);
8
- this.lineTo(dots[0][0], dots[0][1]);
9
- this.lineTo(dots[1][0], dots[1][1]);
10
- this.endFill();
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- /** @description 转盘布局
2
- * @param num 份数
3
- * @param distance 中心距离
4
- * @param layoutCallback 定位计算回调
5
- */
6
- export declare const LibPixiTurntable: (num: number, distance: number, layoutCallback: (x: number, y: number, rotation: number, index: number) => void) => void;
@@ -1,14 +0,0 @@
1
- import { libJsConvertAngle } from "lyb-js/Math/LibJsConvertAngle.js";
2
- /** @description 转盘布局
3
- * @param num 份数
4
- * @param distance 中心距离
5
- * @param layoutCallback 定位计算回调
6
- */
7
- export const LibPixiTurntable = (num, distance, layoutCallback) => {
8
- for (let i = 0; i < num; i++) {
9
- const rotation = libJsConvertAngle((360 / num) * i, "rad");
10
- const cos = Math.cos(rotation + libJsConvertAngle(-90, "rad"));
11
- const sin = Math.sin(rotation + libJsConvertAngle(-90, "rad"));
12
- layoutCallback(cos * distance, sin * distance, rotation, i);
13
- }
14
- };
@@ -1,3 +0,0 @@
1
- import { Container } from "pixi.js";
2
- /** @description 当前容器在父容器居中 */
3
- export declare const libContainerCenter: (parent: Container, item: Container, centerType?: "x" | "y" | "xy") => void;
@@ -1,10 +0,0 @@
1
- /** @description 当前容器在父容器居中 */
2
- export const libContainerCenter = (parent, item, centerType = "xy") => {
3
- const xy = centerType === "xy";
4
- if (centerType === "x" || xy) {
5
- item.x = parent.width / 2 - item.width / 2;
6
- }
7
- if (centerType === "y" || xy) {
8
- item.y = parent.height / 2 - item.height / 2;
9
- }
10
- };
@@ -1,5 +0,0 @@
1
- /** @description 可控延迟调用函数 */
2
- export declare const libControlledDelayedCall: (time: number) => {
3
- start: Promise<void>;
4
- stop: () => void;
5
- };
@@ -1,20 +0,0 @@
1
- import { libPixiTickerTimeout } from "./LibPixiTickerTimeout";
2
- /** @description 可控延迟调用函数 */
3
- export const libControlledDelayedCall = (time) => {
4
- let _resolve;
5
- let timer;
6
- const start = new Promise((resolve) => {
7
- _resolve = resolve;
8
- timer = libPixiTickerTimeout(() => {
9
- resolve();
10
- }, time);
11
- });
12
- const stop = () => {
13
- timer();
14
- _resolve();
15
- };
16
- return {
17
- start,
18
- stop,
19
- };
20
- };
@@ -1,16 +0,0 @@
1
- import type { Container } from "pixi.js";
2
- /**
3
- * @description 线性排列 PIXI.Container 元素(支持横向/纵向排列,多列布局、固定或自定义间隔)
4
- * @param items 需要排列的容器数组
5
- * @param gap 间隔,可为固定值或数组(数组长度必须等于 items.length - 1)
6
- * @param direction 排列方向:"x" 横向排列,"y" 纵向排列
7
- * @param cols 每行(或每列)最多的元素个数,默认为 Infinity(单行/单列)
8
- * @example
9
- * // 横向排列
10
- * LibPixiArrangeLinear([sprite1, sprite2, sprite3], 10, "x");
11
- * // 纵向排列
12
- * LibPixiArrangeLinear([sprite1, sprite2, sprite3], 20, "y");
13
- * // 两列布局
14
- * LibPixiArrangeLinear([sprite1, sprite2, sprite3, sprite4], 10, "x", 2);
15
- */
16
- export declare const LibPixiArrangeLinear: (items: Container[], gap: number | number[], direction?: "x" | "y", cols?: number) => void;
@@ -1,62 +0,0 @@
1
- /**
2
- * @description 线性排列 PIXI.Container 元素(支持横向/纵向排列,多列布局、固定或自定义间隔)
3
- * @param items 需要排列的容器数组
4
- * @param gap 间隔,可为固定值或数组(数组长度必须等于 items.length - 1)
5
- * @param direction 排列方向:"x" 横向排列,"y" 纵向排列
6
- * @param cols 每行(或每列)最多的元素个数,默认为 Infinity(单行/单列)
7
- * @example
8
- * // 横向排列
9
- * LibPixiArrangeLinear([sprite1, sprite2, sprite3], 10, "x");
10
- * // 纵向排列
11
- * LibPixiArrangeLinear([sprite1, sprite2, sprite3], 20, "y");
12
- * // 两列布局
13
- * LibPixiArrangeLinear([sprite1, sprite2, sprite3, sprite4], 10, "x", 2);
14
- */
15
- export const LibPixiArrangeLinear = (items, gap, direction = "x", cols = Infinity) => {
16
- // 验证 gap 数组长度是否正确
17
- if (Array.isArray(gap)) {
18
- if (gap.length !== items.length - 1) {
19
- console.error(new Error("间隔的数组长度只能等于元素数组长度-1"));
20
- return;
21
- }
22
- }
23
- let lastRowMax = 0; // 当前行(或列)的最大高度(或宽度),用于多行/多列换行时计算偏移
24
- let rowOffset = 0; // 累计偏移量,控制换行后的整体偏移位置
25
- items.forEach((item, index) => {
26
- var _a, _b;
27
- const row = Math.floor(index / cols); // 当前行号
28
- const col = index % cols; // 当前列号
29
- if (direction === "x") {
30
- //间隔
31
- const gapValue = Array.isArray(gap) ? (_a = gap[index - 1]) !== null && _a !== void 0 ? _a : 0 : gap;
32
- //在每行第一列重置列偏移量
33
- if (col === 0 && row > 0) {
34
- rowOffset += lastRowMax + gapValue;
35
- lastRowMax = 0;
36
- }
37
- // 横向位置 = 前一个元素的右侧 + 间隔;首列则从 0 开始
38
- item.x =
39
- col === 0 ? 0 : items[index - 1].x + items[index - 1].width + 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 ? 0 : items[index - 1].y + items[index - 1].height + gapValue;
56
- // 横向位置 = 当前累计的列偏移
57
- rowOffset && (item.x = rowOffset);
58
- // 更新当前列的最大宽度
59
- lastRowMax = Math.max(lastRowMax, item.width);
60
- }
61
- });
62
- };
@@ -1,53 +0,0 @@
1
- import "@pixi/sound";
2
- export declare class LibPixiAudio {
3
- /** 是否启用音效 */
4
- effectEnabled: boolean;
5
- /** 是否启用音乐 */
6
- musicEnabled: boolean;
7
- /** 音乐是否处于暂停状态 */
8
- private _isMusicPaused;
9
- /** 是否已切换后台 */
10
- private _isBackground;
11
- /** 当前音乐播放器 */
12
- private _musicPlayer?;
13
- /** 当前正在播放的音效列表 */
14
- private _playingList;
15
- constructor();
16
- /** @description 播放音效
17
- * @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
18
- * @param end 倒数几秒位置播放,单位秒
19
- */
20
- playEffect(key: string, end?: number): Promise<void>;
21
- /** @description 播放音乐
22
- * @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
23
- */
24
- playMusic(key: string): Promise<void>;
25
- /** @description 暂停音乐 */
26
- pauseMusic(): void;
27
- /** @description 继续播放音乐 */
28
- resumeMusic(): void;
29
- /** @description 停止播放指定音效
30
- * @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
31
- */
32
- stopEffect(key: string): void;
33
- /** @description 设置启用音效
34
- * @param enabled 启用状态,false为禁用
35
- */
36
- setEffectEnabled(enabled: boolean): void;
37
- /** @description 设置启用音乐
38
- * @param enabled 启用状态,false为禁用
39
- */
40
- setMusicEnabled(enabled: boolean): void;
41
- /** @description 设置音效和音乐播放状态
42
- * @param status 播放状态,false为暂停
43
- */
44
- private _setPlayStatus;
45
- /** @description 设置静音音乐
46
- * @param disabled 静音状态,true为静音
47
- */
48
- private _setMusicMute;
49
- /** @description 设置静音音效
50
- * @param disabled 静音状态,true为静音
51
- */
52
- private _setEffectMute;
53
- }