@hirokisakabe/pom 9.1.2 → 10.1.0
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/README.md +1 -1
- package/dist/autoFit/autoFit.js +55 -15
- package/dist/autoFit/autoFit.js.map +1 -1
- package/dist/autoFit/strategies/reduceFontSize.js.map +1 -1
- package/dist/buildContext.js +5 -3
- package/dist/buildContext.js.map +1 -1
- package/dist/buildPptx.d.ts +5 -3
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +5 -4
- package/dist/buildPptx.js.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js.map +1 -1
- package/dist/calcYogaLayout/fontLoader.d.ts +13 -0
- package/dist/calcYogaLayout/fontLoader.d.ts.map +1 -0
- package/dist/calcYogaLayout/fontLoader.js +70 -3
- package/dist/calcYogaLayout/fontLoader.js.map +1 -1
- package/dist/calcYogaLayout/measureText.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureText.js +6 -6
- package/dist/calcYogaLayout/measureText.js.map +1 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/extractSlideMastersAsPptx.d.ts.map +1 -1
- package/dist/extractThemeTokensFromPptx.d.ts +0 -1
- package/dist/extractThemeTokensFromPptx.d.ts.map +1 -1
- package/dist/icons/renderIcon.js +12 -10
- package/dist/icons/renderIcon.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/parseXml/coercionRules.js.map +1 -1
- package/dist/parseXml/parseXml.d.ts +0 -1
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js.map +1 -1
- package/dist/parseXml/serializeXml.d.ts +0 -1
- package/dist/parseXml/serializeXml.d.ts.map +1 -1
- package/dist/parseXml/serializeXml.js.map +1 -1
- package/dist/registry/definitions/icon.js +1 -1
- package/dist/registry/definitions/list.js +1 -1
- package/dist/registry/definitions/list.js.map +1 -1
- package/dist/registry/definitions/shape.js +1 -1
- package/dist/registry/definitions/shape.js.map +1 -1
- package/dist/registry/definitions/text.js +1 -1
- package/dist/registry/definitions/text.js.map +1 -1
- package/dist/renderPptx/nodes/chart.js +172 -47
- package/dist/renderPptx/nodes/chart.js.map +1 -1
- package/dist/renderPptx/nodes/flow.js +4 -1
- package/dist/renderPptx/nodes/flow.js.map +1 -1
- package/dist/renderPptx/nodes/icon.js +5 -2
- package/dist/renderPptx/nodes/icon.js.map +1 -1
- package/dist/renderPptx/nodes/list.js +7 -9
- package/dist/renderPptx/nodes/list.js.map +1 -1
- package/dist/renderPptx/nodes/matrix.js +4 -1
- package/dist/renderPptx/nodes/matrix.js.map +1 -1
- package/dist/renderPptx/nodes/processArrow.js +8 -2
- package/dist/renderPptx/nodes/processArrow.js.map +1 -1
- package/dist/renderPptx/nodes/pyramid.js +4 -1
- package/dist/renderPptx/nodes/pyramid.js.map +1 -1
- package/dist/renderPptx/nodes/shape.js +5 -2
- package/dist/renderPptx/nodes/shape.js.map +1 -1
- package/dist/renderPptx/nodes/table.js +89 -59
- package/dist/renderPptx/nodes/table.js.map +1 -1
- package/dist/renderPptx/nodes/text.js +1 -18
- package/dist/renderPptx/nodes/text.js.map +1 -1
- package/dist/renderPptx/nodes/timeline.js +9 -3
- package/dist/renderPptx/nodes/timeline.js.map +1 -1
- package/dist/renderPptx/nodes/tree.js +4 -1
- package/dist/renderPptx/nodes/tree.js.map +1 -1
- package/dist/renderPptx/pptxAuthoring.js +381 -0
- package/dist/renderPptx/pptxAuthoring.js.map +1 -0
- package/dist/renderPptx/renderPptx.js +157 -126
- package/dist/renderPptx/renderPptx.js.map +1 -1
- package/dist/renderPptx/textOptions.js +7 -8
- package/dist/renderPptx/textOptions.js.map +1 -1
- package/dist/renderPptx/units.js +3 -3
- package/dist/renderPptx/units.js.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.js +30 -44
- package/dist/renderPptx/utils/backgroundBorder.js.map +1 -1
- package/dist/renderPptx/utils/contentArea.js +1 -1
- package/dist/renderPptx/utils/contentArea.js.map +1 -1
- package/dist/renderPptx/utils/glimpsePicture.js +3 -22
- package/dist/renderPptx/utils/glimpsePicture.js.map +1 -1
- package/dist/renderPptx/utils/glimpseShape.js +6 -25
- package/dist/renderPptx/utils/glimpseShape.js.map +1 -1
- package/dist/renderPptx/utils/glimpseTextBox.js +41 -60
- package/dist/renderPptx/utils/glimpseTextBox.js.map +1 -1
- package/dist/renderPptx/utils/straightLine.js +5 -2
- package/dist/renderPptx/utils/straightLine.js.map +1 -1
- package/dist/renderPptx/utils/visualStyle.js +3 -33
- package/dist/renderPptx/utils/visualStyle.js.map +1 -1
- package/dist/renderPptx/writablePptx.d.ts +23 -0
- package/dist/renderPptx/writablePptx.d.ts.map +1 -0
- package/dist/renderPptx/writablePptx.js +74 -0
- package/dist/renderPptx/writablePptx.js.map +1 -0
- package/dist/shared/measureImage.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -9
- package/dist/renderPptx/glimpseTextBoxes.js +0 -646
- package/dist/renderPptx/glimpseTextBoxes.js.map +0 -1
|
@@ -1,60 +1,185 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pxToEmu } from "../units.js";
|
|
2
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
3
|
+
import { toColorInput } from "../pptxAuthoring.js";
|
|
4
|
+
import { asEmu, asOoxmlPercent, asPt } from "@pptx-glimpse/document";
|
|
2
5
|
//#region src/renderPptx/nodes/chart.ts
|
|
6
|
+
const DEFAULT_BAR_CHART_COLORS = [
|
|
7
|
+
"C0504D",
|
|
8
|
+
"4F81BD",
|
|
9
|
+
"9BBB59",
|
|
10
|
+
"8064A2",
|
|
11
|
+
"4BACC6",
|
|
12
|
+
"F79646",
|
|
13
|
+
"628FC6",
|
|
14
|
+
"C86360",
|
|
15
|
+
"C0504D",
|
|
16
|
+
"4F81BD",
|
|
17
|
+
"9BBB59",
|
|
18
|
+
"8064A2",
|
|
19
|
+
"4BACC6",
|
|
20
|
+
"F79646",
|
|
21
|
+
"628FC6",
|
|
22
|
+
"C86360"
|
|
23
|
+
];
|
|
24
|
+
const DEFAULT_PIE_CHART_COLORS = [
|
|
25
|
+
"5DA5DA",
|
|
26
|
+
"FAA43A",
|
|
27
|
+
"60BD68",
|
|
28
|
+
"F17CB0",
|
|
29
|
+
"B2912F",
|
|
30
|
+
"B276B2",
|
|
31
|
+
"DECF3F",
|
|
32
|
+
"F15854",
|
|
33
|
+
"A7A7A7",
|
|
34
|
+
"5DA5DA",
|
|
35
|
+
"FAA43A",
|
|
36
|
+
"60BD68",
|
|
37
|
+
"F17CB0",
|
|
38
|
+
"B2912F",
|
|
39
|
+
"B276B2",
|
|
40
|
+
"DECF3F",
|
|
41
|
+
"F15854",
|
|
42
|
+
"A7A7A7"
|
|
43
|
+
];
|
|
3
44
|
function renderChartNode(node, ctx) {
|
|
4
|
-
const chartData = node.data.map((d) => ({
|
|
5
|
-
name: d.name,
|
|
6
|
-
labels: d.labels,
|
|
7
|
-
values: d.values
|
|
8
|
-
}));
|
|
9
45
|
const isSparkline = node.sparkline === true && (node.chartType === "bar" || node.chartType === "line" || node.chartType === "area");
|
|
10
|
-
const
|
|
11
|
-
|
|
46
|
+
const content = getContentArea(node);
|
|
47
|
+
const series = normalizeChartSeries(node.data);
|
|
48
|
+
const chartColors = node.chartColors ?? (node.chartType === "pie" || node.chartType === "doughnut" ? DEFAULT_PIE_CHART_COLORS : DEFAULT_BAR_CHART_COLORS);
|
|
49
|
+
const pointColors = chartColors.length > 0 && (node.chartType === "pie" || node.chartType === "doughnut" || node.chartType === "bar" && node.data.length === 1 && node.chartColors !== void 0 && node.chartColors.length > 1) ? node.data[0]?.values.map((_value, index) => chartColors[index % chartColors.length]) : void 0;
|
|
50
|
+
ctx.buildContext.pptxAuthoring.registerChart({
|
|
51
|
+
chartType: node.chartType,
|
|
52
|
+
series: series.map((item, index) => ({
|
|
53
|
+
name: item.name,
|
|
54
|
+
categories: item.labels,
|
|
55
|
+
values: item.values,
|
|
56
|
+
color: chartColors[index % chartColors.length],
|
|
57
|
+
dataPoints: index === 0 ? pointColors?.map((color, pointIndex) => ({
|
|
58
|
+
index: pointIndex,
|
|
59
|
+
fill: {
|
|
60
|
+
kind: "solid",
|
|
61
|
+
color: toColorInput(color)
|
|
62
|
+
}
|
|
63
|
+
})) : void 0,
|
|
64
|
+
marker: node.chartType === "line" || node.chartType === "radar" ? {
|
|
65
|
+
symbol: "circle",
|
|
66
|
+
size: 6,
|
|
67
|
+
fill: {
|
|
68
|
+
kind: "solid",
|
|
69
|
+
color: toColorInput(chartColors[index % chartColors.length])
|
|
70
|
+
}
|
|
71
|
+
} : void 0
|
|
72
|
+
})),
|
|
73
|
+
offsetX: asEmu(Math.round(pxToEmu(content.x))),
|
|
74
|
+
offsetY: asEmu(Math.round(pxToEmu(content.y))),
|
|
75
|
+
width: asEmu(Math.round(pxToEmu(Math.max(content.w, 1)))),
|
|
76
|
+
height: asEmu(Math.round(pxToEmu(Math.max(content.h, 1)))),
|
|
77
|
+
title: !isSparkline && node.showTitle ? node.title || "Chart Title" : void 0,
|
|
78
|
+
titleStyle: !isSparkline && node.showTitle ? {
|
|
79
|
+
fontFace: "Arial",
|
|
80
|
+
fontSize: asPt(18),
|
|
81
|
+
color: toColorInput("000000"),
|
|
82
|
+
bold: false,
|
|
83
|
+
italic: false
|
|
84
|
+
} : void 0,
|
|
85
|
+
displayBlanksAs: "span",
|
|
86
|
+
roundedCorners: !isSparkline,
|
|
87
|
+
chartArea: isSparkline ? { fill: {
|
|
88
|
+
kind: "solid",
|
|
89
|
+
color: {
|
|
90
|
+
...toColorInput("FFFFFF"),
|
|
91
|
+
transforms: [{
|
|
92
|
+
kind: "alpha",
|
|
93
|
+
value: asOoxmlPercent(0)
|
|
94
|
+
}]
|
|
95
|
+
}
|
|
96
|
+
} } : {
|
|
97
|
+
fill: { kind: "none" },
|
|
98
|
+
outline: { fill: { kind: "none" } }
|
|
99
|
+
},
|
|
100
|
+
plotArea: isSparkline ? { fill: {
|
|
101
|
+
kind: "solid",
|
|
102
|
+
color: {
|
|
103
|
+
...toColorInput("FFFFFF"),
|
|
104
|
+
transforms: [{
|
|
105
|
+
kind: "alpha",
|
|
106
|
+
value: asOoxmlPercent(0)
|
|
107
|
+
}]
|
|
108
|
+
}
|
|
109
|
+
} } : {
|
|
110
|
+
fill: { kind: "none" },
|
|
111
|
+
outline: { fill: { kind: "none" } }
|
|
112
|
+
},
|
|
12
113
|
showLegend: isSparkline ? false : node.showLegend ?? false,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
chartOptions.showValAxisTitle = false;
|
|
25
|
-
chartOptions.catGridLine = { style: "none" };
|
|
26
|
-
chartOptions.valGridLine = { style: "none" };
|
|
27
|
-
chartOptions.chartArea = {
|
|
28
|
-
fill: {
|
|
29
|
-
type: "solid",
|
|
30
|
-
color: "FFFFFF",
|
|
31
|
-
transparency: 100
|
|
114
|
+
radarStyle: node.chartType === "radar" ? node.radarStyle : void 0,
|
|
115
|
+
categoryAxis: isSparkline ? {
|
|
116
|
+
hidden: true,
|
|
117
|
+
lineVisible: false,
|
|
118
|
+
gridLinesVisible: false
|
|
119
|
+
} : {
|
|
120
|
+
majorTickMark: "outside",
|
|
121
|
+
labelPosition: "low",
|
|
122
|
+
numberFormat: {
|
|
123
|
+
formatCode: "General",
|
|
124
|
+
sourceLinked: true
|
|
32
125
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
126
|
+
showMultiLevelLabels: false,
|
|
127
|
+
textStyle: {
|
|
128
|
+
fontFace: "Arial",
|
|
129
|
+
fontSize: asPt(12),
|
|
130
|
+
color: toColorInput("000000")
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
valueAxis: isSparkline ? {
|
|
134
|
+
hidden: true,
|
|
135
|
+
lineVisible: false,
|
|
136
|
+
gridLinesVisible: false
|
|
137
|
+
} : {
|
|
138
|
+
majorTickMark: "outside",
|
|
139
|
+
labelPosition: "nextTo",
|
|
140
|
+
numberFormat: {
|
|
141
|
+
formatCode: "General",
|
|
142
|
+
sourceLinked: false
|
|
36
143
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
transparency: 100
|
|
144
|
+
majorGridline: {
|
|
145
|
+
width: asEmu(12700),
|
|
146
|
+
fill: {
|
|
147
|
+
kind: "solid",
|
|
148
|
+
color: toColorInput("888888")
|
|
149
|
+
}
|
|
44
150
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
151
|
+
textStyle: {
|
|
152
|
+
fontFace: "Arial",
|
|
153
|
+
fontSize: asPt(12),
|
|
154
|
+
color: toColorInput("000000")
|
|
48
155
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
156
|
+
},
|
|
157
|
+
plotLayout: isSparkline ? {
|
|
158
|
+
coordinateMode: "edge",
|
|
51
159
|
x: 0,
|
|
52
160
|
y: 0,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
161
|
+
width: 1,
|
|
162
|
+
height: 1
|
|
163
|
+
} : void 0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* glimpse の native writer は全系列で同じ category 軸と同じ点数を要求する。
|
|
168
|
+
* 従来受理していた不揃いな入力も生成を継続できるよう、位置ベースで
|
|
169
|
+
* category を共有し、欠けた値を 0 で補う。
|
|
170
|
+
*/
|
|
171
|
+
function normalizeChartSeries(data) {
|
|
172
|
+
const sourceData = data.length > 0 ? data : [{
|
|
173
|
+
labels: [],
|
|
174
|
+
values: []
|
|
175
|
+
}];
|
|
176
|
+
const pointCount = Math.max(1, ...sourceData.flatMap((series) => [series.labels.length, series.values.length]));
|
|
177
|
+
const categories = Array.from({ length: pointCount }, (_, index) => sourceData.find((series) => series.labels[index] !== void 0)?.labels[index] ?? "");
|
|
178
|
+
return sourceData.map((series) => ({
|
|
179
|
+
name: series.name,
|
|
180
|
+
labels: categories,
|
|
181
|
+
values: Array.from({ length: pointCount }, (_, index) => series.values[index] ?? 0)
|
|
182
|
+
}));
|
|
58
183
|
}
|
|
59
184
|
//#endregion
|
|
60
185
|
export { renderChartNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","names":[],"sources":["../../../src/renderPptx/nodes/chart.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport {
|
|
1
|
+
{"version":3,"file":"chart.js","names":[],"sources":["../../../src/renderPptx/nodes/chart.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { asEmu, asOoxmlPercent, asPt } from \"@pptx-glimpse/document\";\nimport { pxToEmu } from \"../units.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport { toColorInput } from \"../pptxAuthoring.ts\";\n\ntype ChartPositionedNode = Extract<PositionedNode, { type: \"chart\" }>;\n\nconst DEFAULT_BAR_CHART_COLORS = [\n \"C0504D\",\n \"4F81BD\",\n \"9BBB59\",\n \"8064A2\",\n \"4BACC6\",\n \"F79646\",\n \"628FC6\",\n \"C86360\",\n \"C0504D\",\n \"4F81BD\",\n \"9BBB59\",\n \"8064A2\",\n \"4BACC6\",\n \"F79646\",\n \"628FC6\",\n \"C86360\",\n];\nconst DEFAULT_PIE_CHART_COLORS = [\n \"5DA5DA\",\n \"FAA43A\",\n \"60BD68\",\n \"F17CB0\",\n \"B2912F\",\n \"B276B2\",\n \"DECF3F\",\n \"F15854\",\n \"A7A7A7\",\n \"5DA5DA\",\n \"FAA43A\",\n \"60BD68\",\n \"F17CB0\",\n \"B2912F\",\n \"B276B2\",\n \"DECF3F\",\n \"F15854\",\n \"A7A7A7\",\n];\n\nexport function renderChartNode(\n node: ChartPositionedNode,\n ctx: RenderContext,\n): void {\n // sparkline モードは bar / line / area のみ対応。pie / doughnut / radar は\n // 元々凡例 / 軸の概念が異なるため sparkline=true でも通常描画にフォールバックする。\n const isSparkline =\n node.sparkline === true &&\n (node.chartType === \"bar\" ||\n node.chartType === \"line\" ||\n node.chartType === \"area\");\n\n const content = getContentArea(node);\n const series = normalizeChartSeries(node.data);\n const chartColors =\n node.chartColors ??\n (node.chartType === \"pie\" || node.chartType === \"doughnut\"\n ? DEFAULT_PIE_CHART_COLORS\n : DEFAULT_BAR_CHART_COLORS);\n const pointColors =\n chartColors.length > 0 &&\n (node.chartType === \"pie\" ||\n node.chartType === \"doughnut\" ||\n (node.chartType === \"bar\" &&\n node.data.length === 1 &&\n node.chartColors !== undefined &&\n node.chartColors.length > 1))\n ? node.data[0]?.values.map(\n (_value, index) => chartColors[index % chartColors.length],\n )\n : undefined;\n ctx.buildContext.pptxAuthoring.registerChart({\n chartType: node.chartType,\n series: series.map((item, index) => ({\n name: item.name,\n categories: item.labels,\n values: item.values,\n color: chartColors[index % chartColors.length],\n dataPoints:\n index === 0\n ? pointColors?.map((color, pointIndex) => ({\n index: pointIndex,\n fill: { kind: \"solid\", color: toColorInput(color)! },\n }))\n : undefined,\n marker:\n node.chartType === \"line\" || node.chartType === \"radar\"\n ? {\n symbol: \"circle\",\n size: 6,\n fill: {\n kind: \"solid\",\n color: toColorInput(chartColors[index % chartColors.length])!,\n },\n }\n : undefined,\n })),\n offsetX: asEmu(Math.round(pxToEmu(content.x))),\n offsetY: asEmu(Math.round(pxToEmu(content.y))),\n width: asEmu(Math.round(pxToEmu(Math.max(content.w, 1)))),\n height: asEmu(Math.round(pxToEmu(Math.max(content.h, 1)))),\n title:\n !isSparkline && node.showTitle ? node.title || \"Chart Title\" : undefined,\n titleStyle:\n !isSparkline && node.showTitle\n ? {\n fontFace: \"Arial\",\n fontSize: asPt(18),\n color: toColorInput(\"000000\"),\n bold: false,\n italic: false,\n }\n : undefined,\n displayBlanksAs: \"span\",\n roundedCorners: !isSparkline,\n chartArea: isSparkline\n ? {\n fill: {\n kind: \"solid\",\n color: {\n ...toColorInput(\"FFFFFF\")!,\n transforms: [{ kind: \"alpha\", value: asOoxmlPercent(0) }],\n },\n },\n }\n : { fill: { kind: \"none\" }, outline: { fill: { kind: \"none\" } } },\n plotArea: isSparkline\n ? {\n fill: {\n kind: \"solid\",\n color: {\n ...toColorInput(\"FFFFFF\")!,\n transforms: [{ kind: \"alpha\", value: asOoxmlPercent(0) }],\n },\n },\n }\n : { fill: { kind: \"none\" }, outline: { fill: { kind: \"none\" } } },\n showLegend: isSparkline ? false : (node.showLegend ?? false),\n radarStyle: node.chartType === \"radar\" ? node.radarStyle : undefined,\n categoryAxis: isSparkline\n ? { hidden: true, lineVisible: false, gridLinesVisible: false }\n : {\n majorTickMark: \"outside\",\n labelPosition: \"low\",\n numberFormat: { formatCode: \"General\", sourceLinked: true },\n showMultiLevelLabels: false,\n textStyle: {\n fontFace: \"Arial\",\n fontSize: asPt(12),\n color: toColorInput(\"000000\"),\n },\n },\n valueAxis: isSparkline\n ? { hidden: true, lineVisible: false, gridLinesVisible: false }\n : {\n majorTickMark: \"outside\",\n labelPosition: \"nextTo\",\n numberFormat: { formatCode: \"General\", sourceLinked: false },\n majorGridline: {\n width: asEmu(12700),\n fill: { kind: \"solid\", color: toColorInput(\"888888\")! },\n },\n textStyle: {\n fontFace: \"Arial\",\n fontSize: asPt(12),\n color: toColorInput(\"000000\"),\n },\n },\n plotLayout: isSparkline\n ? { coordinateMode: \"edge\", x: 0, y: 0, width: 1, height: 1 }\n : undefined,\n });\n}\n\n/**\n * glimpse の native writer は全系列で同じ category 軸と同じ点数を要求する。\n * 従来受理していた不揃いな入力も生成を継続できるよう、位置ベースで\n * category を共有し、欠けた値を 0 で補う。\n */\nfunction normalizeChartSeries(data: ChartPositionedNode[\"data\"]) {\n const sourceData = data.length > 0 ? data : [{ labels: [], values: [] }];\n const pointCount = Math.max(\n 1,\n ...sourceData.flatMap((series) => [\n series.labels.length,\n series.values.length,\n ]),\n );\n const categories = Array.from(\n { length: pointCount },\n (_, index) =>\n sourceData.find((series) => series.labels[index] !== undefined)?.labels[\n index\n ] ?? \"\",\n );\n return sourceData.map((series) => ({\n name: series.name,\n labels: categories,\n values: Array.from(\n { length: pointCount },\n (_, index) => series.values[index] ?? 0,\n ),\n }));\n}\n"],"mappings":";;;;;AASA,MAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,gBACd,MACA,KACM;CAGN,MAAM,cACJ,KAAK,cAAc,SAClB,KAAK,cAAc,SAClB,KAAK,cAAc,UACnB,KAAK,cAAc;CAEvB,MAAM,UAAU,eAAe,IAAI;CACnC,MAAM,SAAS,qBAAqB,KAAK,IAAI;CAC7C,MAAM,cACJ,KAAK,gBACJ,KAAK,cAAc,SAAS,KAAK,cAAc,aAC5C,2BACA;CACN,MAAM,cACJ,YAAY,SAAS,MACpB,KAAK,cAAc,SAClB,KAAK,cAAc,cAClB,KAAK,cAAc,SAClB,KAAK,KAAK,WAAW,KACrB,KAAK,gBAAgB,KAAA,KACrB,KAAK,YAAY,SAAS,KAC1B,KAAK,KAAK,EAAE,EAAE,OAAO,KAClB,QAAQ,UAAU,YAAY,QAAQ,YAAY,OACrD,IACA,KAAA;CACN,IAAI,aAAa,cAAc,cAAc;EAC3C,WAAW,KAAK;EAChB,QAAQ,OAAO,KAAK,MAAM,WAAW;GACnC,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,QAAQ,KAAK;GACb,OAAO,YAAY,QAAQ,YAAY;GACvC,YACE,UAAU,IACN,aAAa,K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,MAAM,OAAO;EACb,QAAQ;EACR,QAAQ,MAAM,KACZ,EAAE,QAAQ,WAAW,IACpB,GAAG,UAAU,OAAO,OAAO,UAAU,CACxC;CACF,EAAE;AACJ"}
|
|
@@ -53,7 +53,10 @@ function renderFlowNode(node, ctx) {
|
|
|
53
53
|
const fillColor = item.color ?? defaultColor;
|
|
54
54
|
const textColor = item.textColor ?? "FFFFFF";
|
|
55
55
|
addGlimpseShape(ctx, {
|
|
56
|
-
|
|
56
|
+
geometry: {
|
|
57
|
+
kind: "preset",
|
|
58
|
+
preset: item.shape
|
|
59
|
+
},
|
|
57
60
|
...createShapeBoundsInput({
|
|
58
61
|
x: layout.x,
|
|
59
62
|
y: layout.y,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.js","names":[],"sources":["../../../src/renderPptx/nodes/flow.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { measureFlow } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport { withContentBounds } from \"../utils/contentArea.ts\";\nimport { addStraightLine } from \"../utils/straightLine.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n shapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport {\n createGlimpseParagraphs,\n addGlimpseTextBox,\n} from \"../utils/glimpseTextBox.ts\";\n\ntype FlowPositionedNode = Extract<PositionedNode, { type: \"flow\" }>;\n\ninterface FlowNodeLayout {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n item: FlowPositionedNode[\"nodes\"][0];\n}\n\nexport function renderFlowNode(\n node: FlowPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"horizontal\";\n const nodeWidth = node.nodeWidth ?? 120;\n const nodeHeight = node.nodeHeight ?? 60;\n const nodeGap = node.nodeGap ?? 80;\n const connectorStyle = node.connectorStyle ?? {};\n const defaultColor = \"1D4ED8\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureFlow(node),\n ctx,\n );\n\n const scaledNodeWidth = nodeWidth * scaleFactor;\n const scaledNodeHeight = nodeHeight * scaleFactor;\n const scaledNodeGap = nodeGap * scaleFactor;\n\n const layouts = new Map<string, FlowNodeLayout>();\n const nodeCount = node.nodes.length;\n\n // コンテンツ領域を使用するための仮想ノードを作成\n const contentNode = withContentBounds(node, content);\n\n // ノードのレイアウトを計算\n if (direction === \"horizontal\") {\n calculateHorizontalLayout(\n contentNode,\n layouts,\n nodeCount,\n scaledNodeWidth,\n scaledNodeHeight,\n scaledNodeGap,\n scaleFactor,\n );\n } else {\n calculateVerticalLayout(\n contentNode,\n layouts,\n nodeCount,\n scaledNodeWidth,\n scaledNodeHeight,\n scaledNodeGap,\n scaleFactor,\n );\n }\n\n // 接続線を描画(ノードより先に描画して背面に配置)\n for (const conn of node.connections) {\n const fromLayout = layouts.get(conn.from);\n const toLayout = layouts.get(conn.to);\n\n if (!fromLayout || !toLayout) continue;\n\n const lineColor = conn.color ?? connectorStyle.color ?? \"333333\";\n const lineWidth = (connectorStyle.width ?? 2) * scaleFactor;\n const arrowType = connectorStyle.arrowType ?? \"triangle\";\n\n drawConnection(\n ctx,\n direction,\n fromLayout,\n toLayout,\n lineColor,\n lineWidth,\n arrowType,\n );\n\n // ラベルを描画\n if (conn.label) {\n const labelX =\n (fromLayout.x +\n fromLayout.width / 2 +\n toLayout.x +\n toLayout.width / 2) /\n 2;\n const labelY =\n (fromLayout.y +\n fromLayout.height / 2 +\n toLayout.y +\n toLayout.height / 2) /\n 2;\n\n const labelW = 60 * scaleFactor;\n const labelH = 20 * scaleFactor;\n\n addGlimpseTextBox(\n ctx,\n {\n x: labelX - labelW / 2,\n y: labelY - labelH / 2,\n w: labelW,\n h: labelH,\n },\n {\n text: conn.label,\n fontSize: 10 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color:\n stripHash(conn.labelColor) ??\n stripHash(connectorStyle.labelColor) ??\n \"64748B\",\n align: \"center\",\n valign: \"middle\",\n },\n );\n }\n }\n\n // ノードを描画\n for (const item of node.nodes) {\n const layout = layouts.get(item.id);\n if (!layout) continue;\n\n const fillColor = item.color ?? defaultColor;\n const textColor = item.textColor ?? \"FFFFFF\";\n\n // 図形を描画\n addGlimpseShape(\n ctx,\n {\n preset: item.shape,\n ...createShapeBoundsInput({\n x: layout.x,\n y: layout.y,\n w: layout.width,\n h: layout.height,\n }),\n fill: solidShapeFill(fillColor),\n outline: shapeOutline({ color: \"333333\", width: 1 * scaleFactor }),\n body: { anchor: \"middle\" },\n paragraphs: createGlimpseParagraphs(\n item.text,\n {\n fontSize: 14 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: textColor,\n },\n { align: \"center\" },\n ),\n },\n { x: layout.x, y: layout.y, w: layout.width, h: layout.height },\n { fillColor },\n );\n }\n}\n\nfunction calculateHorizontalLayout(\n node: FlowPositionedNode,\n layouts: Map<string, FlowNodeLayout>,\n nodeCount: number,\n nodeWidth: number,\n nodeHeight: number,\n nodeGap: number,\n scaleFactor: number,\n): void {\n const totalWidth = nodeCount * nodeWidth + (nodeCount - 1) * nodeGap;\n const startX = node.x + (node.w - totalWidth) / 2;\n const centerY = node.y + node.h / 2;\n\n node.nodes.forEach((item, index) => {\n const w = (item.width ?? nodeWidth / scaleFactor) * scaleFactor;\n const h = (item.height ?? nodeHeight / scaleFactor) * scaleFactor;\n layouts.set(item.id, {\n id: item.id,\n x: startX + index * (nodeWidth + nodeGap) + (nodeWidth - w) / 2,\n y: centerY - h / 2,\n width: w,\n height: h,\n item,\n });\n });\n}\n\nfunction calculateVerticalLayout(\n node: FlowPositionedNode,\n layouts: Map<string, FlowNodeLayout>,\n nodeCount: number,\n nodeWidth: number,\n nodeHeight: number,\n nodeGap: number,\n scaleFactor: number,\n): void {\n const totalHeight = nodeCount * nodeHeight + (nodeCount - 1) * nodeGap;\n const startY = node.y + (node.h - totalHeight) / 2;\n const centerX = node.x + node.w / 2;\n\n node.nodes.forEach((item, index) => {\n const w = (item.width ?? nodeWidth / scaleFactor) * scaleFactor;\n const h = (item.height ?? nodeHeight / scaleFactor) * scaleFactor;\n layouts.set(item.id, {\n id: item.id,\n x: centerX - w / 2,\n y: startY + index * (nodeHeight + nodeGap) + (nodeHeight - h) / 2,\n width: w,\n height: h,\n item,\n });\n });\n}\n\nfunction drawConnection(\n ctx: RenderContext,\n direction: \"horizontal\" | \"vertical\",\n fromLayout: FlowNodeLayout,\n toLayout: FlowNodeLayout,\n lineColor: string,\n lineWidth: number,\n arrowType: \"none\" | \"arrow\" | \"diamond\" | \"oval\" | \"stealth\" | \"triangle\",\n): void {\n let startX: number, startY: number, endX: number, endY: number;\n\n if (direction === \"horizontal\") {\n // 水平: 右端から左端へ\n startX = fromLayout.x + fromLayout.width;\n startY = fromLayout.y + fromLayout.height / 2;\n endX = toLayout.x;\n endY = toLayout.y + toLayout.height / 2;\n } else {\n // 垂直: 下端から上端へ\n startX = fromLayout.x + fromLayout.width / 2;\n startY = fromLayout.y + fromLayout.height;\n endX = toLayout.x + toLayout.width / 2;\n endY = toLayout.y;\n }\n\n // 直線接続(シンプルなケース)\n const isHorizontalLine = Math.abs(startY - endY) < 1;\n const isVerticalLine = Math.abs(startX - endX) < 1;\n\n if (isHorizontalLine || isVerticalLine) {\n // 直線で描画\n addStraightLine(\n ctx,\n { x1: startX, y1: startY, x2: endX, y2: endY },\n { color: lineColor, lineWidth, endArrow: { type: arrowType } },\n );\n } else {\n // L字型接続\n drawLShapedConnection(\n ctx,\n direction,\n startX,\n startY,\n endX,\n endY,\n lineColor,\n lineWidth,\n arrowType,\n );\n }\n}\n\nfunction drawLShapedConnection(\n ctx: RenderContext,\n direction: \"horizontal\" | \"vertical\",\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n lineColor: string,\n lineWidth: number,\n arrowType: \"none\" | \"arrow\" | \"diamond\" | \"oval\" | \"stealth\" | \"triangle\",\n): void {\n const midX = (startX + endX) / 2;\n const midY = (startY + endY) / 2;\n\n if (direction === \"horizontal\") {\n // 水平→垂直→水平\n addStraightLine(\n ctx,\n { x1: startX, y1: startY, x2: midX, y2: startY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: midX, y1: startY, x2: midX, y2: endY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: midX, y1: endY, x2: endX, y2: endY },\n { color: lineColor, lineWidth, endArrow: { type: arrowType } },\n );\n } else {\n // 垂直→水平→垂直\n addStraightLine(\n ctx,\n { x1: startX, y1: startY, x2: startX, y2: midY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: startX, y1: midY, x2: endX, y2: midY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: endX, y1: midY, x2: endX, y2: endY },\n { color: lineColor, lineWidth, endArrow: { type: arrowType } },\n );\n }\n}\n"],"mappings":";;;;;;;;AA6BA,SAAgB,eACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,UAAU,KAAK,WAAW;CAChC,MAAM,iBAAiB,KAAK,kBAAkB,CAAC;CAC/C,MAAM,eAAe;CAGrB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,YAAY,IAAI,GAChB,GACF;CAEA,MAAM,kBAAkB,YAAY;CACpC,MAAM,mBAAmB,aAAa;CACtC,MAAM,gBAAgB,UAAU;CAEhC,MAAM,0BAAU,IAAI,IAA4B;CAChD,MAAM,YAAY,KAAK,MAAM;CAG7B,MAAM,cAAc,kBAAkB,MAAM,OAAO;CAGnD,IAAI,cAAc,cAChB,0BACE,aACA,SACA,WACA,iBACA,kBACA,eACA,WACF;MAEA,wBACE,aACA,SACA,WACA,iBACA,kBACA,eACA,WACF;CAIF,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AAI;GAAM,IAAI;GAAM,IAAI;EAAK,GAC3C;GAAE,OAAO;GAAW;EAAU,CAChC;EACA,gBACE,KACA;GAAE,IAAI;GAAM,IAAI;GAAM,IAAI;GAAM,IAAI;EAAK,GACzC;GAAE,OAAO;GAAW;GAAW,UAAU,EAAE,MAAM,UAAU;EAAE,CAC/D;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"flow.js","names":[],"sources":["../../../src/renderPptx/nodes/flow.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { measureFlow } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport { withContentBounds } from \"../utils/contentArea.ts\";\nimport { addStraightLine } from \"../utils/straightLine.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n shapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport {\n createGlimpseParagraphs,\n addGlimpseTextBox,\n} from \"../utils/glimpseTextBox.ts\";\n\ntype FlowPositionedNode = Extract<PositionedNode, { type: \"flow\" }>;\n\ninterface FlowNodeLayout {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n item: FlowPositionedNode[\"nodes\"][0];\n}\n\nexport function renderFlowNode(\n node: FlowPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"horizontal\";\n const nodeWidth = node.nodeWidth ?? 120;\n const nodeHeight = node.nodeHeight ?? 60;\n const nodeGap = node.nodeGap ?? 80;\n const connectorStyle = node.connectorStyle ?? {};\n const defaultColor = \"1D4ED8\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureFlow(node),\n ctx,\n );\n\n const scaledNodeWidth = nodeWidth * scaleFactor;\n const scaledNodeHeight = nodeHeight * scaleFactor;\n const scaledNodeGap = nodeGap * scaleFactor;\n\n const layouts = new Map<string, FlowNodeLayout>();\n const nodeCount = node.nodes.length;\n\n // コンテンツ領域を使用するための仮想ノードを作成\n const contentNode = withContentBounds(node, content);\n\n // ノードのレイアウトを計算\n if (direction === \"horizontal\") {\n calculateHorizontalLayout(\n contentNode,\n layouts,\n nodeCount,\n scaledNodeWidth,\n scaledNodeHeight,\n scaledNodeGap,\n scaleFactor,\n );\n } else {\n calculateVerticalLayout(\n contentNode,\n layouts,\n nodeCount,\n scaledNodeWidth,\n scaledNodeHeight,\n scaledNodeGap,\n scaleFactor,\n );\n }\n\n // 接続線を描画(ノードより先に描画して背面に配置)\n for (const conn of node.connections) {\n const fromLayout = layouts.get(conn.from);\n const toLayout = layouts.get(conn.to);\n\n if (!fromLayout || !toLayout) continue;\n\n const lineColor = conn.color ?? connectorStyle.color ?? \"333333\";\n const lineWidth = (connectorStyle.width ?? 2) * scaleFactor;\n const arrowType = connectorStyle.arrowType ?? \"triangle\";\n\n drawConnection(\n ctx,\n direction,\n fromLayout,\n toLayout,\n lineColor,\n lineWidth,\n arrowType,\n );\n\n // ラベルを描画\n if (conn.label) {\n const labelX =\n (fromLayout.x +\n fromLayout.width / 2 +\n toLayout.x +\n toLayout.width / 2) /\n 2;\n const labelY =\n (fromLayout.y +\n fromLayout.height / 2 +\n toLayout.y +\n toLayout.height / 2) /\n 2;\n\n const labelW = 60 * scaleFactor;\n const labelH = 20 * scaleFactor;\n\n addGlimpseTextBox(\n ctx,\n {\n x: labelX - labelW / 2,\n y: labelY - labelH / 2,\n w: labelW,\n h: labelH,\n },\n {\n text: conn.label,\n fontSize: 10 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color:\n stripHash(conn.labelColor) ??\n stripHash(connectorStyle.labelColor) ??\n \"64748B\",\n align: \"center\",\n valign: \"middle\",\n },\n );\n }\n }\n\n // ノードを描画\n for (const item of node.nodes) {\n const layout = layouts.get(item.id);\n if (!layout) continue;\n\n const fillColor = item.color ?? defaultColor;\n const textColor = item.textColor ?? \"FFFFFF\";\n\n // 図形を描画\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: item.shape },\n ...createShapeBoundsInput({\n x: layout.x,\n y: layout.y,\n w: layout.width,\n h: layout.height,\n }),\n fill: solidShapeFill(fillColor),\n outline: shapeOutline({ color: \"333333\", width: 1 * scaleFactor }),\n body: { anchor: \"middle\" },\n paragraphs: createGlimpseParagraphs(\n item.text,\n {\n fontSize: 14 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: textColor,\n },\n { align: \"center\" },\n ),\n },\n { x: layout.x, y: layout.y, w: layout.width, h: layout.height },\n { fillColor },\n );\n }\n}\n\nfunction calculateHorizontalLayout(\n node: FlowPositionedNode,\n layouts: Map<string, FlowNodeLayout>,\n nodeCount: number,\n nodeWidth: number,\n nodeHeight: number,\n nodeGap: number,\n scaleFactor: number,\n): void {\n const totalWidth = nodeCount * nodeWidth + (nodeCount - 1) * nodeGap;\n const startX = node.x + (node.w - totalWidth) / 2;\n const centerY = node.y + node.h / 2;\n\n node.nodes.forEach((item, index) => {\n const w = (item.width ?? nodeWidth / scaleFactor) * scaleFactor;\n const h = (item.height ?? nodeHeight / scaleFactor) * scaleFactor;\n layouts.set(item.id, {\n id: item.id,\n x: startX + index * (nodeWidth + nodeGap) + (nodeWidth - w) / 2,\n y: centerY - h / 2,\n width: w,\n height: h,\n item,\n });\n });\n}\n\nfunction calculateVerticalLayout(\n node: FlowPositionedNode,\n layouts: Map<string, FlowNodeLayout>,\n nodeCount: number,\n nodeWidth: number,\n nodeHeight: number,\n nodeGap: number,\n scaleFactor: number,\n): void {\n const totalHeight = nodeCount * nodeHeight + (nodeCount - 1) * nodeGap;\n const startY = node.y + (node.h - totalHeight) / 2;\n const centerX = node.x + node.w / 2;\n\n node.nodes.forEach((item, index) => {\n const w = (item.width ?? nodeWidth / scaleFactor) * scaleFactor;\n const h = (item.height ?? nodeHeight / scaleFactor) * scaleFactor;\n layouts.set(item.id, {\n id: item.id,\n x: centerX - w / 2,\n y: startY + index * (nodeHeight + nodeGap) + (nodeHeight - h) / 2,\n width: w,\n height: h,\n item,\n });\n });\n}\n\nfunction drawConnection(\n ctx: RenderContext,\n direction: \"horizontal\" | \"vertical\",\n fromLayout: FlowNodeLayout,\n toLayout: FlowNodeLayout,\n lineColor: string,\n lineWidth: number,\n arrowType: \"none\" | \"arrow\" | \"diamond\" | \"oval\" | \"stealth\" | \"triangle\",\n): void {\n let startX: number, startY: number, endX: number, endY: number;\n\n if (direction === \"horizontal\") {\n // 水平: 右端から左端へ\n startX = fromLayout.x + fromLayout.width;\n startY = fromLayout.y + fromLayout.height / 2;\n endX = toLayout.x;\n endY = toLayout.y + toLayout.height / 2;\n } else {\n // 垂直: 下端から上端へ\n startX = fromLayout.x + fromLayout.width / 2;\n startY = fromLayout.y + fromLayout.height;\n endX = toLayout.x + toLayout.width / 2;\n endY = toLayout.y;\n }\n\n // 直線接続(シンプルなケース)\n const isHorizontalLine = Math.abs(startY - endY) < 1;\n const isVerticalLine = Math.abs(startX - endX) < 1;\n\n if (isHorizontalLine || isVerticalLine) {\n // 直線で描画\n addStraightLine(\n ctx,\n { x1: startX, y1: startY, x2: endX, y2: endY },\n { color: lineColor, lineWidth, endArrow: { type: arrowType } },\n );\n } else {\n // L字型接続\n drawLShapedConnection(\n ctx,\n direction,\n startX,\n startY,\n endX,\n endY,\n lineColor,\n lineWidth,\n arrowType,\n );\n }\n}\n\nfunction drawLShapedConnection(\n ctx: RenderContext,\n direction: \"horizontal\" | \"vertical\",\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n lineColor: string,\n lineWidth: number,\n arrowType: \"none\" | \"arrow\" | \"diamond\" | \"oval\" | \"stealth\" | \"triangle\",\n): void {\n const midX = (startX + endX) / 2;\n const midY = (startY + endY) / 2;\n\n if (direction === \"horizontal\") {\n // 水平→垂直→水平\n addStraightLine(\n ctx,\n { x1: startX, y1: startY, x2: midX, y2: startY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: midX, y1: startY, x2: midX, y2: endY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: midX, y1: endY, x2: endX, y2: endY },\n { color: lineColor, lineWidth, endArrow: { type: arrowType } },\n );\n } else {\n // 垂直→水平→垂直\n addStraightLine(\n ctx,\n { x1: startX, y1: startY, x2: startX, y2: midY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: startX, y1: midY, x2: endX, y2: midY },\n { color: lineColor, lineWidth },\n );\n addStraightLine(\n ctx,\n { x1: endX, y1: midY, x2: endX, y2: endY },\n { color: lineColor, lineWidth, endArrow: { type: arrowType } },\n );\n }\n}\n"],"mappings":";;;;;;;;AA6BA,SAAgB,eACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,UAAU,KAAK,WAAW;CAChC,MAAM,iBAAiB,KAAK,kBAAkB,CAAC;CAC/C,MAAM,eAAe;CAGrB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,YAAY,IAAI,GAChB,GACF;CAEA,MAAM,kBAAkB,YAAY;CACpC,MAAM,mBAAmB,aAAa;CACtC,MAAM,gBAAgB,UAAU;CAEhC,MAAM,0BAAU,IAAI,IAA4B;CAChD,MAAM,YAAY,KAAK,MAAM;CAG7B,MAAM,cAAc,kBAAkB,MAAM,OAAO;CAGnD,IAAI,cAAc,cAChB,0BACE,aACA,SACA,WACA,iBACA,kBACA,eACA,WACF;MAEA,wBACE,aACA,SACA,WACA,iBACA,kBACA,eACA,WACF;CAIF,KAAK,MAAM,QAAQ,KAAK,aAAa;EACnC,MAAM,aAAa,QAAQ,IAAI,KAAK,IAAI;EACxC,MAAM,WAAW,QAAQ,IAAI,KAAK,EAAE;EAEpC,IAAI,CAAC,cAAc,CAAC,UAAU;EAM9B,eACE,KACA,WACA,YACA,UARgB,KAAK,SAAS,eAAe,SAAS,WACrC,eAAe,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AAU;EAAE,CAC/D;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pxToEmu } from "../units.js";
|
|
2
|
-
import { toColorInput } from "../
|
|
2
|
+
import { toColorInput } from "../pptxAuthoring.js";
|
|
3
3
|
import { addGlimpsePicture, imageBytesFromSource } from "../utils/glimpsePicture.js";
|
|
4
4
|
import { addGlimpseShape, createShapeBoundsInput, createShapeRotationInput, noShapeOutline, noneShapeFill, shapeOutline, solidShapeFill } from "../utils/glimpseShape.js";
|
|
5
5
|
import { asEmu } from "@pptx-glimpse/document";
|
|
@@ -24,7 +24,10 @@ function renderIconNode(node, ctx) {
|
|
|
24
24
|
h: node.bgH ?? node.h
|
|
25
25
|
};
|
|
26
26
|
addGlimpseShape(ctx, {
|
|
27
|
-
|
|
27
|
+
geometry: {
|
|
28
|
+
kind: "preset",
|
|
29
|
+
preset: isCircle ? "ellipse" : "roundRect"
|
|
30
|
+
},
|
|
28
31
|
...createShapeBoundsInput(bounds),
|
|
29
32
|
rotation: createShapeRotationInput(node.rotate),
|
|
30
33
|
fill: isFilled ? solidShapeFill(colorValue) : noneShapeFill(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.js","names":[],"sources":["../../../src/renderPptx/nodes/icon.ts"],"sourcesContent":["import { asEmu } from \"@pptx-glimpse/document\";\nimport type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { toColorInput } from \"../
|
|
1
|
+
{"version":3,"file":"icon.js","names":[],"sources":["../../../src/renderPptx/nodes/icon.ts"],"sourcesContent":["import { asEmu } from \"@pptx-glimpse/document\";\nimport type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { toColorInput } from \"../pptxAuthoring.ts\";\nimport { pxToEmu } from \"../units.ts\";\nimport {\n addGlimpsePicture,\n imageBytesFromSource,\n} from \"../utils/glimpsePicture.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n createShapeRotationInput,\n noShapeOutline,\n noneShapeFill,\n shapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\n\ntype IconPositionedNode = Extract<PositionedNode, { type: \"icon\" }>;\n\nexport function renderIconNode(\n node: IconPositionedNode,\n ctx: RenderContext,\n): void {\n // variant 指定時は背景図形を描画\n if (node.variant) {\n const isCircle = node.variant.startsWith(\"circle\");\n const isFilled = node.variant.endsWith(\"-filled\");\n const bgColor = node.bgColor ?? \"#E0E0E0\";\n const colorValue = bgColor.replace(/^#/, \"\");\n\n // 背景図形の line のデフォルト: outlined variant は colorValue / 1.5pt 相当 (2px)、\n // filled variant は undefined (枠線なし)。\n const variantDefaultLine = isFilled\n ? undefined\n : { color: colorValue, width: 2 };\n // outline 指定時は variant のデフォルト line とフィールド単位でマージする。\n // outline 側で省略された属性は variant default の値を引き継ぐので、例えば\n // outlined variant に `outline.color` だけ指定すると、太さは 1.5pt のまま\n // 色だけ outline で上書きされる。\n const outlineLine = node.outline\n ? {\n color: node.outline.color ?? variantDefaultLine?.color ?? \"FFFFFF\",\n width:\n node.outline.size !== undefined\n ? node.outline.size\n : (variantDefaultLine?.width ?? 1),\n }\n : variantDefaultLine;\n\n const bounds = {\n x: node.bgX ?? node.x,\n y: node.bgY ?? node.y,\n w: node.bgW ?? node.w,\n h: node.bgH ?? node.h,\n };\n const shapeType = isCircle ? \"ellipse\" : \"roundRect\";\n\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: shapeType },\n ...createShapeBoundsInput(bounds),\n rotation: createShapeRotationInput(node.rotate),\n fill: isFilled ? solidShapeFill(colorValue) : noneShapeFill(),\n outline: outlineLine ? shapeOutline(outlineLine) : noShapeOutline(),\n effects: node.glow\n ? {\n glow: {\n radius: asEmu(Math.round(pxToEmu(node.glow.size ?? 8))),\n color: toColorInput(node.glow.color ?? \"FFFFFF\")!,\n },\n }\n : undefined,\n },\n bounds,\n {\n fillColor: isFilled ? colorValue : undefined,\n glow: node.glow,\n rectRadius: isCircle ? undefined : 0.1,\n },\n );\n }\n\n addGlimpsePicture(\n ctx,\n {\n x: node.iconX ?? node.x,\n y: node.iconY ?? node.y,\n w: node.iconW ?? node.w,\n h: node.iconH ?? node.h,\n },\n imageBytesFromSource(\"\", node.iconImageData),\n { rotate: node.rotate },\n );\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,eACd,MACA,KACM;CAEN,IAAI,KAAK,SAAS;EAChB,MAAM,WAAW,KAAK,QAAQ,WAAW,QAAQ;EACjD,MAAM,WAAW,KAAK,QAAQ,SAAS,SAAS;EAEhD,MAAM,cADU,KAAK,WAAW,UAAA,CACL,QAAQ,MAAM,EAAE;EAI3C,MAAM,qBAAqB,WACvB,KAAA,IACA;GAAE,OAAO;GAAY,OAAO;EAAE;EAKlC,MAAM,cAAc,KAAK,UACrB;GACE,OAAO,KAAK,QAAQ,SAAS,oBAAoB,SAAS;GAC1D,OACE,KAAK,QAAQ,SAAS,KAAA,IAClB,KAAK,QAAQ,OACZ,oBAAoB,SAAS;EACtC,IACA;EAEJ,MAAM,SAAS;GACb,GAAG,KAAK,OAAO,KAAK;GACpB,GAAG,KAAK,OAAO,KAAK;GACpB,GAAG,KAAK,OAAO,KAAK;GACpB,GAAG,KAAK,OAAO,KAAK;EACtB;EAGA,gBACE,KACA;GACE,UAAU;IAAE,MAAM;IAAU,QALd,WAAW,YAAY;GAKS;GAC9C,GAAG,uBAAuB,MAAM;GAChC,UAAU,yBAAyB,KAAK,MAAM;GAC9C,MAAM,WAAW,eAAe,UAAU,IAAI,cAAc;GAC5D,SAAS,cAAc,aAAa,WAAW,IAAI,eAAe;GAClE,SAAS,KAAK,OACV,EACE,MAAM;IACJ,QAAQ,MAAM,KAAK,MAAM,QAAQ,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;IACtD,OAAO,aAAa,KAAK,KAAK,SAAS,QAAQ;GACjD,EACF,IACA,KAAA;EACN,GACA,QACA;GACE,WAAW,WAAW,aAAa,KAAA;GACnC,MAAM,KAAK;GACX,YAAY,WAAW,KAAA,IAAY;EACrC,CACF;CACF;CAEA,kBACE,KACA;EACE,GAAG,KAAK,SAAS,KAAK;EACtB,GAAG,KAAK,SAAS,KAAK;EACtB,GAAG,KAAK,SAAS,KAAK;EACtB,GAAG,KAAK,SAAS,KAAK;CACxB,GACA,qBAAqB,IAAI,KAAK,aAAa,GAC3C,EAAE,QAAQ,KAAK,OAAO,CACxB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getContentArea } from "../utils/contentArea.js";
|
|
2
2
|
import { resolveSubSup } from "../textOptions.js";
|
|
3
|
-
import { addGlimpseTextBox, createGlimpseRunProperties
|
|
3
|
+
import { addGlimpseTextBox, createGlimpseRunProperties } from "../utils/glimpseTextBox.js";
|
|
4
4
|
//#region src/renderPptx/nodes/list.ts
|
|
5
5
|
function resolveStyle(li, parent) {
|
|
6
6
|
const subSup = resolveSubSup(li, parent);
|
|
@@ -98,10 +98,8 @@ function renderUlNode(node, ctx) {
|
|
|
98
98
|
highlight: node.highlight,
|
|
99
99
|
paragraphs,
|
|
100
100
|
hyperlinks,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
lineHeight: node.lineHeight
|
|
104
|
-
})
|
|
101
|
+
lineHeight: node.lineHeight,
|
|
102
|
+
bullet: { kind: "bullet" }
|
|
105
103
|
});
|
|
106
104
|
}
|
|
107
105
|
function renderOlNode(node, ctx) {
|
|
@@ -125,12 +123,12 @@ function renderOlNode(node, ctx) {
|
|
|
125
123
|
highlight: node.highlight,
|
|
126
124
|
paragraphs,
|
|
127
125
|
hyperlinks,
|
|
128
|
-
|
|
126
|
+
lineHeight: node.lineHeight,
|
|
127
|
+
bullet: {
|
|
129
128
|
kind: "number",
|
|
130
129
|
scheme: node.numberType,
|
|
131
|
-
startAt: node.numberStartAt
|
|
132
|
-
|
|
133
|
-
})
|
|
130
|
+
startAt: node.numberStartAt
|
|
131
|
+
}
|
|
134
132
|
});
|
|
135
133
|
}
|
|
136
134
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":[],"sources":["../../../src/renderPptx/nodes/list.ts"],"sourcesContent":["import type { PositionedNode, LiNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { resolveSubSup } from \"../textOptions.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseTextBox,\n createGlimpseRunProperties,\n
|
|
1
|
+
{"version":3,"file":"list.js","names":[],"sources":["../../../src/renderPptx/nodes/list.ts"],"sourcesContent":["import type { PositionedNode, LiNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { resolveSubSup } from \"../textOptions.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseTextBox,\n createGlimpseRunProperties,\n type GlimpseTextRunStyle,\n} from \"../utils/glimpseTextBox.ts\";\nimport {\n type AddTextBoxParagraphInput,\n type AddTextBoxRunInput,\n} from \"@pptx-glimpse/document\";\n\ntype UlPositionedNode = Extract<PositionedNode, { type: \"ul\" }>;\ntype OlPositionedNode = Extract<PositionedNode, { type: \"ol\" }>;\n\nfunction resolveStyle(li: LiNode, parent: UlPositionedNode | OlPositionedNode) {\n const subSup = resolveSubSup(li, parent);\n return {\n fontSize: li.fontSize ?? parent.fontSize ?? 24,\n color: li.color ?? parent.color,\n bold: li.bold ?? parent.bold,\n italic: li.italic ?? parent.italic,\n underline: li.underline ?? parent.underline,\n strike: li.strike ?? parent.strike,\n subscript: subSup.subscript,\n superscript: subSup.superscript,\n highlight: li.highlight ?? parent.highlight,\n fontFamily: li.fontFamily ?? parent.fontFamily ?? \"Noto Sans JP\",\n };\n}\n\nfunction paragraphProperties(parent: UlPositionedNode | OlPositionedNode) {\n return {\n align: parent.textAlign ?? \"left\",\n };\n}\n\nfunction toRunStyle(\n style: ReturnType<typeof resolveStyle>,\n): GlimpseTextRunStyle {\n return {\n fontSize: style.fontSize,\n fontFace: style.fontFamily,\n color: style.color,\n bold: style.bold,\n italic: style.italic,\n underline: style.underline,\n strike: style.strike,\n subscript: style.subscript,\n superscript: style.superscript,\n highlight: style.highlight,\n };\n}\n\nfunction buildListParagraphs(\n items: LiNode[],\n parent: UlPositionedNode | OlPositionedNode,\n): {\n paragraphs: AddTextBoxParagraphInput[];\n hyperlinks: (string | undefined)[];\n} {\n const paragraphs: AddTextBoxParagraphInput[] = [];\n const hyperlinks: (string | undefined)[] = [];\n for (let i = 0; i < items.length; i++) {\n const li = items[i];\n const style = resolveStyle(li, parent);\n const runs: AddTextBoxRunInput[] = [];\n if (li.runs && li.runs.length > 0) {\n for (const run of li.runs) {\n const runSubSup = resolveSubSup(run, style);\n runs.push({\n text: run.text,\n properties: createGlimpseRunProperties({\n fontSize: run.fontSize ?? style.fontSize,\n fontFace: run.fontFamily ?? style.fontFamily,\n color: run.color ?? style.color,\n bold: run.bold ?? style.bold,\n italic: run.italic ?? style.italic,\n underline: run.underline ?? style.underline,\n strike: run.strike ?? style.strike,\n subscript: runSubSup.subscript,\n superscript: runSubSup.superscript,\n highlight: run.highlight ?? style.highlight,\n }),\n });\n hyperlinks.push(run.text ? run.href : undefined);\n }\n } else {\n runs.push({\n text: li.text,\n properties: createGlimpseRunProperties(toRunStyle(style)),\n });\n hyperlinks.push(undefined);\n }\n paragraphs.push({\n properties: paragraphProperties(parent),\n runs,\n });\n }\n return { paragraphs, hyperlinks };\n}\n\nexport function renderUlNode(node: UlPositionedNode, ctx: RenderContext): void {\n const fontSizePx = node.fontSize ?? 24;\n const fontFamily = node.fontFamily ?? \"Noto Sans JP\";\n const content = getContentArea(node);\n\n const { paragraphs, hyperlinks } = buildListParagraphs(node.items, node);\n addGlimpseTextBox(ctx, content, {\n fontSize: fontSizePx,\n fontFace: fontFamily,\n align: node.textAlign ?? \"left\",\n valign: \"top\",\n margin: 0,\n color: node.color,\n bold: node.bold,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n subscript: node.subscript,\n superscript: node.superscript,\n highlight: node.highlight,\n paragraphs,\n hyperlinks,\n lineHeight: node.lineHeight,\n bullet: {\n kind: \"bullet\",\n },\n });\n}\n\nexport function renderOlNode(node: OlPositionedNode, ctx: RenderContext): void {\n const fontSizePx = node.fontSize ?? 24;\n const fontFamily = node.fontFamily ?? \"Noto Sans JP\";\n const content = getContentArea(node);\n\n const { paragraphs, hyperlinks } = buildListParagraphs(node.items, node);\n addGlimpseTextBox(ctx, content, {\n fontSize: fontSizePx,\n fontFace: fontFamily,\n align: node.textAlign ?? \"left\",\n valign: \"top\",\n margin: 0,\n color: node.color,\n bold: node.bold,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n subscript: node.subscript,\n superscript: node.superscript,\n highlight: node.highlight,\n paragraphs,\n hyperlinks,\n lineHeight: node.lineHeight,\n bullet: {\n kind: \"number\",\n scheme: node.numberType,\n startAt: node.numberStartAt,\n },\n });\n}\n"],"mappings":";;;;AAiBA,SAAS,aAAa,IAAY,QAA6C;CAC7E,MAAM,SAAS,cAAc,IAAI,MAAM;CACvC,OAAO;EACL,UAAU,GAAG,YAAY,OAAO,YAAY;EAC5C,OAAO,GAAG,SAAS,OAAO;EAC1B,MAAM,GAAG,QAAQ,OAAO;EACxB,QAAQ,GAAG,UAAU,OAAO;EAC5B,WAAW,GAAG,aAAa,OAAO;EAClC,QAAQ,GAAG,UAAU,OAAO;EAC5B,WAAW,OAAO;EAClB,aAAa,OAAO;EACpB,WAAW,GAAG,aAAa,OAAO;EAClC,YAAY,GAAG,cAAc,OAAO,cAAc;CACpD;AACF;AAEA,SAAS,oBAAoB,QAA6C;CACxE,OAAO,EACL,OAAO,OAAO,aAAa,OAC7B;AACF;AAEA,SAAS,WACP,OACqB;CACrB,OAAO;EACL,UAAU,MAAM;EAChB,UAAU,MAAM;EAChB,OAAO,MAAM;EACb,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,aAAa,MAA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AAU;EACV,UAAU;EACV,OAAO,KAAK,aAAa;EACzB,QAAQ;EACR,QAAQ;EACR,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB;EACA;EACA,YAAY,KAAK;EACjB,QAAQ,EACN,MAAM,SACR;CACF,CAAC;AACH;AAEA,SAAgB,aAAa,MAAwB,KAA0B;CAC7E,MAAM,aAAa,KAAK,YAAY;CACpC,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,UAAU,eAAe,IAAI;CAEnC,MAAM,EAAE,YAAY,eAAe,oBAAoB,KAAK,OAAO,IAAI;CACvE,kBAAkB,KAAK,SAAS;EAC9B,UAAU;EACV,UAAU;EACV,OAAO,KAAK,aAAa;EACzB,QAAQ;EACR,QAAQ;EACR,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB;EACA;EACA,YAAY,KAAK;EACjB,QAAQ;GACN,MAAM;GACN,QAAQ,KAAK;GACb,SAAS,KAAK;EAChB;CACF,CAAC;AACH"}
|
|
@@ -82,7 +82,10 @@ function renderMatrixNode(node, ctx) {
|
|
|
82
82
|
const itemY = areaY + (1 - item.y) * areaH;
|
|
83
83
|
const itemColor = item.color ?? defaultItemColor;
|
|
84
84
|
addGlimpseShape(ctx, {
|
|
85
|
-
|
|
85
|
+
geometry: {
|
|
86
|
+
kind: "preset",
|
|
87
|
+
preset: "ellipse"
|
|
88
|
+
},
|
|
86
89
|
...createShapeBoundsInput({
|
|
87
90
|
x: itemX - itemSize / 2,
|
|
88
91
|
y: itemY - itemSize / 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","names":[],"sources":["../../../src/renderPptx/nodes/matrix.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { measureMatrix } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport { addStraightLine } from \"../utils/straightLine.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype MatrixPositionedNode = Extract<PositionedNode, { type: \"matrix\" }>;\n\nexport function renderMatrixNode(\n node: MatrixPositionedNode,\n ctx: RenderContext,\n): void {\n const items = node.items;\n const axes = node.axes;\n const quadrants = node.quadrants;\n\n const defaultItemColor = \"1D4ED8\"; // blue\n const baseItemSize = 24; // px\n const baseLineWidth = 2; // px\n const axisColor = \"E2E8F0\";\n const axisLabelColor = stripHash(node.axisLabelColor) ?? \"64748B\";\n const itemLabelColor = stripHash(node.itemLabelColor) ?? \"1E293B\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureMatrix(node),\n ctx,\n );\n\n const itemSize = baseItemSize * scaleFactor;\n const lineWidth = baseLineWidth * scaleFactor;\n\n // マトリクスの描画領域(軸ラベル用の余白を考慮)\n const axisMargin = 60 * scaleFactor; // 軸ラベル用の余白\n const areaX = content.x + axisMargin;\n const areaY = content.y + axisMargin;\n const areaW = content.w - axisMargin * 2;\n const areaH = content.h - axisMargin * 2;\n\n // 中心座標\n const centerX = areaX + areaW / 2;\n const centerY = areaY + areaH / 2;\n\n // === 1. 十字線(軸線)を描画 ===\n // 横線(X軸)\n addStraightLine(\n ctx,\n { x1: areaX, y1: centerY, x2: areaX + areaW, y2: centerY },\n { color: axisColor, lineWidth },\n );\n\n // 縦線(Y軸)\n addStraightLine(\n ctx,\n { x1: centerX, y1: areaY, x2: centerX, y2: areaY + areaH },\n { color: axisColor, lineWidth },\n );\n\n // === 2. 軸ラベルを描画 ===\n const axisLabelW = 120 * scaleFactor;\n const axisLabelH = 24 * scaleFactor;\n\n // X軸ラベル(下部中央)\n addGlimpseTextBox(\n ctx,\n {\n x: centerX - axisLabelW / 2,\n y: areaY + areaH + 8 * scaleFactor,\n w: axisLabelW,\n h: axisLabelH,\n },\n {\n text: axes.x,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"top\",\n },\n );\n\n // Y軸ラベル(左部中央)270° 回転で下から上読み。w が視覚的な高さになるため CJK 5 文字以上も収まる幅を確保\n const yLabelW = 100 * scaleFactor;\n const yLabelH = 20 * scaleFactor;\n addGlimpseTextBox(\n ctx,\n {\n x: content.x + axisMargin / 2 - yLabelW / 2,\n y: centerY - yLabelH / 2,\n w: yLabelW,\n h: yLabelH,\n },\n {\n text: axes.y,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"middle\",\n rotate: 270,\n },\n );\n\n // === 3. 象限ラベルを描画 ===\n if (quadrants) {\n renderQuadrantLabels(\n ctx,\n quadrants,\n areaX,\n areaY,\n areaW,\n areaH,\n centerX,\n centerY,\n scaleFactor,\n stripHash(node.quadrantLabelColor) ?? \"94A3B8\",\n );\n }\n\n // === 4. アイテムをプロット ===\n const itemLabelW = 100 * scaleFactor;\n const itemLabelH = 18 * scaleFactor;\n\n for (const item of items) {\n // 座標変換: (0,0)=左下, (1,1)=右上\n // x: 0 -> areaX, 1 -> areaX + areaW\n // y: 0 -> areaY + areaH, 1 -> areaY (反転)\n const itemX = areaX + item.x * areaW;\n const itemY = areaY + (1 - item.y) * areaH; // Y軸反転\n const itemColor = item.color ?? defaultItemColor;\n\n // 円を描画\n addGlimpseShape(\n ctx,\n {\n preset: \"ellipse\",\n ...createShapeBoundsInput({\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n }),\n fill: solidShapeFill(itemColor),\n outline: noShapeOutline(),\n },\n {\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n },\n { fillColor: itemColor },\n );\n\n // ラベルを描画(円の上)\n addGlimpseTextBox(\n ctx,\n {\n x: itemX - itemLabelW / 2,\n y: itemY - itemSize / 2 - 20 * scaleFactor,\n w: itemLabelW,\n h: itemLabelH,\n },\n {\n text: item.label,\n fontSize: 11 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: stripHash(item.textColor) ?? itemLabelColor,\n bold: true,\n align: \"center\",\n valign: \"bottom\",\n },\n );\n }\n}\n\nfunction renderQuadrantLabels(\n ctx: RenderContext,\n quadrants: NonNullable<MatrixPositionedNode[\"quadrants\"]>,\n areaX: number,\n areaY: number,\n areaW: number,\n areaH: number,\n centerX: number,\n centerY: number,\n scaleFactor: number,\n quadrantColor: string,\n): void {\n const quadrantFontSize = 11 * scaleFactor;\n const quadrantInset = 10 * scaleFactor;\n const quadrantW = areaW / 2 - 20 * scaleFactor;\n const quadrantH = 48 * scaleFactor;\n\n // 左上\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"top\",\n },\n );\n\n // 右上\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"top\",\n },\n );\n\n // 左下\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"bottom\",\n },\n );\n\n // 右下\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"bottom\",\n },\n );\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,iBACd,MACA,KACM;CACN,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK;CAClB,MAAM,YAAY,KAAK;CAEvB,MAAM,mBAAmB;CACzB,MAAM,eAAe;CACrB,MAAM,gBAAgB;CACtB,MAAM,YAAY;CAClB,MAAM,iBAAiB,UAAU,KAAK,cAAc,KAAK;CACzD,MAAM,iBAAiB,UAAU,KAAK,cAAc,KAAK;CAGzD,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,cAAc,IAAI,GAClB,GACF;CAEA,MAAM,WAAW,eAAe;CAChC,MAAM,YAAY,gBAAgB;CAGlC,MAAM,aAAa,KAAK;CACxB,MAAM,QAAQ,QAAQ,IAAI;CAC1B,MAAM,QAAQ,QAAQ,IAAI;CAC1B,MAAM,QAAQ,QAAQ,IAAI,aAAa;CACvC,MAAM,QAAQ,QAAQ,IAAI,aAAa;CAGvC,MAAM,UAAU,QAAQ,QAAQ;CAChC,MAAM,UAAU,QAAQ,QAAQ;CAIhC,gBACE,KACA;EAAE,IAAI;EAAO,IAAI;EAAS,IAAI,QAAQ;EAAO,IAAI;CAAQ,GACzD;EAAE,OAAO;EAAW;CAAU,CAChC;CAGA,gBACE,KACA;EAAE,IAAI;EAAS,IAAI;EAAO,IAAI;EAAS,IAAI,QAAQ;CAAM,GACzD;EAAE,OAAO;EAAW;CAAU,CAChC;CAGA,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,KAAK;CAGxB,kBACE,KACA;EACE,GAAG,UAAU,aAAa;EAC1B,GAAG,QAAQ,QAAQ,IAAI;EACvB,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,KAAK;EACX,UAAU,KAAK;EACf,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,MAAM,UAAU,MAAM;CACtB,MAAM,UAAU,KAAK;CACrB,kBACE,KACA;EACE,GAAG,QAAQ,IAAI,aAAa,IAAI,UAAU;EAC1C,GAAG,UAAU,UAAU;EACvB,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,KAAK;EACX,UAAU,KAAK;EACf,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;EACR,QAAQ;CACV,CACF;CAGA,IAAI,WACF,qBACE,KACA,WACA,OACA,OACA,OACA,OACA,SACA,SACA,aACA,UAAU,KAAK,kBAAkB,KAAK,QACxC;CAIF,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,KAAK;CAExB,KAAK,MAAM,QAAQ,OAAO;EAIxB,MAAM,QAAQ,QAAQ,KAAK,IAAI;EAC/B,MAAM,QAAQ,SAAS,IAAI,KAAK,KAAK;EACrC,MAAM,YAAY,KAAK,SAAS;EAGhC,gBACE,KACA;GACE,QAAQ;
|
|
1
|
+
{"version":3,"file":"matrix.js","names":[],"sources":["../../../src/renderPptx/nodes/matrix.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { measureMatrix } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport { addStraightLine } from \"../utils/straightLine.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype MatrixPositionedNode = Extract<PositionedNode, { type: \"matrix\" }>;\n\nexport function renderMatrixNode(\n node: MatrixPositionedNode,\n ctx: RenderContext,\n): void {\n const items = node.items;\n const axes = node.axes;\n const quadrants = node.quadrants;\n\n const defaultItemColor = \"1D4ED8\"; // blue\n const baseItemSize = 24; // px\n const baseLineWidth = 2; // px\n const axisColor = \"E2E8F0\";\n const axisLabelColor = stripHash(node.axisLabelColor) ?? \"64748B\";\n const itemLabelColor = stripHash(node.itemLabelColor) ?? \"1E293B\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureMatrix(node),\n ctx,\n );\n\n const itemSize = baseItemSize * scaleFactor;\n const lineWidth = baseLineWidth * scaleFactor;\n\n // マトリクスの描画領域(軸ラベル用の余白を考慮)\n const axisMargin = 60 * scaleFactor; // 軸ラベル用の余白\n const areaX = content.x + axisMargin;\n const areaY = content.y + axisMargin;\n const areaW = content.w - axisMargin * 2;\n const areaH = content.h - axisMargin * 2;\n\n // 中心座標\n const centerX = areaX + areaW / 2;\n const centerY = areaY + areaH / 2;\n\n // === 1. 十字線(軸線)を描画 ===\n // 横線(X軸)\n addStraightLine(\n ctx,\n { x1: areaX, y1: centerY, x2: areaX + areaW, y2: centerY },\n { color: axisColor, lineWidth },\n );\n\n // 縦線(Y軸)\n addStraightLine(\n ctx,\n { x1: centerX, y1: areaY, x2: centerX, y2: areaY + areaH },\n { color: axisColor, lineWidth },\n );\n\n // === 2. 軸ラベルを描画 ===\n const axisLabelW = 120 * scaleFactor;\n const axisLabelH = 24 * scaleFactor;\n\n // X軸ラベル(下部中央)\n addGlimpseTextBox(\n ctx,\n {\n x: centerX - axisLabelW / 2,\n y: areaY + areaH + 8 * scaleFactor,\n w: axisLabelW,\n h: axisLabelH,\n },\n {\n text: axes.x,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"top\",\n },\n );\n\n // Y軸ラベル(左部中央)270° 回転で下から上読み。w が視覚的な高さになるため CJK 5 文字以上も収まる幅を確保\n const yLabelW = 100 * scaleFactor;\n const yLabelH = 20 * scaleFactor;\n addGlimpseTextBox(\n ctx,\n {\n x: content.x + axisMargin / 2 - yLabelW / 2,\n y: centerY - yLabelH / 2,\n w: yLabelW,\n h: yLabelH,\n },\n {\n text: axes.y,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"middle\",\n rotate: 270,\n },\n );\n\n // === 3. 象限ラベルを描画 ===\n if (quadrants) {\n renderQuadrantLabels(\n ctx,\n quadrants,\n areaX,\n areaY,\n areaW,\n areaH,\n centerX,\n centerY,\n scaleFactor,\n stripHash(node.quadrantLabelColor) ?? \"94A3B8\",\n );\n }\n\n // === 4. アイテムをプロット ===\n const itemLabelW = 100 * scaleFactor;\n const itemLabelH = 18 * scaleFactor;\n\n for (const item of items) {\n // 座標変換: (0,0)=左下, (1,1)=右上\n // x: 0 -> areaX, 1 -> areaX + areaW\n // y: 0 -> areaY + areaH, 1 -> areaY (反転)\n const itemX = areaX + item.x * areaW;\n const itemY = areaY + (1 - item.y) * areaH; // Y軸反転\n const itemColor = item.color ?? defaultItemColor;\n\n // 円を描画\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: \"ellipse\" },\n ...createShapeBoundsInput({\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n }),\n fill: solidShapeFill(itemColor),\n outline: noShapeOutline(),\n },\n {\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n },\n { fillColor: itemColor },\n );\n\n // ラベルを描画(円の上)\n addGlimpseTextBox(\n ctx,\n {\n x: itemX - itemLabelW / 2,\n y: itemY - itemSize / 2 - 20 * scaleFactor,\n w: itemLabelW,\n h: itemLabelH,\n },\n {\n text: item.label,\n fontSize: 11 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: stripHash(item.textColor) ?? itemLabelColor,\n bold: true,\n align: \"center\",\n valign: \"bottom\",\n },\n );\n }\n}\n\nfunction renderQuadrantLabels(\n ctx: RenderContext,\n quadrants: NonNullable<MatrixPositionedNode[\"quadrants\"]>,\n areaX: number,\n areaY: number,\n areaW: number,\n areaH: number,\n centerX: number,\n centerY: number,\n scaleFactor: number,\n quadrantColor: string,\n): void {\n const quadrantFontSize = 11 * scaleFactor;\n const quadrantInset = 10 * scaleFactor;\n const quadrantW = areaW / 2 - 20 * scaleFactor;\n const quadrantH = 48 * scaleFactor;\n\n // 左上\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"top\",\n },\n );\n\n // 右上\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"top\",\n },\n );\n\n // 左下\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"bottom\",\n },\n );\n\n // 右下\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right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kBACE,KACA;EACE,GAAG,QAAQ;EACX,GAAG,QAAQ;EACX,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,kBACE,KACA;EACE,GAAG,UAAU;EACb,GAAG,QAAQ;EACX,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,kBACE,KACA;EACE,GAAG,QAAQ;EACX,GAAG,UAAU,QAAQ,IAAI,YAAY;EACrC,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,kBACE,KACA;EACE,GAAG,UAAU;EACb,GAAG,UAAU,QAAQ,IAAI,YAAY;EACrC,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;AACF"}
|
|
@@ -87,7 +87,10 @@ function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, it
|
|
|
87
87
|
{ close: true }
|
|
88
88
|
];
|
|
89
89
|
addGlimpseShape(ctx, {
|
|
90
|
-
|
|
90
|
+
geometry: {
|
|
91
|
+
kind: "preset",
|
|
92
|
+
preset: "rect"
|
|
93
|
+
},
|
|
91
94
|
...createShapeBoundsInput({
|
|
92
95
|
x: stepX,
|
|
93
96
|
y: stepY,
|
|
@@ -191,7 +194,10 @@ function renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, item
|
|
|
191
194
|
{ close: true }
|
|
192
195
|
];
|
|
193
196
|
addGlimpseShape(ctx, {
|
|
194
|
-
|
|
197
|
+
geometry: {
|
|
198
|
+
kind: "preset",
|
|
199
|
+
preset: "rect"
|
|
200
|
+
},
|
|
195
201
|
...createShapeBoundsInput({
|
|
196
202
|
x: stepX,
|
|
197
203
|
y: stepY,
|