lyb-pixi-js 1.1.10 → 1.1.11

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 (63) hide show
  1. package/README.md +72 -40
  2. package/package.json +1 -1
  3. package/Components/Base/LibPixiBitText.d.ts +0 -20
  4. package/Components/Base/LibPixiBitText.js +0 -26
  5. package/Components/Base/LibPixiContainer.d.ts +0 -22
  6. package/Components/Base/LibPixiContainer.js +0 -51
  7. package/Components/Base/LibPixiParticleMove.d.ts +0 -39
  8. package/Components/Base/LibPixiParticleMove.js +0 -100
  9. package/Components/Base/LibPixiRectBgColor.d.ts +0 -45
  10. package/Components/Base/LibPixiRectBgColor.js +0 -98
  11. package/Components/Base/LibPixiSpine.d.ts +0 -57
  12. package/Components/Base/LibPixiSpine.js +0 -122
  13. package/Components/Base/LibPixiText.d.ts +0 -37
  14. package/Components/Base/LibPixiText.js +0 -32
  15. package/Components/Custom/LibPixiButtonHover.d.ts +0 -32
  16. package/Components/Custom/LibPixiButtonHover.js +0 -44
  17. package/Components/Custom/LibPixiCloseBtn.d.ts +0 -14
  18. package/Components/Custom/LibPixiCloseBtn.js +0 -35
  19. package/Components/Custom/LibPixiDrawer.d.ts +0 -16
  20. package/Components/Custom/LibPixiDrawer.js +0 -59
  21. package/Components/Custom/LibPixiPerforMon.d.ts +0 -31
  22. package/Components/Custom/LibPixiPerforMon.js +0 -107
  23. package/Components/Custom/LibPixiProgress.d.ts +0 -29
  24. package/Components/Custom/LibPixiProgress.js +0 -36
  25. package/Components/Custom/LibPixiScrollContainer.d.ts +0 -57
  26. package/Components/Custom/LibPixiScrollContainer.js +0 -166
  27. package/Components/Custom/LibPixiScrollNum.d.ts +0 -62
  28. package/Components/Custom/LibPixiScrollNum.js +0 -146
  29. package/Components/Custom/LibPixiSlider.d.ts +0 -45
  30. package/Components/Custom/LibPixiSlider.js +0 -111
  31. package/Components/Custom/LibPixiSubAddMinMax.d.ts +0 -49
  32. package/Components/Custom/LibPixiSubAddMinMax.js +0 -76
  33. package/Components/Custom/LibPixiTable.d.ts +0 -52
  34. package/Components/Custom/LibPixiTable.js +0 -70
  35. package/Utils/LibPixiAudio.d.ts +0 -34
  36. package/Utils/LibPixiAudio.js +0 -140
  37. package/Utils/LibPixiCreateNineGrid.d.ts +0 -15
  38. package/Utils/LibPixiCreateNineGrid.js +0 -19
  39. package/Utils/LibPixiEvent.d.ts +0 -9
  40. package/Utils/LibPixiEvent.js +0 -22
  41. package/Utils/LibPixiEventControlled.d.ts +0 -8
  42. package/Utils/LibPixiEventControlled.js +0 -21
  43. package/Utils/LibPixiFilter.d.ts +0 -9
  44. package/Utils/LibPixiFilter.js +0 -30
  45. package/Utils/LibPixiIntervalTrigger.d.ts +0 -6
  46. package/Utils/LibPixiIntervalTrigger.js +0 -33
  47. package/Utils/LibPixiOutsideClick.d.ts +0 -8
  48. package/Utils/LibPixiOutsideClick.js +0 -22
  49. package/Utils/LibPixiOverflowHidden.d.ts +0 -6
  50. package/Utils/LibPixiOverflowHidden.js +0 -14
  51. package/Utils/LibPixiPromiseTickerTimeout.d.ts +0 -6
  52. package/Utils/LibPixiPromiseTickerTimeout.js +0 -22
  53. package/Utils/LibPixiScaleContainer.d.ts +0 -8
  54. package/Utils/LibPixiScaleContainer.js +0 -14
  55. package/Utils/LibPixiShadow.d.ts +0 -17
  56. package/Utils/LibPixiShadow.js +0 -18
  57. package/Utils/LibPixiTickerTimeout.d.ts +0 -6
  58. package/Utils/LibPixiTickerTimeout.js +0 -28
  59. package/index.d.ts +0 -1
  60. package/index.js +0 -2
  61. package/libPixiJs.d.ts +0 -163
  62. package/libPixiJs.js +0 -174
  63. package/lyb-pixi.js +0 -1263
@@ -1,76 +0,0 @@
1
- import { libPixiFilter } from "../../Utils/LibPixiFilter"; //@ts-ignore
2
- import { LibJsNumberStepper } from 'lyb-js/Misc/LibJsNumberStepper.js';
3
- /** @description 最小、最大按钮和增减按钮功能及置灰逻辑
4
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiSubAddMinMax-数字控制器
5
- */
6
- export class LibPixiSubAddMinMax {
7
- constructor(params) {
8
- /** 金额列表数量 */
9
- this.betAmountListLength = 0;
10
- const { minBtn, maxBtn, addBtn, subBtn, initialBetIndex, betAmountListLength, onAmountIndex, } = params;
11
- this.minBtn = minBtn;
12
- this.maxBtn = maxBtn;
13
- this.subBtn = subBtn;
14
- this.addBtn = addBtn;
15
- this.onAmountIndex = onAmountIndex;
16
- this.betAmountListLength = betAmountListLength;
17
- //金额增减步进器
18
- this.baseNumSteper = new LibJsNumberStepper(betAmountListLength, //@ts-ignore
19
- (index) => {
20
- this.onAmountIndex(index);
21
- this.minMaxUpdateIndex(index);
22
- });
23
- //设置初始状态
24
- this.minMaxUpdateIndex(initialBetIndex);
25
- this.baseNumSteper.updateIndex(initialBetIndex);
26
- }
27
- /** @description 点击最小按钮 */
28
- min() {
29
- this.minMaxUpdateIndex(0);
30
- this.onAmountIndex(0);
31
- }
32
- /** @description 点击最大按钮 */
33
- max() {
34
- const index = this.betAmountListLength - 1;
35
- this.minMaxUpdateIndex(index);
36
- this.onAmountIndex(index);
37
- }
38
- /** @description 点击减少按钮 */
39
- sub() {
40
- this.baseNumSteper.down("sub");
41
- }
42
- /** @description 点击增加按钮 */
43
- add() {
44
- this.baseNumSteper.down("add");
45
- }
46
- /** @description 改变最小最大按钮状态及回调
47
- * @param index 索引
48
- */
49
- minMaxUpdateIndex(index) {
50
- if (index === 0) {
51
- this._setGrey("min");
52
- }
53
- else if (index === this.betAmountListLength - 1) {
54
- this._setGrey("max");
55
- }
56
- else {
57
- this._setGrey();
58
- }
59
- this.baseNumSteper.updateIndex(index);
60
- }
61
- /** @description 设置最大最小按钮置灰及恢复 */
62
- _setGrey(type) {
63
- this.minBtn.filters = [];
64
- this.maxBtn.filters = [];
65
- this.subBtn.filters = [];
66
- this.addBtn.filters = [];
67
- if (type === "min") {
68
- this.minBtn.filters = [libPixiFilter("desaturate")];
69
- this.subBtn.filters = [libPixiFilter("desaturate")];
70
- }
71
- else if (type === "max") {
72
- this.maxBtn.filters = [libPixiFilter("desaturate")];
73
- this.addBtn.filters = [libPixiFilter("desaturate")];
74
- }
75
- }
76
- }
@@ -1,52 +0,0 @@
1
- /** @description 表格绘制并填入数字 */
2
- import { Container } from "pixi.js";
3
- export interface LibPixiTableParams {
4
- /** 表格数据 */
5
- data: (number | string)[][];
6
- /** 单元格宽度 */
7
- cellWidth?: number;
8
- /** 单元格高度 */
9
- cellHeight?: number;
10
- /** 字体大小 */
11
- fontSize?: number;
12
- /** 字体颜色 */
13
- fontColor?: string;
14
- /** 线条厚度 */
15
- lineWidth?: number;
16
- /** 线条颜色 */
17
- lineColor?: string;
18
- }
19
- /** @description 绘制表格并填充数字
20
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
21
- */
22
- export declare class LibPixiTable extends Container {
23
- /** 行数 */
24
- private _rows;
25
- /** 列数 */
26
- private _cols;
27
- /** 单元格宽度 */
28
- private _cellWidth;
29
- /** 单元格高度 */
30
- private _cellHeight;
31
- /** 字体大小 */
32
- private _fontSize;
33
- /** 线条宽度 */
34
- private _lineWidth;
35
- /** 字体颜色 */
36
- private _fontColor;
37
- /** 线条颜色 */
38
- private _lineColor;
39
- /** 二维数字数组 */
40
- private _data;
41
- constructor(params: LibPixiTableParams);
42
- /** @description 绘制表格 */
43
- private _drawTable;
44
- /** @description 填充数字 */
45
- private fillNumbers;
46
- /** @description 创建数字文本
47
- * @param number 数字
48
- * @param col 列索引
49
- * @param row 行索引
50
- */
51
- private _createNumberText;
52
- }
@@ -1,70 +0,0 @@
1
- /** @description 表格绘制并填入数字 */
2
- import { Text, Container, Graphics } 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 = "#B4B4B8", fontSize = 24, lineWidth = 3, lineColor = "#B4B4B8", } = 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._drawTable();
21
- this.fillNumbers();
22
- }
23
- /** @description 绘制表格 */
24
- _drawTable() {
25
- const tableWidth = this._cellWidth * this._cols;
26
- const tableHeight = this._cellHeight * this._rows;
27
- const graphics = new Graphics();
28
- graphics.lineStyle(this._lineWidth, this._lineColor);
29
- // 绘制表格外框
30
- graphics.drawRect(0, 0, tableWidth, tableHeight);
31
- // 绘制横线
32
- for (let i = 1; i < this._rows; i++) {
33
- graphics.moveTo(0, i * this._cellHeight);
34
- graphics.lineTo(tableWidth, i * this._cellHeight);
35
- }
36
- // 绘制竖线
37
- for (let j = 1; j < this._cols; j++) {
38
- graphics.moveTo(j * this._cellWidth, 0);
39
- graphics.lineTo(j * this._cellWidth, tableHeight);
40
- }
41
- this.addChild(graphics);
42
- }
43
- /** @description 填充数字 */
44
- fillNumbers() {
45
- for (let row = 0; row < this._rows; row++) {
46
- for (let col = 0; col < this._cols; col++) {
47
- const number = this._data[row][col];
48
- this._createNumberText(number, col, row);
49
- }
50
- }
51
- }
52
- /** @description 创建数字文本
53
- * @param number 数字
54
- * @param col 列索引
55
- * @param row 行索引
56
- */
57
- _createNumberText(number, col, row) {
58
- const text = new Text(number.toString(), {
59
- _fontSize: this._fontSize,
60
- fill: this._fontColor,
61
- });
62
- // 计算文本的居中位置
63
- const x = col * this._cellWidth + this._cellWidth / 2;
64
- const y = row * this._cellHeight + this._cellHeight / 2;
65
- this.addChild(text);
66
- text.anchor.set(0.5);
67
- text.position.set(x, y);
68
- libPixiScaleContainer(text, this._cellWidth * 0.9);
69
- }
70
- }
@@ -1,34 +0,0 @@
1
- /** @description 音频播放器
2
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiAudio-音频播放器
3
- */
4
- export declare class LibPixiAudio {
5
- /** 是否启用音效 */
6
- effectEnabled: boolean;
7
- /** 是否启用音乐 */
8
- musicEnabled: boolean;
9
- /** 音乐是否处于暂停状态 */
10
- private _isMusicPaused;
11
- /** 是否已切换后台 */
12
- private _isBackground;
13
- /** 当前音乐播放器 */
14
- private _musicPlayer;
15
- /** 当前正在播放的音效列表 */
16
- private _playingList;
17
- constructor();
18
- /** @description 播放音效 */
19
- playEffect(link: string): Promise<void>;
20
- /** @description 播放音乐 */
21
- playMusic(link: string): Promise<void>;
22
- /** @description 暂停音乐,一般是为了停止音乐后播放指定的音效,音效结束后调用 resumeMusic */
23
- pauseMusic(): void;
24
- /** @description 继续播放音乐,调用 pauseMusic 之后调用 */
25
- resumeMusic(): void;
26
- /** @description 停止播放指定音效 */
27
- stopEffect(link: string): void;
28
- /** @description 设置启用音效 */
29
- setEffectEnabled(enabled: boolean): void;
30
- /** @description 设置启用音乐 */
31
- setMusicEnabled(enabled: boolean): void;
32
- /** @description 设置音效和音乐播放状态 */
33
- private _setPlayStatus;
34
- }
@@ -1,140 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Assets } from "pixi.js";
11
- /** @description 音频播放器
12
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiAudio-音频播放器
13
- */
14
- export class LibPixiAudio {
15
- constructor() {
16
- /** 是否启用音效 */
17
- this.effectEnabled = true;
18
- /** 是否启用音乐 */
19
- this.musicEnabled = true;
20
- /** 音乐是否处于暂停状态 */
21
- this._isMusicPaused = false;
22
- /** 是否已切换后台 */
23
- this._isBackground = false;
24
- /** 当前正在播放的音效列表 */
25
- this._playingList = [];
26
- this._musicPlayer = new Audio();
27
- document.addEventListener("visibilitychange", () => {
28
- this._isBackground = document.hidden;
29
- this._setPlayStatus(!document.hidden);
30
- });
31
- }
32
- /** @description 播放音效 */
33
- playEffect(link) {
34
- return new Promise((resolve) => {
35
- const id = new Date().getTime();
36
- const url = Assets.get(link).url;
37
- const audio = new Audio(url);
38
- audio.muted = this._isBackground || !this.effectEnabled;
39
- audio.addEventListener("ended", () => {
40
- this._playingList = this._playingList.filter((item) => item.id !== id);
41
- resolve();
42
- });
43
- audio
44
- .play()
45
- .then(() => {
46
- this._playingList.push({
47
- id,
48
- audio,
49
- url,
50
- });
51
- })
52
- .catch(() => { });
53
- });
54
- }
55
- /** @description 播放音乐 */
56
- playMusic(link) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- //如果有音乐正在播放,则停止
59
- if (this._musicPlayer) {
60
- gsap.killTweensOf(this._musicPlayer);
61
- yield gsap.to(this._musicPlayer, {
62
- volume: 0,
63
- duration: 1,
64
- ease: "linear",
65
- });
66
- this._musicPlayer.pause();
67
- }
68
- const url = Assets.get(link).url;
69
- this._musicPlayer.src = url;
70
- this._musicPlayer.loop = true;
71
- this._musicPlayer.volume = 0;
72
- const play = () => {
73
- this._musicPlayer
74
- .play()
75
- .then(() => {
76
- this._isMusicPaused = false;
77
- gsap.killTweensOf(this._musicPlayer);
78
- gsap.to(this._musicPlayer, {
79
- volume: 1,
80
- duration: 1,
81
- ease: "linear",
82
- });
83
- })
84
- .catch(() => {
85
- requestAnimationFrame(play.bind(this));
86
- });
87
- };
88
- play();
89
- });
90
- }
91
- /** @description 暂停音乐,一般是为了停止音乐后播放指定的音效,音效结束后调用 resumeMusic */
92
- pauseMusic() {
93
- this._isMusicPaused = true;
94
- this._musicPlayer.pause();
95
- }
96
- /** @description 继续播放音乐,调用 pauseMusic 之后调用 */
97
- resumeMusic() {
98
- this._isMusicPaused = false;
99
- this._musicPlayer.play();
100
- }
101
- /** @description 停止播放指定音效 */
102
- stopEffect(link) {
103
- const url = Assets.get(link).url;
104
- this._playingList.forEach((item) => {
105
- if (item.url === url) {
106
- item.audio.pause();
107
- }
108
- });
109
- this._playingList = this._playingList.filter((item) => item.url !== url);
110
- }
111
- /** @description 设置启用音效 */
112
- setEffectEnabled(enabled) {
113
- this.effectEnabled = enabled;
114
- this._playingList.forEach((item) => {
115
- item.audio.muted = !enabled;
116
- });
117
- }
118
- /** @description 设置启用音乐 */
119
- setMusicEnabled(enabled) {
120
- this.musicEnabled = enabled;
121
- this._musicPlayer.muted = !enabled;
122
- }
123
- /** @description 设置音效和音乐播放状态 */
124
- _setPlayStatus(status) {
125
- if (status) {
126
- !this._isMusicPaused && this._musicPlayer.play();
127
- }
128
- else {
129
- this._musicPlayer.pause();
130
- }
131
- this._playingList.forEach((item) => {
132
- if (status) {
133
- item.audio.play();
134
- }
135
- else {
136
- item.audio.pause();
137
- }
138
- });
139
- }
140
- }
@@ -1,15 +0,0 @@
1
- import { NineSlicePlane, type Texture } from "pixi.js";
2
- export interface LibPixiCreateNineGridParams {
3
- /** 九宫格图片 */
4
- texture: Texture;
5
- /** 四个角的宽度 */
6
- dotWidth: number | [number, number, number, number];
7
- /** 宽度 */
8
- width: number;
9
- /** 高度 */
10
- height: number;
11
- }
12
- /** @description 九宫格图
13
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCreateNineGrid-九宫格图
14
- */
15
- export declare const libPixiCreateNineGrid: (params: LibPixiCreateNineGridParams) => NineSlicePlane;
@@ -1,19 +0,0 @@
1
- import { NineSlicePlane } from "pixi.js";
2
- /** @description 九宫格图
3
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCreateNineGrid-九宫格图
4
- */
5
- export const libPixiCreateNineGrid = (params) => {
6
- const { texture, dotWidth, width, height } = params;
7
- let slice_width = [];
8
- // 四个角的宽度
9
- if (Array.isArray(dotWidth)) {
10
- slice_width = dotWidth;
11
- }
12
- else {
13
- slice_width = [dotWidth, dotWidth, dotWidth, dotWidth];
14
- }
15
- const nineSlicePlane = new NineSlicePlane(texture, slice_width[0], slice_width[1], slice_width[2], slice_width[3]);
16
- nineSlicePlane.width = width;
17
- nineSlicePlane.height = height;
18
- return nineSlicePlane;
19
- };
@@ -1,9 +0,0 @@
1
- import type { Container, DisplayObjectEvents } from "pixi.js";
2
- /** @description 事件注册
3
- * @param v 事件容器
4
- * @param eventName 事件名称
5
- * @param callback 回调函数
6
- * @param once 是否只执行一次
7
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
8
- */
9
- export declare const libPixiEvent: (v: Container, eventName: keyof DisplayObjectEvents, callback: (...args: any) => void, once?: boolean) => void;
@@ -1,22 +0,0 @@
1
- /** @description 事件注册
2
- * @param v 事件容器
3
- * @param eventName 事件名称
4
- * @param callback 回调函数
5
- * @param once 是否只执行一次
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEvent-事件注册
7
- */
8
- export const libPixiEvent = (v, eventName, callback, once = false) => {
9
- v.cursor = "pointer";
10
- v.eventMode = "static";
11
- const fn = (e) => {
12
- if (e.button === 2)
13
- return;
14
- callback(e);
15
- };
16
- if (once) {
17
- v.once(eventName, fn);
18
- }
19
- else {
20
- v.on(eventName, fn);
21
- }
22
- };
@@ -1,8 +0,0 @@
1
- import type { Container, DisplayObjectEvents } from "pixi.js";
2
- /** @description 设置可关闭的事件监听,调用自身后不再触发
3
- * @param container 事件容器
4
- * @param eventName 事件名称
5
- * @param callback 事件回调
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEventControlled-可关闭的事件
7
- */
8
- export declare const libPixiEventControlled: (container: Container, eventName: keyof DisplayObjectEvents, callback: (...args: any) => void) => () => void;
@@ -1,21 +0,0 @@
1
- /** @description 设置可关闭的事件监听,调用自身后不再触发
2
- * @param container 事件容器
3
- * @param eventName 事件名称
4
- * @param callback 事件回调
5
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiEventControlled-可关闭的事件
6
- */
7
- export const libPixiEventControlled = (container, eventName, callback) => {
8
- let isDestroy = false;
9
- container.cursor = "pointer";
10
- container.eventMode = "static";
11
- container.on(eventName, (e) => {
12
- if (isDestroy)
13
- return;
14
- if (e.button === 2)
15
- return;
16
- callback(e);
17
- });
18
- return () => {
19
- isDestroy = true;
20
- };
21
- };
@@ -1,9 +0,0 @@
1
- /** @description 设置滤镜 */
2
- import { ColorMatrixFilter, BlurFilter } from "pixi.js";
3
- export type LibPixiSetFilterFilterName = "brightness" | "blur" | "desaturate" | "contrast";
4
- /** @description 滤镜
5
- * @param filterName 滤镜名称
6
- * @param v 滤镜值
7
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiFilter-滤镜
8
- */
9
- export declare const libPixiFilter: (filterName: LibPixiSetFilterFilterName, v?: number) => ColorMatrixFilter | BlurFilter;
@@ -1,30 +0,0 @@
1
- /** @description 设置滤镜 */
2
- import { ColorMatrixFilter, BlurFilter } from "pixi.js";
3
- /** @description 滤镜
4
- * @param filterName 滤镜名称
5
- * @param v 滤镜值
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiFilter-滤镜
7
- */
8
- export const libPixiFilter = (filterName, v) => {
9
- let filter;
10
- if (filterName === "brightness") {
11
- filter = new ColorMatrixFilter();
12
- filter.brightness(v, false); // 设置亮度
13
- }
14
- else if (filterName === "blur") {
15
- filter = new BlurFilter();
16
- }
17
- else if (filterName === "desaturate") {
18
- filter = new ColorMatrixFilter();
19
- filter.desaturate();
20
- }
21
- else if (filterName === "contrast") {
22
- filter = new ColorMatrixFilter();
23
- filter.contrast(v, false);
24
- }
25
- else {
26
- throw new Error("未知滤镜名称");
27
- }
28
- filter.resolution = window.devicePixelRatio || 1;
29
- return filter;
30
- };
@@ -1,6 +0,0 @@
1
- /** @description 间隔触发
2
- * @param callback 回调函数
3
- * @param interval 间隔毫秒,或随机范围
4
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiIntervalTrigger-间隔触发
5
- */
6
- export declare const libPixiIntervalTrigger: (callback: () => void, interval: number | [number, number]) => () => void;
@@ -1,33 +0,0 @@
1
- import { Ticker } from "pixi.js"; //@ts-ignore
2
- import { libJsRandom } from "lyb-js/Random/LibJsRandom.js";
3
- /** @description 间隔触发
4
- * @param callback 回调函数
5
- * @param interval 间隔毫秒,或随机范围
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiIntervalTrigger-间隔触发
7
- */
8
- export const libPixiIntervalTrigger = (callback, interval) => {
9
- let elapsedTime = 0;
10
- // 创建一个新的 Ticker 实例
11
- const ticker = new Ticker();
12
- // 创建回调函数
13
- const tickerCallback = (deltaTime) => {
14
- elapsedTime += deltaTime * ticker.deltaMS;
15
- let intervalNum = 0;
16
- if (Array.isArray(interval)) {
17
- intervalNum = libJsRandom(interval[0], interval[1], 2);
18
- }
19
- else {
20
- intervalNum = interval;
21
- }
22
- if (elapsedTime >= intervalNum) {
23
- callback();
24
- elapsedTime = 0;
25
- }
26
- };
27
- ticker.add(tickerCallback);
28
- ticker.start();
29
- return () => {
30
- ticker.remove(tickerCallback);
31
- ticker.stop();
32
- };
33
- };
@@ -1,8 +0,0 @@
1
- import type { Container } from "pixi.js";
2
- /** @description 点击容器外或入口按钮时隐藏
3
- * @param container 容器
4
- * @param btn 按钮
5
- * @param onClose 关闭回调
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiOutsideClick-失焦隐藏
7
- */
8
- export declare const libPixiOutsideClick: (container: Container, btn: Container, onClose: () => void) => () => void;
@@ -1,22 +0,0 @@
1
- /** @description 点击容器外或入口按钮时隐藏
2
- * @param container 容器
3
- * @param btn 按钮
4
- * @param onClose 关闭回调
5
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiOutsideClick-失焦隐藏
6
- */
7
- export const libPixiOutsideClick = (container, btn, onClose) => {
8
- const outsideClick = (e) => {
9
- const btnInside = btn.getBounds().contains(e.clientX, e.clientY);
10
- const containerInside = container
11
- .getBounds()
12
- .contains(e.clientX, e.clientY);
13
- if (!btnInside && !containerInside && container.visible) {
14
- onClose();
15
- window.removeEventListener("pointerdown", outsideClick);
16
- }
17
- };
18
- window.addEventListener("pointerdown", outsideClick);
19
- return () => {
20
- window.removeEventListener("pointerdown", outsideClick);
21
- };
22
- };
@@ -1,6 +0,0 @@
1
- import { Graphics, type Container } from "pixi.js";
2
- /** @description 为容器创建并应用一个矩形遮罩,用于隐藏溢出的内容,函数会返回遮罩,可控制是否显示遮罩
3
- * @param container 需要设置遮罩裁剪的容器
4
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiOverflowHidden-溢出裁剪
5
- */
6
- export declare const libPixiOverflowHidden: (container: Container) => Graphics;
@@ -1,14 +0,0 @@
1
- import { Graphics } from "pixi.js";
2
- /** @description 为容器创建并应用一个矩形遮罩,用于隐藏溢出的内容,函数会返回遮罩,可控制是否显示遮罩
3
- * @param container 需要设置遮罩裁剪的容器
4
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiOverflowHidden-溢出裁剪
5
- */
6
- export const libPixiOverflowHidden = (container) => {
7
- const mask = new Graphics();
8
- mask.beginFill(0xffffff);
9
- mask.drawRect(0, 0, container.width, container.height);
10
- mask.endFill();
11
- container.addChild(mask);
12
- container.mask = mask;
13
- return mask;
14
- };
@@ -1,6 +0,0 @@
1
- /** @description 基于 Ticker 和 Promise 的定时器
2
- * @param delay 延迟时间
3
- * @param callback 延迟后执行的函数
4
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPromiseTickerTimeout-TickerPromise定时器
5
- */
6
- export declare const libPixiPromiseTickerTimeout: (delay?: number, callback?: () => void) => Promise<void>;
@@ -1,22 +0,0 @@
1
- import { Ticker } from "pixi.js";
2
- /** @description 基于 Ticker 和 Promise 的定时器
3
- * @param delay 延迟时间
4
- * @param callback 延迟后执行的函数
5
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPromiseTickerTimeout-TickerPromise定时器
6
- */
7
- export const libPixiPromiseTickerTimeout = (delay = 1, callback) => {
8
- return new Promise((resolve) => {
9
- let elapsedTime = 0;
10
- const ticker = new Ticker();
11
- const tickerCallback = () => {
12
- elapsedTime += ticker.deltaMS;
13
- if (elapsedTime >= delay) {
14
- callback === null || callback === void 0 ? void 0 : callback();
15
- ticker.destroy();
16
- resolve();
17
- }
18
- };
19
- ticker.add(tickerCallback);
20
- ticker.start();
21
- });
22
- };
@@ -1,8 +0,0 @@
1
- import type { Container, Sprite, Text } from "pixi.js";
2
- /** @description 元素超过指定宽度就缩放
3
- * @param scaleContainer 需要缩放的元素
4
- * @param maxWidth 最大宽度
5
- * @param maxHeight 最大高度
6
- * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiScaleContainer-超出缩放
7
- */
8
- export declare const libPixiScaleContainer: (scaleContainer: Container | Sprite | Text, maxWidth: number, maxHeight?: number) => void;