lyb-pixi-js 1.12.88 → 1.12.90

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.
@@ -2,8 +2,6 @@ import { Container, type ITextStyle } from "pixi.js";
2
2
  interface TextItem {
3
3
  text: string | number;
4
4
  style?: Partial<ITextStyle>;
5
- anchorX?: number;
6
- anchorY?: number;
7
5
  }
8
6
  interface TextGroupOptions {
9
7
  items: TextItem[];
@@ -14,9 +12,13 @@ interface TextGroupOptions {
14
12
  align?: "left" | "center" | "right";
15
13
  anchorX?: number;
16
14
  anchorY?: number;
15
+ /** 垂直居中 */
16
+ verticalCenter?: boolean;
17
+ /** 行间隔 */
18
+ lineGap?: number;
17
19
  }
18
20
  /** @description 文本组换行 */
19
21
  export declare class LibPixiTextGroupWrap extends Container {
20
- constructor({ items, defaultStyle, wordWrapWidth, paddingX, paddingY, align, anchorX, anchorY, }: TextGroupOptions);
22
+ constructor({ items, defaultStyle, wordWrapWidth, paddingX, paddingY, align, anchorX, anchorY, verticalCenter, lineGap, }: TextGroupOptions);
21
23
  }
22
24
  export {};
@@ -2,7 +2,7 @@ import { Container, Text } from "pixi.js";
2
2
  import { libPixiPivot } from "../../Utils/LibPixiActhor";
3
3
  /** @description 文本组换行 */
4
4
  export class LibPixiTextGroupWrap extends Container {
5
- constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, }) {
5
+ constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, verticalCenter, lineGap, }) {
6
6
  super();
7
7
  if (!items.length)
8
8
  return;
@@ -10,9 +10,9 @@ export class LibPixiTextGroupWrap extends Container {
10
10
  let currentLine = [];
11
11
  let x = 0;
12
12
  // 分行
13
- for (const { text, anchorX, anchorY, style = {} } of items) {
13
+ for (const { text, style = {} } of items) {
14
14
  const instance = new Text(text, Object.assign(Object.assign({}, defaultStyle), style));
15
- instance.anchor.set(anchorX, anchorY);
15
+ instance.anchor.y = verticalCenter ? 0.5 : 0;
16
16
  const w = instance.width;
17
17
  if (wordWrapWidth && x + w > wordWrapWidth && x > 0) {
18
18
  lineGroups.push(currentLine);
@@ -43,7 +43,7 @@ export class LibPixiTextGroupWrap extends Container {
43
43
  if (item.height > maxHeight)
44
44
  maxHeight = item.height;
45
45
  }
46
- y += maxHeight + paddingY;
46
+ y += (lineGap !== null && lineGap !== void 0 ? lineGap : maxHeight) + paddingY;
47
47
  }
48
48
  // 根据 anchor 调整整体偏移
49
49
  libPixiPivot(this, anchorX, anchorY);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.88",
3
+ "version": "1.12.90",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {