lyb-pixi-js 1.12.75 → 1.12.77
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Container } from "pixi.js";
|
|
1
|
+
import { Container, TextStyleAlign } from "pixi.js";
|
|
2
2
|
export interface LibPixiTableParams {
|
|
3
3
|
/** 表格数据 */
|
|
4
4
|
data: (number | string)[][];
|
|
@@ -24,6 +24,8 @@ export interface LibPixiTableParams {
|
|
|
24
24
|
lineWidth?: number;
|
|
25
25
|
/** 线条颜色 */
|
|
26
26
|
lineColor?: string;
|
|
27
|
+
/** 文本对齐方式 */
|
|
28
|
+
textAlign?: TextStyleAlign;
|
|
27
29
|
}
|
|
28
30
|
/** @description 绘制表格 */
|
|
29
31
|
export declare class LibPixiTable extends Container {
|
|
@@ -4,7 +4,7 @@ export class LibPixiTable extends Container {
|
|
|
4
4
|
constructor(params) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
super();
|
|
7
|
-
const { data, outsideBorder = true, cellWidth = 80, cellHeight = 30, fontSize = 14, fontColor = "#000000", firstColumnFontColor, firstRowFontColor, fontBold = false, cellPadding = 6, lineWidth = 1, lineColor = "#cccccc", } = params;
|
|
7
|
+
const { data, outsideBorder = true, cellWidth = 80, cellHeight = 30, fontSize = 14, fontColor = "#000000", firstColumnFontColor, firstRowFontColor, fontBold = false, cellPadding = 6, lineWidth = 1, textAlign = "left", lineColor = "#cccccc", } = params;
|
|
8
8
|
if (!data || !data.length)
|
|
9
9
|
return;
|
|
10
10
|
// 计算列数(取最长行)
|
|
@@ -13,6 +13,7 @@ export class LibPixiTable extends Container {
|
|
|
13
13
|
const baseStyle = new TextStyle({
|
|
14
14
|
fontSize,
|
|
15
15
|
fontWeight: fontBold ? "bold" : "normal",
|
|
16
|
+
align: textAlign,
|
|
16
17
|
});
|
|
17
18
|
// 先测量所有单元格尺寸,得到每列宽度、每行高度
|
|
18
19
|
const colWidths = Array(cols).fill(cellWidth);
|
|
@@ -71,11 +72,14 @@ export class LibPixiTable extends Container {
|
|
|
71
72
|
for (let r = 0; r < data.length; r += 1) {
|
|
72
73
|
for (let c = 0; c < cols; c += 1) {
|
|
73
74
|
const raw = (_b = (data[r] && data[r][c])) !== null && _b !== void 0 ? _b : "";
|
|
74
|
-
const color = (r === 0 && firstRowFontColor) ||
|
|
75
|
+
const color = (r === 0 && firstRowFontColor) ||
|
|
76
|
+
(c === 0 && firstColumnFontColor) ||
|
|
77
|
+
fontColor;
|
|
75
78
|
const style = new TextStyle({
|
|
76
79
|
fontSize,
|
|
77
80
|
fontWeight: fontBold ? "bold" : "normal",
|
|
78
81
|
fill: color,
|
|
82
|
+
align: textAlign,
|
|
79
83
|
});
|
|
80
84
|
const txt = new Text(String(raw), style);
|
|
81
85
|
const cx = colX[c];
|