lyb-pixi-js 1.10.6 → 1.10.7

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.
@@ -0,0 +1,30 @@
1
+ import { BitmapText, Container, Sprite } from "pixi.js";
2
+ import { LibPixiText } from "../Base/LibPixiText";
3
+ type T = Sprite | LibPixiText | BitmapText;
4
+ interface LabelValueParams {
5
+ /** 描述 */
6
+ label: T;
7
+ /** 值 */
8
+ value: T;
9
+ /** 最大宽度 */
10
+ maxWidth?: number;
11
+ /** 间隔 */
12
+ gap?: number;
13
+ }
14
+ /** @description 自适应宽度的标签和值组件
15
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
16
+ */
17
+ export declare class LibPixiLabelValue extends Container {
18
+ /** 描述 */
19
+ private _label;
20
+ /** 值 */
21
+ private _value;
22
+ /** 间隔 */
23
+ private _gap;
24
+ /** 最大宽度 */
25
+ private _maxWidth?;
26
+ constructor(params: LabelValueParams);
27
+ /** @description 更新坐标 */
28
+ updatePosition(): void;
29
+ }
30
+ export {};
@@ -0,0 +1,26 @@
1
+ import { Container } from "pixi.js";
2
+ import { libPixiScaleContainer } from "../../Utils/LibPixiScaleContainer";
3
+ /** @description 自适应宽度的标签和值组件
4
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
5
+ */
6
+ export class LibPixiLabelValue extends Container {
7
+ constructor(params) {
8
+ super();
9
+ const { label, value, maxWidth, gap = 0 } = params;
10
+ this._label = label;
11
+ this._value = value;
12
+ this._maxWidth = maxWidth;
13
+ this._gap = gap;
14
+ this.addChild(this._label);
15
+ this._label.anchor.set(1, 0.5);
16
+ this.addChild(this._value);
17
+ this._value.anchor.set(0.5);
18
+ this.updatePosition();
19
+ }
20
+ /** @description 更新坐标 */
21
+ updatePosition() {
22
+ this._label.x = this._label.width * 0.5 - this._value.width * 0.5;
23
+ this._value.x = this._label.width * 0.5 + this._gap;
24
+ this._maxWidth && libPixiScaleContainer(this, this._maxWidth);
25
+ }
26
+ }
package/README.md CHANGED
@@ -112,9 +112,9 @@ app.stage.addChild(box);
112
112
 
