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.
- package/Components/Base/LibPixiArc.d.ts +16 -0
- package/Components/Base/LibPixiArc.js +14 -0
- package/Components/Base/LibPixiBitText.d.ts +20 -0
- package/Components/Base/LibPixiBitText.js +26 -0
- package/Components/Base/LibPixiCircular.d.ts +7 -0
- package/Components/Base/LibPixiCircular.js +12 -0
- package/Components/Base/LibPixiContainer.d.ts +22 -0
- package/Components/Base/LibPixiContainer.js +51 -0
- package/Components/Base/LibPixiHtmlText.d.ts +31 -0
- package/Components/Base/LibPixiHtmlText.js +30 -0
- package/Components/Base/LibPixiOval.d.ts +5 -0
- package/Components/Base/LibPixiOval.js +10 -0
- package/Components/Base/LibPixiParticleMove.d.ts +101 -0
- package/Components/Base/LibPixiParticleMove.js +136 -0
- package/Components/Base/LibPixiPolygon.d.ts +7 -0
- package/Components/Base/LibPixiPolygon.js +15 -0
- package/Components/Base/LibPixiRectBgColor.d.ts +41 -0
- package/Components/Base/LibPixiRectBgColor.js +95 -0
- package/Components/Base/LibPixiRectangle.d.ts +7 -0
- package/Components/Base/LibPixiRectangle.js +15 -0
- package/Components/Base/LibPixiRound.d.ts +5 -0
- package/Components/Base/LibPixiRound.js +9 -0
- package/Components/Base/LibPixiRoundedRect.d.ts +5 -0
- package/Components/Base/LibPixiRoundedRect.js +10 -0
- package/Components/Base/LibPixiSpine.d.ts +58 -0
- package/Components/Base/LibPixiSpine.js +128 -0
- package/Components/Base/LibPixiText.d.ts +37 -0
- package/Components/Base/LibPixiText.js +35 -0
- package/Components/Custom/LibPixiAreaClick.d.ts +6 -0
- package/Components/Custom/LibPixiAreaClick.js +16 -0
- package/Components/Custom/LibPixiArrangeLinearV2.d.ts +25 -0
- package/Components/Custom/LibPixiArrangeLinearV2.js +80 -0
- package/Components/Custom/LibPixiButtonHover.d.ts +40 -0
- package/Components/Custom/LibPixiButtonHover.js +53 -0
- package/Components/Custom/LibPixiCapsule.d.ts +5 -0
- package/Components/Custom/LibPixiCapsule.js +10 -0
- package/Components/Custom/LibPixiCloseBtn.d.ts +14 -0
- package/Components/Custom/LibPixiCloseBtn.js +36 -0
- package/Components/Custom/LibPixiDragLocate.d.ts +36 -0
- package/Components/Custom/LibPixiDragLocate.js +230 -0
- package/Components/Custom/LibPixiDrawer.d.ts +16 -0
- package/Components/Custom/LibPixiDrawer.js +59 -0
- package/Components/Custom/LibPixiGridLayoutV2.d.ts +27 -0
- package/Components/Custom/LibPixiGridLayoutV2.js +37 -0
- package/Components/Custom/LibPixiHeadingParagraphLayout.d.ts +18 -0
- package/Components/Custom/LibPixiHeadingParagraphLayout.js +27 -0
- package/Components/Custom/LibPixiInput.d.ts +77 -0
- package/Components/Custom/LibPixiInput.js +198 -0
- package/Components/Custom/LibPixiLabelValue.d.ts +30 -0
- package/Components/Custom/LibPixiLabelValue.js +26 -0
- package/Components/Custom/LibPixiPerforMon.d.ts +47 -0
- package/Components/Custom/LibPixiPerforMon.js +166 -0
- package/Components/Custom/LibPixiProgress.d.ts +33 -0
- package/Components/Custom/LibPixiProgress.js +47 -0
- package/Components/Custom/LibPixiPuzzleBg.d.ts +7 -0
- package/Components/Custom/LibPixiPuzzleBg.js +46 -0
- package/Components/Custom/LibPixiScrollContainerX.d.ts +71 -0
- package/Components/Custom/LibPixiScrollContainerX.js +198 -0
- package/Components/Custom/LibPixiScrollContainerY.d.ts +109 -0
- package/Components/Custom/LibPixiScrollContainerY.js +340 -0
- package/Components/Custom/LibPixiScrollNum.d.ts +67 -0
- package/Components/Custom/LibPixiScrollNum.js +184 -0
- package/Components/Custom/LibPixiSlide.d.ts +94 -0
- package/Components/Custom/LibPixiSlide.js +285 -0
- package/Components/Custom/LibPixiSlider.d.ts +82 -0
- package/Components/Custom/LibPixiSlider.js +165 -0
- package/Components/Custom/LibPixiTable.d.ts +64 -0
- package/Components/Custom/LibPixiTable.js +76 -0
- package/Components/Custom/LibPixiTextGroupWrap.d.ts +20 -0
- package/Components/Custom/LibPixiTextGroupWrap.js +50 -0
- package/Components/Custom/LibPixiTriangle.d.ts +5 -0
- package/Components/Custom/LibPixiTriangle.js +12 -0
- package/Components/Custom/LibPixiTurntable.d.ts +6 -0
- package/Components/Custom/LibPixiTurntable.js +14 -0
- package/Utils/LibContainerCenter.d.ts +3 -0
- package/Utils/LibContainerCenter.js +10 -0
- package/Utils/LibControlledDelayedCall.d.ts +5 -0
- package/Utils/LibControlledDelayedCall.js +20 -0
- package/Utils/LibPixiArrangeLinear.d.ts +16 -0
- package/Utils/LibPixiArrangeLinear.js +62 -0
- package/Utils/LibPixiAudio.d.ts +53 -0
- package/Utils/LibPixiAudio.js +168 -0
- package/Utils/LibPixiCreateNineGrid.d.ts +15 -0
- package/Utils/LibPixiCreateNineGrid.js +19 -0
- package/Utils/LibPixiDialogManager/index.d.ts +25 -0
- package/Utils/LibPixiDialogManager/index.js +43 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.d.ts +11 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiBaseContainer.js +31 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.d.ts +40 -0
- package/Utils/LibPixiDialogManager/ui/LibPixiDialog.js +145 -0
- package/Utils/LibPixiDigitalIncreasingAnimation.d.ts +18 -0
- package/Utils/LibPixiDigitalIncreasingAnimation.js +26 -0
- package/Utils/LibPixiDownScaleAnimation.d.ts +7 -0
- package/Utils/LibPixiDownScaleAnimation.js +33 -0
- package/Utils/LibPixiEmitContainerEvent.d.ts +7 -0
- package/Utils/LibPixiEmitContainerEvent.js +13 -0
- package/Utils/LibPixiEvent.d.ts +19 -0
- package/Utils/LibPixiEvent.js +68 -0
- package/Utils/LibPixiFilter.d.ts +9 -0
- package/Utils/LibPixiFilter.js +34 -0
- package/Utils/LibPixiGlobalUpdater.d.ts +15 -0
- package/Utils/LibPixiGlobalUpdater.js +21 -0
- package/Utils/LibPixiGridLayout.d.ts +10 -0
- package/Utils/LibPixiGridLayout.js +27 -0
- package/Utils/LibPixiHVCenter.d.ts +7 -0
- package/Utils/LibPixiHVCenter.js +14 -0
- package/Utils/LibPixiHVGap.d.ts +8 -0
- package/Utils/LibPixiHVGap.js +26 -0
- package/Utils/LibPixiIntervalTrigger.d.ts +7 -0
- package/Utils/LibPixiIntervalTrigger.js +35 -0
- package/Utils/LibPixiOutsideClick.d.ts +8 -0
- package/Utils/LibPixiOutsideClick.js +22 -0
- package/Utils/LibPixiOverflowHidden.d.ts +6 -0
- package/Utils/LibPixiOverflowHidden.js +14 -0
- package/Utils/LibPixiPolygonDrawTool.d.ts +44 -0
- package/Utils/LibPixiPolygonDrawTool.js +114 -0
- package/Utils/LibPixiPromiseTickerTimeout.d.ts +6 -0
- package/Utils/LibPixiPromiseTickerTimeout.js +22 -0
- package/Utils/LibPixiScaleContainer.d.ts +8 -0
- package/Utils/LibPixiScaleContainer.js +14 -0
- package/Utils/LibPixiShadow.d.ts +17 -0
- package/Utils/LibPixiShadow.js +18 -0
- package/Utils/LibPixiSlideInput.d.ts +55 -0
- package/Utils/LibPixiSlideInput.js +61 -0
- package/Utils/LibPixiTicker.d.ts +14 -0
- package/Utils/LibPixiTicker.js +49 -0
- package/Utils/LibPixiTickerTimeout.d.ts +6 -0
- package/Utils/LibPixiTickerTimeout.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
interface Params {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
radius: number;
|
|
6
|
+
color: string;
|
|
7
|
+
strokeColor?: string;
|
|
8
|
+
thickness?: number;
|
|
9
|
+
alpha?: number;
|
|
10
|
+
anticlockwise?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** @description 弧形 */
|
|
13
|
+
export declare class LibPixiArc extends Graphics {
|
|
14
|
+
constructor(params: Params);
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
/** @description 弧形 */
|
|
3
|
+
export class LibPixiArc extends Graphics {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
super();
|
|
6
|
+
const { start, end, radius, color, strokeColor, thickness, alpha = 1, anticlockwise = false } = params;
|
|
7
|
+
this.beginFill(color, alpha); // 半透明绿色填充
|
|
8
|
+
strokeColor && this.lineStyle(thickness, strokeColor); // 线宽为2,红色
|
|
9
|
+
this.moveTo(0, 0);
|
|
10
|
+
this.arc(0, 0, radius, start, end, anticlockwise);
|
|
11
|
+
this.closePath();
|
|
12
|
+
this.endFill();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BitmapText } from "pixi.js";
|
|
2
|
+
/** @description 自定义位图文本
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiBitText-位图
|
|
4
|
+
*/
|
|
5
|
+
export declare class LibPixiBitText {
|
|
6
|
+
/** 字体名称 */
|
|
7
|
+
private _fontName;
|
|
8
|
+
private _defaultFontSize?;
|
|
9
|
+
/**
|
|
10
|
+
* @param fontName 字体名称
|
|
11
|
+
* @param defaultFontSize 默认字体大小
|
|
12
|
+
*/
|
|
13
|
+
constructor(fontName: string, defaultFontSize?: number);
|
|
14
|
+
/** @description 创建位图文本
|
|
15
|
+
* @param text 文本内容
|
|
16
|
+
* @param fontSize 字体大小,不填则使用默认大小
|
|
17
|
+
* @returns 位图实例
|
|
18
|
+
*/
|
|
19
|
+
createText(text: string | number, fontSize?: number): BitmapText;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BitmapText } from "pixi.js";
|
|
2
|
+
/** @description 自定义位图文本
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiBitText-位图
|
|
4
|
+
*/
|
|
5
|
+
export class LibPixiBitText {
|
|
6
|
+
/**
|
|
7
|
+
* @param fontName 字体名称
|
|
8
|
+
* @param defaultFontSize 默认字体大小
|
|
9
|
+
*/
|
|
10
|
+
constructor(fontName, defaultFontSize) {
|
|
11
|
+
this._fontName = fontName;
|
|
12
|
+
this._defaultFontSize = defaultFontSize;
|
|
13
|
+
}
|
|
14
|
+
/** @description 创建位图文本
|
|
15
|
+
* @param text 文本内容
|
|
16
|
+
* @param fontSize 字体大小,不填则使用默认大小
|
|
17
|
+
* @returns 位图实例
|
|
18
|
+
*/
|
|
19
|
+
createText(text, fontSize) {
|
|
20
|
+
const bitMapText = new BitmapText(text.toString(), {
|
|
21
|
+
fontName: this._fontName,
|
|
22
|
+
fontSize: this._defaultFontSize || fontSize,
|
|
23
|
+
});
|
|
24
|
+
return bitMapText;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
/** @description 圆形
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiCircular-圆形
|
|
4
|
+
*/
|
|
5
|
+
export class LibPixiCircular extends Graphics {
|
|
6
|
+
constructor(radius, color) {
|
|
7
|
+
super();
|
|
8
|
+
this.beginFill(color);
|
|
9
|
+
this.drawCircle(0, 0, radius);
|
|
10
|
+
this.endFill();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
/** @description 自定义容器大小及背景色
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiContainer-容器
|
|
4
|
+
*/
|
|
5
|
+
export declare class LibPixiContainer extends Container {
|
|
6
|
+
/** 填充容器 */
|
|
7
|
+
private _fill?;
|
|
8
|
+
/** 背景色填充 */
|
|
9
|
+
private _bgColorFill?;
|
|
10
|
+
/**
|
|
11
|
+
* @param width 容器宽度
|
|
12
|
+
* @param height 容器高度
|
|
13
|
+
* @param bgColor 背景色
|
|
14
|
+
* @param overHidden 是否溢出裁剪
|
|
15
|
+
*/
|
|
16
|
+
constructor(width: number, height: number, bgColor?: string, overHidden?: boolean);
|
|
17
|
+
/** @description 设置容器大小
|
|
18
|
+
* @param width 容器宽度
|
|
19
|
+
* @param height 容器高度
|
|
20
|
+
*/
|
|
21
|
+
setSize(width: number, height: number): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Container, Graphics, Sprite } from "pixi.js";
|
|
2
|
+
import { LibPixiRectBgColor } from './LibPixiRectBgColor';
|
|
3
|
+
/** @description 自定义容器大小及背景色
|
|
4
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiContainer-容器
|
|
5
|
+
*/
|
|
6
|
+
export class LibPixiContainer extends Container {
|
|
7
|
+
/**
|
|
8
|
+
* @param width 容器宽度
|
|
9
|
+
* @param height 容器高度
|
|
10
|
+
* @param bgColor 背景色
|
|
11
|
+
* @param overHidden 是否溢出裁剪
|
|
12
|
+
*/
|
|
13
|
+
constructor(width, height, bgColor, overHidden) {
|
|
14
|
+
super();
|
|
15
|
+
if (overHidden) {
|
|
16
|
+
const mask = new Graphics();
|
|
17
|
+
mask.beginFill(0xffffff);
|
|
18
|
+
mask.drawRect(0, 0, width, height);
|
|
19
|
+
mask.endFill();
|
|
20
|
+
this.addChild(mask);
|
|
21
|
+
this.mask = mask;
|
|
22
|
+
}
|
|
23
|
+
if (bgColor) {
|
|
24
|
+
this._bgColorFill = new LibPixiRectBgColor({
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
bgColor,
|
|
28
|
+
});
|
|
29
|
+
this.addChild(this._bgColorFill);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this._fill = new Sprite();
|
|
33
|
+
this._fill.width = width;
|
|
34
|
+
this._fill.height = height;
|
|
35
|
+
this.addChild(this._fill);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** @description 设置容器大小
|
|
39
|
+
* @param width 容器宽度
|
|
40
|
+
* @param height 容器高度
|
|
41
|
+
*/
|
|
42
|
+
setSize(width, height) {
|
|
43
|
+
if (this._fill) {
|
|
44
|
+
this._fill.width = width;
|
|
45
|
+
this._fill.height = height;
|
|
46
|
+
}
|
|
47
|
+
if (this._bgColorFill) {
|
|
48
|
+
this._bgColorFill.renderBg(width, height);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HTMLText, type TextStyleAlign, type TextStyleFontWeight } from "pixi.js";
|
|
2
|
+
export interface LibPixiHtmlTextParams {
|
|
3
|
+
/** 文本内容 */
|
|
4
|
+
text: string | number;
|
|
5
|
+
/** 字体大小 */
|
|
6
|
+
fontSize?: number;
|
|
7
|
+
/** 字体颜色 */
|
|
8
|
+
fontColor?: any;
|
|
9
|
+
/** 描边颜色 */
|
|
10
|
+
stroke?: string | number;
|
|
11
|
+
/** 描边宽度 */
|
|
12
|
+
strokeThickness?: number;
|
|
13
|
+
/** 字体样式 */
|
|
14
|
+
fontFamily?: string;
|
|
15
|
+
/** 字体粗细 */
|
|
16
|
+
fontWeight?: TextStyleFontWeight;
|
|
17
|
+
/** 换行宽度 */
|
|
18
|
+
wordWrapWidth?: number;
|
|
19
|
+
/** 行高 */
|
|
20
|
+
lineHeight?: number;
|
|
21
|
+
/** 对齐方式 */
|
|
22
|
+
align?: TextStyleAlign;
|
|
23
|
+
/** 阴影-颜色 角度 模糊度 阴影距离 */
|
|
24
|
+
shadow?: [string, number, number, number];
|
|
25
|
+
}
|
|
26
|
+
/** @description 自定义富文本类
|
|
27
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiHtmlText-富文本
|
|
28
|
+
*/
|
|
29
|
+
export declare class LibPixiHtmlText extends HTMLText {
|
|
30
|
+
constructor(options: LibPixiHtmlTextParams);
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HTMLText, } from "pixi.js";
|
|
2
|
+
/** @description 自定义富文本类
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiHtmlText-富文本
|
|
4
|
+
*/
|
|
5
|
+
export class LibPixiHtmlText extends HTMLText {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
const { text, fontSize = 36, fontColor = 0xffffff, stroke, strokeThickness, fontFamily = "Arial", fontWeight = "normal", wordWrapWidth, lineHeight = 1.25, align = "left", shadow, } = options;
|
|
8
|
+
super(text.toString(), {
|
|
9
|
+
fontSize,
|
|
10
|
+
wordWrap: !!wordWrapWidth,
|
|
11
|
+
wordWrapWidth,
|
|
12
|
+
fontWeight,
|
|
13
|
+
lineHeight: lineHeight * fontSize,
|
|
14
|
+
breakWords: !!wordWrapWidth,
|
|
15
|
+
fill: fontColor,
|
|
16
|
+
align,
|
|
17
|
+
whiteSpace: "pre-line",
|
|
18
|
+
fontFamily: fontFamily,
|
|
19
|
+
stroke: stroke ? stroke : "transparent",
|
|
20
|
+
strokeThickness: strokeThickness ? strokeThickness : 0,
|
|
21
|
+
});
|
|
22
|
+
if (shadow) {
|
|
23
|
+
this.style.dropShadow = true;
|
|
24
|
+
this.style.dropShadowColor = shadow[0];
|
|
25
|
+
this.style.dropShadowAngle = shadow[1] * (Math.PI / 180);
|
|
26
|
+
this.style.dropShadowBlur = shadow[2];
|
|
27
|
+
this.style.dropShadowDistance = shadow[3];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
export interface LibPixiParticleMoveParams {
|
|
3
|
+
/** 粒子JSON资源 */
|
|
4
|
+
container: Container;
|
|
5
|
+
/** 运动时长 */
|
|
6
|
+
duration: number;
|
|
7
|
+
/** 粒子开始位置 */
|
|
8
|
+
start: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
/** 粒子控制点 */
|
|
13
|
+
control: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}[];
|
|
17
|
+
/** 粒子结束点 */
|
|
18
|
+
end: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
/** 运动曲线 */
|
|
23
|
+
ease?: gsap.EaseString;
|
|
24
|
+
/** 是否显示控制点,调试使用 */
|
|
25
|
+
showControl?: boolean;
|
|
26
|
+
/** 是否循环,调试使用 */
|
|
27
|
+
loop?: boolean;
|
|
28
|
+
/** 是否启用粒子容器 */
|
|
29
|
+
enableParticleContainer?: boolean;
|
|
30
|
+
/** 粒子配置 */
|
|
31
|
+
particleConfig: {
|
|
32
|
+
/** 随机时长 */
|
|
33
|
+
lifetime: {
|
|
34
|
+
/** 最小时长 */
|
|
35
|
+
min: number;
|
|
36
|
+
/** 最大时长 */
|
|
37
|
+
max: number;
|
|
38
|
+
};
|
|
39
|
+
/** 混合模式 */
|
|
40
|
+
blendMode?: string;
|
|
41
|
+
/** 频率,秒/个 */
|
|
42
|
+
frequency?: number;
|
|
43
|
+
/** 透明度变化 */
|
|
44
|
+
alpha?: {
|
|
45
|
+
/** 开始透明度 */
|
|
46
|
+
start: number;
|
|
47
|
+
/** 结束透明度 */
|
|
48
|
+
end: number;
|
|
49
|
+
};
|
|
50
|
+
/** 颜色变化 */
|
|
51
|
+
color?: {
|
|
52
|
+
/** 开始颜色 */
|
|
53
|
+
start: string;
|
|
54
|
+
/** 结束颜色 */
|
|
55
|
+
end: string;
|
|
56
|
+
};
|
|
57
|
+
/** 随机缩放变化 */
|
|
58
|
+
scale?: {
|
|
59
|
+
/** 最小 */
|
|
60
|
+
start: number;
|
|
61
|
+
/** 最大 */
|
|
62
|
+
end: number;
|
|
63
|
+
};
|
|
64
|
+
/** 随机偏移角度变化 */
|
|
65
|
+
rotation?: {
|
|
66
|
+
/** 最小角度 */
|
|
67
|
+
min: number;
|
|
68
|
+
/** 最大角度 */
|
|
69
|
+
max: number;
|
|
70
|
+
};
|
|
71
|
+
/** 随机自身旋转角度变化 */
|
|
72
|
+
rotate?: {
|
|
73
|
+
/** 最小角度 */
|
|
74
|
+
min: number;
|
|
75
|
+
/** 最大角度 */
|
|
76
|
+
max: number;
|
|
77
|
+
};
|
|
78
|
+
/** 移动速度,像素 */
|
|
79
|
+
speed?: {
|
|
80
|
+
/** 开始速度,不能为0,可无限接近0 */
|
|
81
|
+
start: number;
|
|
82
|
+
/** 结束速度,开始速度会衰减到结束速度 */
|
|
83
|
+
end: number;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** 头部粒子到达终点后触发,可在此设置隐藏动画,隐藏动画结束后调用 destroy 参数进行销毁 */
|
|
87
|
+
onDestroy?: (destroy: () => void) => void;
|
|
88
|
+
}
|
|
89
|
+
/** @description 利用贝塞尔曲线实现粒子移动
|
|
90
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiParticleMove-粒子容器
|
|
91
|
+
*/
|
|
92
|
+
export declare class LibPixiParticleMove extends Container {
|
|
93
|
+
private _particleContainer;
|
|
94
|
+
constructor(params: LibPixiParticleMoveParams);
|
|
95
|
+
/** @description 创建贝塞尔曲线路径点组 */
|
|
96
|
+
private _createBezierPoints;
|
|
97
|
+
/** @description 计算贝塞尔曲线单个路径衔接点 */
|
|
98
|
+
private _multiPointBezier;
|
|
99
|
+
/** @description 计算组合数 */
|
|
100
|
+
private _binomial;
|
|
101
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Container, ParticleContainer, Ticker } from "pixi.js";
|
|
2
|
+
import { Emitter, upgradeConfig } from "@pixi/particle-emitter";
|
|
3
|
+
import gsap from "gsap";
|
|
4
|
+
import { LibPixiText } from "./LibPixiText";
|
|
5
|
+
/** @description 利用贝塞尔曲线实现粒子移动
|
|
6
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiParticleMove-粒子容器
|
|
7
|
+
*/
|
|
8
|
+
export class LibPixiParticleMove extends Container {
|
|
9
|
+
constructor(params) {
|
|
10
|
+
super();
|
|
11
|
+
const { start, control, end, container, duration, ease = "power1.out", showControl = false, loop = false, enableParticleContainer = false, particleConfig, onDestroy, } = params;
|
|
12
|
+
const config = upgradeConfig({
|
|
13
|
+
lifetime: particleConfig.lifetime,
|
|
14
|
+
blendMode: particleConfig.blendMode,
|
|
15
|
+
frequency: particleConfig.frequency || 0.01,
|
|
16
|
+
maxParticles: 1 / (particleConfig.frequency || 0.01),
|
|
17
|
+
alpha: particleConfig.alpha,
|
|
18
|
+
scale: particleConfig.scale,
|
|
19
|
+
color: particleConfig.color,
|
|
20
|
+
startRotation: particleConfig.rotation,
|
|
21
|
+
rotationSpeed: particleConfig.rotate,
|
|
22
|
+
speed: particleConfig.speed,
|
|
23
|
+
pos: {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0,
|
|
26
|
+
},
|
|
27
|
+
}, [container]);
|
|
28
|
+
if (enableParticleContainer) {
|
|
29
|
+
this._particleContainer = new ParticleContainer();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this._particleContainer = new Container();
|
|
33
|
+
}
|
|
34
|
+
this.addChild(this._particleContainer);
|
|
35
|
+
// 初始化粒子发射器
|
|
36
|
+
const flyParticle = new Emitter(this._particleContainer, config);
|
|
37
|
+
// 创建贝塞尔曲线的路径
|
|
38
|
+
const path = this._createBezierPoints([start, ...control, end], 100, showControl);
|
|
39
|
+
// 用来控制路径动画的对象
|
|
40
|
+
const flyObj = { pathThrough: 0 };
|
|
41
|
+
gsap.to(flyObj, {
|
|
42
|
+
duration,
|
|
43
|
+
pathThrough: path.length - 1,
|
|
44
|
+
repeat: loop ? -1 : 0,
|
|
45
|
+
repeatDelay: loop ? 1 : 0,
|
|
46
|
+
ease,
|
|
47
|
+
onStart: () => {
|
|
48
|
+
flyParticle.emit = true;
|
|
49
|
+
},
|
|
50
|
+
onUpdate: () => {
|
|
51
|
+
const i = Math.floor(flyObj.pathThrough);
|
|
52
|
+
const p = path[i];
|
|
53
|
+
flyParticle.updateOwnerPos(p.x, p.y);
|
|
54
|
+
},
|
|
55
|
+
onComplete: () => {
|
|
56
|
+
if (onDestroy) {
|
|
57
|
+
onDestroy(() => {
|
|
58
|
+
flyParticle.emit = false;
|
|
59
|
+
ticker.destroy();
|
|
60
|
+
this.destroy({ children: true });
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
gsap.to(this, {
|
|
65
|
+
alpha: 0,
|
|
66
|
+
duration: 1,
|
|
67
|
+
onComplete: () => {
|
|
68
|
+
flyParticle.emit = false;
|
|
69
|
+
ticker.destroy();
|
|
70
|
+
this.destroy({ children: true });
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const ticker = new Ticker();
|
|
77
|
+
ticker.add(() => {
|
|
78
|
+
flyParticle.update(ticker.deltaMS / 1000);
|
|
79
|
+
});
|
|
80
|
+
ticker.start();
|
|
81
|
+
}
|
|
82
|
+
/** @description 创建贝塞尔曲线路径点组 */
|
|
83
|
+
_createBezierPoints(anchorPoints, pointsAmount, showControl) {
|
|
84
|
+
const points = [];
|
|
85
|
+
// 渲染控制点
|
|
86
|
+
if (showControl) {
|
|
87
|
+
anchorPoints.forEach((item, index) => {
|
|
88
|
+
//创建一个小圆点
|
|
89
|
+
const text = new LibPixiText({
|
|
90
|
+
text: index + 1,
|
|
91
|
+
fontSize: 20,
|
|
92
|
+
stroke: "#000",
|
|
93
|
+
strokeThickness: 1,
|
|
94
|
+
});
|
|
95
|
+
text.position.set(item.x, item.y);
|
|
96
|
+
this.addChild(text);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// 计算并存储贝塞尔曲线上的点
|
|
100
|
+
for (let i = 0; i < pointsAmount; i++) {
|
|
101
|
+
const point = this._multiPointBezier(anchorPoints, i / pointsAmount);
|
|
102
|
+
points.push(point);
|
|
103
|
+
}
|
|
104
|
+
return points;
|
|
105
|
+
}
|
|
106
|
+
/** @description 计算贝塞尔曲线单个路径衔接点 */
|
|
107
|
+
_multiPointBezier(points, t) {
|
|
108
|
+
const len = points.length;
|
|
109
|
+
let x = 0, y = 0;
|
|
110
|
+
// 预计算组合数
|
|
111
|
+
const binomials = [];
|
|
112
|
+
for (let i = 0; i < len; i++) {
|
|
113
|
+
binomials[i] = this._binomial(len - 1, i);
|
|
114
|
+
}
|
|
115
|
+
// 计算贝塞尔曲线上的点
|
|
116
|
+
for (let i = 0; i < len; i++) {
|
|
117
|
+
const point = points[i];
|
|
118
|
+
const binom = binomials[i];
|
|
119
|
+
const factorT = Math.pow(t, i);
|
|
120
|
+
const factor1MinusT = Math.pow(1 - t, len - 1 - i);
|
|
121
|
+
x += point.x * factor1MinusT * factorT * binom;
|
|
122
|
+
y += point.y * factor1MinusT * factorT * binom;
|
|
123
|
+
}
|
|
124
|
+
return { x, y };
|
|
125
|
+
}
|
|
126
|
+
/** @description 计算组合数 */
|
|
127
|
+
_binomial(n, k) {
|
|
128
|
+
if (k === 0 || k === n)
|
|
129
|
+
return 1;
|
|
130
|
+
let res = 1;
|
|
131
|
+
for (let i = 1; i <= k; i++) {
|
|
132
|
+
res = (res * (n - i + 1)) / i;
|
|
133
|
+
}
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Graphics, type IPointData } from "pixi.js";
|
|
2
|
+
/** @description 多边形类,可用于一些场景的局部点击,传颜色是为了方便定位,最终可能需要将颜色隐藏掉
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPolygon-多边形
|
|
4
|
+
*/
|
|
5
|
+
export declare class LibPixiPolygon extends Graphics {
|
|
6
|
+
constructor(points: IPointData[] | number[], color?: string);
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
/** @description 多边形类,可用于一些场景的局部点击,传颜色是为了方便定位,最终可能需要将颜色隐藏掉
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPolygon-多边形
|
|
4
|
+
*/
|
|
5
|
+
export class LibPixiPolygon extends Graphics {
|
|
6
|
+
constructor(points, color) {
|
|
7
|
+
super();
|
|
8
|
+
this.beginFill(color || 0x000000);
|
|
9
|
+
this.drawPolygon(points);
|
|
10
|
+
this.endFill();
|
|
11
|
+
if (!color) {
|
|
12
|
+
this.alpha = 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
export interface LibPixiRectBgColorParams {
|
|
3
|
+
/** 宽度 */
|
|
4
|
+
width: number;
|
|
5
|
+
/** 高度 */
|
|
6
|
+
height: number;
|
|
7
|
+
/** 背景颜色 */
|
|
8
|
+
bgColor?: string | number;
|
|
9
|
+
/** 透明度 */
|
|
10
|
+
alpha?: number;
|
|
11
|
+
/** 圆角半径 */
|
|
12
|
+
radius?: number | number[];
|
|
13
|
+
/** 边框宽度 */
|
|
14
|
+
borderWidth?: number;
|
|
15
|
+
/** 边框颜色 */
|
|
16
|
+
borderColor?: string;
|
|
17
|
+
/** 是否启用变色功能 */
|
|
18
|
+
enableTint?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** @description 自定义矩形背景色
|
|
21
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiRectBgColor-矩形
|
|
22
|
+
*/
|
|
23
|
+
export declare class LibPixiRectBgColor extends Graphics {
|
|
24
|
+
/** 圆边大小 */
|
|
25
|
+
private radius;
|
|
26
|
+
/** 启用着色 */
|
|
27
|
+
private enableTint;
|
|
28
|
+
/** 背景颜色 */
|
|
29
|
+
private bgColor;
|
|
30
|
+
/** 边框宽度 */
|
|
31
|
+
private borderWidth;
|
|
32
|
+
/** 边框颜色 */
|
|
33
|
+
private borderColor;
|
|
34
|
+
/** 背景色 */
|
|
35
|
+
private bgAlpha;
|
|
36
|
+
constructor(options: LibPixiRectBgColorParams);
|
|
37
|
+
/** @description 重新绘制并添加颜色 */
|
|
38
|
+
updateColor(tint: string): void;
|
|
39
|
+
/** @description 更新宽度 */
|
|
40
|
+
renderBg(width: number, height: number): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
import gsap from "gsap";
|
|
3
|
+
/** @description 自定义矩形背景色
|
|
4
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiRectBgColor-矩形
|
|
5
|
+
*/
|
|
6
|
+
export class LibPixiRectBgColor extends Graphics {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super();
|
|
9
|
+
/** 圆边大小 */
|
|
10
|
+
this.radius = 0;
|
|
11
|
+
/** 启用着色 */
|
|
12
|
+
this.enableTint = true;
|
|
13
|
+
/** 背景颜色 */
|
|
14
|
+
this.bgColor = "#fff";
|
|
15
|
+
/** 边框宽度 */
|
|
16
|
+
this.borderWidth = 0;
|
|
17
|
+
/** 边框颜色 */
|
|
18
|
+
this.borderColor = "black";
|
|
19
|
+
/** 背景色 */
|
|
20
|
+
this.bgAlpha = 1;
|
|
21
|
+
const { width, height, bgColor = "#fff", alpha = 1, radius = 0, borderWidth = 0, borderColor = "black", enableTint = true, } = options;
|
|
22
|
+
this.bgAlpha = alpha;
|
|
23
|
+
this.radius = radius;
|
|
24
|
+
this.enableTint = enableTint;
|
|
25
|
+
this.bgColor = bgColor;
|
|
26
|
+
this.borderWidth = borderWidth;
|
|
27
|
+
this.borderColor = borderColor;
|
|
28
|
+
this.renderBg(width, height);
|
|
29
|
+
}
|
|
30
|
+
/** @description 重新绘制并添加颜色 */
|
|
31
|
+
updateColor(tint) {
|
|
32
|
+
gsap.to(this, { tint, duration: 0.25 });
|
|
33
|
+
}
|
|
34
|
+
/** @description 更新宽度 */
|
|
35
|
+
renderBg(width, height) {
|
|
36
|
+
this.clear();
|
|
37
|
+
if (this.enableTint) {
|
|
38
|
+
this.beginFill("#fff", this.bgAlpha);
|
|
39
|
+
this.tint = this.bgColor;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.beginFill(this.bgColor, this.bgAlpha);
|
|
43
|
+
}
|
|
44
|
+
this.borderWidth && this.lineStyle(this.borderWidth, this.borderColor, 1);
|
|
45
|
+
if (this.radius !== 0) {
|
|
46
|
+
if (typeof this.radius === "number") {
|
|
47
|
+
this.drawRoundedRect(0, 0, width, height, this.radius);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// 绘制顶部边
|
|
51
|
+
this.moveTo(0 + this.radius[0], 0);
|
|
52
|
+
this.lineTo(0 + width - this.radius[1], 0);
|
|
53
|
+
// 绘制右上角的圆角
|
|
54
|
+
if (this.radius[1] > 0) {
|
|
55
|
+
this.arcTo(0 + width, 0, 0 + width, 0 + this.radius[1], this.radius[1]);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.lineTo(0 + width, 0);
|
|
59
|
+
}
|
|
60
|
+
// 绘制右侧边
|
|
61
|
+
this.lineTo(0 + width, 0 + height - this.radius[2]);
|
|
62
|
+
// 绘制右下角的圆角
|
|
63
|
+
if (this.radius[2] > 0) {
|
|
64
|
+
this.arcTo(0 + width, 0 + height, 0 + width - this.radius[2], 0 + height, this.radius[2]);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.lineTo(0 + width, 0 + height);
|
|
68
|
+
}
|
|
69
|
+
// 绘制底部边
|
|
70
|
+
this.lineTo(0 + this.radius[3], 0 + height);
|
|
71
|
+
// 绘制左下角的圆角
|
|
72
|
+
if (this.radius[3] > 0) {
|
|
73
|
+
this.arcTo(0, 0 + height, 0, 0 + height - this.radius[3], this.radius[3]);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.lineTo(0, 0 + height);
|
|
77
|
+
}
|
|
78
|
+
// 绘制左侧边
|
|
79
|
+
this.lineTo(0, 0 + this.radius[0]);
|
|
80
|
+
// 绘制左上角的圆角
|
|
81
|
+
if (this.radius[0] > 0) {
|
|
82
|
+
this.arcTo(0, 0, 0 + this.radius[0], 0, this.radius[0]);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.lineTo(0, 0);
|
|
86
|
+
}
|
|
87
|
+
this.closePath();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.drawRect(0, 0, width, height);
|
|
92
|
+
}
|
|
93
|
+
this.endFill();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Graphics } from "pixi.js";
|
|
2
|
+
/** @description 矩形类,可用于一些场景的局部点击,传颜色是为了方便定位,最终可能需要将颜色隐藏掉
|
|
3
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiRectangle-矩形
|
|
4
|
+
*/
|
|
5
|
+
export declare class LibPixiRectangle extends Graphics {
|
|
6
|
+
constructor(width: number, height: number, color?: string);
|
|
7
|
+
}
|