113
113
  \- [LibPixiProgress-进度条](#LibPixiProgress-进度条)
114
114
 
115
- \- [LibPixiScrollContainerX-X 轴滚动容器](#LibPixiScrollContainerX-X 轴滚动容器)
115
+ \- [LibPixiScrollContainerX-X轴滚动容器](#LibPixiScrollContainerX-X轴滚动容器)
116
116
 
117
- \- [LibPixiScrollContainerY-Y 轴滚动容器](#LibPixiScrollContainerY-Y 轴滚动容器)
117
+ \- [LibPixiScrollContainerY-Y轴滚动容器](#LibPixiScrollContainerY-Y轴滚动容器)
118
118
 
119
119
  \- [LibPixiScrollNum-数字滑动](#LibPixiScrollNum-数字滑动)
120
120
 
@@ -126,7 +126,7 @@ app.stage.addChild(box);
126
126
 
127
127
  \- [LibPixiTable-数字表格](#LibPixiTable-数字表格)
128
128
 
129
- \- [LibPixiParticleMove-粒子移动特效](#LibPixiParticleMove-粒子移动特效)
129
+ \- [LibPixiLabelValue-标签值](#LibPixiLabelValue-标签值)
130
130
 
131
131
  ### 方法
132
132
 
@@ -662,7 +662,7 @@ progress.setProgress(0.5); //50% 完成
662
662
  app.stage.addChild(progress);
663
663
  ```
664
664
 
665
- ### LibPixiScrollContainerX-X 轴滚动容器
665
+ ### LibPixiScrollContainerX-X轴滚动容器
666
666
 
667
667
  > 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
668
668
 
@@ -692,7 +692,7 @@ scrollContainer.setDimensions(800, 600);
692
692
  scrollContainer.addContent(new Sprite(Texture.from("new-content.png")));
693
693
  ```
694
694
 
695
- ### LibPixiScrollContainerY-Y 轴滚动容器
695
+ ### LibPixiScrollContainerY-Y轴滚动容器
696
696
 
697
697
  > 支持鼠标滚轮滚动、鼠标拖动、手指滑动,支持惯性滚动及回弹
698
698
 
@@ -881,6 +881,37 @@ const table = new LibPixiTable({
881
881
  stage.addChild(table);
882
882
  ```
883
883
 
884
+ ### LibPixiLabelValue-标签值
885
+
886
+ > 适用于左边图标右边动态数值锚点在容器正中间的场景
887
+
888
+ ```ts
889
+ //单位
890
+ const unit = new LibPixiText({
891
+ text: "Rp",
892
+ fontSize: 40,
893
+ fontColor: "#fff551",
894
+ strokeThickness: 4,
895
+ stroke: "#cc5114",
896
+ });
897
+
898
+ //金额
899
+ const amount = new LibPixiText({
900
+ text: value,
901
+ fontSize: 40,
902
+ fontColor: "#fff551",
903
+ strokeThickness: 4,
904
+ stroke: "#cc5114",
905
+ });
906
+
907
+ //容器
908
+ const amountContainer = new LibLabelValue({
909
+ label: unit,
910
+ value: amount,
911
+ gap: 10,
912
+ });
913
+ ```
914
+
884
915
  ## Utils-工具方法
885
916
 
886
917
  ### LibPixiAudio-音频播放器
package/libPixiJs.d.ts CHANGED
@@ -24,6 +24,7 @@ import { LibPixiRectangle } from "./Components/Base/LibPixiRectangle";
24
24
  import { LibPixiPolygon } from "./Components/Base/LibPixiPolygon";
25
25
  import { LibPixiCircular } from "./Components/Base/LibPixiCircular";
26
26
  import { LibPixiSlide } from "./Components/Custom/LibPixiSlide";
27
+ import { LibPixiLabelValue } from "./Components/Custom/LibPixiLabelValue";
27
28
  /** @description 组件 */
28
29
  export declare const Components: {
29
30
  Base: {
@@ -117,6 +118,10 @@ export declare const Components: {
117
118
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
118
119
  */
119
120
  LibPixiTable: typeof LibPixiTable;
121
+ /** @description 自适应宽度的标签和值组件
122
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
123
+ */
124
+ LibPixiLabelValue: typeof LibPixiLabelValue;
120
125
  };
121
126
  };
122
127
  /** @description 方法 */
package/libPixiJs.js CHANGED
@@ -39,6 +39,7 @@ import { LibPixiGridLayout } from "./Utils/LibPixiGridLayout";
39
39
  import { LibPixiArrangeLinear } from "./Utils/LibPixiArrangeLinear";
40
40
  import { LibPixiSlide } from "./Components/Custom/LibPixiSlide";
41
41
  import { LibPixiEmitContainerEvent } from "./Utils/LibPixiEmitContainerEvent";
42
+ import { LibPixiLabelValue } from "./Components/Custom/LibPixiLabelValue";
42
43
  /** @description 组件 */
43
44
  export const Components = {
44
45
  Base: {
@@ -132,6 +133,10 @@ export const Components = {
132
133
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
133
134
  */
134
135
  LibPixiTable,
136
+ /** @description 自适应宽度的标签和值组件
137
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
138
+ */
139
+ LibPixiLabelValue,
135
140
  },
136
141
  };
137
142
  /** @description 方法 */
package/lyb-pixi.js CHANGED
@@ -55398,6 +55398,27 @@ void main(void){
55398
55398
  }
55399
55399
  });
55400
55400
  };
55401
+ class LibPixiLabelValue extends Container {
55402
+ constructor(params) {
55403
+ super();
55404
+ const { label, value, maxWidth, gap = 0 } = params;
55405
+ this._label = label;
55406
+ this._value = value;
55407
+ this._maxWidth = maxWidth;
55408
+ this._gap = gap;
55409
+ this.addChild(this._label);
55410
+ this._label.anchor.set(1, 0.5);
55411
+ this.addChild(this._value);
55412
+ this._value.anchor.set(0.5);
55413
+ this.updatePosition();
55414
+ }
55415
+ /** @description 更新坐标 */
55416
+ updatePosition() {
55417
+ this._label.x = this._label.width * 0.5 - this._value.width * 0.5;
55418
+ this._value.x = this._label.width * 0.5 + this._gap;
55419
+ this._maxWidth && libPixiScaleContainer(this, this._maxWidth);
55420
+ }
55421
+ }
55401
55422
  const Components = {
55402
55423
  Base: {
55403
55424
  /** @description 自定义位图文本
@@ -55489,7 +55510,11 @@ void main(void){
55489
55510
  /** @description 绘制表格并填充数字
55490
55511
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiTable-数字表格
55491
55512
  */
55492
- LibPixiTable
55513
+ LibPixiTable,
55514
+ /** @description 自适应宽度的标签和值组件
55515
+ * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiLabelValue-标签值
55516
+ */
55517
+ LibPixiLabelValue
55493
55518
  }
55494
55519
  };
55495
55520
  const Utils = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.10.6",
3
+ "version": "1.10.7",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {